mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-01 11:52:52 +01:00
Add native shortcut handling & dashboard shortcut to installer
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
File.Delete(Path.Combine(startMenu,linkName));
|
||||
}
|
||||
catch {} // oh well
|
||||
|
||||
RemoveShortcut(Path.Combine(startMenu, linkName));
|
||||
linkName = "Uninstall " + linkName;
|
||||
try
|
||||
RemoveShortcut(Path.Combine(startMenu, linkName));
|
||||
if (Product == "Server")
|
||||
{
|
||||
File.Delete(Path.Combine(startMenu,linkName));
|
||||
RemoveShortcut(Path.Combine(startMenu, "Dashboard.lnk"));
|
||||
}
|
||||
// if the startmenu item is empty now - delete it too
|
||||
if (Directory.GetFiles(startMenu).Length == 0)
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user