]> granicus.if.org Git - handbrake/commitdiff
WinGui: Only allow 1 instance of the Queue, About, Log and Preview window to be opened.
authorsr55 <sr55.hb@outlook.com>
Sat, 1 Sep 2012 20:02:07 +0000 (20:02 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 1 Sep 2012 20:02:07 +0000 (20:02 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4925 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs

index 340036373195f213dc7264c47a1cf77ec0081b38..59d442393ff5f9b9de429f184b5c9ee0989df7da 100644 (file)
@@ -33,6 +33,7 @@ namespace HandBrakeWPF.ViewModels
     using HandBrakeWPF.Model;\r
     using HandBrakeWPF.Services.Interfaces;\r
     using HandBrakeWPF.ViewModels.Interfaces;\r
+    using HandBrakeWPF.Views;\r
 \r
     using Ookii.Dialogs.Wpf;\r
 \r
@@ -843,7 +844,16 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void OpenAboutApplication()\r
         {\r
-            this.WindowManager.ShowWindow(IoC.Get<IAboutViewModel>());\r
+            Window window = Application.Current.Windows.Cast<Window>().FirstOrDefault(x => x.GetType() == typeof(AboutView));\r
+\r
+            if (window != null)\r
+            {\r
+                window.Activate();\r
+            }\r
+            else\r
+            {\r
+                this.WindowManager.ShowWindow(IoC.Get<IAboutViewModel>());\r
+            }\r
         }\r
 \r
         /// <summary>\r
@@ -859,7 +869,16 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void OpenLogWindow()\r
         {\r
-            this.WindowManager.ShowWindow(IoC.Get<ILogViewModel>());\r
+            Window window = Application.Current.Windows.Cast<Window>().FirstOrDefault(x => x.GetType() == typeof(LogView));\r
+\r
+            if (window != null)\r
+            {\r
+                window.Activate();\r
+            }\r
+            else\r
+            {\r
+                this.WindowManager.ShowWindow(IoC.Get<ILogViewModel>());\r
+            }\r
         }\r
 \r
         /// <summary>\r
@@ -867,7 +886,16 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void OpenQueueWindow()\r
         {\r
-            this.WindowManager.ShowWindow(IoC.Get<IQueueViewModel>());\r
+            Window window = Application.Current.Windows.Cast<Window>().FirstOrDefault(x => x.GetType() == typeof(QueueView));\r
+\r
+            if (window != null)\r
+            {\r
+                window.Activate();\r
+            }\r
+            else\r
+            {\r
+                this.WindowManager.ShowWindow(IoC.Get<IQueueViewModel>());\r
+            }\r
         }\r
 \r
         /// <summary>\r
@@ -875,9 +903,17 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void OpenPreviewWindow()\r
         {\r
-            IPreviewViewModel viewModel = IoC.Get<IPreviewViewModel>();\r
-            this.WindowManager.ShowWindow(viewModel);\r
-            viewModel.Task = this.CurrentTask;\r
+            Window window = Application.Current.Windows.Cast<Window>().FirstOrDefault(x => x.GetType() == typeof(PreviewView));\r
+\r
+            if (window != null)\r
+            {\r
+                window.Activate();\r
+            }\r
+            else\r
+            {\r
+                IPreviewViewModel viewModel = IoC.Get<IPreviewViewModel>();\r
+                this.WindowManager.ShowWindow(viewModel);\r
+            }\r
         }\r
 \r
         /// <summary>\r