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

@@ -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);
}
}
}