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.
- Fix console not working due to incorrect mpv.conf value generated
(script-opts=console-scale=0).
- Registry usage is not portable and also not popular, so settings
are stored in the file settings.xml now instead of the Registry.
- Settings are stored in the file settings.xml now instead of the Registry.
- 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)

View File

@@ -1,14 +1,13 @@

using mpvnet;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Navigation;
using Tommy;
using mpvnet;
namespace DynamicGUI
{
@@ -62,10 +61,10 @@ namespace DynamicGUI
baseSetting.File = setting["file"];
baseSetting.Filter = setting["filter"];
if (setting.HasKey("help")) baseSetting.Help = setting["help"];
if (setting.HasKey("url")) baseSetting.URL = setting["url"];
if (setting.HasKey("help")) baseSetting.Help = setting["help"];
if (setting.HasKey("url")) baseSetting.URL = setting["url"];
if (setting.HasKey("width")) baseSetting.Width = setting["width"];
if (setting.HasKey("type")) baseSetting.Type = setting["type"];
if (setting.HasKey("type")) baseSetting.Type = setting["type"];
settingsList.Add(baseSetting);
}
@@ -75,26 +74,29 @@ namespace DynamicGUI
public class ConfItem
{
public string Name { get; set; } = "";
public string Value { get; set; } = "";
public string Comment { get; set; } = "";
public string LineComment { get; set; } = "";
public string Section { 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 SettingBase SettingBase { get; set; }
}
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 URL { get; set; }
public string File { 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 URL { get; set; }
public string Value { get; set; }
public int Width { get; set; }
public ConfItem ConfItem { get; set; }
}

View File

@@ -1,61 +1,70 @@
<UserControl x:Name="OptionSettingControl1" x:Class="DynamicGUI.OptionSettingControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:DynamicGUI"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
d:DesignHeight="450"
d:DesignWidth="800">
<UserControl
x:Name="OptionSettingControl1" x:Class="DynamicGUI.OptionSettingControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:DynamicGUI"
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="{x:Static mpvnet:Theme.Heading}"
Background="{x:Static mpvnet:Theme.Background}" />
<TextBox
x:Name="TitleTextBox"
FontSize="24"
Margin="0,10"
BorderThickness="0"
IsReadOnly="True"
Foreground="{Binding Theme.Heading}"
Background="{Binding 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="{x:Static mpvnet:Theme.Foreground}"/>
<RadioButton
x:Name="RadioButton"
VerticalContentAlignment="Center"
IsChecked="{Binding Checked}"
GroupName="{Binding OptionSetting.Name}"
Content="{Binding Text}"
FontSize="16"
FontWeight="Normal"
VerticalAlignment="Top"
Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.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 mpvnet:Theme.Foreground2}"
Background="{x:Static mpvnet:Theme.Background}"/>
<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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Foreground2}"
Background="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Background}"
/>
</WrapPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBox x:Name="HelpTextBox"
TextWrapping="WrapWithOverflow"
BorderThickness="0"
IsReadOnly="True"
Margin="0,10,0,0"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"/>
<TextBox
x:Name="HelpTextBox"
TextWrapping="WrapWithOverflow"
BorderThickness="0"
IsReadOnly="True"
Margin="0,10,0,0"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
/>
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
</TextBlock>

View File

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

View File

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

View File

@@ -1,9 +1,11 @@

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

View File

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

View File

@@ -10,6 +10,8 @@ using System.Text;
using Microsoft.CSharp;
using static mpvnet.Global;
namespace mpvnet
{
class CSharpScriptHost
@@ -66,7 +68,7 @@ namespace mpvnet
i.Line + "\n" + "Error Number: " + i.ErrorNumber + "\n" + i.ErrorText);
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)

View File

