After using the config editor it's no longer necessary to restart mpv.net.

This commit is contained in:
Frank Skare
2021-05-28 11:38:36 +02:00
parent 45a2b7f976
commit 765854cd10
36 changed files with 570 additions and 395 deletions

View File

@@ -19,9 +19,9 @@
open source code however. Example scripts and extensions were updated. open source code however. Example scripts and extensions were updated.
- Fix console not working due to incorrect mpv.conf value generated - Fix console not working due to incorrect mpv.conf value generated
(script-opts=console-scale=0). (script-opts=console-scale=0).
- Registry usage is not portable and also not popular, so settings - Settings are stored in the file settings.xml now instead of the Registry.
are stored in the file settings.xml now instead of the Registry.
- Video rotation support added. - Video rotation support added.
- After using the config editor it's no longer necessary to restart mpv.net.
5.4.8.8 Beta (2021-05-09) 5.4.8.8 Beta (2021-05-09)

View File

@@ -1,14 +1,13 @@
 
using mpvnet;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Navigation; using System.Windows.Navigation;
using Tommy; using Tommy;
using mpvnet;
namespace DynamicGUI namespace DynamicGUI
{ {
@@ -75,26 +74,29 @@ namespace DynamicGUI
public class ConfItem public class ConfItem
{ {
public string Name { get; set; } = "";
public string Value { get; set; } = "";
public string Comment { get; set; } = ""; public string Comment { get; set; } = "";
public string LineComment { get; set; } = "";
public string Section { get; set; } = "";
public string File { get; set; } = ""; public string File { get; set; } = "";
public string LineComment { get; set; } = "";
public string Name { get; set; } = "";
public string Section { get; set; } = "";
public string Value { get; set; } = "";
public bool IsSectionItem { get; set; } public bool IsSectionItem { get; set; }
public SettingBase SettingBase { get; set; } public SettingBase SettingBase { get; set; }
} }
public abstract class SettingBase public abstract class SettingBase
{ {
public string Name { get; set; }
public string File { get; set; }
public string Value { get; set; }
public string Help { get; set; }
public string Default { get; set; } public string Default { get; set; }
public string URL { get; set; } public string File { get; set; }
public string Filter { get; set; } public string Filter { get; set; }
public string Help { get; set; }
public string Name { get; set; }
public string StartValue { get; set; }
public string Type { get; set; } public string Type { get; set; }
public string URL { get; set; }
public string Value { get; set; }
public int Width { get; set; } public int Width { get; set; }
public ConfItem ConfItem { get; set; } public ConfItem ConfItem { get; set; }
} }

View File

@@ -1,10 +1,10 @@
<UserControl x:Name="OptionSettingControl1" x:Class="DynamicGUI.OptionSettingControl" <UserControl
x:Name="OptionSettingControl1" x:Class="DynamicGUI.OptionSettingControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DynamicGUI" xmlns:local="clr-namespace:DynamicGUI"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignHeight="450"
@@ -12,19 +12,22 @@
<Grid Margin="20,0"> <Grid Margin="20,0">
<StackPanel> <StackPanel>
<TextBox x:Name="TitleTextBox" <TextBox
x:Name="TitleTextBox"
FontSize="24" FontSize="24"
Margin="0,10" Margin="0,10"
BorderThickness="0" BorderThickness="0"
IsReadOnly="True" IsReadOnly="True"
Foreground="{x:Static mpvnet:Theme.Heading}" Foreground="{Binding Theme.Heading}"
Background="{x:Static mpvnet:Theme.Background}" /> Background="{Binding Theme.Background}"
/>
<ItemsControl x:Name="ItemsControl"> <ItemsControl x:Name="ItemsControl">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<WrapPanel Orientation="Vertical"> <WrapPanel Orientation="Vertical">
<RadioButton x:Name="RadioButton" <RadioButton
x:Name="RadioButton"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
IsChecked="{Binding Checked}" IsChecked="{Binding Checked}"
GroupName="{Binding OptionSetting.Name}" GroupName="{Binding OptionSetting.Name}"
@@ -32,30 +35,36 @@
FontSize="16" FontSize="16"
FontWeight="Normal" FontWeight="Normal"
VerticalAlignment="Top" VerticalAlignment="Top"
Foreground="{x:Static mpvnet:Theme.Foreground}"/> Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Foreground}"
/>
<TextBox x:Name="ItemHelpTextBox" <TextBox
x:Name="ItemHelpTextBox"
TextWrapping="WrapWithOverflow" TextWrapping="WrapWithOverflow"
Text="{Binding Help}" Text="{Binding Help}"
Visibility="{Binding Visibility}" Visibility="{Binding Visibility}"
Margin="10,0,0,0" BorderThickness="0" Margin="10,0,0,0" BorderThickness="0"
IsReadOnly="True" Padding="7,0,0,0" IsReadOnly="True" Padding="7,0,0,0"
MinHeight="0" MinHeight="0"
Foreground="{x:Static mpvnet:Theme.Foreground2}" Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Foreground2}"
Background="{x:Static mpvnet:Theme.Background}"/> Background="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Background}"
/>
</WrapPanel> </WrapPanel>
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
<TextBox x:Name="HelpTextBox" <TextBox
x:Name="HelpTextBox"
TextWrapping="WrapWithOverflow" TextWrapping="WrapWithOverflow"
BorderThickness="0" BorderThickness="0"
IsReadOnly="True" IsReadOnly="True"
Margin="0,10,0,0" Margin="0,10,0,0"
Foreground="{x:Static mpvnet:Theme.Foreground}" Foreground="{Binding Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"/> Background="{Binding Theme.Background}"
/>
<TextBlock x:Name="LinkTextBlock" Margin="0,10"> <TextBlock x:Name="LinkTextBlock" Margin="0,10">
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx> <local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
</TextBlock> </TextBlock>

View File

