fixed a few more bugs in the config window

This commit is contained in:
David Sparer
2019-04-02 15:21:45 -05:00
parent 02c05a6c63
commit 500608b383
4 changed files with 28 additions and 10 deletions

View File

@@ -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>();

View File

@@ -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)

View File

@@ -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();
}

View File

@@ -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;
}