@@ -144,12 +144,12 @@ namespace mpvnet
mpv_error err = mpv_initialize(Handle);
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);
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();
InvokeAsync(InitializedAsync);
@@ -929,7 +929,7 @@ namespace mpvnet
Terminal.WriteError(msg);
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)))
catalog.Catalogs.Add(new DirectoryCatalog(extDir, Path.GetFileName(extDir) + ".dll"));
else
Terminal.WriteError("Failed to load extension:\n\n" + extDir +
"\n\nOnly extensions that ship with mpv.net are allowed in <startup>\\extensions" +
"\n\nUser extensions have to use <config folder>\\extensions" +
"\n\nNever copy or install a new mpv.net version over a old mpv.net version.");
Terminal.WriteError("Failed to load extension:" + BR2 + extDir +
BR2 + "Only extensions that ship with mpv.net are allowed in <startup>\\extensions" +
BR2 + "User extensions have to use <config folder>\\extensions" +
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.Windows.Forms;
using static mpvnet.Global;
public class Msg
{
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,
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);
}
}

View File

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

View File

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

View File

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

View File

@@ -1,19 +1,20 @@
<Window x:Class="mpvnet.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="About mpv.net"
FontSize="16"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}">
<Window
x:Class="mpvnet.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
Title="About mpv.net"
FontSize="16"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
>
<Grid>
<StackPanel HorizontalAlignment="Center">

View File

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

View File

@@ -1,19 +1,19 @@
<Window x:Class="mpvnet.CommandPaletteWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="Command Palette"
Height="295"
Width="400"
FontSize="13"
ResizeMode="NoResize"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded">
<Window
x:Class="mpvnet.CommandPaletteWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
Title="Command Palette"
Height="295"
Width="400"
FontSize="13"
ResizeMode="NoResize"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded">
<Grid>
<Grid.RowDefinitions>
@@ -21,17 +21,21 @@
<RowDefinition />
</Grid.RowDefinitions>
<TextBox Name="FilterTextBox"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"/>
<TextBox
Name="FilterTextBox"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"
/>
<ListView Name="ListView"
Grid.Row="1"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
MouseUp="ListView_MouseUp">
<ListView
Name="ListView"
Grid.Row="1"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
MouseUp="ListView_MouseUp"
>
<ListView.ItemContainerStyle>
<Style TargetType="ListBoxItem">
@@ -48,10 +52,12 @@
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Display}"></TextBlock>
<TextBlock Grid.Column="1"
Text="{Binding Input}"
HorizontalAlignment="Right"></TextBlock>
<TextBlock
Grid.Column="1"
Text="{Binding Input}"
HorizontalAlignment="Right"
/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>

View File

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

View File

@@ -1,19 +1,20 @@
<Window xmlns:Controls="clr-namespace:Controls" x:Name="ConfWindow1" x:Class="mpvnet.ConfWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="Config Editor"
Height="530"
Width="700"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"
Loaded="ConfWindow1_Loaded">
<Window
xmlns:Controls="clr-namespace:Controls" x:Name="ConfWindow1" x:Class="mpvnet.ConfWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
Title="Config Editor"
Height="530"
Width="700"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"
Loaded="ConfWindow1_Loaded"
>
<Grid>
<Grid.RowDefinitions>
@@ -31,24 +32,29 @@
HintText="Find a setting"
Width="250"
Margin="0,20,0,0"
Grid.ColumnSpan="2"/>
Grid.ColumnSpan="2"
/>
<ScrollViewer Name="MainScrollViewer"
VerticalScrollBarVisibility="Auto"
Grid.Row="1"
Grid.Column="2"
Margin="0,0,0,10">
<ScrollViewer
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 Name="FilterListBox"
ItemsSource="{Binding FilterStrings}"
BorderThickness="0"
SelectionChanged="FilterListBox_SelectionChanged"
Foreground="{x:Static mpvnet:Theme.Heading}"
Background="{x:Static mpvnet:Theme.Background}">
<ListBox
Name="FilterListBox"
ItemsSource="{Binding FilterStrings}"
BorderThickness="0"
SelectionChanged="FilterListBox_SelectionChanged"
Foreground="{Binding Theme.Heading}"
Background="{Binding Theme.Background}"
>
<ListBox.ItemTemplate>
<DataTemplate>
@@ -57,10 +63,10 @@
</ListBox.ItemTemplate>
</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="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="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="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="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="{Binding Theme.Heading}" MouseUp="PreviewTextBlock_MouseUp">Preview mpv.conf</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="{Binding Theme.Heading}" MouseUp="SupportTextBlock_MouseUp">Show support forum</TextBlock>
</StackPanel>
</Grid>
</Window>