@@ -2,6 +2,8 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using mpvnet;
namespace DynamicGUI namespace DynamicGUI
{ {
public partial class OptionSettingControl : UserControl, ISettingControl public partial class OptionSettingControl : UserControl, ISettingControl
@@ -12,6 +14,7 @@ namespace DynamicGUI
{ {
OptionSetting = optionSetting; OptionSetting = optionSetting;
InitializeComponent(); InitializeComponent();
DataContext = this;
TitleTextBox.Text = optionSetting.Name; TitleTextBox.Text = optionSetting.Name;
if (string.IsNullOrEmpty(optionSetting.Help)) if (string.IsNullOrEmpty(optionSetting.Help))
@@ -26,6 +29,10 @@ namespace DynamicGUI
Link.SetURL(optionSetting.URL); Link.SetURL(optionSetting.URL);
} }
public Theme Theme {
get => Theme.Current;
}
string _SearchableText; string _SearchableText;
public string SearchableText { public string SearchableText {

View File

@@ -1,54 +1,61 @@
<UserControl x:Name="StringSettingControl1" x:Class="DynamicGUI.StringSettingControl" <UserControl
x:Name="StringSettingControl1" x:Class="DynamicGUI.StringSettingControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DynamicGUI" xmlns:local="clr-namespace:DynamicGUI"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800"> d:DesignWidth="800">
<Grid Margin="20,0"> <Grid Margin="20,0">
<StackPanel> <StackPanel>
<TextBox x:Name="TitleTextBox" <TextBox
x:Name="TitleTextBox"
FontSize="24" FontSize="24"
Margin="0,10" Margin="0,10"
BorderThickness="0" BorderThickness="0"
IsReadOnly="True" IsReadOnly="True"
Foreground="{x:Static mpvnet:Theme.Heading}" Foreground="{Binding Theme.Heading}"
Background="{x:Static mpvnet:Theme.Background}"/> Background="{Binding Theme.Background}"
/>
<Grid Margin="0,0,0,10"> <Grid Margin="0,0,0,10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBox x:Name="ValueTextBox" <TextBox
x:Name="ValueTextBox"
Text="{Binding Path=Text, ElementName=StringSettingControl1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Text="{Binding Path=Text, ElementName=StringSettingControl1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Width="150" Width="150"
Height="20" Height="20"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Foreground="{x:Static mpvnet:Theme.Foreground}" Foreground="{Binding Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}" Background="{Binding Theme.Background}"
CaretBrush="{x:Static mpvnet:Theme.Foreground}" CaretBrush="{Binding Theme.Foreground}"
TextChanged="ValueTextBox_TextChanged"/> TextChanged="ValueTextBox_TextChanged"
/>
<Button x:Name="Button" <Button
x:Name="Button"
Height="20" Height="20"
Grid.Column="1" Grid.Column="1"
Visibility="{Binding Path=Text, ElementName=StringSettingControl1}"
Margin="5,0,0,0" Margin="5,0,0,0"
Width="20" Width="20"
Click="Button_Click">...</Button> Click="Button_Click"
>...</Button>
</Grid> </Grid>
<TextBox x:Name="HelpTextBox" <TextBox
x:Name="HelpTextBox"
TextWrapping="WrapWithOverflow" TextWrapping="WrapWithOverflow"
BorderThickness="0" BorderThickness="0"
IsReadOnly="True" IsReadOnly="True"
Foreground="{x:Static mpvnet:Theme.Foreground}" Foreground="{Binding Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"/> Background="{Binding Theme.Background}"
/>
<TextBlock x:Name="LinkTextBlock" Margin="0,10"> <TextBlock x:Name="LinkTextBlock" Margin="0,10">
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx> <local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>

View File

@@ -1,9 +1,11 @@
 
using mpvnet;
using System; using System;
using System.Globalization; using System.Globalization;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using WinForms = System.Windows.Forms; using WinForms = System.Windows.Forms;
namespace DynamicGUI namespace DynamicGUI
@@ -16,6 +18,7 @@ namespace DynamicGUI
{ {
StringSetting = stringSetting; StringSetting = stringSetting;
InitializeComponent(); InitializeComponent();
DataContext = this;
TitleTextBox.Text = stringSetting.Name; TitleTextBox.Text = stringSetting.Name;
HelpTextBox.Text = stringSetting.Help; HelpTextBox.Text = stringSetting.Help;
ValueTextBox.Text = StringSetting.Value; ValueTextBox.Text = StringSetting.Value;
@@ -32,6 +35,10 @@ namespace DynamicGUI
LinkTextBlock.Visibility = Visibility.Collapsed; LinkTextBlock.Visibility = Visibility.Collapsed;
} }
public Theme Theme {
get => Theme.Current;
}
string _SearchableText; string _SearchableText;
public string SearchableText { public string SearchableText {

View File

@@ -94,7 +94,9 @@ namespace RatingExtension // the assembly name must end with 'Extension'!
} }
} }
else if (args[1] == "about") else if (args[1] == "about")
MessageBox.Show("This extension writes a rating to the filename of rated videos when mpv.net shuts down.\n\nThe input.conf defaults contain key bindings for this extension to set ratings.", MessageBox.Show($"This extension writes a rating to the filename of rated videos " +
"when mpv.net shuts down." + BR2 +
"The input.conf defaults contain key bindings for this extension to set ratings.",
"Rating Extension"); "Rating Extension");
} }

View File

@@ -26,7 +26,6 @@ namespace mpvnet
public static bool AutoLoadFolder { get; set; } = true; public static bool AutoLoadFolder { get; set; } = true;
public static bool Queue { get; set; } public static bool Queue { get; set; }
public static bool UpdateCheck { get; set; } public static bool UpdateCheck { get; set; }
public static bool GlobalMediaKeys { get; set; }
public static int StartThreshold { get; set; } = 1500; public static int StartThreshold { get; set; } = 1500;
public static int RecentCount { get; set; } = 15; public static int RecentCount { get; set; } = 15;
@@ -52,8 +51,8 @@ namespace mpvnet
public static void Init() public static void Init()
{ {
string dummy = Core.ConfigFolder; var useless1 = Core.ConfigFolder;
var dummy2 = Core.Conf; var useless2 = Core.Conf;
foreach (var i in Conf) foreach (var i in Conf)
ProcessProperty(i.Key, i.Value, true); ProcessProperty(i.Key, i.Value, true);
@@ -79,6 +78,14 @@ namespace mpvnet
} }
} }
InitTheme();
Core.Shutdown += Shutdown;
Core.Initialized += Initialized;
}
public static void InitTheme()
{
string themeContent = null; string themeContent = null;
if (File.Exists(Core.ConfigFolder + "theme.conf")) if (File.Exists(Core.ConfigFolder + "theme.conf"))
@@ -89,8 +96,11 @@ namespace mpvnet
Properties.Resources.theme, Properties.Resources.theme,
IsDarkMode ? DarkTheme : LightTheme); IsDarkMode ? DarkTheme : LightTheme);
Core.Shutdown += Shutdown; ToolStripRendererEx.ForegroundColor = Theme.Current.GetWinFormsColor("menu-foreground");
Core.Initialized += Initialized; 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");
} }
public static void RunTask(Action action) public static void RunTask(Action action)

