mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-26 12:08:37 +08:00
mode now correctly switches to connection properties when inheritance isnt a valid selection
This commit is contained in:
@@ -22,6 +22,7 @@ namespace mRemoteNG.UI.Controls.ConnectionInfoPropertyGrid
|
||||
{
|
||||
private readonly Dictionary<Type, IEnumerable<PropertyInfo>> _propertyCache = new Dictionary<Type, IEnumerable<PropertyInfo>>();
|
||||
private ConnectionInfo _selectedConnectionInfo;
|
||||
private PropertyMode _propertyMode;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ConnectionInfo"/> currently being shown by this
|
||||
@@ -43,18 +44,35 @@ namespace mRemoteNG.UI.Controls.ConnectionInfoPropertyGrid
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines which set of properties this grid will display.
|
||||
/// </summary>
|
||||
public PropertyMode PropertyMode
|
||||
{
|
||||
get => _propertyMode;
|
||||
set
|
||||
{
|
||||
if (_propertyMode == value)
|
||||
return;
|
||||
_propertyMode = value;
|
||||
SetGridObject();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the property grid showing the selected connection's
|
||||
/// inheritance info? If false, the connection's normal
|
||||
/// properties are shown instead.
|
||||
/// </summary>
|
||||
public bool IsShowingInheritance { get; private set; }
|
||||
public bool IsShowingInheritance => PropertyMode == PropertyMode.Inheritance ||
|
||||
PropertyMode == PropertyMode.DefaultInheritance;
|
||||
|
||||
/// <summary>
|
||||
/// This indicates whether the current <see cref="SelectedConnectionInfo"/>
|
||||
/// is a <see cref="DefaultConnectionInfo"/>.
|
||||
/// </summary>
|
||||
public bool IsShowingDefaultProperties { get; private set; }
|
||||
public bool IsShowingDefaultProperties => PropertyMode == PropertyMode.DefaultConnection ||
|
||||
PropertyMode == PropertyMode.DefaultInheritance;
|
||||
|
||||
/// <summary>
|
||||
/// True when the <see cref="SelectedConnectionInfo"/> is
|
||||
@@ -68,25 +86,26 @@ namespace mRemoteNG.UI.Controls.ConnectionInfoPropertyGrid
|
||||
PropertyValueChanged += pGrid_PropertyValueChanged;
|
||||
}
|
||||
|
||||
public void SetDisplayMode(bool showInheritance = false, bool showDefaultProperties = false)
|
||||
{
|
||||
IsShowingInheritance = showInheritance;
|
||||
IsShowingDefaultProperties = showDefaultProperties;
|
||||
SetGridObject();
|
||||
}
|
||||
|
||||
private void SetGridObject()
|
||||
{
|
||||
ClearFilters();
|
||||
|
||||
if (IsShowingDefaultProperties && IsShowingInheritance)
|
||||
SelectedObject = DefaultConnectionInheritance.Instance;
|
||||
else if (IsShowingDefaultProperties)
|
||||
SelectedObject = DefaultConnectionInfo.Instance;
|
||||
else if (IsShowingInheritance)
|
||||
SelectedObject = SelectedConnectionInfo.Inheritance;
|
||||
else
|
||||
SelectedObject = SelectedConnectionInfo;
|
||||
switch (PropertyMode)
|
||||
{
|
||||
case PropertyMode.Connection:
|
||||
default:
|
||||
SelectedObject = SelectedConnectionInfo;
|
||||
break;
|
||||
case PropertyMode.Inheritance:
|
||||
SelectedObject = SelectedConnectionInfo.Inheritance;
|
||||
break;
|
||||
case PropertyMode.DefaultConnection:
|
||||
SelectedObject = DefaultConnectionInfo.Instance;
|
||||
break;
|
||||
case PropertyMode.DefaultInheritance:
|
||||
SelectedObject = DefaultConnectionInheritance.Instance;
|
||||
break;
|
||||
}
|
||||
|
||||
ShowHideGridItems();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace mRemoteNG.UI.Controls.ConnectionInfoPropertyGrid
|
||||
{
|
||||
public enum PropertyMode
|
||||
{
|
||||
Connection,
|
||||
Inheritance,
|
||||
DefaultConnection,
|
||||
DefaultInheritance,
|
||||
}
|
||||
}
|
||||
@@ -261,6 +261,14 @@ namespace mRemoteNG.UI.Window
|
||||
{
|
||||
try
|
||||
{
|
||||
// if we are on the show inheritance tab but it isn't a
|
||||
// valid choice, switch to the properties tab
|
||||
if (_pGrid.PropertyMode == PropertyMode.Inheritance && !ConnectionInheritanceCanBeShown())
|
||||
{
|
||||
ShowConnectionProperties();
|
||||
return;
|
||||
}
|
||||
|
||||
UpdatePropertiesButton();
|
||||
UpdateShowInheritanceButton();
|
||||
UpdateShowDefaultPropertiesButton();
|
||||
@@ -280,40 +288,33 @@ namespace mRemoteNG.UI.Window
|
||||
private void UpdatePropertiesButton()
|
||||
{
|
||||
_btnShowProperties.Checked =
|
||||
!_pGrid.IsShowingDefaultProperties &&
|
||||
!_pGrid.IsShowingInheritance;
|
||||
_pGrid.PropertyMode == PropertyMode.Connection;
|
||||
}
|
||||
|
||||
private void UpdateShowInheritanceButton()
|
||||
{
|
||||
// if we are on the show inheritance tab but it isn't a
|
||||
// valid choice, switch to the properties tab
|
||||
if (_btnShowInheritance.Checked && !_btnShowInheritance.Enabled)
|
||||
ShowConnectionProperties();
|
||||
|
||||
_btnShowInheritance.Enabled =
|
||||
!_pGrid.RootNodeSelected &&
|
||||
_pGrid.SelectedConnectionInfo.Parent != null &&
|
||||
!(_pGrid.SelectedConnectionInfo.Parent is RootNodeInfo);
|
||||
|
||||
_btnShowInheritance.Enabled = ConnectionInheritanceCanBeShown();
|
||||
_btnShowInheritance.Checked =
|
||||
_btnShowInheritance.Enabled &&
|
||||
_pGrid.IsShowingInheritance &&
|
||||
!_pGrid.IsShowingDefaultProperties;
|
||||
_pGrid.PropertyMode == PropertyMode.Inheritance;
|
||||
}
|
||||
|
||||
private bool ConnectionInheritanceCanBeShown()
|
||||
{
|
||||
return !_pGrid.RootNodeSelected &&
|
||||
_pGrid.SelectedConnectionInfo.Parent != null &&
|
||||
!(_pGrid.SelectedConnectionInfo.Parent is RootNodeInfo);
|
||||
}
|
||||
|
||||
private void UpdateShowDefaultPropertiesButton()
|
||||
{
|
||||
_btnShowDefaultProperties.Checked =
|
||||
_pGrid.IsShowingDefaultProperties &&
|
||||
!_pGrid.IsShowingInheritance;
|
||||
_pGrid.PropertyMode == PropertyMode.DefaultConnection;
|
||||
}
|
||||
|
||||
private void UpdateShowDefaultInheritanceButton()
|
||||
{
|
||||
_btnShowDefaultInheritance.Checked =
|
||||
_pGrid.IsShowingDefaultProperties &&
|
||||
_pGrid.IsShowingInheritance;
|
||||
_pGrid.PropertyMode == PropertyMode.DefaultInheritance;
|
||||
}
|
||||
|
||||
private void UpdateHostStatusButton()
|
||||
@@ -479,25 +480,25 @@ namespace mRemoteNG.UI.Window
|
||||
|
||||
private void ShowConnectionProperties()
|
||||
{
|
||||
_pGrid.SetDisplayMode(showInheritance: false, showDefaultProperties: false);
|
||||
_pGrid.PropertyMode = PropertyMode.Connection;
|
||||
UpdateTopRow();
|
||||
}
|
||||
|
||||
private void btnShowDefaultProperties_Click(object sender, EventArgs e)
|
||||
{
|
||||
_pGrid.SetDisplayMode(showDefaultProperties: true);
|
||||
_pGrid.PropertyMode = PropertyMode.DefaultConnection;
|
||||
UpdateTopRow();
|
||||
}
|
||||
|
||||
private void btnShowInheritance_Click(object sender, EventArgs e)
|
||||
{
|
||||
_pGrid.SetDisplayMode(showInheritance: true);
|
||||
_pGrid.PropertyMode = PropertyMode.Inheritance;
|
||||
UpdateTopRow();
|
||||
}
|
||||
|
||||
private void btnShowDefaultInheritance_Click(object sender, EventArgs e)
|
||||
{
|
||||
_pGrid.SetDisplayMode(showInheritance: true, showDefaultProperties: true);
|
||||
_pGrid.PropertyMode = PropertyMode.DefaultInheritance;
|
||||
UpdateTopRow();
|
||||
}
|
||||
|
||||
|
||||
@@ -423,6 +423,7 @@
|
||||
<Compile Include="UI\Controls\ConnectionInfoPropertyGrid\ConnectionInfoPropertyGrid.Designer.cs">
|
||||
<DependentUpon>ConnectionInfoPropertyGrid.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\ConnectionInfoPropertyGrid\PropertyMode.cs" />
|
||||
<Compile Include="UI\Controls\ConnectionTree\ConnectionTree.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
||||
Reference in New Issue
Block a user