mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
fixed a few more bugs in the config window
This commit is contained in:
@@ -126,6 +126,19 @@ namespace mRemoteNGTests.UI.Window.ConfigWindowTests
|
||||
Assert.That(_configWindow.CanShowProperties, Is.EqualTo(selectedObjectNotNull));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(EveryNodeType))]
|
||||
public void InheritancePropertiesAreVisibleInCertainCases(ConnectionInfo selectedObject)
|
||||
{
|
||||
_configWindow.SelectedTreeNode = selectedObject;
|
||||
|
||||
var shouldBeAvailable = selectedObject != null &&
|
||||
!(selectedObject is RootNodeInfo) &&
|
||||
!(selectedObject is PuttySessionInfo) &&
|
||||
!(selectedObject.Parent is RootNodeInfo);
|
||||
|
||||
Assert.That(_configWindow.CanShowInheritance, Is.EqualTo(shouldBeAvailable));
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> ConnectionInfoGeneralTestCases()
|
||||
{
|
||||
var protocolTypes = typeof(ProtocolType).GetEnumValues().OfType<ProtocolType>();
|
||||
|
||||
@@ -33,8 +33,6 @@ namespace mRemoteNG.UI.Controls.ConnectionInfoPropertyGrid
|
||||
get => _selectedConnectionInfo;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
return;
|
||||
if (_selectedConnectionInfo == value)
|
||||
return;
|
||||
|
||||
@@ -97,7 +95,7 @@ namespace mRemoteNG.UI.Controls.ConnectionInfoPropertyGrid
|
||||
SelectedObject = SelectedConnectionInfo;
|
||||
break;
|
||||
case PropertyMode.Inheritance:
|
||||
SelectedObject = SelectedConnectionInfo.Inheritance;
|
||||
SelectedObject = SelectedConnectionInfo?.Inheritance;
|
||||
break;
|
||||
case PropertyMode.DefaultConnection:
|
||||
SelectedObject = DefaultConnectionInfo.Instance;
|
||||
@@ -107,13 +105,17 @@ namespace mRemoteNG.UI.Controls.ConnectionInfoPropertyGrid
|
||||
break;
|
||||
}
|
||||
|
||||
ShowHideGridItems();
|
||||
if (SelectedObject != null)
|
||||
ShowHideGridItems();
|
||||
}
|
||||
|
||||
private void ShowHideGridItems()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (SelectedConnectionInfo == null)
|
||||
return;
|
||||
|
||||
if (RootNodeSelected && PropertyMode == PropertyMode.Connection)
|
||||
{
|
||||
if (SelectedConnectionInfo is RootPuttySessionsNodeInfo)
|
||||
|
||||
@@ -125,8 +125,8 @@ namespace mRemoteNG.UI.Controls.FilteredPropertyGrid
|
||||
}
|
||||
else if (_mWrapper.SelectedObject != value)
|
||||
{
|
||||
var needrefresh = value.GetType() != _mWrapper.SelectedObject.GetType();
|
||||
_mWrapper.SelectedObject = value;
|
||||
var needrefresh = value?.GetType() != _mWrapper.SelectedObject?.GetType();
|
||||
_mWrapper.SelectedObject = value ?? new object();
|
||||
if (needrefresh)
|
||||
RefreshProperties();
|
||||
}
|
||||
|
||||
@@ -208,7 +208,8 @@ namespace mRemoteNG.UI.Window
|
||||
|
||||
public bool InheritanceVisible => _btnShowInheritance.Checked;
|
||||
public bool CanShowInheritance => !_pGrid.RootNodeSelected &&
|
||||
_pGrid.SelectedConnectionInfo.Parent != null &&
|
||||
SelectedTreeNode != null &&
|
||||
_pGrid.SelectedConnectionInfo?.Parent != null &&
|
||||
!(_pGrid.SelectedConnectionInfo.Parent is RootNodeInfo);
|
||||
|
||||
public bool DefaultPropertiesVisible => _btnShowDefaultProperties.Checked;
|
||||
@@ -389,12 +390,14 @@ namespace mRemoteNG.UI.Window
|
||||
|
||||
private void UpdateIconButton()
|
||||
{
|
||||
_btnIcon.Enabled = !_pGrid.IsShowingDefaultProperties &&
|
||||
!_pGrid.RootNodeSelected;
|
||||
_btnIcon.Enabled =
|
||||
_pGrid.SelectedConnectionInfo != null &&
|
||||
!_pGrid.IsShowingDefaultProperties &&
|
||||
!_pGrid.RootNodeSelected;
|
||||
|
||||
_btnIcon.Image = _btnIcon.Enabled
|
||||
? ConnectionIcon
|
||||
.FromString(_pGrid.SelectedConnectionInfo.Icon)
|
||||
.FromString(_pGrid.SelectedConnectionInfo?.Icon)?
|
||||
.ToBitmap()
|
||||
: null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user