View File

@@ -10,6 +10,8 @@ using System.Text;
using Microsoft.CSharp; using Microsoft.CSharp;
using static mpvnet.Global;
namespace mpvnet namespace mpvnet
{ {
class CSharpScriptHost class CSharpScriptHost
@@ -66,7 +68,7 @@ namespace mpvnet
i.Line + "\n" + "Error Number: " + i.ErrorNumber + "\n" + i.ErrorText); i.Line + "\n" + "Error Number: " + i.ErrorNumber + "\n" + i.ErrorText);
if (errors.Count() > 0) if (errors.Count() > 0)
Terminal.WriteError(string.Join("\n\n", errors), Path.GetFileName(file)); Terminal.WriteError(string.Join(BR2, errors), Path.GetFileName(file));
} }
static string GetMD5(string code) static string GetMD5(string code)

View File

@@ -144,12 +144,12 @@ namespace mpvnet
mpv_error err = mpv_initialize(Handle); mpv_error err = mpv_initialize(Handle);
if (err < 0) if (err < 0)
throw new Exception("mpv_initialize error\n\n" + GetError(err)); throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR);
err = mpv_observe_property(Handle, 0, "video-rotate", mpv_format.MPV_FORMAT_INT64); err = mpv_observe_property(Handle, 0, "video-rotate", mpv_format.MPV_FORMAT_INT64);
if (err < 0) if (err < 0)
throw new Exception("mpv_observe_property video-rotate error\n\n" + GetError(err)); throw new Exception("mpv_observe_property video-rotate error" + BR2 + GetError(err) + BR);
Initialized?.Invoke(); Initialized?.Invoke();
InvokeAsync(InitializedAsync); InvokeAsync(InitializedAsync);
@@ -929,7 +929,7 @@ namespace mpvnet
Terminal.WriteError(msg); Terminal.WriteError(msg);
Terminal.WriteError(GetError(err)); Terminal.WriteError(GetError(err));
throw new Exception(string.Join(BR2, messages) + BR2 + GetError(err)); throw new Exception(string.Join(BR2, messages) + BR2 + GetError(err) + BR);
} }
} }

View File

@@ -33,10 +33,10 @@ namespace mpvnet
if (knownExtensions.Contains(Path.GetFileName(extDir))) if (knownExtensions.Contains(Path.GetFileName(extDir)))
catalog.Catalogs.Add(new DirectoryCatalog(extDir, Path.GetFileName(extDir) + ".dll")); catalog.Catalogs.Add(new DirectoryCatalog(extDir, Path.GetFileName(extDir) + ".dll"));
else else
Terminal.WriteError("Failed to load extension:\n\n" + extDir + Terminal.WriteError("Failed to load extension:" + BR2 + extDir +
"\n\nOnly extensions that ship with mpv.net are allowed in <startup>\\extensions" + BR2 + "Only extensions that ship with mpv.net are allowed in <startup>\\extensions" +
"\n\nUser extensions have to use <config folder>\\extensions" + BR2 + "User extensions have to use <config folder>\\extensions" +
"\n\nNever copy or install a new mpv.net version over a old mpv.net version."); BR2 + "Never copy or install a new mpv.net version over a old mpv.net version.");
} }
} }

View File

@@ -2,6 +2,8 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using static mpvnet.Global;
public class Msg public class Msg
{ {
public static void ShowInfo(object title, object content = null) public static void ShowInfo(object title, object content = null)
@@ -33,7 +35,7 @@ public class Msg
public static DialogResult Show(object title, object content, MessageBoxIcon icon, public static DialogResult Show(object title, object content, MessageBoxIcon icon,
MessageBoxButtons buttons = MessageBoxButtons.OK) MessageBoxButtons buttons = MessageBoxButtons.OK)
{ {
string msg = (title?.ToString().TrimEx() + "\n\n" + content?.ToString().TrimEx()).Trim(); string msg = (title?.ToString().TrimEx() + BR2 + content?.ToString().TrimEx()).Trim();
return MessageBox.Show(msg, Application.ProductName, buttons, icon); return MessageBox.Show(msg, Application.ProductName, buttons, icon);
} }
} }

View File