View File

@@ -35,10 +35,16 @@ namespace mpvnet
FilterListBox.SelectedItem = SearchControl.Text.TrimEnd(':');
}
public Theme Theme {
get => Theme.Current;
}
void LoadSettings()
{
foreach (SettingBase setting in SettingsDefinitions)
{
setting.StartValue = setting.Value;
if (!FilterStrings.Contains(setting.Filter))
FilterStrings.Add(setting.Filter);
@@ -47,9 +53,9 @@ namespace mpvnet
if (setting.Name == confItem.Name && confItem.Section == "" && !confItem.IsSectionItem)
{
setting.Value = confItem.Value.Trim('\'', '"');
setting.StartValue = setting.Value;
setting.ConfItem = confItem;
confItem.SettingBase = setting;
continue;
}
}
@@ -75,7 +81,30 @@ namespace mpvnet
File.WriteAllText(Core.ConfPath, GetContent("mpv"));
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()
@@ -90,6 +119,7 @@ namespace mpvnet
string comment = "";
string section = "";
bool isSectionItem = false;
foreach (string currentLine in File.ReadAllLines(file))
@@ -175,7 +205,7 @@ namespace mpvnet
}
else if ((item.SettingBase.Value ?? "") != item.SettingBase.Default)
{
string value = "";
string value;
if (item.SettingBase.Type == "string" ||
item.SettingBase.Type == "folder" ||
@@ -205,7 +235,7 @@ namespace mpvnet
if ((setting.Value ?? "") != setting.Default)
{
string value = "";
string value;
if (setting.Type == "string" ||
setting.Type == "folder" ||
@@ -300,7 +330,7 @@ namespace mpvnet
ProcessHelp.ShellExecute("https://mpv.io/manual/master/");
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)
{

View File

@@ -1,18 +1,19 @@
<Window x:Class="mpvnet.EverythingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="Media File Search"
FontSize="13"
Height="300"
Width="600"
ResizeMode="NoResize"
WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded">
<Window
x:Class="mpvnet.EverythingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
Title="Media File Search"
FontSize="13"
Height="300"
Width="600"
ResizeMode="NoResize"
WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded"
>
<Grid>
<Grid.RowDefinitions>
@@ -20,18 +21,22 @@
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox Name="FilterTextBox"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"/>
<TextBox
Name="FilterTextBox"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"
/>
<ListView Name="ListView"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
Grid.Row="1"
MouseUp="ListView_MouseUp"
PreviewKeyDown="ListView_PreviewKeyDown">
<ListView
Name="ListView"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
Grid.Row="1"
MouseUp="ListView_MouseUp"
PreviewKeyDown="ListView_PreviewKeyDown"
>
<ListView.ItemContainerStyle>
<Style TargetType="ListBoxItem">

View File

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

View File

@@ -1,20 +1,21 @@
<Window xmlns:Controls="clr-namespace:Controls" x:Class="mpvnet.InputWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="Input Editor"
Height="500"
Width="750"
FontSize="13"
ShowInTaskbar="False"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
Loaded="Window_Loaded"
Closed="Window_Closed">
<Window
xmlns:Controls="clr-namespace:Controls" x:Class="mpvnet.InputWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
Title="Input Editor"
Height="500"
Width="750"
FontSize="13"
ShowInTaskbar="False"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
Loaded="Window_Loaded"
Closed="Window_Closed"
>
<Window.Resources>
<Style x:Key="DataGrid_Font_Centering" TargetType="{x:Type DataGridCell}">
@@ -41,13 +42,16 @@
x:Name="SearchControl"
Width="300"
Margin="0,20,0,20"
Grid.ColumnSpan="2" />
Grid.ColumnSpan="2"
/>
<DataGrid x:Name="DataGrid"
Grid.Row="1"
CommandManager.PreviewCanExecute="DataGrid_PreviewCanExecute"
AutoGenerateColumns="False"
CellStyle="{StaticResource DataGrid_Font_Centering}" >
<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}"/>

View File

@@ -20,6 +20,7 @@ namespace mpvnet
public InputWindow()
{
InitializeComponent();
DataContext = this;
InitialInputConfContent = GetInputConfContent();
SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
DataGrid.SelectionMode = DataGridSelectionMode.Single;
@@ -30,6 +31,10 @@ namespace mpvnet
DataGrid.ItemsSource = CollectionView;
}
public Theme Theme {
get => Theme.Current;
}
void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
CollectionView.Refresh();
@@ -38,7 +43,10 @@ namespace mpvnet
{
SearchControl.SearchTextBox.Text = "";
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.");
}
}
@@ -87,7 +95,7 @@ namespace mpvnet
foreach (CommandItem i in CommandItem.Items)
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
items[i.Input] = i;
}

View File

@@ -1,22 +1,23 @@
<Window x:Class="mpvnet.LearnWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="Learn Input"
Height="200"
Width="400"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
Loaded="Window_Loaded"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
MouseWheel="Window_MouseWheel"
MouseUp="Window_MouseUp"
MouseDoubleClick="Window_MouseDoubleClick" PreviewKeyDown="Window_PreviewKeyDown">
<Window
x:Class="mpvnet.LearnWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
Title="Learn Input"
Height="200"
Width="400"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
Loaded="Window_Loaded"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
MouseWheel="Window_MouseWheel"
MouseUp="Window_MouseUp"
MouseDoubleClick="Window_MouseDoubleClick" PreviewKeyDown="Window_PreviewKeyDown"
>
<Grid>
<Grid.RowDefinitions>
@@ -29,19 +30,24 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<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" />
<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>

View File

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

View File

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

View File

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

View File

@@ -3,6 +3,8 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using mpvnet;
namespace Controls
{
public partial class SearchTextBoxUserControl : UserControl
@@ -10,9 +12,17 @@ namespace Controls
public SearchTextBoxUserControl()
{
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;

View File

@@ -1,17 +1,19 @@
<Window x:Class="mpvnet.SetupWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="mpv.net Setup"
FontSize="13"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner" >
<Window
x:Class="mpvnet.SetupWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="mpv.net Setup"
FontSize="13"
Foreground="{Binding Theme.Foreground}"
Background="{Binding Theme.Background}"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner"
>
<Window.Resources>
<Style TargetType="Button">
@@ -32,11 +34,13 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0"
Source="{x:Static mpvnet:SetupWindow.ShieldIcon}"
Width="18"
Height="18"
Margin="3,0,0,0"/>
<Image
Grid.Column="0"
Source="{x:Static mpvnet:SetupWindow.ShieldIcon}"
Width="18"
Height="18"
Margin="3,0,0,0"
/>
<ContentPresenter Grid.Column="1" HorizontalAlignment="Center" />
</Grid>
</Button>

View File

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

View File

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

View File

@@ -33,7 +33,6 @@ namespace mpvnet
public MainForm()
{
InitializeComponent();
SetColors();
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)
{
base.OnResize(e);

View File

@@ -197,7 +197,9 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
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 y1 = e.Item.Height * 0.25f;
float x2 = x1 + e.Item.Height * 0.25f;

View File

@@ -234,6 +234,7 @@
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.