diff --git a/XenAdmin/Commands/SelectionBroadcaster.cs b/XenAdmin/Commands/SelectionBroadcaster.cs index 1eaa3fabf..78196e160 100644 --- a/XenAdmin/Commands/SelectionBroadcaster.cs +++ b/XenAdmin/Commands/SelectionBroadcaster.cs @@ -109,6 +109,9 @@ namespace XenAdmin.Commands /// public event EventHandler SelectionChanged; + public abstract void SaveAndClearSelection(); + public abstract void RestoreSavedSelection(); + #region IDisposable Members /// diff --git a/XenAdmin/Commands/SelectionManager.cs b/XenAdmin/Commands/SelectionManager.cs index 6cd7db7b3..fd46c3830 100644 --- a/XenAdmin/Commands/SelectionManager.cs +++ b/XenAdmin/Commands/SelectionManager.cs @@ -42,6 +42,7 @@ namespace XenAdmin.Commands internal class SelectionManager : SelectionBroadcaster { private SelectedItemCollection _selection = new SelectedItemCollection(); + private SelectedItemCollection savedSelection = new SelectedItemCollection(); /// /// Sets the main selection for XenCenter. @@ -86,5 +87,20 @@ namespace XenAdmin.Commands { SetSelection(Selection); } + + public override void SaveAndClearSelection() + { + savedSelection = new SelectedItemCollection(_selection); + SetSelection(new SelectedItemCollection()); + } + + public override void RestoreSavedSelection() + { + if (savedSelection != null) + { + SetSelection(new SelectedItemCollection(savedSelection)); + savedSelection = null; + } + } } } diff --git a/XenAdmin/Controls/MainWindowControls/NavigationPane.cs b/XenAdmin/Controls/MainWindowControls/NavigationPane.cs index 076d1700e..370d9f6f9 100644 --- a/XenAdmin/Controls/MainWindowControls/NavigationPane.cs +++ b/XenAdmin/Controls/MainWindowControls/NavigationPane.cs @@ -278,11 +278,15 @@ namespace XenAdmin.Controls.MainWindowControls { if (currentMode == NavigationMode.Notifications) { + SelectionManager.SaveAndClearSelection(); + //restore the last selected view SwitchToNotificationsView(lastNotificationsMode); } else { + SelectionManager.RestoreSavedSelection(); + //show the navigationView first and then hide the notificationsView //to avoid instantaneous appearance of empty panels navigationView.Visible = true;