@@ -14,10 +14,10 @@ namespace mpvnet
public static Theme Current { get; set; } public static Theme Current { get; set; }
public static Brush Foreground { get; set; } public Brush Foreground { get; set; }
public static Brush Foreground2 { get; set; } public Brush Foreground2 { get; set; }
public static Brush Background { get; set; } public Brush Background { get; set; }
public static Brush Heading { get; set; } public Brush Heading { get; set; }
public System.Drawing.Color GetWinFormsColor(string key) public System.Drawing.Color GetWinFormsColor(string key)
{ {
@@ -31,6 +31,8 @@ namespace mpvnet
public static void Init(string customContent, string defaultContent, string activeTheme) public static void Init(string customContent, string defaultContent, string activeTheme)
{ {
Current = null;
DefaultThemes = Load(defaultContent); DefaultThemes = Load(defaultContent);
CustomThemes = Load(customContent); CustomThemes = Load(customContent);
@@ -65,10 +67,10 @@ namespace mpvnet
if (Current == null) if (Current == null)
Current = DefaultThemes[0]; Current = DefaultThemes[0];
Foreground = Current.GetBrush("foreground"); Current.Foreground = Current.GetBrush("foreground");
Foreground2 = Current.GetBrush("foreground2"); Current.Foreground2 = Current.GetBrush("foreground2");
Background = Current.GetBrush("background"); Current.Background = Current.GetBrush("background");
Heading = Current.GetBrush("heading"); Current.Heading = Current.GetBrush("heading");
} }
static List<Theme> Load(string content) static List<Theme> Load(string content)

View File

@@ -44,8 +44,8 @@
_ ignore #menu: - _ ignore #menu: -
Enter cycle fullscreen #menu: Toggle Fullscreen Enter cycle fullscreen #menu: Toggle Fullscreen
F11 playlist-prev #menu: Navigate > Previous File F11 playlist-prev; set pause no #menu: Navigate > Previous File
F12 playlist-next #menu: Navigate > Next File F12 playlist-next; set pause no #menu: Navigate > Next File
_ ignore #menu: Navigate > - _ ignore #menu: Navigate > -
Home script-message mpv.net playlist-first #menu: Navigate > First File Home script-message mpv.net playlist-first #menu: Navigate > First File
End script-message mpv.net playlist-last #menu: Navigate > Last File End script-message mpv.net playlist-last #menu: Navigate > Last File

View File

@@ -3,12 +3,12 @@
// In input.conf add: // In input.conf add:
// KP0 script-message rate-file 0 #menu: Extensions > Rating > 0stars // KP0 script-message rate-file 0 #menu: Script > Rating > 0stars
// KP1 script-message rate-file 1 #menu: Extensions > Rating > 1stars // KP1 script-message rate-file 1 #menu: Script > Rating > 1stars
// KP2 script-message rate-file 2 #menu: Extensions > Rating > 2stars // KP2 script-message rate-file 2 #menu: Script > Rating > 2stars
// KP3 script-message rate-file 3 #menu: Extensions > Rating > 3stars // KP3 script-message rate-file 3 #menu: Script > Rating > 3stars
// KP4 script-message rate-file 4 #menu: Extensions > Rating > 4stars // KP4 script-message rate-file 4 #menu: Script > Rating > 4stars
// KP5 script-message rate-file 5 #menu: Extensions > Rating > 5stars // KP5 script-message rate-file 5 #menu: Script > Rating > 5stars
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@@ -1,9 +1,9 @@
<Window x:Class="mpvnet.AboutWindow" <Window
x:Class="mpvnet.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="About mpv.net" Title="About mpv.net"
@@ -12,8 +12,9 @@
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
ResizeMode="NoResize" ResizeMode="NoResize"
SizeToContent="WidthAndHeight" SizeToContent="WidthAndHeight"
Foreground="{x:Static mpvnet:Theme.Foreground}" Foreground="{Binding Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"> Background="{Binding Theme.Background}"
>
<Grid> <Grid>
<StackPanel HorizontalAlignment="Center"> <StackPanel HorizontalAlignment="Center">

View File

@@ -9,10 +9,15 @@ namespace mpvnet
public AboutWindow() public AboutWindow()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this;
ContentBlock.Text = App.Version; ContentBlock.Text = App.Version;
} }
protected override void OnPreviewKeyDown(KeyEventArgs e) => Close(); protected override void OnPreviewKeyDown(KeyEventArgs e) => Close();
protected override void OnMouseDown(MouseButtonEventArgs e) => Close(); protected override void OnMouseDown(MouseButtonEventArgs e) => Close();
public Theme Theme {
get => Theme.Current;
}
} }
} }

View File

@@ -1,9 +1,9 @@
<Window x:Class="mpvnet.CommandPaletteWindow" <Window
x:Class="mpvnet.CommandPaletteWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="Command Palette" Title="Command Palette"
@@ -21,17 +21,21 @@
<RowDefinition /> <RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBox Name="FilterTextBox" <TextBox
Foreground="{x:Static mpvnet:Theme.Foreground}" Name="FilterTextBox"
Background="{x:Static mpvnet:Theme.Background}" Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown" PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"/> TextChanged="FilterTextBox_TextChanged"
/>
<ListView Name="ListView" <ListView
Name="ListView"
Grid.Row="1" Grid.Row="1"
Foreground="{x:Static mpvnet:Theme.Foreground}" Foreground="{Binding Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}" Background="{Binding Theme.Background}"
MouseUp="ListView_MouseUp"> MouseUp="ListView_MouseUp"
>
<ListView.ItemContainerStyle> <ListView.ItemContainerStyle>
<Style TargetType="ListBoxItem"> <Style TargetType="ListBoxItem">
@@ -49,9 +53,11 @@
<TextBlock Text="{Binding Display}"></TextBlock> <TextBlock Text="{Binding Display}"></TextBlock>
<TextBlock Grid.Column="1" <TextBlock
Grid.Column="1"
Text="{Binding Input}" Text="{Binding Input}"
HorizontalAlignment="Right"></TextBlock> HorizontalAlignment="Right"
/>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>

View File

