aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Uninstaller.Execute
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Uninstaller.Execute')
-rw-r--r--MediaBrowser.Uninstaller.Execute/MainWindow.xaml12
-rw-r--r--MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs111
2 files changed, 111 insertions, 12 deletions
diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml
index d2a093ec4..803917109 100644
--- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml
+++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml
@@ -7,10 +7,14 @@
<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>
+ <Button x:Name="btnFinished" Content="Finish" HorizontalAlignment="Left" Margin="505,341,0,0" VerticalAlignment="Top" Width="75" IsDefault="True" RenderTransformOrigin="0.991,-1.041" Click="BtnFinished_OnClick" Visibility="Hidden"/>
</Grid>
</Window>
diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs
index bdf34b956..9937177a7 100644
--- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs
+++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs
@@ -13,6 +13,7 @@ namespace MediaBrowser.Uninstaller.Execute
public partial class MainWindow : Window
{
protected string Product = "Server";
+ protected string RootSuffix = "-Server";
public MainWindow()
{
@@ -27,10 +28,12 @@ namespace MediaBrowser.Uninstaller.Execute
{
case "server":
Product = "Server";
+ RootSuffix = "-Server";
break;
case "mbt":
Product = "Theater";
+ RootSuffix = "-UI";
break;
default:
@@ -62,21 +65,113 @@ 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));
+ RemoveShortcut(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup),linkName));
+ linkName = "Uninstall " + linkName;
+ RemoveShortcut(Path.Combine(startMenu, linkName));
+ if (Product == "Server")
+ {
+ RemoveShortcut(Path.Combine(startMenu, "MB Dashboard.lnk"));
+ }
+ // 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
- linkName = "Uninstall " + linkName;
- try
+ var rootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MediaBrowser" + RootSuffix);
+
+ if (cbxRemoveAll.IsChecked == true)
+ {
+ // Just remove our whole directory
+ RemovePath(rootPath);
+ }
+ else
{
- File.Delete(Path.Combine(startMenu,linkName));
+ // First remove the system
+ lblHeading.Content = "Removing System Files...";
+ RemovePath(Path.Combine(rootPath, "System"));
+ RemovePath(Path.Combine(rootPath, "MediaTools"));
+
+ // And then the others specified
+ if (cbxRemoveCache.IsChecked == true)
+ {
+ lblHeading.Content = "Removing Cache and Data Files...";
+ RemovePath(Path.Combine(rootPath, "cache"));
+ RemovePath(Path.Combine(rootPath, "data"));
+ }
+ if (cbxRemoveConfig.IsChecked == true)
+ {
+ lblHeading.Content = "Removing Config Files...";
+ RemovePath(Path.Combine(rootPath, "config"));
+ RemovePath(Path.Combine(rootPath, "logs"));
+ }
+ if (cbxRemovePlugins.IsChecked == true)
+ {
+ lblHeading.Content = "Removing Plugin Files...";
+ RemovePath(Path.Combine(rootPath, "plugins"));
+ }
}
- catch {} // oh well
+ // and done
+ lblHeading.Content = string.Format("Media Browser {0} Uninstalled.", Product);
+ btnUninstall.Visibility = Visibility.Hidden;
+ btnFinished.Visibility = Visibility.Visible;
+ }
+
+ 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");
+ }
+
+ }
+
+ private static void RemovePath(string path)
+ {
+ try
+ {
+ Directory.Delete(path, true);
+ }
+ catch (DirectoryNotFoundException)
+ {
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(string.Format("Error attempting to remove progam folder {0}\n\n {1}", path, ex.Message), "Error");
+ }
+
+ }
+
+ private void BtnFinished_OnClick(object sender, RoutedEventArgs e)
+ {
+ Close();
}
}
}