improved setup dialog
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
|
||||
- Load AviSynth DLL from environment variable AviSynthDLL
|
||||
in order to support AviSynth portable mode.
|
||||
- New option global-media-keys (next, previous, play/pause, stop)
|
||||
- libmpv shinshiro 2020-11-22
|
||||
- New option global-media-keys (next, previous, play/pause, stop).
|
||||
- Improved setup dialog.
|
||||
- libmpv updated to shinshiro 2020-11-22.
|
||||
|
||||
|
||||
5.4.8.4 Beta
|
||||
|
||||
@@ -6,6 +6,33 @@ using System.Windows.Forms;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public static class ProcessHelp
|
||||
{
|
||||
public static void Execute(string file, string arguments = null)
|
||||
{
|
||||
using (Process proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = file;
|
||||
proc.StartInfo.Arguments = arguments;
|
||||
// default is true in .NET Framework and false in .NET Core
|
||||
proc.StartInfo.UseShellExecute = false;
|
||||
proc.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShellExecute(string file, string arguments = null)
|
||||
{
|
||||
using (Process proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = file;
|
||||
proc.StartInfo.Arguments = arguments;
|
||||
// default is true in .NET Framework and false in .NET Core
|
||||
proc.StartInfo.UseShellExecute = true;
|
||||
proc.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConsoleHelp
|
||||
{
|
||||
public static int Padding { get; set; }
|
||||
|
||||
@@ -80,25 +80,6 @@ namespace mpvnet
|
||||
RegistryHelp.SetValue(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Unregister()
|
||||
{
|
||||
RegistryHelp.RemoveKey($@"HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename);
|
||||
RegistryHelp.RemoveKey($@"HKCR\Applications\" + ExeFilename);
|
||||
RegistryHelp.RemoveKey($@"HKLM\SOFTWARE\Clients\Media\mpv.net");
|
||||
RegistryHelp.RemoveKey($@"HKCR\SystemFileAssociations\video\OpenWithList\" + ExeFilename);
|
||||
RegistryHelp.RemoveKey($@"HKCR\SystemFileAssociations\audio\OpenWithList\" + ExeFilename);
|
||||
RegistryHelp.RemoveValue(@"HKLM\SOFTWARE\RegisteredApplications", "mpv.net");
|
||||
|
||||
foreach (string id in Registry.ClassesRoot.GetSubKeyNames())
|
||||
{
|
||||
if (id.StartsWith(ExeFilenameNoExt + "."))
|
||||
Registry.ClassesRoot.DeleteSubKeyTree(id);
|
||||
|
||||
RegistryHelp.RemoveValue($@"HKCR\Software\Classes\{id}\OpenWithProgIDs", ExeFilenameNoExt + id);
|
||||
RegistryHelp.RemoveValue($@"HKLM\Software\Classes\{id}\OpenWithProgIDs", ExeFilenameNoExt + id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MediaTrack
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace mpvnet
|
||||
if (args[1] == "audio") FileAssociation.Register(App.AudioTypes);
|
||||
if (args[1] == "video") FileAssociation.Register(App.VideoTypes);
|
||||
if (args[1] == "image") FileAssociation.Register(App.ImageTypes);
|
||||
if (args[1] == "unreg") FileAssociation.Unregister();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -55,7 +56,7 @@ namespace mpvnet
|
||||
proc.StartInfo.UseShellExecute = true;
|
||||
proc.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||
proc.StartInfo.FileName = "PowerShell";
|
||||
proc.StartInfo.Arguments = $"-NoLogo -NoExit -File \"{Folder.Startup + "Update.ps1"}\" \"{url}\" \"{Application.StartupPath.TrimEnd('\\')}\"";
|
||||
proc.StartInfo.Arguments = $"-NoLogo -NoExit -File \"{Folder.Startup + "Update.ps1"}\" \"{url}\" \"{Folder.Startup.TrimEnd(Path.DirectorySeparatorChar)}\"";
|
||||
|
||||
if (Folder.Startup.Contains("Program Files"))
|
||||
proc.StartInfo.Verb = "runas";
|
||||
|
||||
@@ -19,27 +19,51 @@
|
||||
<Setter Property="Height" Value="25"></Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="FontSize" Value="14"></Setter>
|
||||
<Setter Property="Margin" Value="3,0,0,0"></Setter>
|
||||
<Setter Property="TextAlignment" Value="Center"></Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key = "ShieldButtonTemplate" TargetType = "Button">
|
||||
<Button Margin="0">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="{x:Static mpvnet:SetupWindow.ShieldIcon}"
|
||||
<Button Margin="0" HorizontalContentAlignment="Stretch">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Grid.Column="0"
|
||||
Source="{x:Static mpvnet:SetupWindow.ShieldIcon}"
|
||||
Width="18"
|
||||
Height="18"
|
||||
Margin="0,0,3,0"/>
|
||||
<ContentPresenter/>
|
||||
</StackPanel>
|
||||
Margin="3,0,0,0"/>
|
||||
<ContentPresenter Grid.Column="1" HorizontalAlignment="Center" />
|
||||
</Grid>
|
||||
</Button>
|
||||
</ControlTemplate>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<StackPanel Margin="10">
|
||||
<Button Name="RegisterVideo" Click="RegisterVideo_Click" Template="{StaticResource ShieldButtonTemplate}">Register video file extensions</Button>
|
||||
<Button Name="RegisterAudio" Click="RegisterAudio_Click" Template="{StaticResource ShieldButtonTemplate}">Register audio file extensions</Button>
|
||||
<Button Name="RegisterImage" Click="RegisterImage_Click" Template="{StaticResource ShieldButtonTemplate}">Register image file extensions</Button>
|
||||
<Button Name="UnregisterFileAssociations" Click="UnregisterFileAssociations_Click" Template="{StaticResource ShieldButtonTemplate}">Unregister file extensions</Button>
|
||||
<Button Name="AddToPathEnvVar" Margin="3,15,3,3" Click="AddToPathEnvVar_Click">Add to Path environment variable</Button>
|
||||
<Button Name="RemoveFromPathEnvVar" Padding="10,0,10,0" Click="RemoveFromPathEnvVar_Click">Remove from Path environment variable</Button>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel Width="180" Margin="5">
|
||||
<TextBlock>Start Menu Shortcut</TextBlock>
|
||||
<Button Name="AddStartMenuShortcut" Click="AddStartMenuShortcut_Click">Add</Button>
|
||||
<Button Name="RemoveStartMenuShortcut" Click="RemoveStartMenuShortcut_Click">Remove</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Width="180" Margin="20,5,5,5">
|
||||
<TextBlock>File Extensions</TextBlock>
|
||||
<Button Name="AddVideo" Click="AddVideo_Click" Template="{StaticResource ShieldButtonTemplate}">Add Video</Button>
|
||||
<Button Name="AddAudio" Click="AddAudio_Click" Template="{StaticResource ShieldButtonTemplate}">Add Audio</Button>
|
||||
<Button Name="AddImage" Click="AddImage_Click" Template="{StaticResource ShieldButtonTemplate}">Add Image</Button>
|
||||
<Button Name="RemoveFileAssociations" Click="RemoveFileAssociations_Click" Template="{StaticResource ShieldButtonTemplate}">Remove All</Button>
|
||||
<Button Name="EditDefaultApp" Click="EditDefaultApp_Click">Edit Default App</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Width="180" Margin="20,5,5,5">
|
||||
<TextBlock>Path Environment Variable</TextBlock>
|
||||
<Button Name="AddToPathEnvVar" Click="AddToPathEnvVar_Click">Add</Button>
|
||||
<Button Name="RemoveFromPathEnvVar" Click="RemoveFromPathEnvVar_Click">Remove</Button>
|
||||
<Button Name="ShowEnvVarEditor" Click="ShowEnvVarEditor_Click">Show Editor</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,9 +1,10 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.IO;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows;
|
||||
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
||||
@@ -39,22 +40,38 @@ namespace mpvnet
|
||||
proc.StartInfo.FileName = WinForms.Application.ExecutablePath;
|
||||
proc.StartInfo.Arguments = "--reg-file-assoc " + value;
|
||||
proc.StartInfo.Verb = "runas";
|
||||
proc.StartInfo.UseShellExecute = true;
|
||||
proc.Start();
|
||||
}
|
||||
|
||||
Process.Start("ms-settings:defaultapps");
|
||||
Msg.Show(value[0].ToString().ToUpper() + value.Substring(1) +
|
||||
" file associations successfully created.");
|
||||
} catch {}
|
||||
}
|
||||
|
||||
void RegisterVideo_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("video");
|
||||
void RegisterAudio_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("audio");
|
||||
void RegisterImage_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("image");
|
||||
void AddVideo_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("video");
|
||||
void AddAudio_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("audio");
|
||||
void AddImage_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("image");
|
||||
|
||||
void UnregisterFileAssociations_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("unreg");
|
||||
void RemoveFileAssociations_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Process proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = "powershell.exe";
|
||||
proc.StartInfo.Arguments = "-NoLogo -NoExit -ExecutionPolicy Unrestricted -File \"" +
|
||||
Folder.Startup + "Setup\\uninstall.ps1\"";
|
||||
proc.StartInfo.Verb = "runas";
|
||||
proc.StartInfo.UseShellExecute = true;
|
||||
proc.Start();
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
|
||||
void AddToPathEnvVar_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string var = WinForms.Application.StartupPath + ";";
|
||||
string var = Folder.Startup.TrimEnd(Path.DirectorySeparatorChar) + ";";
|
||||
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User);
|
||||
|
||||
if (path.Contains(var))
|
||||
@@ -68,7 +85,7 @@ namespace mpvnet
|
||||
|
||||
void RemoveFromPathEnvVar_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string var = WinForms.Application.StartupPath + ";";
|
||||
string var = Folder.Startup.TrimEnd(Path.DirectorySeparatorChar) + ";";
|
||||
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User);
|
||||
|
||||
if (path.Contains(var))
|
||||
@@ -80,17 +97,29 @@ namespace mpvnet
|
||||
Msg.ShowWarning("Path was not containing mpv.net.");
|
||||
}
|
||||
|
||||
void aaa()
|
||||
void AddStartMenuShortcut_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BitmapSource shieldSource = null;
|
||||
IntPtr icon = GetIcon(SHSTOCKICONID.Shield, SHSTOCKICONFLAGS.SHGSI_LARGEICON);
|
||||
shieldSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
|
||||
icon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
||||
DestroyIcon(icon);
|
||||
//shieldSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
|
||||
// System.Drawing.SystemIcons.Shield.Handle,
|
||||
// Int32Rect.Empty,
|
||||
// BitmapSizeOptions.FromEmptyOptions());
|
||||
ExecutePowerShellScript(Folder.Startup + "Setup\\create start menu shortcut.ps1");
|
||||
}
|
||||
|
||||
void RemoveStartMenuShortcut_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ExecutePowerShellScript(Folder.Startup + "Setup\\remove start menu shortcut.ps1");
|
||||
}
|
||||
|
||||
void ShowEnvVarEditor_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProcessHelp.Execute("rundll32.exe", "sysdm.cpl,EditEnvironmentVariables");
|
||||
}
|
||||
|
||||
void ExecutePowerShellScript(string file)
|
||||
{
|
||||
ProcessHelp.Execute("powershell.exe", "-NoLogo -NoExit -ExecutionPolicy Unrestricted -File \"" + file + "\"");
|
||||
}
|
||||
|
||||
private void EditDefaultApp_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProcessHelp.ShellExecute("ms-settings:defaultapps");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -814,9 +814,6 @@ namespace mpvnet
|
||||
core.LoadScripts();
|
||||
Task.Run(() => App.Extension = new Extension());
|
||||
ShownTickCount = Environment.TickCount;
|
||||
|
||||
SetupWindow win = new SetupWindow();
|
||||
win.Show();
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user