@@ -17,6 +17,7 @@ namespace mpvnet
public CommandPaletteWindow() public CommandPaletteWindow()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this;
CollectionViewSource collectionViewSource = new CollectionViewSource() { Source = CommandItem.Items }; CollectionViewSource collectionViewSource = new CollectionViewSource() { Source = CommandItem.Items };
CollectionView = collectionViewSource.View; CollectionView = collectionViewSource.View;
var yourCostumFilter = new Predicate<object>(item => Filter((CommandItem)item)); var yourCostumFilter = new Predicate<object>(item => Filter((CommandItem)item));
@@ -24,6 +25,10 @@ namespace mpvnet
ListView.ItemsSource = CollectionView; ListView.ItemsSource = CollectionView;
} }
public Theme Theme {
get => Theme.Current;
}
bool Filter(CommandItem item) bool Filter(CommandItem item)
{ {
if (item.Command == "") if (item.Command == "")

View File

@@ -1,19 +1,20 @@
<Window xmlns:Controls="clr-namespace:Controls" x:Name="ConfWindow1" x:Class="mpvnet.ConfWindow" <Window
xmlns:Controls="clr-namespace:Controls" x:Name="ConfWindow1" x:Class="mpvnet.ConfWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="Config Editor" Title="Config Editor"
Height="530" Height="530"
Width="700" Width="700"
Foreground="{x:Static mpvnet:Theme.Foreground}" Foreground="{Binding Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}" Background="{Binding Theme.Background}"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Loaded="ConfWindow1_Loaded"> Loaded="ConfWindow1_Loaded"
>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -31,24 +32,29 @@
HintText="Find a setting" HintText="Find a setting"
Width="250" Width="250"
Margin="0,20,0,0" Margin="0,20,0,0"
Grid.ColumnSpan="2"/> Grid.ColumnSpan="2"
/>
<ScrollViewer Name="MainScrollViewer" <ScrollViewer
Name="MainScrollViewer"
VerticalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
Grid.Row="1" Grid.Row="1"
Grid.Column="2" Grid.Column="2"
Margin="0,0,0,10"> Margin="0,0,0,10"
>
<StackPanel x:Name="MainStackPanel"></StackPanel> <StackPanel x:Name="MainStackPanel"></StackPanel>
</ScrollViewer> </ScrollViewer>
<StackPanel Margin="20,0,0,0" Grid.Row="1"> <StackPanel Margin="20,0,0,0" Grid.Row="1">
<ListBox Name="FilterListBox" <ListBox
Name="FilterListBox"
ItemsSource="{Binding FilterStrings}" ItemsSource="{Binding FilterStrings}"
BorderThickness="0" BorderThickness="0"
SelectionChanged="FilterListBox_SelectionChanged" SelectionChanged="FilterListBox_SelectionChanged"
Foreground="{x:Static mpvnet:Theme.Heading}" Foreground="{Binding Theme.Heading}"
Background="{x:Static mpvnet:Theme.Background}"> Background="{Binding Theme.Background}"
>
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
@@ -57,10 +63,10 @@
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<TextBlock Name="OpenSettingsTextBlock" Margin="0,30,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static mpvnet:Theme.Heading}" MouseUp="OpenSettingsTextBlock_MouseUp">Open config folder</TextBlock> <TextBlock Name="OpenSettingsTextBlock" Margin="0,30,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{Binding Theme.Heading}" MouseUp="OpenSettingsTextBlock_MouseUp">Open config folder</TextBlock>
<TextBlock Name="PreviewTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static mpvnet:Theme.Heading}" MouseUp="PreviewTextBlock_MouseUp">Preview mpv.conf</TextBlock> <TextBlock Name="PreviewTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{Binding Theme.Heading}" MouseUp="PreviewTextBlock_MouseUp">Preview mpv.conf</TextBlock>
<TextBlock Name="ShowManualTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static mpvnet:Theme.Heading}" MouseUp="ShowManualTextBlock_MouseUp">Show mpv manual</TextBlock> <TextBlock Name="ShowManualTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{Binding Theme.Heading}" MouseUp="ShowManualTextBlock_MouseUp">Show mpv manual</TextBlock>
<TextBlock Name="SupportTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static mpvnet:Theme.Heading}" MouseUp="SupportTextBlock_MouseUp">Show support forum</TextBlock> <TextBlock Name="SupportTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{Binding Theme.Heading}" MouseUp="SupportTextBlock_MouseUp">Show support forum</TextBlock>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Window> </Window>

View File

@@ -35,10 +35,16 @@ namespace mpvnet
FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':'); FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
} }
public Theme Theme {
get => Theme.Current;
}
void LoadSettings() void LoadSettings()
{ {
foreach (SettingBase setting in SettingsDefinitions) foreach (SettingBase setting in SettingsDefinitions)
{ {
setting.StartValue = setting.Value;
if (!FilterStrings.Contains(setting.Filter)) if (!FilterStrings.Contains(setting.Filter))
FilterStrings.Add(setting.Filter); FilterStrings.Add(setting.Filter);
@@ -47,9 +53,9 @@ namespace mpvnet
if (setting.Name == confItem.Name && confItem.Section == "" && !confItem.IsSectionItem) if (setting.Name == confItem.Name && confItem.Section == "" && !confItem.IsSectionItem)
{ {
setting.Value = confItem.Value.Trim('\'', '"'); setting.Value = confItem.Value.Trim('\'', '"');
setting.StartValue = setting.Value;
setting.ConfItem = confItem; setting.ConfItem = confItem;
confItem.SettingBase = setting; confItem.SettingBase = setting;
continue;
} }
} }
@@ -75,7 +81,30 @@ namespace mpvnet
File.WriteAllText(Core.ConfPath, GetContent("mpv")); File.WriteAllText(Core.ConfPath, GetContent("mpv"));
File.WriteAllText(App.ConfPath, GetContent("mpvnet")); File.WriteAllText(App.ConfPath, GetContent("mpvnet"));
Msg.ShowInfo("Changes will be available on next startup.");
foreach (SettingBase item in SettingsDefinitions)
{
if (item.Value != item.StartValue)
{
if (item.File == "mpv")
{
Core.ProcessProperty(item.Name, item.Value);
try
{
Core.set_property_string(item.Name, item.Value, true);
}
catch (Exception ex)
{
App.ShowError(ex.Message);
}
}
else if (item.File == "mpvnet")
App.ProcessProperty(item.Name, item.Value, true);
}
}
App.InitTheme();
} }
string GetCompareString() string GetCompareString()
@@ -90,6 +119,7 @@ namespace mpvnet
string comment = ""; string comment = "";
string section = ""; string section = "";
bool isSectionItem = false; bool isSectionItem = false;
foreach (string currentLine in File.ReadAllLines(file)) foreach (string currentLine in File.ReadAllLines(file))
@@ -175,7 +205,7 @@ namespace mpvnet
} }
else if ((item.SettingBase.Value ?? "") != item.SettingBase.Default) else if ((item.SettingBase.Value ?? "") != item.SettingBase.Default)
{ {
string value = ""; string value;
if (item.SettingBase.Type == "string" || if (item.SettingBase.Type == "string" ||
item.SettingBase.Type == "folder" || item.SettingBase.Type == "folder" ||
@@ -205,7 +235,7 @@ namespace mpvnet
if ((setting.Value ?? "") != setting.Default) if ((setting.Value ?? "") != setting.Default)
{ {
string value = ""; string value;
if (setting.Type == "string" || if (setting.Type == "string" ||
setting.Type == "folder" || setting.Type == "folder" ||
@@ -300,7 +330,7 @@ namespace mpvnet
ProcessHelp.ShellExecute("https://mpv.io/manual/master/"); ProcessHelp.ShellExecute("https://mpv.io/manual/master/");
void SupportTextBlock_MouseUp(object sender, MouseButtonEventArgs e) => void SupportTextBlock_MouseUp(object sender, MouseButtonEventArgs e) =>
ProcessHelp.ShellExecute("https://github.com/stax76/mpv.net#Support"); ProcessHelp.ShellExecute("https://github.com/stax76/mpv.net/blob/master/docs/Manual.md#support");
protected override void OnKeyDown(KeyEventArgs e) protected override void OnKeyDown(KeyEventArgs e)
{ {

View File

@@ -1,9 +1,9 @@
<Window x:Class="mpvnet.EverythingWindow" <Window
x:Class="mpvnet.EverythingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="Media File Search" Title="Media File Search"
@@ -12,7 +12,8 @@
Width="600" Width="600"
ResizeMode="NoResize" ResizeMode="NoResize"
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded"> Loaded="Window_Loaded"
>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -20,18 +21,22 @@
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBox Name="FilterTextBox" <TextBox
Foreground="{x:Static mpvnet:Theme.Foreground}" Name="FilterTextBox"
Background="{x:Static mpvnet:Theme.Background}" Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown" PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"/> TextChanged="FilterTextBox_TextChanged"
/>
<ListView Name="ListView" <ListView
Foreground="{x:Static mpvnet:Theme.Foreground}" Name="ListView"
Background="{x:Static mpvnet:Theme.Background}" Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
Grid.Row="1" Grid.Row="1"
MouseUp="ListView_MouseUp" MouseUp="ListView_MouseUp"
PreviewKeyDown="ListView_PreviewKeyDown"> PreviewKeyDown="ListView_PreviewKeyDown"
>
<ListView.ItemContainerStyle> <ListView.ItemContainerStyle>
<Style TargetType="ListBoxItem"> <Style TargetType="ListBoxItem">

View File

@@ -18,6 +18,11 @@ namespace mpvnet
public EverythingWindow() public EverythingWindow()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this;
}
public Theme Theme {
get => Theme.Current;
} }
const int EVERYTHING_REQUEST_FILE_NAME = 0x00000001; const int EVERYTHING_REQUEST_FILE_NAME = 0x00000001;

View File

@@ -1,9 +1,9 @@
<Window xmlns:Controls="clr-namespace:Controls" x:Class="mpvnet.InputWindow" <Window
xmlns:Controls="clr-namespace:Controls" x:Class="mpvnet.InputWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="Input Editor" Title="Input Editor"
@@ -11,10 +11,11 @@
Width="750" Width="750"
FontSize="13" FontSize="13"
ShowInTaskbar="False" ShowInTaskbar="False"
Foreground="{x:Static mpvnet:Theme.Foreground}" Foreground="{Binding Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}" Background="{Binding Theme.Background}"
Loaded="Window_Loaded" Loaded="Window_Loaded"
Closed="Window_Closed"> Closed="Window_Closed"
>
<Window.Resources> <Window.Resources>
<Style x:Key="DataGrid_Font_Centering" TargetType="{x:Type DataGridCell}"> <Style x:Key="DataGrid_Font_Centering" TargetType="{x:Type DataGridCell}">
@@ -41,13 +42,16 @@
x:Name="SearchControl" x:Name="SearchControl"
Width="300" Width="300"
Margin="0,20,0,20" Margin="0,20,0,20"
Grid.ColumnSpan="2" /> Grid.ColumnSpan="2"
/>
<DataGrid x:Name="DataGrid" <DataGrid
x:Name="DataGrid"
Grid.Row="1" Grid.Row="1"
CommandManager.PreviewCanExecute="DataGrid_PreviewCanExecute" CommandManager.PreviewCanExecute="DataGrid_PreviewCanExecute"
AutoGenerateColumns="False" AutoGenerateColumns="False"
CellStyle="{StaticResource DataGrid_Font_Centering}" > CellStyle="{StaticResource DataGrid_Font_Centering}"
>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="Menu" Binding="{Binding Path}"/> <DataGridTextColumn Header="Menu" Binding="{Binding Path}"/>

View File

@@ -20,6 +20,7 @@ namespace mpvnet
public InputWindow() public InputWindow()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this;
InitialInputConfContent = GetInputConfContent(); InitialInputConfContent = GetInputConfContent();
SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged; SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
DataGrid.SelectionMode = DataGridSelectionMode.Single; DataGrid.SelectionMode = DataGridSelectionMode.Single;
@@ -30,6 +31,10 @@ namespace mpvnet
DataGrid.ItemsSource = CollectionView; DataGrid.ItemsSource = CollectionView;
} }
public Theme Theme {
get => Theme.Current;
}
void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e) void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
{ {
CollectionView.Refresh(); CollectionView.Refresh();
@@ -38,7 +43,10 @@ namespace mpvnet
{ {
SearchControl.SearchTextBox.Text = ""; SearchControl.SearchTextBox.Text = "";
Msg.ShowInfo("Filtering", Msg.ShowInfo("Filtering",
"Reduce the filter scope with:\n\ni input\n\nm menu\n\nc command\n\n" + "Reduce the filter scope with:" + BR2 +
"i input" + BR2 +
"m menu" + BR2 +
"c command" + BR2 +
"If only one character is entered input search is performed."); "If only one character is entered input search is performed.");
} }
} }
@@ -87,7 +95,7 @@ namespace mpvnet
foreach (CommandItem i in CommandItem.Items) foreach (CommandItem i in CommandItem.Items)
if (items.ContainsKey(i.Input) && i.Input != "") if (items.ContainsKey(i.Input) && i.Input != "")
Msg.ShowInfo($"Duplicate found:\n\n{i.Input}: {i.Path}\n\n{items[i.Input].Input}: {items[i.Input].Path}\n\nPlease note that you can chain multiple commands in the same line by using a semicolon as separator.", "Duplicate Found"); Msg.ShowInfo($"Duplicate found:{BR2 + i.Input}: {i.Path + BR2}{items[i.Input].Input}: {items[i.Input].Path + BR2}Please note that you can chain multiple commands in the same line by using a semicolon as separator.", "Duplicate Found");
else else
items[i.Input] = i; items[i.Input] = i;
} }

View File

@@ -1,9 +1,9 @@
<Window x:Class="mpvnet.LearnWindow" <Window
x:Class="mpvnet.LearnWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="Learn Input" Title="Learn Input"
@@ -12,11 +12,12 @@
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
ResizeMode="NoResize" ResizeMode="NoResize"
Loaded="Window_Loaded" Loaded="Window_Loaded"
Foreground="{x:Static mpvnet:Theme.Foreground}" Foreground="{Binding Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}" Background="{Binding Theme.Background}"
MouseWheel="Window_MouseWheel" MouseWheel="Window_MouseWheel"
MouseUp="Window_MouseUp" MouseUp="Window_MouseUp"
MouseDoubleClick="Window_MouseDoubleClick" PreviewKeyDown="Window_PreviewKeyDown"> MouseDoubleClick="Window_MouseDoubleClick" PreviewKeyDown="Window_PreviewKeyDown"
>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -30,18 +31,23 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock x:Name="MenuTextBlock" <TextBlock
x:Name="MenuTextBlock"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center" HorizontalAlignment="Center"
FontSize="16"></TextBlock> FontSize="16"
>
</TextBlock>
<TextBlock x:Name="KeyTextBlock" <TextBlock
x:Name="KeyTextBlock"
Grid.Row="1" Grid.Row="1"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
VerticalAlignment="Top" VerticalAlignment="Top"
HorizontalAlignment="Center" HorizontalAlignment="Center"
FontSize="16" /> FontSize="16"
/>
<Button x:Name="ConfirmButton" Grid.Row="2" Click="ConfirmButton_Click">Confirm</Button> <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> <Button x:Name="ClearButton" Grid.Row="2" Click="ClearButton_Click" Grid.Column="1">Clear</Button>

View File

@@ -24,7 +24,15 @@ namespace mpvnet
int VK_LCONTROL = 0xA2; int VK_LCONTROL = 0xA2;
int VK_RCONTROL = 0xA3; int VK_RCONTROL = 0xA3;
public LearnWindow() => InitializeComponent(); public LearnWindow()
{
InitializeComponent();
DataContext = this;
}
public Theme Theme {
get => Theme.Current;
}
[DllImport("user32.dll", CharSet = CharSet.Auto)] [DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern short GetKeyState(int keyCode); static extern short GetKeyState(int keyCode);

View File

@@ -1,18 +1,21 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mpvnet="clr-namespace:mpvnet"> >
<Style TargetType="TextBox"> <Style TargetType="TextBox">
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}"> <ControlTemplate TargetType="{x:Type TextBox}">
<Border x:Name="border" <Border
x:Name="border"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
SnapsToDevicePixels="True"> SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ContentHost" <ScrollViewer
x:Name="PART_ContentHost"
Focusable="false" Focusable="false"
HorizontalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden"/> VerticalScrollBarVisibility="Hidden"/>
@@ -26,7 +29,7 @@
<Setter Property="BorderBrush" TargetName="border" Value="#FF7EB4EA"/> <Setter Property="BorderBrush" TargetName="border" Value="#FF7EB4EA"/>
</Trigger> </Trigger>
<Trigger Property="IsFocused" Value="true"> <Trigger Property="IsFocused" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{x:Static mpvnet:Theme.Heading}"/> <Setter Property="BorderBrush" TargetName="border" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Heading}"/>
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
@@ -49,22 +52,25 @@
x:Name="normal" x:Name="normal"
Width="18" Width="18"
Height="18" Height="18"
Fill="{x:Static mpvnet:Theme.Background}" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Background}"
Stroke="{x:Static mpvnet:Theme.Heading}" Stroke="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Heading}"
StrokeThickness="2" /> StrokeThickness="2"
/>
<Ellipse <Ellipse
x:Name="Checked1" x:Name="Checked1"
Width="8" Width="8"
Height="8" Height="8"
Fill="{TemplateBinding Foreground}" Fill="{TemplateBinding Foreground}"
Opacity="0" /> Opacity="0"
/>
<Ellipse <Ellipse
x:Name="disabled" x:Name="disabled"
Width="18" Width="18"
Height="18" Height="18"
Fill="{DynamicResource SemiTransparentWhiteBrush}" Fill="{DynamicResource SemiTransparentWhiteBrush}"
Opacity="0" Opacity="0"
StrokeThickness="{TemplateBinding BorderThickness}" /> StrokeThickness="{TemplateBinding BorderThickness}"
/>
</Grid> </Grid>
<ContentPresenter <ContentPresenter
@@ -77,7 +83,8 @@
ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
RecognizesAccessKey="True" /> RecognizesAccessKey="True"
/>
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates"> <VisualStateGroup x:Name="CommonStates">
@@ -88,12 +95,14 @@
Storyboard.TargetName="contentPresenter" Storyboard.TargetName="contentPresenter"
Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetProperty="(UIElement.Opacity)"
To=".55" To=".55"
Duration="0" /> Duration="0"
/>
<DoubleAnimation <DoubleAnimation
Storyboard.TargetName="disabled" Storyboard.TargetName="disabled"
Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetProperty="(UIElement.Opacity)"
To="1" To="1"
Duration="0" /> Duration="0"
/>
</Storyboard> </Storyboard>
</VisualState> </VisualState>
</VisualStateGroup> </VisualStateGroup>
@@ -104,7 +113,8 @@
Storyboard.TargetName="Checked1" Storyboard.TargetName="Checked1"
Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetProperty="(UIElement.Opacity)"
To="1" To="1"
Duration="0" /> Duration="0"
/>
</Storyboard> </Storyboard>
</VisualState> </VisualState>
<VisualState x:Name="Unchecked" /> <VisualState x:Name="Unchecked" />

View File

@@ -1,33 +1,41 @@
<UserControl x:Class="Controls.SearchTextBoxUserControl" <UserControl
x:Class="Controls.SearchTextBoxUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800"> d:DesignWidth="800"
>
<Grid Name="SearchTextBoxUserControl1" <Grid
Background="{x:Static mpvnet:Theme.Background}"> Name="SearchTextBoxUserControl1"
Background="{Binding Theme.Background}"
>
<TextBlock Name="HintTextBlock" <TextBlock
Name="HintTextBlock"
Margin="5,2" Margin="5,2"
Text="Find a setting" Text="Find a setting"
VerticalAlignment="Center" VerticalAlignment="Center"
Foreground="{x:Static mpvnet:Theme.Foreground2}" Foreground="{Binding Theme.Foreground2}"
Background="{x:Static mpvnet:Theme.Background}" /> Background="{Binding Theme.Background}"
/>
<TextBox Name="SearchTextBox" <TextBox
Name="SearchTextBox"
Height="25" Height="25"
Padding="1,2,0,0" Padding="1,2,0,0"
BorderThickness="2" BorderThickness="2"
Background="Transparent" Background="Transparent"
TextChanged="SearchTextBox_TextChanged" TextChanged="SearchTextBox_TextChanged"
Foreground="{x:Static mpvnet:Theme.Foreground}" Foreground="{Binding Theme.Foreground}"
CaretBrush="{x:Static mpvnet:Theme.Foreground}" /> CaretBrush="{Binding Theme.Foreground}"
/>
<Button Name="SearchClearButton" <Button
Name="SearchClearButton"
Background="Transparent" Background="Transparent"
HorizontalAlignment="Right" HorizontalAlignment="Right"
FontFamily="Marlett" FontFamily="Marlett"
@@ -36,21 +44,26 @@
Height="17" Height="17"
Margin="2,0,4,0" Margin="2,0,4,0"
Visibility="Hidden" Visibility="Hidden"
Click="SearchClearButton_Click" >r Click="SearchClearButton_Click"
>r
<Button.Style> <Button.Style>
<Style TargetType="Button"> <Style TargetType="Button">
<Setter Property="Background" Value="{x:Static mpvnet:Theme.Background}"/> <Setter Property="Background" Value="{Binding Theme.Background}"/>
<Setter Property="Foreground" Value="{x:Static mpvnet:Theme.Foreground2}"/> <Setter Property="Foreground" Value="{Binding Theme.Foreground2}"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
<Border BorderThickness="1" <Border
BorderThickness="1"
BorderBrush="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding Foreground}"
SnapsToDevicePixels="True"> SnapsToDevicePixels="True"
>
<ContentPresenter HorizontalAlignment="Center" <ContentPresenter
VerticalAlignment="Center" /> HorizontalAlignment="Center"
VerticalAlignment="Center"
/>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
@@ -58,7 +71,7 @@
<Style.Triggers> <Style.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{x:Static mpvnet:Theme.Heading}"/> <Setter Property="Foreground" Value="{Binding Theme.Heading}"/>
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>

View File

@@ -3,6 +3,8 @@ using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using mpvnet;
namespace Controls namespace Controls
{ {
public partial class SearchTextBoxUserControl : UserControl public partial class SearchTextBoxUserControl : UserControl
@@ -10,9 +12,17 @@ namespace Controls
public SearchTextBoxUserControl() public SearchTextBoxUserControl()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this;
} }
public string Text { get => SearchTextBox.Text; set => SearchTextBox.Text = value; } public Theme Theme {
get => Theme.Current;
}
public string Text {
get => SearchTextBox.Text;
set => SearchTextBox.Text = value;
}
string _HintText; string _HintText;

View File

@@ -1,4 +1,5 @@
<Window x:Class="mpvnet.SetupWindow" <Window
x:Class="mpvnet.SetupWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -8,10 +9,11 @@
Title="mpv.net Setup" Title="mpv.net Setup"
FontSize="13" FontSize="13"
Foreground="{x:Static mpvnet:Theme.Foreground}" Foreground="{Binding Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}" Background="{Binding Theme.Background}"
SizeToContent="WidthAndHeight" SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner" > WindowStartupLocation="CenterOwner"
>
<Window.Resources> <Window.Resources>
<Style TargetType="Button"> <Style TargetType="Button">
@@ -32,11 +34,13 @@
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image Grid.Column="0" <Image
Grid.Column="0"
Source="{x:Static mpvnet:SetupWindow.ShieldIcon}" Source="{x:Static mpvnet:SetupWindow.ShieldIcon}"
Width="18" Width="18"
Height="18" Height="18"
Margin="3,0,0,0"/> Margin="3,0,0,0"
/>
<ContentPresenter Grid.Column="1" HorizontalAlignment="Center" /> <ContentPresenter Grid.Column="1" HorizontalAlignment="Center" />
</Grid> </Grid>
</Button> </Button>

View File

@@ -13,7 +13,15 @@ namespace mpvnet
{ {
public partial class SetupWindow : Window public partial class SetupWindow : Window
{ {
public SetupWindow() => InitializeComponent(); public SetupWindow()
{
InitializeComponent();
DataContext = this;
}
public Theme Theme {
get => Theme.Current;
}
static BitmapSource _ShieldIcon; static BitmapSource _ShieldIcon;

View File

@@ -15,8 +15,6 @@ namespace mpvnet
Application.Current.Resources.MergedDictionaries.Add( Application.Current.Resources.MergedDictionaries.Add(
Application.LoadComponent(new Uri("mpvnet;component/WPF/Resources.xaml", Application.LoadComponent(new Uri("mpvnet;component/WPF/Resources.xaml",
UriKind.Relative)) as ResourceDictionary); UriKind.Relative)) as ResourceDictionary);
Application.Current.DispatcherUnhandledException += (sender, e) => App.ShowException(e.Exception);
} }
} }
} }

View File

@@ -33,7 +33,6 @@ namespace mpvnet
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
SetColors();
try try
{ {
@@ -945,15 +944,6 @@ namespace mpvnet
//} //}
} }
static void SetColors()
{
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");
}
protected override void OnResize(EventArgs e) protected override void OnResize(EventArgs e)
{ {
base.OnResize(e); base.OnResize(e);

View File

@@ -197,7 +197,9 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
{ {
if (e.Direction == ArrowDirection.Down) throw new NotImplementedException(); if (e.Direction == ArrowDirection.Down)
throw new NotImplementedException();
float x1 = e.Item.Width - e.Item.Height * 0.6f; float x1 = e.Item.Width - e.Item.Height * 0.6f;
float y1 = e.Item.Height * 0.25f; float y1 = e.Item.Height * 0.25f;
float x2 = x1 + e.Item.Height * 0.25f; float x2 = x1 + e.Item.Height * 0.25f;

View File

@@ -234,6 +234,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.