new theme feature
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
###
|
||||
|
||||
- fix: window restore was broken
|
||||
- fix: window restore from maximized and from minimized was broken
|
||||
- fix: it's possible to multi select files in File Explorer and press
|
||||
enter to open the files, this did however only work when the
|
||||
auto load folder feature was disabled or the shift key was
|
||||
pressed (blocks auto load folder). Now it should also work
|
||||
without shift key and with auto load folder being enabled.
|
||||
|
||||
- update: libmpv shinchiro 2019-10-27
|
||||
- update: youtube-dl 2019-10-31
|
||||
|
||||
### 5.4.2.1 Beta
|
||||
|
||||
- pressing shift key suppresses auto-load-folder
|
||||
|
||||
14
Manual.md
14
Manual.md
@@ -90,6 +90,7 @@
|
||||
+ [Exit](#exit)
|
||||
+ [Exit Watch Later](#exit-watch-later)
|
||||
* [Command Line Interface](#command-line-interface)
|
||||
* [Theme](#theme)
|
||||
|
||||
## About mpv.net
|
||||
|
||||
@@ -819,8 +820,17 @@ Exits mpv.net and remembers the position in the file using the following command
|
||||
|
||||
## Command Line Interface
|
||||
|
||||
mpvnet implements a basic CLI to set mpv commands.
|
||||
mpvnet implements a command line interface to set mpv commands.
|
||||
|
||||
Supported are all mpv properties which are documented at:
|
||||
|
||||
<https://mpv.io/manual/master>
|
||||
|
||||
Example:
|
||||
|
||||
mpvnet --mute=yes <file|URL>
|
||||
mpvnet --mute=yes <file|URL>
|
||||
|
||||
## Theme
|
||||
|
||||
mpv.net supports custom themes, the definition of the built-in themes can be found at:
|
||||
|
||||
|
||||
@@ -4,22 +4,58 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox x:Name="TitleTextBox" FontSize="24" Margin="0,10" BorderThickness="0" IsReadOnly="True" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"></TextBox>
|
||||
<TextBox x:Name="TitleTextBox"
|
||||
FontSize="24"
|
||||
Margin="0,10"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{x:Static UI:Theme.Heading}"
|
||||
Background="{x:Static UI:Theme.Background}" />
|
||||
|
||||
<ItemsControl x:Name="ItemsControl">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<WrapPanel Orientation="Vertical">
|
||||
<RadioButton x:Name="RadioButton" VerticalContentAlignment="Center" IsChecked="{Binding Checked}" GroupName="{Binding OptionSetting.Name}" Content="{Binding Text}" FontSize="16" FontWeight="Normal" VerticalAlignment="Top" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"></RadioButton>
|
||||
<TextBox x:Name="ItemHelpTextBox" TextWrapping="WrapWithOverflow" Text="{Binding Help}" Visibility="{Binding Visibility}" Margin="10,0,0,0" BorderThickness="0" IsReadOnly="True" Padding="7,0,0,0" MinHeight="0" Foreground="{Binding Path=Foreground2, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"></TextBox>
|
||||
<RadioButton x:Name="RadioButton"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Checked}"
|
||||
GroupName="{Binding OptionSetting.Name}"
|
||||
Content="{Binding Text}"
|
||||
FontSize="16"
|
||||
FontWeight="Normal"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"/>
|
||||
|
||||
<TextBox x:Name="ItemHelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
Text="{Binding Help}"
|
||||
Visibility="{Binding Visibility}"
|
||||
Margin="10,0,0,0" BorderThickness="0"
|
||||
IsReadOnly="True" Padding="7,0,0,0"
|
||||
MinHeight="0"
|
||||
Foreground="{x:Static UI:Theme.Foreground2}"
|
||||
Background="{x:Static UI:Theme.Background}"/>
|
||||
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<TextBox x:Name="HelpTextBox" TextWrapping="WrapWithOverflow" BorderThickness="0" IsReadOnly="True" Margin="0,10,0,0" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"></TextBox>
|
||||
|
||||
<TextBox x:Name="HelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Margin="0,10,0,0"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"/>
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
|
||||
@@ -4,21 +4,52 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox x:Name="TitleTextBox" FontSize="24" Margin="0,10" BorderThickness="0" IsReadOnly="True" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"></TextBox>
|
||||
<TextBox x:Name="TitleTextBox"
|
||||
FontSize="24"
|
||||
Margin="0,10"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{x:Static UI:Theme.Heading}"
|
||||
Background="{x:Static UI:Theme.Background}"/>
|
||||
|
||||
<Grid Margin="0,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="ValueTextBox" Text="{Binding Path=Text, ElementName=StringSettingControl1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="150" HorizontalAlignment="Left" Height="20" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" CaretBrush="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" TextChanged="ValueTextBox_TextChanged"/>
|
||||
<Button x:Name="Button" Height="20" Grid.Column="1" Visibility="{Binding Path=Text, ElementName=StringSettingControl1}" Margin="5,0,0,0" Width="20" Click="Button_Click">...</Button>
|
||||
<TextBox x:Name="ValueTextBox"
|
||||
Text="{Binding Path=Text, ElementName=StringSettingControl1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Width="150"
|
||||
Height="20"
|
||||
HorizontalAlignment="Left"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
CaretBrush="{x:Static UI:Theme.Foreground}"
|
||||
TextChanged="ValueTextBox_TextChanged"/>
|
||||
|
||||
<Button x:Name="Button"
|
||||
Height="20"
|
||||
Grid.Column="1"
|
||||
Visibility="{Binding Path=Text, ElementName=StringSettingControl1}"
|
||||
Margin="5,0,0,0"
|
||||
Width="20"
|
||||
Click="Button_Click">...</Button>
|
||||
</Grid>
|
||||
<TextBox x:Name="HelpTextBox" TextWrapping="WrapWithOverflow" BorderThickness="0" IsReadOnly="True" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"></TextBox>
|
||||
|
||||
<TextBox x:Name="HelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"/>
|
||||
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
|
||||
@@ -61,18 +61,20 @@ namespace DynamicGUI
|
||||
}
|
||||
break;
|
||||
case "color":
|
||||
using (var d = new WinForms.ColorDialog())
|
||||
using (var dialog = new WinForms.ColorDialog())
|
||||
{
|
||||
d.FullOpen = true;
|
||||
dialog.FullOpen = true;
|
||||
|
||||
try {
|
||||
if (!string.IsNullOrEmpty(ValueTextBox.Text))
|
||||
{
|
||||
Color col = GetColor(ValueTextBox.Text);
|
||||
d.Color = System.Drawing.Color.FromArgb(col.A, col.R, col.G, col.B);
|
||||
dialog.Color = System.Drawing.Color.FromArgb(col.A, col.R, col.G, col.B);
|
||||
}
|
||||
} catch {}
|
||||
if (d.ShowDialog() == WinForms.DialogResult.OK)
|
||||
ValueTextBox.Text = "#" + d.Color.ToArgb().ToString("X8");
|
||||
|
||||
if (dialog.ShowDialog() == WinForms.DialogResult.OK)
|
||||
ValueTextBox.Text = "#" + dialog.Color.ToArgb().ToString("X8");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using UI;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -15,10 +16,10 @@ namespace mpvnet
|
||||
|
||||
public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName;
|
||||
public static string ConfPath { get => mp.ConfigFolder + "mpvnet.conf"; }
|
||||
public static string DarkMode { get; set; } = "always";
|
||||
public static string ProcessInstance { get; set; } = "single";
|
||||
public static string DarkColor { get; set; }
|
||||
public static string LightColor { get; set; }
|
||||
public static string DarkMode { get; set; } = "always";
|
||||
public static string DarkTheme { get; set; } = "dark";
|
||||
public static string LightTheme { get; set; } = "light";
|
||||
|
||||
public static bool RememberHeight { get; set; } = true;
|
||||
public static bool RememberPosition { get; set; }
|
||||
@@ -27,7 +28,6 @@ namespace mpvnet
|
||||
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
|
||||
public static bool RememberVolume { get; set; } = true;
|
||||
public static bool AutoLoadFolder { get; set; } = true;
|
||||
public static bool ThemedMenu { get; set; }
|
||||
public static bool Queue { get; set; }
|
||||
|
||||
public static int StartThreshold { get; set; } = 1500;
|
||||
@@ -65,6 +65,16 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
string themeContent = null;
|
||||
|
||||
if (File.Exists(mp.ConfigFolder + "theme.conf"))
|
||||
themeContent = File.ReadAllText(mp.ConfigFolder + "theme.conf");
|
||||
|
||||
Theme.Init(
|
||||
themeContent,
|
||||
Properties.Resources.theme,
|
||||
IsDarkMode ? DarkTheme : LightTheme);
|
||||
|
||||
mp.Shutdown += Shutdown;
|
||||
mp.Initialized += Initialized;
|
||||
}
|
||||
@@ -114,15 +124,14 @@ namespace mpvnet
|
||||
case "process-instance": ProcessInstance = value; return true;
|
||||
case "dark-mode": DarkMode = value; return true;
|
||||
case "debug-mode": DebugMode = value == "yes"; return true;
|
||||
case "dark-color": DarkColor = value.Trim('\'', '"'); return true;
|
||||
case "light-color": LightColor = value.Trim('\'', '"'); return true;
|
||||
case "remember-volume": RememberVolume = value == "yes"; return true;
|
||||
case "start-threshold": StartThreshold = value.Int(); return true;
|
||||
case "minimum-aspect-ratio": MinimumAspectRatio = value.Float(); return true;
|
||||
case "auto-load-folder": AutoLoadFolder = value == "yes"; return true;
|
||||
case "themed-menu": ThemedMenu = value == "yes"; return true;
|
||||
case "recent-count": RecentCount = value.Int(); return true;
|
||||
case "queue": Queue = value == "yes"; return true;
|
||||
case "dark-theme": DarkTheme = value.Trim('\'', '"'); return true;
|
||||
case "light-theme": LightTheme = value.Trim('\'', '"'); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
11
mpv.net/Misc/Help.cs
Normal file
11
mpv.net/Misc/Help.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
class ConsoleHelp
|
||||
{
|
||||
public static void WriteError(object obj)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine(obj?.ToString());
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,11 @@ namespace mpvnet
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
if (mp.ConfigFolder == "") return;
|
||||
if (App.IsStartedFromTerminal)
|
||||
Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
|
||||
|
||||
if (mp.ConfigFolder == "")
|
||||
return;
|
||||
|
||||
string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
|
||||
|
||||
@@ -62,20 +66,26 @@ namespace mpvnet
|
||||
data.cbData = data.lpData.Length * 2 + 1;
|
||||
Native.SendMessage(proc.MainWindowHandle, 0x004A /*WM_COPYDATA*/, IntPtr.Zero, ref data);
|
||||
mutex.Dispose();
|
||||
|
||||
if (App.IsStartedFromTerminal)
|
||||
Native.FreeConsole();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
|
||||
mutex.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
if (App.IsStartedFromTerminal)
|
||||
Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
|
||||
|
||||
Application.Run(new MainForm());
|
||||
if (App.IsStartedFromTerminal) Native.FreeConsole();
|
||||
|
||||
if (App.IsStartedFromTerminal)
|
||||
Native.FreeConsole();
|
||||
|
||||
mutex.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
96
mpv.net/Misc/Theme.cs
Normal file
96
mpv.net/Misc/Theme.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class Theme
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Dictionary<string, string> Dictionary { get; } = new Dictionary<string, string>();
|
||||
|
||||
public static List<Theme> DefaultThemes { get; set; }
|
||||
public static List<Theme> CustomThemes { get; set; }
|
||||
|
||||
public static Theme Current { get; set; }
|
||||
|
||||
public static Brush Foreground { get; set; }
|
||||
public static Brush Foreground2 { get; set; }
|
||||
public static Brush Background { get; set; }
|
||||
public static Brush Heading { get; set; }
|
||||
|
||||
public System.Drawing.Color GetWinFormsColor(string key)
|
||||
{
|
||||
return System.Drawing.ColorTranslator.FromHtml(Dictionary[key]);
|
||||
}
|
||||
|
||||
public Brush GetBrush(string key)
|
||||
{
|
||||
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(Dictionary[key]));
|
||||
}
|
||||
|
||||
public static void Init(string customContent, string defaultContent, string activeTheme)
|
||||
{
|
||||
DefaultThemes = Load(defaultContent);
|
||||
CustomThemes = Load(customContent);
|
||||
|
||||
foreach (Theme theme in CustomThemes)
|
||||
{
|
||||
if (theme.Name == activeTheme)
|
||||
{
|
||||
bool isKeyMissing = false;
|
||||
|
||||
foreach (string key in DefaultThemes[0].Dictionary.Keys)
|
||||
{
|
||||
if (!theme.Dictionary.ContainsKey(key))
|
||||
{
|
||||
isKeyMissing = true;
|
||||
ConsoleHelp.WriteError($"Theme '{activeTheme}' misses '{key}'");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isKeyMissing)
|
||||
Current = theme;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Current == null)
|
||||
foreach (Theme theme in DefaultThemes)
|
||||
if (theme.Name == activeTheme)
|
||||
Current = theme;
|
||||
|
||||
if (Current == null)
|
||||
Current = DefaultThemes[0];
|
||||
|
||||
Foreground = Current.GetBrush("foreground");
|
||||
Foreground2 = Current.GetBrush("foreground2");
|
||||
Background = Current.GetBrush("background");
|
||||
Heading = Current.GetBrush("heading");
|
||||
}
|
||||
|
||||
static List<Theme> Load(string content)
|
||||
{
|
||||
List<Theme> list = new List<Theme>();
|
||||
Theme theme = null;
|
||||
|
||||
foreach (string currentLine in (content ?? "").Split(new [] { '\r', '\n' }))
|
||||
{
|
||||
string line = currentLine.Trim();
|
||||
|
||||
if (line.StartsWith("[") && line.EndsWith("]"))
|
||||
list.Add(theme = new Theme() { Name = line.Substring(1, line.Length - 2).Trim() });
|
||||
|
||||
if (line.Contains("=") && theme != null)
|
||||
{
|
||||
string left = line.Substring(0, line.IndexOf("=")).Trim();
|
||||
theme.Dictionary[left] = line.Substring(line.IndexOf("=") + 1).Trim();
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
mpv.net/Properties/Resources.Designer.cs
generated
39
mpv.net/Properties/Resources.Designer.cs
generated
@@ -71,9 +71,9 @@ namespace mpvnet.Properties {
|
||||
///options = [{ name = "no", help = "always use software decoding" },
|
||||
/// { name = "auto", hel [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string ConfToml {
|
||||
internal static string confToml {
|
||||
get {
|
||||
return ResourceManager.GetString("ConfToml", resourceCulture);
|
||||
return ResourceManager.GetString("confToml", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace mpvnet.Properties {
|
||||
///keep-open = yes
|
||||
///keep-open-pause = no
|
||||
///osd-playing-msg = '${filename}'
|
||||
///script-opts=osc-scalewindowed=1.5
|
||||
///script-opts = osc-scalewindowed=1.5
|
||||
///screenshot-directory = '~~desktop/'
|
||||
///cscale = spline36
|
||||
///dscale = spline36
|
||||
@@ -132,12 +132,37 @@ namespace mpvnet.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to dark-color = '#1E90FF'
|
||||
///light-color = '#28394F'.
|
||||
/// Looks up a localized string similar to
|
||||
///[dark]
|
||||
///
|
||||
///heading = #1E90FF
|
||||
///foreground = #FFFFFF
|
||||
///foreground2 = #C0C0C0
|
||||
///background = #323232
|
||||
///
|
||||
///menu-foreground = #FFFFFF
|
||||
///menu-background = #323232
|
||||
///menu-highlight = #505050
|
||||
///menu-border = #FFFFFF
|
||||
///menu-checked = #5A5A5A
|
||||
///
|
||||
///[light]
|
||||
///
|
||||
///heading = #0068B2
|
||||
///foreground = #000000
|
||||
///foreground2 = #4C4C4C
|
||||
///background = #F7F7F7
|
||||
///
|
||||
///menu-foreground = #000000
|
||||
///menu-background = #DFDFDF
|
||||
///menu-highlight = #BFBFBF
|
||||
///menu-border = #6A6A6A
|
||||
///menu-checked = #AAAAAA
|
||||
///.
|
||||
/// </summary>
|
||||
internal static string mpvNetConf {
|
||||
internal static string theme {
|
||||
get {
|
||||
return ResourceManager.GetString("mpvNetConf", resourceCulture);
|
||||
return ResourceManager.GetString("theme", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="ConfToml" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<data name="confToml" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ConfToml.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
<data name="inputConf" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
@@ -130,7 +130,7 @@
|
||||
<data name="mpvnet" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\mpvnet.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="mpvNetConf" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\mpvNetConf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
<data name="theme" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\theme.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -537,24 +537,13 @@ options = [{ name = "always" },
|
||||
{ name = "never" }]
|
||||
|
||||
[[settings]]
|
||||
name = "dark-color"
|
||||
name = "dark-theme"
|
||||
file = "mpvnet"
|
||||
type = "color"
|
||||
filter = "UI"
|
||||
help = "Theme color used in dark-mode. Leave empty to use OS theme. (mpv.net specific setting)"
|
||||
help = "Color theme used in dark mode. Default: dark"
|
||||
|
||||
[[settings]]
|
||||
name = "light-color"
|
||||
name = "light-theme"
|
||||
file = "mpvnet"
|
||||
type = "color"
|
||||
filter = "UI"
|
||||
help = "Theme color used when dark-mode is disabled. Leave empty to use OS theme. (mpv.net specific setting)"
|
||||
|
||||
[[settings]]
|
||||
name = "themed-menu"
|
||||
file = "mpvnet"
|
||||
default = "no"
|
||||
filter = "UI"
|
||||
help = "Follow theme color in context menu. (mpv.net specific setting)"
|
||||
options = [{ name = "yes" },
|
||||
{ name = "no" }]
|
||||
help = "Color theme used in light mode. Default: light"
|
||||
@@ -1,2 +0,0 @@
|
||||
dark-color = '#1E90FF'
|
||||
light-color = '#28394F'
|
||||
27
mpv.net/Resources/theme.txt
Normal file
27
mpv.net/Resources/theme.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
[dark]
|
||||
|
||||
heading = #1E90FF
|
||||
foreground = #FFFFFF
|
||||
foreground2 = #C0C0C0
|
||||
background = #323232
|
||||
|
||||
menu-foreground = #FFFFFF
|
||||
menu-background = #323232
|
||||
menu-highlight = #505050
|
||||
menu-border = #FFFFFF
|
||||
menu-checked = #5A5A5A
|
||||
|
||||
|
||||
[light]
|
||||
|
||||
heading = #0068B2
|
||||
foreground = #000000
|
||||
foreground2 = #4C4C4C
|
||||
background = #F7F7F7
|
||||
|
||||
menu-foreground = #000000
|
||||
menu-background = #DFDFDF
|
||||
menu-highlight = #BFBFBF
|
||||
menu-border = #6A6A6A
|
||||
menu-checked = #AAAAAA
|
||||
@@ -94,20 +94,24 @@ namespace mpvnet
|
||||
|
||||
public void Output_DataReady(object sender, EventArgs e)
|
||||
{
|
||||
if (!WriteStandard) return;
|
||||
if (!WriteStandard)
|
||||
return;
|
||||
|
||||
var output = sender as PipelineReader<PSObject>;
|
||||
|
||||
while (output.Count > 0)
|
||||
Console.WriteLine("[" + ModuleName + "] " + output.Read().ToString());
|
||||
}
|
||||
|
||||
public void Error_DataReady(object sender, EventArgs e)
|
||||
{
|
||||
if (!WriteError) return;
|
||||
if (!WriteError)
|
||||
return;
|
||||
|
||||
var output = sender as PipelineReader<Object>;
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
|
||||
while (output.Count > 0)
|
||||
Console.WriteLine("[" + ModuleName + "] " + output.Read().ToString());
|
||||
Console.ResetColor();
|
||||
ConsoleHelp.WriteError("[" + ModuleName + "] " + output.Read().ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,19 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
Title="About mpv.net" Height="230" Width="400" FontSize="16" ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterOwner" ResizeMode="NoResize">
|
||||
|
||||
Title="About mpv.net"
|
||||
Height="230"
|
||||
Width="400"
|
||||
FontSize="16"
|
||||
ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}">
|
||||
|
||||
<Grid>
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock FontSize="48" HorizontalAlignment="Center" Margin="0,0,0,10">mpv.net</TextBlock>
|
||||
|
||||
@@ -3,21 +3,41 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
Title="Command Palette" Height="295" Width="400" ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterOwner" Loaded="Window_Loaded" FontSize="13">
|
||||
|
||||
Title="Command Palette"
|
||||
Height="295"
|
||||
Width="400"
|
||||
FontSize="13"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Loaded="Window_Loaded">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Name="FilterTextBox" PreviewKeyDown="FilterTextBox_PreviewKeyDown" TextChanged="FilterTextBox_TextChanged"></TextBox>
|
||||
<ListView Name="ListView" Grid.Row="1" MouseUp="ListView_MouseUp">
|
||||
|
||||
<TextBox Name="FilterTextBox"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
PreviewKeyDown="FilterTextBox_PreviewKeyDown"
|
||||
TextChanged="FilterTextBox_TextChanged"/>
|
||||
|
||||
<ListView Name="ListView"
|
||||
Grid.Row="1"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
MouseUp="ListView_MouseUp">
|
||||
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
@@ -25,8 +45,12 @@
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Path}"></TextBlock>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Input}" HorizontalAlignment="Right"></TextBlock>
|
||||
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding Input}"
|
||||
HorizontalAlignment="Right"></TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
|
||||
@@ -23,14 +23,6 @@ namespace mpvnet
|
||||
var yourCostumFilter = new Predicate<object>(item => Filter((CommandItem)item));
|
||||
CollectionView.Filter = yourCostumFilter;
|
||||
ListView.ItemsSource = CollectionView;
|
||||
|
||||
if (App.IsDarkMode)
|
||||
{
|
||||
ListView.Foreground = Brushes.White;
|
||||
ListView.Background = Brushes.Black;
|
||||
FilterTextBox.Foreground = Brushes.White;
|
||||
FilterTextBox.Background = Brushes.Black;
|
||||
}
|
||||
}
|
||||
|
||||
bool Filter(CommandItem item)
|
||||
|
||||
@@ -3,35 +3,63 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:WPF="clr-namespace:WPF"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
Height="530" Width="700" Loaded="ConfWindow1_Loaded" ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterScreen" Title="Config Editor">
|
||||
|
||||
Title="Config Editor"
|
||||
Height="530"
|
||||
Width="700"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Loaded="ConfWindow1_Loaded">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Controls:SearchTextBoxUserControl HintText="Find a setting" x:Name="SearchControl" Width="250" Margin="0,20,0,0" Grid.ColumnSpan="2"/>
|
||||
<ScrollViewer x:Name="MainScrollViewer" VerticalScrollBarVisibility="Auto" Grid.Row="1" Grid.Column="2" Margin="0,0,0,10">
|
||||
|
||||
<Controls:SearchTextBoxUserControl HintText="Find a setting"
|
||||
x:Name="SearchControl"
|
||||
Width="250"
|
||||
Margin="0,20,0,0"
|
||||
Grid.ColumnSpan="2"/>
|
||||
|
||||
<ScrollViewer x:Name="MainScrollViewer"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Margin="0,0,0,10">
|
||||
|
||||
<StackPanel x:Name="MainStackPanel"></StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<StackPanel Margin="20,0,0,0" Grid.Row="1">
|
||||
<ListBox x:Name="FilterListBox" ItemsSource="{Binding FilterStrings}" BorderThickness="0" SelectionChanged="FilterListBox_SelectionChanged" Foreground="{x:Static WPF:WPF.ThemeBrush}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
|
||||
<ListBox x:Name="FilterListBox"
|
||||
ItemsSource="{Binding FilterStrings}"
|
||||
BorderThickness="0"
|
||||
SelectionChanged="FilterListBox_SelectionChanged"
|
||||
Foreground="{x:Static UI:Theme.Heading}"
|
||||
Background="{x:Static UI:Theme.Background}">
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" FontSize="16" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<TextBlock x:Name="OpenSettingsTextBlock" Margin="0,30,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static WPF:WPF.ThemeBrush}" MouseUp="OpenSettingsTextBlock_MouseUp">Open config folder</TextBlock>
|
||||
<TextBlock x:Name="PreviewTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static WPF:WPF.ThemeBrush}" MouseUp="PreviewTextBlock_MouseUp">Preview mpv.conf</TextBlock>
|
||||
<TextBlock x:Name="ShowManualTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static WPF:WPF.ThemeBrush}" MouseUp="ShowManualTextBlock_MouseUp">Show mpv manual</TextBlock>
|
||||
<TextBlock x:Name="SupportTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static WPF:WPF.ThemeBrush}" MouseUp="SupportTextBlock_MouseUp">Show support forum</TextBlock>
|
||||
|
||||
<TextBlock x:Name="OpenSettingsTextBlock" Margin="0,30,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static UI:Theme.Heading}" MouseUp="OpenSettingsTextBlock_MouseUp">Open config folder</TextBlock>
|
||||
<TextBlock x:Name="PreviewTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static UI:Theme.Heading}" MouseUp="PreviewTextBlock_MouseUp">Preview mpv.conf</TextBlock>
|
||||
<TextBlock x:Name="ShowManualTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static UI:Theme.Heading}" MouseUp="ShowManualTextBlock_MouseUp">Show mpv manual</TextBlock>
|
||||
<TextBlock x:Name="SupportTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static UI:Theme.Heading}" MouseUp="SupportTextBlock_MouseUp">Show support forum</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,26 +1,26 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Linq;
|
||||
|
||||
using DynamicGUI;
|
||||
using System.Text;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public partial class ConfWindow : Window
|
||||
{
|
||||
private List<SettingBase> SettingsDefinitions = Settings.LoadSettings(Properties.Resources.ConfToml);
|
||||
private List<ConfItem> ConfItems = new List<ConfItem>();
|
||||
List<SettingBase> SettingsDefinitions = Settings.LoadSettings(Properties.Resources.confToml);
|
||||
List<ConfItem> ConfItems = new List<ConfItem>();
|
||||
public ObservableCollection<string> FilterStrings { get; } = new ObservableCollection<string>();
|
||||
string InitialContent;
|
||||
|
||||
|
||||
public ConfWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -31,23 +31,8 @@ namespace mpvnet
|
||||
LoadSettings();
|
||||
InitialContent = GetCompareString();
|
||||
SearchControl.Text = RegHelp.GetString(App.RegPath, "ConfigEditorSearch");
|
||||
|
||||
if (App.IsDarkMode)
|
||||
{
|
||||
Foreground = Brushes.White;
|
||||
Foreground2 = Brushes.Silver;
|
||||
Background = Brushes.Black;
|
||||
}
|
||||
}
|
||||
|
||||
public Brush Foreground2 {
|
||||
get { return (Brush)GetValue(Foreground2Property); }
|
||||
set { SetValue(Foreground2Property, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty Foreground2Property =
|
||||
DependencyProperty.Register("Foreground2", typeof(Brush), typeof(ConfWindow), new PropertyMetadata(Brushes.DarkSlateGray));
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
foreach (SettingBase setting in SettingsDefinitions)
|
||||
@@ -70,12 +55,10 @@ namespace mpvnet
|
||||
{
|
||||
case StringSetting s:
|
||||
var sc = new StringSettingControl(s);
|
||||
sc.TitleTextBox.Foreground = WPF.WPF.ThemeBrush;
|
||||
MainStackPanel.Children.Add(sc);
|
||||
break;
|
||||
case OptionSetting s:
|
||||
var oc = new OptionSettingControl(s);
|
||||
oc.TitleTextBox.Foreground = WPF.WPF.ThemeBrush;
|
||||
MainStackPanel.Children.Add(oc);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,21 +3,42 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
Title="Media File Search" Height="300" Width="600" ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterOwner" Loaded="Window_Loaded" FontSize="13">
|
||||
|
||||
Title="Media File Search"
|
||||
FontSize="13"
|
||||
Height="300"
|
||||
Width="600"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Loaded="Window_Loaded">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Name="FilterTextBox" PreviewKeyDown="FilterTextBox_PreviewKeyDown" TextChanged="FilterTextBox_TextChanged"></TextBox>
|
||||
<ListView Name="ListView" Grid.Row="1" MouseUp="ListView_MouseUp" PreviewKeyDown="ListView_PreviewKeyDown">
|
||||
|
||||
<TextBox Name="FilterTextBox"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
PreviewKeyDown="FilterTextBox_PreviewKeyDown"
|
||||
TextChanged="FilterTextBox_TextChanged"/>
|
||||
|
||||
<ListView Name="ListView"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
Grid.Row="1"
|
||||
MouseUp="ListView_MouseUp"
|
||||
PreviewKeyDown="ListView_PreviewKeyDown">
|
||||
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -8,7 +9,6 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -17,19 +17,10 @@ namespace mpvnet
|
||||
public EverythingWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (App.IsDarkMode)
|
||||
{
|
||||
ListView.Foreground = Brushes.White;
|
||||
ListView.Background = Brushes.Black;
|
||||
FilterTextBox.Foreground = Brushes.White;
|
||||
FilterTextBox.Background = Brushes.Black;
|
||||
}
|
||||
}
|
||||
|
||||
const int EVERYTHING_REQUEST_FILE_NAME = 0x00000001;
|
||||
const int EVERYTHING_REQUEST_PATH = 0x00000002;
|
||||
const int EVERYTHING_SORT_SIZE_DESCENDING = 6;
|
||||
|
||||
[DllImport("Everything.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern int Everything_SetSearch(string lpSearchString);
|
||||
@@ -69,6 +60,7 @@ namespace mpvnet
|
||||
{
|
||||
if (msg == 0x200 /*WM_MOUSEMOVE*/ && Mouse.LeftButton != MouseButtonState.Pressed)
|
||||
handled = true;
|
||||
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
@@ -101,14 +93,18 @@ namespace mpvnet
|
||||
|
||||
private void ListView_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Escape) Close();
|
||||
if (e.Key == Key.Enter) Execute();
|
||||
if (e.Key == Key.Escape)
|
||||
Close();
|
||||
|
||||
if (e.Key == Key.Enter)
|
||||
Execute();
|
||||
}
|
||||
|
||||
void Execute()
|
||||
{
|
||||
if (ListView.SelectedItem != null)
|
||||
mp.Load(new[] { ListView.SelectedItem as string }, true, Keyboard.Modifiers == ModifierKeys.Control);
|
||||
|
||||
Keyboard.Focus(FilterTextBox);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,25 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
Title="Input Editor" Height="500" Width="750" FontSize="13"
|
||||
Loaded="Window_Loaded" Closed="Window_Closed" ShowInTaskbar="False">
|
||||
|
||||
Title="Input Editor"
|
||||
Height="500"
|
||||
Width="750"
|
||||
FontSize="13"
|
||||
ShowInTaskbar="False"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
Loaded="Window_Loaded"
|
||||
Closed="Window_Closed">
|
||||
|
||||
<Window.Resources>
|
||||
<Style x:Key="DataGrid_Font_Centering" TargetType="{x:Type DataGridCell}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGridCell}">
|
||||
<Grid Background="{TemplateBinding Background}">
|
||||
<Grid>
|
||||
<ContentPresenter VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
@@ -19,15 +29,29 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Controls:SearchTextBoxUserControl HintText="Type ? to get help." x:Name="SearchControl" Width="300" Margin="0,20,0,20" Grid.ColumnSpan="2" />
|
||||
<DataGrid Grid.Row="1" x:Name="DataGrid" CommandManager.PreviewCanExecute="DataGrid_PreviewCanExecute" AutoGenerateColumns="False" CellStyle="{StaticResource DataGrid_Font_Centering}">
|
||||
|
||||
<Controls:SearchTextBoxUserControl
|
||||
HintText="Type ? to get help."
|
||||
x:Name="SearchControl"
|
||||
Width="300"
|
||||
Margin="0,20,0,20"
|
||||
Grid.ColumnSpan="2" />
|
||||
|
||||
<DataGrid x:Name="DataGrid"
|
||||
Grid.Row="1"
|
||||
CommandManager.PreviewCanExecute="DataGrid_PreviewCanExecute"
|
||||
AutoGenerateColumns="False"
|
||||
CellStyle="{StaticResource DataGrid_Font_Centering}" >
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Menu" Binding="{Binding Path}"/>
|
||||
|
||||
<DataGridTemplateColumn Header="Input">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
@@ -37,7 +61,9 @@
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTextColumn Header="Command" Binding="{Binding Command}" MaxWidth="330" />
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
@@ -6,7 +7,6 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -26,23 +26,8 @@ namespace mpvnet
|
||||
var yourCostumFilter = new Predicate<object>(item => Filter((CommandItem)item));
|
||||
CollectionView.Filter = yourCostumFilter;
|
||||
DataGrid.ItemsSource = CollectionView;
|
||||
|
||||
if (App.IsDarkMode)
|
||||
{
|
||||
Foreground = Brushes.White;
|
||||
Foreground2 = Brushes.Silver;
|
||||
Background = Brushes.Black;
|
||||
}
|
||||
}
|
||||
|
||||
public Brush Foreground2 {
|
||||
get { return (Brush)GetValue(Foreground2Property); }
|
||||
set { SetValue(Foreground2Property, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty Foreground2Property =
|
||||
DependencyProperty.Register("Foreground2", typeof(Brush), typeof(InputWindow), new PropertyMetadata(Brushes.DarkSlateGray));
|
||||
|
||||
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
CollectionView.Refresh();
|
||||
|
||||
@@ -3,21 +3,47 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
Title="Learn Input" Height="200" Width="400" WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize" Loaded="Window_Loaded" Background="Black" MouseWheel="Window_MouseWheel" MouseUp="Window_MouseUp" MouseDoubleClick="Window_MouseDoubleClick" TextInput="Window_TextInput">
|
||||
|
||||
Title="Learn Input"
|
||||
Height="200"
|
||||
Width="400"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
Loaded="Window_Loaded"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
MouseWheel="Window_MouseWheel"
|
||||
MouseUp="Window_MouseUp"
|
||||
MouseDoubleClick="Window_MouseDoubleClick"
|
||||
TextInput="Window_TextInput">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="40" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="MenuTextBlock" Grid.ColumnSpan="2" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16"></TextBlock>
|
||||
<TextBlock x:Name="KeyTextBlock" Grid.Row="1" Grid.ColumnSpan="2" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Center" FontSize="16"></TextBlock>
|
||||
|
||||
<TextBlock x:Name="MenuTextBlock"
|
||||
Grid.ColumnSpan="2"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="16"></TextBlock>
|
||||
|
||||
<TextBlock x:Name="KeyTextBlock"
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="16" />
|
||||
|
||||
<Button x:Name="ConfirmButton" Grid.Row="2" Click="ConfirmButton_Click">Confirm</Button>
|
||||
<Button x:Name="ClearButton" Grid.Row="2" Click="ClearButton_Click" Grid.Column="1">Clear</Button>
|
||||
</Grid>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using WF = System.Windows.Forms;
|
||||
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -17,7 +19,7 @@ namespace mpvnet
|
||||
|
||||
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
WF.Message m = new WF.Message();
|
||||
WinForms.Message m = new WinForms.Message();
|
||||
m.HWnd = hwnd;
|
||||
m.Msg = msg;
|
||||
m.WParam = wParam;
|
||||
@@ -26,10 +28,10 @@ namespace mpvnet
|
||||
return m.Result;
|
||||
}
|
||||
|
||||
void OnKeyUp(WF.KeyEventArgs e)
|
||||
void OnKeyUp(WinForms.KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == WF.Keys.ControlKey || e.KeyCode == WF.Keys.ShiftKey ||
|
||||
e.KeyCode == WF.Keys.Menu || e.KeyCode == WF.Keys.None)
|
||||
if (e.KeyCode == WinForms.Keys.ControlKey || e.KeyCode == WinForms.Keys.ShiftKey ||
|
||||
e.KeyCode == WinForms.Keys.Menu || e.KeyCode == WinForms.Keys.None)
|
||||
|
||||
return;
|
||||
|
||||
@@ -49,70 +51,70 @@ namespace mpvnet
|
||||
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case WF.Keys.NumPad0:
|
||||
case WF.Keys.NumPad1:
|
||||
case WF.Keys.NumPad2:
|
||||
case WF.Keys.NumPad3:
|
||||
case WF.Keys.NumPad4:
|
||||
case WF.Keys.NumPad5:
|
||||
case WF.Keys.NumPad6:
|
||||
case WF.Keys.NumPad7:
|
||||
case WF.Keys.NumPad8:
|
||||
case WF.Keys.NumPad9:
|
||||
case WinForms.Keys.NumPad0:
|
||||
case WinForms.Keys.NumPad1:
|
||||
case WinForms.Keys.NumPad2:
|
||||
case WinForms.Keys.NumPad3:
|
||||
case WinForms.Keys.NumPad4:
|
||||
case WinForms.Keys.NumPad5:
|
||||
case WinForms.Keys.NumPad6:
|
||||
case WinForms.Keys.NumPad7:
|
||||
case WinForms.Keys.NumPad8:
|
||||
case WinForms.Keys.NumPad9:
|
||||
text = "KP" + e.KeyCode.ToString()[6]; break;
|
||||
case WF.Keys.Space:
|
||||
case WinForms.Keys.Space:
|
||||
text = "Space"; break;
|
||||
case WF.Keys.Enter:
|
||||
case WinForms.Keys.Enter:
|
||||
text = "Enter"; break;
|
||||
case WF.Keys.Tab:
|
||||
case WinForms.Keys.Tab:
|
||||
text = "TAB"; break;
|
||||
case WF.Keys.Back:
|
||||
case WinForms.Keys.Back:
|
||||
text = "BS"; break;
|
||||
case WF.Keys.Delete:
|
||||
case WinForms.Keys.Delete:
|
||||
text = "DEL"; break;
|
||||
case WF.Keys.Insert:
|
||||
case WinForms.Keys.Insert:
|
||||
text = "INS"; break;
|
||||
case WF.Keys.Home:
|
||||
case WinForms.Keys.Home:
|
||||
text = "Home"; break;
|
||||
case WF.Keys.End:
|
||||
case WinForms.Keys.End:
|
||||
text = "END"; break;
|
||||
case WF.Keys.PageUp:
|
||||
case WinForms.Keys.PageUp:
|
||||
text = "PGUP"; break;
|
||||
case WF.Keys.PageDown:
|
||||
case WinForms.Keys.PageDown:
|
||||
text = "PGDWN"; break;
|
||||
case WF.Keys.Escape:
|
||||
case WinForms.Keys.Escape:
|
||||
text = "ESC"; break;
|
||||
case WF.Keys.PrintScreen:
|
||||
case WinForms.Keys.PrintScreen:
|
||||
text = "Print"; break;
|
||||
case WF.Keys.Play:
|
||||
case WinForms.Keys.Play:
|
||||
text = "Play"; break;
|
||||
case WF.Keys.Pause:
|
||||
case WinForms.Keys.Pause:
|
||||
text = "Pause"; break;
|
||||
case WF.Keys.MediaPlayPause:
|
||||
case WinForms.Keys.MediaPlayPause:
|
||||
text = "PlayPause"; break;
|
||||
case WF.Keys.MediaStop:
|
||||
case WinForms.Keys.MediaStop:
|
||||
text = "Stop"; break;
|
||||
case WF.Keys.MediaNextTrack:
|
||||
case WinForms.Keys.MediaNextTrack:
|
||||
text = "Next"; break;
|
||||
case WF.Keys.MediaPreviousTrack:
|
||||
case WinForms.Keys.MediaPreviousTrack:
|
||||
text = "Prev"; break;
|
||||
case WF.Keys.VolumeUp:
|
||||
case WinForms.Keys.VolumeUp:
|
||||
text = "Volume_Up"; break;
|
||||
case WF.Keys.VolumeDown:
|
||||
case WinForms.Keys.VolumeDown:
|
||||
text = "Volume_Down"; break;
|
||||
case WF.Keys.VolumeMute:
|
||||
case WinForms.Keys.VolumeMute:
|
||||
text = "Mute"; break;
|
||||
case WF.Keys.BrowserHome:
|
||||
case WinForms.Keys.BrowserHome:
|
||||
text = "Homepage"; break;
|
||||
case WF.Keys.LaunchMail:
|
||||
case WinForms.Keys.LaunchMail:
|
||||
text = "Mail"; break;
|
||||
case WF.Keys.BrowserFavorites:
|
||||
case WinForms.Keys.BrowserFavorites:
|
||||
text = "Favorites"; break;
|
||||
case WF.Keys.BrowserSearch:
|
||||
case WinForms.Keys.BrowserSearch:
|
||||
text = "Search"; break;
|
||||
case WF.Keys.Sleep:
|
||||
case WinForms.Keys.Sleep:
|
||||
text = "Sleep"; break;
|
||||
case WF.Keys.Cancel:
|
||||
case WinForms.Keys.Cancel:
|
||||
text = "Cancel"; break;
|
||||
}
|
||||
|
||||
@@ -130,9 +132,14 @@ namespace mpvnet
|
||||
|
||||
if (text == "#") text = "SHARP";
|
||||
|
||||
if (isAlt && !wasModified) text = "ALT+" + text;
|
||||
if (isShift && !wasModified) text = "SHIFT+" + text;
|
||||
if (isCtrl && !wasModified) text = "CTRL+" + text;
|
||||
if (isAlt && !wasModified)
|
||||
text = "ALT+" + text;
|
||||
|
||||
if (isShift && !wasModified)
|
||||
text = "SHIFT+" + text;
|
||||
|
||||
if (isCtrl && !wasModified)
|
||||
text = "CTRL+" + text;
|
||||
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
SetKey(text);
|
||||
@@ -151,25 +158,29 @@ namespace mpvnet
|
||||
[DllImport("user32.dll")]
|
||||
static extern uint MapVirtualKey(uint uCode, uint uMapType);
|
||||
|
||||
public static WF.Keys ModifierKeys {
|
||||
public static WinForms.Keys ModifierKeys {
|
||||
get {
|
||||
WF.Keys keys = WF.Keys.None;
|
||||
WinForms.Keys keys = WinForms.Keys.None;
|
||||
|
||||
if (GetKeyState(17) < (short)0)
|
||||
keys |= WF.Keys.Control;
|
||||
keys |= WinForms.Keys.Control;
|
||||
|
||||
if (GetKeyState(16) < (short)0)
|
||||
keys |= WF.Keys.Shift;
|
||||
keys |= WinForms.Keys.Shift;
|
||||
|
||||
if (GetKeyState(18) < (short)0)
|
||||
keys |= WF.Keys.Alt;
|
||||
keys |= WinForms.Keys.Alt;
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessKeyEventArgs(ref WF.Message m)
|
||||
void ProcessKeyEventArgs(ref WinForms.Message m)
|
||||
{
|
||||
int WM_KEYUP = 0x0101, WM_SYSKEYUP = 0x0105, WM_APPCOMMAND = 0x0319;
|
||||
|
||||
if (m.Msg == WM_KEYUP || m.Msg == WM_SYSKEYUP)
|
||||
OnKeyUp(new WF.KeyEventArgs((WF.Keys)(unchecked((int)(long)m.WParam)) | ModifierKeys));
|
||||
OnKeyUp(new WinForms.KeyEventArgs((WinForms.Keys)(unchecked((int)(long)m.WParam)) | ModifierKeys));
|
||||
else if (m.Msg == WM_APPCOMMAND)
|
||||
{
|
||||
var value = (AppCommand)(m.LParam.ToInt64() >> 16 & ~0xf000);
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:WPF="clr-namespace:WPF">
|
||||
xmlns:UI="clr-namespace:UI">
|
||||
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
<Border x:Name="border"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
SnapsToDevicePixels="True">
|
||||
|
||||
<ScrollViewer x:Name="PART_ContentHost"
|
||||
Focusable="false"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Hidden"/>
|
||||
</Border>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
|
||||
@@ -17,7 +26,7 @@
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="#FF7EB4EA"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsFocused" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{x:Static WPF:WPF.ThemeBrush}"/>
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{x:Static UI:Theme.Heading}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
@@ -34,13 +43,14 @@
|
||||
<ColumnDefinition x:Name="LeftCol" Width="18" />
|
||||
<ColumnDefinition x:Name="RightCol" Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid x:Name="PART_CHECKBOX">
|
||||
<Ellipse
|
||||
x:Name="normal"
|
||||
Width="18"
|
||||
Height="18"
|
||||
Fill="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"
|
||||
Stroke="{x:Static WPF:WPF.ThemeBrush}"
|
||||
Fill="{x:Static UI:Theme.Background}"
|
||||
Stroke="{x:Static UI:Theme.Heading}"
|
||||
StrokeThickness="2" />
|
||||
<Ellipse
|
||||
x:Name="Checked1"
|
||||
@@ -56,6 +66,7 @@
|
||||
Opacity="0"
|
||||
StrokeThickness="{TemplateBinding BorderThickness}" />
|
||||
</Grid>
|
||||
|
||||
<ContentPresenter
|
||||
x:Name="contentPresenter"
|
||||
Grid.Column="1"
|
||||
@@ -67,6 +78,7 @@
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
||||
RecognizesAccessKey="True" />
|
||||
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal" />
|
||||
|
||||
@@ -3,11 +3,40 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid x:Name="SearchTextBoxUserControl1" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
|
||||
<TextBlock x:Name="HintTextBlock" Margin="5,2" Text="Find a setting" Foreground="LightSteelBlue" VerticalAlignment="Center" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" />
|
||||
<TextBox Name="SearchTextBox" Height="25" Padding="1,2,0,0" BorderThickness="2" Background="Transparent" TextChanged="SearchTextBox_TextChanged" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" CaretBrush="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" />
|
||||
<Button x:Name="SearchClearButton" Background="Transparent" HorizontalAlignment="Right" Margin="2,0,4,0" FontSize="10" Width="17" Height="17" Visibility="Hidden" Click="SearchClearButton_Click" FontFamily="Marlett" Foreground="{Binding Path=Foreground2, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">r</Button>
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Name="SearchTextBoxUserControl1"
|
||||
Background="{x:Static UI:Theme.Background}">
|
||||
|
||||
<TextBlock Name="HintTextBlock"
|
||||
Margin="5,2"
|
||||
Text="Find a setting"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{x:Static UI:Theme.Foreground2}"
|
||||
Background="{x:Static UI:Theme.Background}" />
|
||||
|
||||
<TextBox Name="SearchTextBox"
|
||||
Height="25"
|
||||
Padding="1,2,0,0"
|
||||
BorderThickness="2"
|
||||
Background="Transparent"
|
||||
TextChanged="SearchTextBox_TextChanged"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
CaretBrush="{x:Static UI:Theme.Foreground}" />
|
||||
|
||||
<Button Name="SearchClearButton"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="Transparent"
|
||||
HorizontalAlignment="Right"
|
||||
FontFamily="Marlett"
|
||||
FontSize="10"
|
||||
Width="17"
|
||||
Height="17"
|
||||
Margin="2,0,4,0"
|
||||
Visibility="Hidden"
|
||||
Click="SearchClearButton_Click">r</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -3,17 +3,31 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
Title="mpv.net OS Setup" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterOwner">
|
||||
|
||||
Title="mpv.net OS Setup"
|
||||
FontSize="13"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
SizeToContent="WidthAndHeight"
|
||||
WindowStartupLocation="CenterOwner" >
|
||||
|
||||
<Window.Resources>
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Padding" Value="10"></Setter>
|
||||
<Setter Property="Margin" Value="5"></Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<StackPanel>
|
||||
<Button Name="RegisterVideo" Margin="5" Click="RegisterVideo_Click">Register video file extensions (requires elevated privileges)</Button>
|
||||
<Button Name="RegisterAudio" Margin="5" Click="RegisterAudio_Click">Register audio file extensions (requires elevated privileges)</Button>
|
||||
<Button Name="RegisterImage" Margin="5" Click="RegisterImage_Click">Register image file extensions (requires elevated privileges)</Button>
|
||||
<Button Name="AddToPathEnvVar" Margin="5" Click="AddToPathEnvVar_Click">Add mpv.net to Path environment variable</Button>
|
||||
<Button Name="ManageDefaultApps" Margin="5" Click="ManageDefaultApps_Click">Manage Default Apps (Win 10 or higher)</Button>
|
||||
<Button Name="UnregisterFileAssociations" Margin="5,20,5,5" Click="UnregisterFileAssociations_Click">Unregister file extensions (requires elevated privileges)</Button>
|
||||
<Button Name="RemoveFromPathEnvVar" Margin="5" Click="RemoveFromPathEnvVar_Click">Remove mpv.net from Path environment variable</Button>
|
||||
<StackPanel Margin="10">
|
||||
<Button Name="RegisterVideo" Click="RegisterVideo_Click">Register video file extensions (requires elevated privileges)</Button>
|
||||
<Button Name="RegisterAudio" Click="RegisterAudio_Click">Register audio file extensions (requires elevated privileges)</Button>
|
||||
<Button Name="RegisterImage" Click="RegisterImage_Click">Register image file extensions (requires elevated privileges)</Button>
|
||||
<Button Name="UnregisterFileAssociations" Click="UnregisterFileAssociations_Click">Unregister file extensions (requires elevated privileges)</Button>
|
||||
<Button Name="AddToPathEnvVar" Click="AddToPathEnvVar_Click">Add mpv.net to Path environment variable</Button>
|
||||
<Button Name="RemoveFromPathEnvVar" Click="RemoveFromPathEnvVar_Click">Remove mpv.net from Path environment variable</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using WF = System.Windows.Forms;
|
||||
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -11,24 +13,29 @@ namespace mpvnet
|
||||
|
||||
void RegisterFileAssociations(string value)
|
||||
{
|
||||
using (var proc = new Process())
|
||||
try
|
||||
{
|
||||
proc.StartInfo.FileName = System.Windows.Forms.Application.ExecutablePath;
|
||||
proc.StartInfo.Arguments = "--reg-file-assoc " + value;
|
||||
proc.StartInfo.Verb = "runas";
|
||||
try { proc.Start(); } catch { }
|
||||
}
|
||||
using (var proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = WinForms.Application.ExecutablePath;
|
||||
proc.StartInfo.Arguments = "--reg-file-assoc " + value;
|
||||
proc.StartInfo.Verb = "runas";
|
||||
proc.Start();
|
||||
}
|
||||
|
||||
Process.Start("ms-settings:defaultapps");
|
||||
} catch {}
|
||||
}
|
||||
|
||||
private void RegisterVideo_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("video");
|
||||
private void RegisterAudio_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("audio");
|
||||
private void RegisterImage_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("image");
|
||||
|
||||
private void UnregisterFileAssociations_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("unreg");
|
||||
private void ManageDefaultApps_Click(object sender, RoutedEventArgs e) => Process.Start("ms-settings:defaultapps");
|
||||
|
||||
private void AddToPathEnvVar_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string var = WF.Application.StartupPath + ";";
|
||||
string var = WinForms.Application.StartupPath + ";";
|
||||
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User);
|
||||
|
||||
if (path.Contains(var))
|
||||
@@ -42,7 +49,7 @@ namespace mpvnet
|
||||
|
||||
private void RemoveFromPathEnvVar_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string var = WF.Application.StartupPath + ";";
|
||||
string var = WinForms.Application.StartupPath + ";";
|
||||
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User);
|
||||
|
||||
if (path.Contains(var))
|
||||
|
||||
@@ -1,68 +1,20 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
using Microsoft.Win32;
|
||||
using mpvnet;
|
||||
|
||||
namespace WPF
|
||||
{
|
||||
public class WPF
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
EnsureApplicationResources();
|
||||
}
|
||||
|
||||
public static void EnsureApplicationResources()
|
||||
{
|
||||
if (Application.Current == null)
|
||||
{
|
||||
new Application();
|
||||
|
||||
Application.Current.Resources.MergedDictionaries.Add(
|
||||
Application.LoadComponent(new Uri("mpvnet;component/WPF/Resources.xaml",
|
||||
UriKind.Relative)) as ResourceDictionary);
|
||||
}
|
||||
}
|
||||
|
||||
public static Brush ThemeBrush { get; } = new SolidColorBrush(ThemeColor);
|
||||
|
||||
static bool WasThemeColorSet;
|
||||
|
||||
static Color _ThemeColor;
|
||||
|
||||
public static Color ThemeColor {
|
||||
get {
|
||||
if (!WasThemeColorSet)
|
||||
{
|
||||
Color? color = null;
|
||||
|
||||
try {
|
||||
if (App.IsDarkMode && !string.IsNullOrEmpty(App.DarkColor))
|
||||
color = (Color)ColorConverter.ConvertFromString(App.DarkColor);
|
||||
else if (!App.IsDarkMode && !string.IsNullOrEmpty(App.LightColor))
|
||||
color = (Color)ColorConverter.ConvertFromString(App.LightColor);
|
||||
} catch { }
|
||||
|
||||
if (!color.HasValue)
|
||||
{
|
||||
if (Environment.OSVersion.Version.Major < 10)
|
||||
{
|
||||
int argb = Convert.ToInt32(Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", 0));
|
||||
var wfc = System.Drawing.Color.FromArgb(argb);
|
||||
color = Color.FromArgb(wfc.A, wfc.R, wfc.G, wfc.B);
|
||||
}
|
||||
else
|
||||
color = SystemParameters.WindowGlassColor;
|
||||
}
|
||||
|
||||
if (App.IsDarkMode && color == Colors.Black) color = Colors.Orange;
|
||||
if (!App.IsDarkMode && color == Colors.White) color = Colors.Orange;
|
||||
_ThemeColor = color.Value;
|
||||
WasThemeColorSet = true;
|
||||
}
|
||||
return _ThemeColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -9,6 +10,7 @@ using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using UI;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -610,7 +612,10 @@ namespace mpvnet
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
if (mp.GPUAPI != "vulkan") mp.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold);
|
||||
|
||||
if (mp.GPUAPI != "vulkan")
|
||||
mp.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold);
|
||||
|
||||
SetFormPosAndSize();
|
||||
}
|
||||
|
||||
@@ -621,9 +626,12 @@ namespace mpvnet
|
||||
if (mp.GPUAPI == "vulkan")
|
||||
mp.ProcessCommandLine(false);
|
||||
|
||||
var wpfColor = WPF.WPF.ThemeColor;
|
||||
Color color = Color.FromArgb(wpfColor.A, wpfColor.R, wpfColor.G, wpfColor.B);
|
||||
ToolStripRendererEx.InitColors(color, App.IsDarkMode, App.ThemedMenu);
|
||||
ToolStripRendererEx.ForegroundColor = Theme.Current.GetWinFormsColor("menu-foreground");
|
||||
ToolStripRendererEx.BackgroundColor = Theme.Current.GetWinFormsColor("menu-background");
|
||||
ToolStripRendererEx.SelectionColor = Theme.Current.GetWinFormsColor("menu-highlight");
|
||||
ToolStripRendererEx.BorderColor = Theme.Current.GetWinFormsColor("menu-border");
|
||||
ToolStripRendererEx.CheckedColor = Theme.Current.GetWinFormsColor("menu-checked");
|
||||
|
||||
BuildMenu();
|
||||
ContextMenuStrip = ContextMenu;
|
||||
WPF.WPF.Init();
|
||||
|
||||
@@ -130,49 +130,29 @@ public class MenuItem : ToolStripMenuItem
|
||||
|
||||
public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
{
|
||||
public static Color ColorForeground { get; set; } = Color.Black;
|
||||
public static Color ColorTheme { get; set; }
|
||||
public static Color ColorChecked { get; set; }
|
||||
public static Color ColorBorder { get; set; }
|
||||
public static Color ColorTop { get; set; }
|
||||
public static Color ColorSelection { get; set; }
|
||||
public static Color ColorBackground { get; set; }
|
||||
public static Color ForegroundColor { get; set; }
|
||||
public static Color BackgroundColor { get; set; }
|
||||
public static Color SelectionColor { get; set; }
|
||||
public static Color CheckedColor { get; set; }
|
||||
public static Color BorderColor { get; set; }
|
||||
|
||||
int TextOffset;
|
||||
|
||||
public static void InitColors(Color themeColor, bool darkMode, bool themed)
|
||||
public static void SetDefaultColors()
|
||||
{
|
||||
if (darkMode)
|
||||
{
|
||||
ColorBorder = Color.White;
|
||||
ColorBackground = Color.FromArgb(50, 50, 50);
|
||||
ColorSelection = Color.FromArgb(80, 80, 80);
|
||||
|
||||
if (themed)
|
||||
ColorForeground = themeColor;
|
||||
else
|
||||
ColorForeground = Color.White;
|
||||
|
||||
ColorChecked = Color.FromArgb(90, 90, 90);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!themed) themeColor = Color.FromArgb(238, 238, 238);
|
||||
|
||||
ColorBorder = HSLColor.Convert(themeColor).ToColorSetLuminosity(100);
|
||||
ColorChecked = HSLColor.Convert(themeColor).ToColorSetLuminosity(160);
|
||||
ColorSelection = HSLColor.Convert(themeColor).ToColorSetLuminosity(180);
|
||||
ColorBackground = HSLColor.Convert(themeColor).ToColorSetLuminosity(210);
|
||||
ColorTop = HSLColor.Convert(themeColor).ToColorSetLuminosity(240);
|
||||
}
|
||||
ForegroundColor = Color.FromArgb(unchecked((int)0xFF000000));
|
||||
BackgroundColor = Color.FromArgb(unchecked((int)0xFFDFDFDF));
|
||||
SelectionColor = Color.FromArgb(unchecked((int)0xFFBFBFBF));
|
||||
CheckedColor = Color.FromArgb(unchecked((int)0xFFAAAAAA));
|
||||
BorderColor = Color.FromArgb(unchecked((int)0xFF6A6A6A));
|
||||
}
|
||||
|
||||
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
|
||||
{
|
||||
Rectangle r = e.AffectedBounds;
|
||||
r.Inflate(-1, -1);
|
||||
ControlPaint.DrawBorder(e.Graphics, r, ColorBackground, ButtonBorderStyle.Solid);
|
||||
ControlPaint.DrawBorder(e.Graphics, e.AffectedBounds, ColorBorder, ButtonBorderStyle.Solid);
|
||||
ControlPaint.DrawBorder(e.Graphics, r, BackgroundColor, ButtonBorderStyle.Solid);
|
||||
ControlPaint.DrawBorder(e.Graphics, e.AffectedBounds, BorderColor, ButtonBorderStyle.Solid);
|
||||
}
|
||||
|
||||
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
|
||||
@@ -189,7 +169,7 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
else
|
||||
TextOffset = Convert.ToInt32(e.Item.Height * 0.2);
|
||||
|
||||
e.TextColor = ColorForeground;
|
||||
e.TextColor = ForegroundColor;
|
||||
e.TextRectangle = new Rectangle(TextOffset, Convert.ToInt32((e.Item.Height - rect.Height) / 2.0), rect.Width, rect.Height);
|
||||
}
|
||||
|
||||
@@ -201,14 +181,14 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
Rectangle rect = new Rectangle(Point.Empty, e.Item.Size);
|
||||
|
||||
if (!(e.Item.Owner is MenuStrip))
|
||||
e.Graphics.Clear(ColorBackground);
|
||||
e.Graphics.Clear(BackgroundColor);
|
||||
|
||||
if (e.Item.Selected && e.Item.Enabled)
|
||||
{
|
||||
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
rect = new Rectangle(rect.X + 2, rect.Y, rect.Width - 4, rect.Height - 1);
|
||||
rect.Inflate(-1, -1);
|
||||
using (SolidBrush b = new SolidBrush(ColorSelection))
|
||||
using (SolidBrush b = new SolidBrush(SelectionColor))
|
||||
e.Graphics.FillRectangle(b, rect);
|
||||
}
|
||||
}
|
||||
@@ -224,7 +204,7 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
float y3 = e.Item.Height * 0.75f;
|
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
||||
using (Brush b = new SolidBrush(ColorForeground))
|
||||
using (Brush b = new SolidBrush(ForegroundColor))
|
||||
{
|
||||
using (Pen p = new Pen(b, Control.DefaultFont.Height / 20f))
|
||||
{
|
||||
@@ -250,7 +230,7 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
rect = new Rectangle(rect.X + 2, rect.Y, rect.Height - 1, rect.Height - 1);
|
||||
rect.Inflate(-1, -1);
|
||||
|
||||
using (Brush brush = new SolidBrush(ColorChecked))
|
||||
using (Brush brush = new SolidBrush(CheckedColor))
|
||||
e.Graphics.FillRectangle(brush, rect);
|
||||
|
||||
float ellipseWidth = rect.Height / 3f;
|
||||
@@ -260,17 +240,17 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
ellipseWidth,
|
||||
ellipseWidth);
|
||||
|
||||
using (Brush brush = new SolidBrush(ColorForeground))
|
||||
using (Brush brush = new SolidBrush(ForegroundColor))
|
||||
e.Graphics.FillEllipse(brush, rectF);
|
||||
}
|
||||
|
||||
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
|
||||
{
|
||||
e.Graphics.Clear(ColorBackground);
|
||||
e.Graphics.Clear(BackgroundColor);
|
||||
int top = e.Item.Height / 2;
|
||||
top -= 1;
|
||||
int offset = Convert.ToInt32(e.Item.Font.Height * 0.7);
|
||||
using (Pen p = new Pen(ColorBorder))
|
||||
using (Pen p = new Pen(BorderColor))
|
||||
e.Graphics.DrawLine(p,
|
||||
new Point(offset, top),
|
||||
new Point(e.Item.Width - offset, top));
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Misc\App.cs" />
|
||||
<Compile Include="Misc\Extension.cs" />
|
||||
<Content Include="Resources\theme.txt" />
|
||||
<Page Include="WPF\SearchTextBoxUserControl.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -140,6 +141,8 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Compile Include="Misc\Help.cs" />
|
||||
<Compile Include="Misc\Theme.cs" />
|
||||
<Compile Include="WPF\SearchTextBoxUserControl.xaml.cs">
|
||||
<DependentUpon>SearchTextBoxUserControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -239,10 +242,9 @@
|
||||
</Content>
|
||||
<Content Include="mpvnet.ico" />
|
||||
<Content Include="Resources\mpvConf.txt" />
|
||||
<Content Include="Resources\ConfToml.txt" />
|
||||
<Content Include="Resources\confToml.txt" />
|
||||
<None Include="Resources\mpvnet.ico" />
|
||||
<None Include="Resources\mpvnet.png" />
|
||||
<None Include="Resources\mpvNetConf.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
|
||||
@@ -209,10 +209,8 @@ namespace mpvnet
|
||||
|
||||
if (!File.Exists(_ConfigFolder + "mpv.conf"))
|
||||
File.WriteAllText(_ConfigFolder + "mpv.conf", Properties.Resources.mpvConf);
|
||||
|
||||
if (!File.Exists(_ConfigFolder + "mpvnet.conf"))
|
||||
File.WriteAllText(_ConfigFolder + "mpvnet.conf", Properties.Resources.mpvNetConf);
|
||||
}
|
||||
|
||||
return _ConfigFolder;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user