diff options
| author | Eric Reed <ebr@mediabrowser3.com> | 2013-02-26 09:13:49 -0500 |
|---|---|---|
| committer | Eric Reed <ebr@mediabrowser3.com> | 2013-02-26 09:13:49 -0500 |
| commit | a15b6db0dccc6680e012fdbde021a364991a0d4b (patch) | |
| tree | 3af5e2cb8d7f9f30d5ccc7c1f49b629d79f226d9 /MediaBrowser.Uninstaller.Execute | |
| parent | d4690904fbd2733118d5a8d540105d90a202ff7a (diff) | |
Add native shortcut handling & dashboard shortcut to installer
Diffstat (limited to 'MediaBrowser.Uninstaller.Execute')
| -rw-r--r-- | MediaBrowser.Uninstaller.Execute/MainWindow.xaml | 11 | ||||
| -rw-r--r-- | MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs | 54 |
2 files changed, 52 insertions, 13 deletions
diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml index d2a093ec42..c1466f9a49 100644 --- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml +++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml @@ -7,10 +7,13 @@ <Label x:Name="lblHeading" Content="Uninstall " HorizontalAlignment="Left" Margin="51,169,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.478,-2.753" Height="29" Width="423" FontSize="14" FontWeight="Bold"/> <Button x:Name="btnUninstall" Content="Uninstall" HorizontalAlignment="Left" Margin="505,341,0,0" VerticalAlignment="Top" Width="75" IsDefault="True" RenderTransformOrigin="0.991,-1.041" Click="btnUninstall_Click"/> <Button x:Name="btnCancel" Content="Cancel" HorizontalAlignment="Left" Margin="412,341,0,0" VerticalAlignment="Top" Width="75" IsCancel="True" Click="btnCancel_Click"/> - <CheckBox x:Name="cbxRemoveAll" Content="Remove All Traces" HorizontalAlignment="Left" Margin="137,234,0,0" VerticalAlignment="Top" Checked="cbxRemoveAll_Checked" Unchecked="cbxRemoveAll_Checked"/> - <CheckBox x:Name="cbxRemoveCache" Content="Delete Cache Files" HorizontalAlignment="Left" Margin="152,255,0,0" VerticalAlignment="Top"/> - <CheckBox x:Name="cbxRemoveConfig" Content="Delete Configuration and Log Files" HorizontalAlignment="Left" Margin="152,276,0,0" VerticalAlignment="Top"/> - <CheckBox x:Name="cbxRemovePlugins" Content="Delete Plug-ins" HorizontalAlignment="Left" Margin="152,297,0,0" VerticalAlignment="Top"/> + <Grid x:Name="grdOptions" HorizontalAlignment="Left" Height="108" Margin="134,213,0,0" VerticalAlignment="Top" Width="261"> + <CheckBox x:Name="cbxRemoveAll" Content="Remove All Traces" HorizontalAlignment="Left" Margin="0,3,0,0" VerticalAlignment="Top" Checked="cbxRemoveAll_Checked" Unchecked="cbxRemoveAll_Checked"/> + <CheckBox x:Name="cbxRemoveCache" Content="Delete Cache Files" HorizontalAlignment="Left" Margin="16,25,0,0" VerticalAlignment="Top"/> + <CheckBox x:Name="cbxRemoveConfig" Content="Delete Configuration and Log Files" HorizontalAlignment="Left" Margin="16,47,0,0" VerticalAlignment="Top"/> + <CheckBox x:Name="cbxRemovePlugins" Content="Delete Plug-ins" HorizontalAlignment="Left" Margin="16,68,0,0" VerticalAlignment="Top"/> + + </Grid> </Grid> </Window> diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs index bdf34b956b..7f82d18407 100644 --- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs +++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs @@ -62,21 +62,57 @@ namespace MediaBrowser.Uninstaller.Execute private void btnUninstall_Click(object sender, RoutedEventArgs e) { // First remove our shortcuts - var startMenu = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser"); + lblHeading.Content = "Removing Shortcuts..."; + btnCancel.IsEnabled = btnUninstall.IsEnabled = false; + grdOptions.Visibility = Visibility.Hidden; + + var startMenu = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3"); var linkName = "Media Browser " + Product + ".lnk"; - try + RemoveShortcut(Path.Combine(startMenu, linkName)); + linkName = "Uninstall " + linkName; + RemoveShortcut(Path.Combine(startMenu, linkName)); + if (Product == "Server") { - File.Delete(Path.Combine(startMenu,linkName)); + RemoveShortcut(Path.Combine(startMenu, "Dashboard.lnk")); } - catch {} // oh well - - linkName = "Uninstall " + linkName; - try + // if the startmenu item is empty now - delete it too + if (Directory.GetFiles(startMenu).Length == 0) { - File.Delete(Path.Combine(startMenu,linkName)); + try + { + Directory.Delete(startMenu); + } + catch (DirectoryNotFoundException) + { + } + catch (Exception ex) + { + { + MessageBox.Show(string.Format("Error attempting to remove shortcut folder {0}\n\n {1}", startMenu, ex.Message), "Error"); + } + } } - catch {} // oh well + + // and done + lblHeading.Content = string.Format("Media Browser {0} Uninstalled.", Product); + btnUninstall.Content = "Finish"; + } + + private static void RemoveShortcut(string path) + { + try + { + File.Delete(path); + } + catch (FileNotFoundException) + { + } // we're trying to get rid of it anyway + catch (Exception ex) + { + MessageBox.Show(string.Format("Error attempting to remove shortcut {0}\n\n {1}", path, ex.Message), "Error"); + } + } } } |
