improved setup dialog
This commit is contained in:
131
mpv.net/Native/StockIcon.cs
Normal file
131
mpv.net/Native/StockIcon.cs
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
public class StockIcon
|
||||||
|
{
|
||||||
|
[DllImport("shell32.dll")]
|
||||||
|
public static extern int SHGetStockIconInfo(SHSTOCKICONID siid, SHSTOCKICONFLAGS uFlags, ref SHSTOCKICONINFO info);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern bool DestroyIcon(IntPtr handle);
|
||||||
|
|
||||||
|
public static IntPtr GetIcon(SHSTOCKICONID identifier, SHSTOCKICONFLAGS flags)
|
||||||
|
{
|
||||||
|
SHSTOCKICONINFO info = new SHSTOCKICONINFO();
|
||||||
|
info.cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(SHSTOCKICONINFO)));
|
||||||
|
Marshal.ThrowExceptionForHR(SHGetStockIconInfo(identifier, flags, ref info));
|
||||||
|
return info.hIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
|
public struct SHSTOCKICONINFO
|
||||||
|
{
|
||||||
|
public uint cbSize;
|
||||||
|
public IntPtr hIcon;
|
||||||
|
int iSysImageIndex;
|
||||||
|
int iIcon;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
||||||
|
string szPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SHSTOCKICONFLAGS : uint
|
||||||
|
{
|
||||||
|
SHGSI_ICONLOCATION = 0,
|
||||||
|
SHGSI_ICON = 0x000000100,
|
||||||
|
SHGSI_SYSICONINDEX = 0x000004000,
|
||||||
|
SHGSI_LINKOVERLAY = 0x000008000,
|
||||||
|
SHGSI_SELECTED = 0x000010000,
|
||||||
|
SHGSI_LARGEICON = 0x000000000,
|
||||||
|
SHGSI_SMALLICON = 0x000000001,
|
||||||
|
SHGSI_SHELLICONSIZE = 0x000000004
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SHSTOCKICONID : uint
|
||||||
|
{
|
||||||
|
DocumentNotAssociated = 0,
|
||||||
|
DocumentAssociated = 1,
|
||||||
|
Application = 2,
|
||||||
|
Folder = 3,
|
||||||
|
FolderOpen = 4,
|
||||||
|
Drive525 = 5,
|
||||||
|
Drive35 = 6,
|
||||||
|
DriveRemove = 7,
|
||||||
|
DriveFixed = 8,
|
||||||
|
DriveNetwork = 9,
|
||||||
|
DriveNetworkDisabled = 10,
|
||||||
|
DriveCD = 11,
|
||||||
|
DriveRAM = 12,
|
||||||
|
World = 13,
|
||||||
|
Server = 15,
|
||||||
|
Printer = 16,
|
||||||
|
MyNetwork = 17,
|
||||||
|
Find = 22,
|
||||||
|
Help = 23,
|
||||||
|
Share = 28,
|
||||||
|
Link = 29,
|
||||||
|
SlowFile = 30,
|
||||||
|
Recycler = 31,
|
||||||
|
RecyclerFull = 32,
|
||||||
|
MediaCDAudio = 40,
|
||||||
|
Lock = 47,
|
||||||
|
AutoList = 49,
|
||||||
|
PrinterNet = 50,
|
||||||
|
ServerShare = 51,
|
||||||
|
PrinterFax = 52,
|
||||||
|
PrinterFaxNet = 53,
|
||||||
|
PrinterFile = 54,
|
||||||
|
Stack = 55,
|
||||||
|
MediaSVCD = 56,
|
||||||
|
StuffedFolder = 57,
|
||||||
|
DriveUnknown = 58,
|
||||||
|
DriveDVD = 59,
|
||||||
|
MediaDVD = 60,
|
||||||
|
MediaDVDRAM = 61,
|
||||||
|
MediaDVDRW = 62,
|
||||||
|
MediaDVDR = 63,
|
||||||
|
MediaDVDROM = 64,
|
||||||
|
MediaCDAudioPlus = 65,
|
||||||
|
MediaCDRW = 66,
|
||||||
|
MediaCDR = 67,
|
||||||
|
MediaCDBurn = 68,
|
||||||
|
MediaBlankCD = 69,
|
||||||
|
MediaCDROM = 70,
|
||||||
|
AudioFiles = 71,
|
||||||
|
ImageFiles = 72,
|
||||||
|
VideoFiles = 73,
|
||||||
|
MixedFiles = 74,
|
||||||
|
FolderBack = 75,
|
||||||
|
FolderFront = 76,
|
||||||
|
Shield = 77,
|
||||||
|
Warning = 78,
|
||||||
|
Info = 79,
|
||||||
|
Error = 80,
|
||||||
|
Key = 81,
|
||||||
|
Software = 82,
|
||||||
|
Rename = 83,
|
||||||
|
Delete = 84,
|
||||||
|
MediaAudioDVD = 85,
|
||||||
|
MediaMovieDVD = 86,
|
||||||
|
MediaEnhancedCD = 87,
|
||||||
|
MediaEnhancedDVD = 88,
|
||||||
|
MediaHDDVD = 89,
|
||||||
|
MediaBluRay = 90,
|
||||||
|
MediaVCD = 91,
|
||||||
|
MediaDVDPlusR = 92,
|
||||||
|
MediaDVDPlusRW = 93,
|
||||||
|
DesktopPC = 94,
|
||||||
|
MobilePC = 95,
|
||||||
|
Users = 96,
|
||||||
|
MediaSmartMedia = 97,
|
||||||
|
MediaCompactFlash = 98,
|
||||||
|
DeviceCellPhone = 99,
|
||||||
|
DeviceCamera = 100,
|
||||||
|
DeviceVideoCamera = 101,
|
||||||
|
DeviceAudioPlayer = 102,
|
||||||
|
NetworkConnect = 103,
|
||||||
|
Internet = 104,
|
||||||
|
ZipFile = 105,
|
||||||
|
Settings = 106
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,19 +15,31 @@
|
|||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<Style TargetType="Button">
|
<Style TargetType="Button">
|
||||||
<Setter Property="Padding" Value="10"></Setter>
|
<Setter Property="Margin" Value="3"></Setter>
|
||||||
<Setter Property="Margin" Value="5"></Setter>
|
<Setter Property="Height" Value="25"></Setter>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<ControlTemplate x:Key = "ShieldButtonTemplate" TargetType = "Button">
|
||||||
|
<Button Margin="0">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Image Source="{x:Static mpvnet:SetupWindow.ShieldIcon}"
|
||||||
|
Width="18"
|
||||||
|
Height="18"
|
||||||
|
Margin="0,0,3,0"/>
|
||||||
|
<ContentPresenter/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
</ControlTemplate>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<StackPanel Margin="10">
|
<StackPanel Margin="10">
|
||||||
<Button Name="RegisterVideo" Click="RegisterVideo_Click">Register video file extensions (requires admin rights)</Button>
|
<Button Name="RegisterVideo" Click="RegisterVideo_Click" Template="{StaticResource ShieldButtonTemplate}">Register video file extensions</Button>
|
||||||
<Button Name="RegisterAudio" Click="RegisterAudio_Click">Register audio file extensions (requires admin rights)</Button>
|
<Button Name="RegisterAudio" Click="RegisterAudio_Click" Template="{StaticResource ShieldButtonTemplate}">Register audio file extensions</Button>
|
||||||
<Button Name="RegisterImage" Click="RegisterImage_Click">Register image file extensions (requires admin rights)</Button>
|
<Button Name="RegisterImage" Click="RegisterImage_Click" Template="{StaticResource ShieldButtonTemplate}">Register image file extensions</Button>
|
||||||
<Button Name="UnregisterFileAssociations" Click="UnregisterFileAssociations_Click">Unregister file extensions (requires admin rights)</Button>
|
<Button Name="UnregisterFileAssociations" Click="UnregisterFileAssociations_Click" Template="{StaticResource ShieldButtonTemplate}">Unregister file extensions</Button>
|
||||||
<Button Name="AddToPathEnvVar" Click="AddToPathEnvVar_Click">Add mpv.net to Path environment variable</Button>
|
<Button Name="AddToPathEnvVar" Margin="3,15,3,3" Click="AddToPathEnvVar_Click">Add to Path environment variable</Button>
|
||||||
<Button Name="RemoveFromPathEnvVar" Click="RemoveFromPathEnvVar_Click">Remove mpv.net from Path environment variable</Button>
|
<Button Name="RemoveFromPathEnvVar" Padding="10,0,10,0" Click="RemoveFromPathEnvVar_Click">Remove from Path environment variable</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -2,15 +2,34 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
|
||||||
using WinForms = System.Windows.Forms;
|
using WinForms = System.Windows.Forms;
|
||||||
|
|
||||||
|
using static StockIcon;
|
||||||
|
|
||||||
namespace mpvnet
|
namespace mpvnet
|
||||||
{
|
{
|
||||||
public partial class SetupWindow : Window
|
public partial class SetupWindow : Window
|
||||||
{
|
{
|
||||||
public SetupWindow() => InitializeComponent();
|
public SetupWindow() => InitializeComponent();
|
||||||
|
|
||||||
|
static BitmapSource _ShieldIcon;
|
||||||
|
|
||||||
|
public static BitmapSource ShieldIcon {
|
||||||
|
get {
|
||||||
|
if (_ShieldIcon == null)
|
||||||
|
{
|
||||||
|
IntPtr icon = GetIcon(SHSTOCKICONID.Shield, SHSTOCKICONFLAGS.SHGSI_ICON);
|
||||||
|
_ShieldIcon = Imaging.CreateBitmapSourceFromHIcon(
|
||||||
|
icon, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
||||||
|
DestroyIcon(icon);
|
||||||
|
}
|
||||||
|
return _ShieldIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RegisterFileAssociations(string value)
|
void RegisterFileAssociations(string value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -60,5 +79,18 @@ namespace mpvnet
|
|||||||
else
|
else
|
||||||
Msg.ShowWarning("Path was not containing mpv.net.");
|
Msg.ShowWarning("Path was not containing mpv.net.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void aaa()
|
||||||
|
{
|
||||||
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
|
||||||
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace WPF
|
namespace WPF
|
||||||
|
|||||||
@@ -814,6 +814,9 @@ namespace mpvnet
|
|||||||
core.LoadScripts();
|
core.LoadScripts();
|
||||||
Task.Run(() => App.Extension = new Extension());
|
Task.Run(() => App.Extension = new Extension());
|
||||||
ShownTickCount = Environment.TickCount;
|
ShownTickCount = Environment.TickCount;
|
||||||
|
|
||||||
|
SetupWindow win = new SetupWindow();
|
||||||
|
win.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnActivated(EventArgs e)
|
protected override void OnActivated(EventArgs e)
|
||||||
|
|||||||
@@ -134,6 +134,7 @@
|
|||||||
<Compile Include="Misc\RegistryHelp.cs" />
|
<Compile Include="Misc\RegistryHelp.cs" />
|
||||||
<Compile Include="Misc\Theme.cs" />
|
<Compile Include="Misc\Theme.cs" />
|
||||||
<Compile Include="Misc\PowerShell.cs" />
|
<Compile Include="Misc\PowerShell.cs" />
|
||||||
|
<Compile Include="Native\StockIcon.cs" />
|
||||||
<Compile Include="WPF\SearchTextBoxUserControl.xaml.cs">
|
<Compile Include="WPF\SearchTextBoxUserControl.xaml.cs">
|
||||||
<DependentUpon>SearchTextBoxUserControl.xaml</DependentUpon>
|
<DependentUpon>SearchTextBoxUserControl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
Reference in New Issue
Block a user