瀏覽代碼

MBTheater shutdown code in installer/uninstaller

Eric Reed 12 年之前
父節點
當前提交
d3e6dd5535
共有 2 個文件被更改,包括 36 次插入0 次删除
  1. 20 0
      MediaBrowser.Installer/MainWindow.xaml.cs
  2. 16 0
      MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs

+ 20 - 0
MediaBrowser.Installer/MainWindow.xaml.cs

@@ -131,6 +131,26 @@ namespace MediaBrowser.Installer
                     }
                     }
                 }
                 }
             }
             }
+            else
+            {
+                if (PackageName == "MBTheater")
+                {
+                    // Uninstalling MBT - shut it down if it is running
+                    var processes = Process.GetProcessesByName("mediabrowser.ui");
+                    if (processes.Length > 0)
+                    {
+                        try
+                        {
+                            processes[0].CloseMainWindow();
+                        }
+                        catch (Exception ex)
+                        {
+                            MessageBox.Show("Unable to shutdown Media Browser Theater.  Please ensure it is not running before hitting OK.\n\n" + ex.Message, "Error");
+                        }
+                    }
+                    
+                }
+            }
 
 
             // Download
             // Download
             var archive = await DownloadPackage(version);
             var archive = await DownloadPackage(version);

+ 16 - 0
MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs

@@ -98,6 +98,22 @@ namespace MediaBrowser.Uninstaller.Execute
                     }
                     }
                 }
                 }
             }
             }
+            else
+            {
+                // Installing MBT - shut it down if it is running
+                var processes = Process.GetProcessesByName("mediabrowser.ui");
+                if (processes.Length > 0)
+                {
+                    try
+                    {
+                        processes[0].CloseMainWindow();
+                    }
+                    catch (Exception ex)
+                    {
+                        MessageBox.Show("Unable to shutdown Media Browser Theater.  Please ensure it is not running before hitting OK.\n\n" + ex.Message, "Error");
+                    }
+                }
+            }
             // if the startmenu item is empty now - delete it too
             // if the startmenu item is empty now - delete it too
             if (Directory.GetFiles(startMenu).Length == 0)
             if (Directory.GetFiles(startMenu).Length == 0)
             {
             {