misc
This commit is contained in:
@@ -65,6 +65,8 @@ public class GuiCommand
|
||||
Window? win = Activator.CreateInstance(winType) as Window;
|
||||
new WindowInteropHelper(win).Owner = MainForm.Instance!.Handle;
|
||||
win?.ShowDialog();
|
||||
//TODO: Player.Command("quit");
|
||||
Player.Command("quit");
|
||||
}
|
||||
|
||||
public void LoadSubtitle(IList<string> args)
|
||||
|
||||
@@ -40,7 +40,7 @@ public class OptionSettingOption
|
||||
|
||||
public string? Text
|
||||
{
|
||||
get => string.IsNullOrEmpty(_text) ? Name : _text;
|
||||
get => _text ?? Name;
|
||||
set => _text = value;
|
||||
}
|
||||
|
||||
|
||||
18
src/MpvNet.Windows/WPF/ComboBoxTemplateSelector.cs
Normal file
18
src/MpvNet.Windows/WPF/ComboBoxTemplateSelector.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
|
||||
namespace MpvNet.Windows.WPF;
|
||||
|
||||
public class ComboBoxTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
ContentPresenter presenter = (ContentPresenter)container;
|
||||
|
||||
if (presenter.TemplatedParent is ComboBox)
|
||||
return (DataTemplate)presenter.FindResource("ComboBoxCollapsedDataTemplate");
|
||||
else // Templated parent is ComboBoxItem
|
||||
return (DataTemplate)presenter.FindResource("ComboBoxExpandedDataTemplate");
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,10 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
||||
MainStackPanel.Children.Add(new StringSettingControl(s) { Visibility = Visibility.Collapsed });
|
||||
break;
|
||||
case OptionSetting s:
|
||||
MainStackPanel.Children.Add(new OptionSettingControl(s) { Visibility = Visibility.Collapsed });
|
||||
if (s.Options.Count > 3)
|
||||
MainStackPanel.Children.Add(new ComboBoxSettingControl(s) { Visibility = Visibility.Collapsed });
|
||||
else
|
||||
MainStackPanel.Children.Add(new OptionSettingControl(s) { Visibility = Visibility.Collapsed });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
57
src/MpvNet.Windows/WPF/Controls/ComboBoxSettingControl.xaml
Normal file
57
src/MpvNet.Windows/WPF/Controls/ComboBoxSettingControl.xaml
Normal file
@@ -0,0 +1,57 @@
|
||||
<UserControl
|
||||
x:Name="ComboBoxSettingControl1"
|
||||
x:Class="MpvNet.Windows.WPF.ComboBoxSettingControl"
|
||||
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:MpvNet.Windows.WPF"
|
||||
mc:Ignorable="d"
|
||||
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox
|
||||
x:Name="TitleTextBox"
|
||||
FontSize="24"
|
||||
Margin="0,10"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{Binding Theme.Heading}"
|
||||
Background="{Binding Theme.Background}"
|
||||
/>
|
||||
|
||||
<ComboBox
|
||||
Name="ComboBoxControl"
|
||||
Width="200"
|
||||
HorizontalAlignment="Left"
|
||||
MaxDropDownHeight="500"
|
||||
Foreground="{Binding Theme.Heading}"
|
||||
Background="{Binding Theme.Background}"
|
||||
BorderBrush="{Binding Theme.Foreground}"
|
||||
Style="{DynamicResource ComboBoxStyle}"
|
||||
SelectionChanged="ComboBoxControl_SelectionChanged"
|
||||
>
|
||||
<ComboBox.ItemTemplateSelector>
|
||||
<local:ComboBoxTemplateSelector/>
|
||||
</ComboBox.ItemTemplateSelector>
|
||||
</ComboBox>
|
||||
|
||||
<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>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
using MpvNet.Windows.UI;
|
||||
|
||||
namespace MpvNet.Windows.WPF;
|
||||
|
||||
public partial class ComboBoxSettingControl : UserControl, ISettingControl
|
||||
{
|
||||
OptionSetting OptionSetting;
|
||||
|
||||
public ComboBoxSettingControl(OptionSetting optionSetting)
|
||||
{
|
||||
OptionSetting = optionSetting;
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
TitleTextBox.Text = optionSetting.Name;
|
||||
|
||||
if (string.IsNullOrEmpty(optionSetting.Help))
|
||||
HelpTextBox.Visibility = Visibility.Collapsed;
|
||||
|
||||
HelpTextBox.Text = optionSetting.Help;
|
||||
ComboBoxControl.ItemsSource = optionSetting.Options;
|
||||
|
||||
foreach (var item in optionSetting.Options)
|
||||
if (item.Name == optionSetting.Value)
|
||||
ComboBoxControl.SelectedItem = item;
|
||||
|
||||
if (string.IsNullOrEmpty(optionSetting.URL))
|
||||
LinkTextBlock.Visibility = Visibility.Collapsed;
|
||||
|
||||
Link.SetURL(optionSetting.URL);
|
||||
}
|
||||
|
||||
public Theme? Theme => Theme.Current;
|
||||
|
||||
public Setting Setting => OptionSetting;
|
||||
|
||||
public bool Contains(string searchString) => ContainsInternal(searchString.ToLower());
|
||||
|
||||
public bool ContainsInternal(string search)
|
||||
{
|
||||
if (TitleTextBox.Text.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) > -1)
|
||||
return true;
|
||||
|
||||
if (HelpTextBox.Text.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) > -1)
|
||||
return true;
|
||||
|
||||
foreach (var i in OptionSetting.Options)
|
||||
{
|
||||
if (i.Text?.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) > -1)
|
||||
return true;
|
||||
|
||||
if (i.Help?.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) > -1)
|
||||
return true;
|
||||
|
||||
if (i.Name?.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) > -1)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ComboBoxControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
OptionSetting.Value = (ComboBoxControl.SelectedItem as OptionSettingOption)?.Name;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,183 @@
|
||||
xmlns:local="clr-namespace:MpvNet.Windows.WPF"
|
||||
>
|
||||
|
||||
<Style x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="32" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border
|
||||
x:Name="Border"
|
||||
Grid.ColumnSpan="2"
|
||||
CornerRadius="3"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="1"
|
||||
/>
|
||||
|
||||
<Path
|
||||
x:Name="Arrow"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Data="M 1,1.5 L 4.5,5 L 8,1.5"
|
||||
SnapsToDevicePixels="false"
|
||||
Stroke="#666"
|
||||
StrokeThickness="1.5"
|
||||
/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="ComboBoxTextBox" TargetType="TextBox">
|
||||
<Border x:Name="PART_ContentHost" Focusable="True" />
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}">
|
||||
<Setter Property="Foreground" Value="#333" />
|
||||
<Setter Property="BorderBrush" Value="Gray" />
|
||||
<Setter Property="Background" Value="White" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="true"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
|
||||
<Setter Property="FontSize" Value="13" />
|
||||
<Setter Property="MinWidth" Value="150"/>
|
||||
<Setter Property="MinHeight" Value="25"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ComboBox">
|
||||
<Grid>
|
||||
<ToggleButton
|
||||
Cursor="Hand"
|
||||
Name="ToggleButton"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Background="{TemplateBinding Background}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Style="{StaticResource ComboBoxToggleButton}"
|
||||
Grid.Column="2"
|
||||
Focusable="false"
|
||||
IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
|
||||
ClickMode="Press"
|
||||
/>
|
||||
|
||||
<ContentPresenter
|
||||
Name="ContentSite"
|
||||
IsHitTestVisible="False"
|
||||
Content="{TemplateBinding SelectionBoxItem}"
|
||||
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
|
||||
Margin="10,3,30,3"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Left"
|
||||
/>
|
||||
|
||||
<TextBox
|
||||
x:Name="PART_EditableTextBox"
|
||||
Style="{x:Null}"
|
||||
Template="{StaticResource ComboBoxTextBox}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Margin="3,3,23,3"
|
||||
Focusable="True"
|
||||
Visibility="Hidden"
|
||||
IsReadOnly="{TemplateBinding IsReadOnly}"
|
||||
/>
|
||||
|
||||
<Popup
|
||||
Name="Popup"
|
||||
Placement="Bottom"
|
||||
IsOpen="{TemplateBinding IsDropDownOpen}"
|
||||
AllowsTransparency="True"
|
||||
Focusable="False"
|
||||
PopupAnimation="Slide"
|
||||
>
|
||||
|
||||
<Grid
|
||||
Name="DropDown"
|
||||
SnapsToDevicePixels="True"
|
||||
MinWidth="{TemplateBinding ActualWidth}"
|
||||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||
>
|
||||
|
||||
<Border
|
||||
CornerRadius="3"
|
||||
x:Name="DropDownBorder"
|
||||
Background="White"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#F6F6F6"
|
||||
/>
|
||||
|
||||
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
|
||||
<StackPanel
|
||||
IsItemsHost="True"
|
||||
KeyboardNavigation.DirectionalNavigation="Contained" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Popup>
|
||||
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="HasItems" Value="false">
|
||||
<Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsGrouping" Value="true">
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEditable" Value="true">
|
||||
<Setter Property="IsTabStop" Value="false"/>
|
||||
<Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ComboBoxItemStyle" TargetType="{x:Type ComboBoxItem}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="true" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
||||
<Setter Property="FontSize" Value="13" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ComboBoxItem">
|
||||
<Border
|
||||
Name="Border"
|
||||
Padding="5"
|
||||
Margin="2"
|
||||
BorderThickness="2,0,0,0"
|
||||
CornerRadius="0"
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
>
|
||||
|
||||
<TextBlock TextAlignment="Left">
|
||||
<ContentPresenter />
|
||||
</TextBlock>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsHighlighted" Value="true">
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="#B3CB37"/>
|
||||
<Setter TargetName="Border" Property="Background" Value="#F8FAEB"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="local:HyperlinkEx">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
@@ -53,20 +230,23 @@
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="MinHeight" Value="25" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border x:Name="border"
|
||||
BorderBrush="{DynamicResource PrimaryTextBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="3"
|
||||
SnapsToDevicePixels="True">
|
||||
<Border
|
||||
x:Name="border"
|
||||
BorderBrush="{DynamicResource PrimaryTextBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="3"
|
||||
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>
|
||||
@@ -1043,4 +1223,23 @@
|
||||
|
||||
<Style BasedOn="{StaticResource MenuBaseStyle}" TargetType="Menu"/>
|
||||
|
||||
<DataTemplate x:Key="ComboBoxCollapsedDataTemplate" >
|
||||
<TextBlock
|
||||
Text="{Binding Text}"
|
||||
|
||||
/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="ComboBoxExpandedDataTemplate" >
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Text="{Binding Text}"
|
||||
Width="100"
|
||||
/>
|
||||
<TextBlock
|
||||
Text="{Binding Help}"
|
||||
Padding="5,0,0,0"
|
||||
/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
@@ -1258,6 +1258,9 @@ public partial class MainForm : Form
|
||||
WinMpvHelp.AddToPath();
|
||||
}, DispatcherPriority.Background);
|
||||
});
|
||||
|
||||
//TODO: Player.Command("script-message-to mpvnet show-conf-editor");
|
||||
Player.Command("script-message-to mpvnet show-conf-editor");
|
||||
}
|
||||
|
||||
void ContextMenu_Closed(object sender, System.Windows.RoutedEventArgs e) => MenuAutoResetEvent.Set();
|
||||
|
||||
Reference in New Issue
Block a user