This commit is contained in:
David Sparer
2018-07-18 14:52:12 -05:00
parent 3bdcf655fd
commit 2db6fabbe9
3 changed files with 2 additions and 17 deletions

View File

@@ -1,9 +1,7 @@
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using mRemoteNG.App;
using mRemoteNG.Connection;
using mRemoteNG.Messages;
namespace mRemoteNG.Config.Connections
{
@@ -22,10 +20,9 @@ namespace mRemoteNG.Config.Connections
private void ConnectionsServiceOnConnectionsLoaded(object sender, ConnectionsLoadedEventArgs connectionsLoadedEventArgs)
{
connectionsLoadedEventArgs.NewConnectionTreeModel.CollectionChanged += ConnectionTreeModelOnCollectionChanged;
connectionsLoadedEventArgs.NewConnectionTreeModel.PropertyChanged += ConnectionTreeModelOnPropertyChanged;
foreach (var oldTree in connectionsLoadedEventArgs.PreviousConnectionTreeModel)
{
oldTree.CollectionChanged -= ConnectionTreeModelOnCollectionChanged;
@@ -47,9 +44,8 @@ namespace mRemoteNG.Config.Connections
{
if (!mRemoteNG.Settings.Default.SaveConnectionsAfterEveryEdit)
return;
_connectionsService.SaveConnections();
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Auto saved connections");
_connectionsService.SaveConnectionsAsync();
}
}
}

View File

@@ -11,8 +11,6 @@ namespace mRemoteNG.Tree
public sealed class ConnectionTreeModel : INotifyCollectionChanged, INotifyPropertyChanged
{
public List<ContainerInfo> RootNodes { get; } = new List<ContainerInfo>();
public bool SuspendingCollectionChangedEvents { get; set; }
public bool SuspendingPropertyChangedEvents { get; set; }
public void AddRootNode(ContainerInfo rootNode)
{
@@ -68,9 +66,6 @@ namespace mRemoteNG.Tree
public event NotifyCollectionChangedEventHandler CollectionChanged;
private void RaiseCollectionChangedEvent(object sender, NotifyCollectionChangedEventArgs args)
{
if (SuspendingCollectionChangedEvents)
return;
CollectionChanged?.Invoke(sender, args);
}
@@ -78,9 +73,6 @@ namespace mRemoteNG.Tree
private void RaisePropertyChangedEvent(object sender, PropertyChangedEventArgs args)
{
if (SuspendingPropertyChangedEvents)
return;
PropertyChanged?.Invoke(sender, args);
}
}

View File

@@ -311,14 +311,11 @@ namespace mRemoteNG.UI.Controls
if (sortTarget == null)
sortTarget = GetRootConnectionNode();
var wasSuspendingEvents = _connectionTreeModel.SuspendingCollectionChangedEvents;
_connectionTreeModel.SuspendingCollectionChangedEvents = true;
var sortTargetAsContainer = sortTarget as ContainerInfo;
if (sortTargetAsContainer != null)
sortTargetAsContainer.SortRecursive(sortDirection);
else
SelectedNode.Parent.SortRecursive(sortDirection);
_connectionTreeModel.SuspendingCollectionChangedEvents = wasSuspendingEvents;
}
/// <summary>