misc
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
customizing the conf directory location.
|
customizing the conf directory location.
|
||||||
- Improved support for third party osc scripts like uosc.
|
- Improved support for third party osc scripts like uosc.
|
||||||
- Support of the mpv property `focused`.
|
- Support of the mpv property `focused`.
|
||||||
- Fix Ctrl+Alt and right mouse button usage in input learn window.
|
- Various improvements and fixes in the input bindings editor.
|
||||||
|
|
||||||
|
|
||||||
# v6.0.3.2 Beta (2022-10-14)
|
# v6.0.3.2 Beta (2022-10-14)
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class ConfParser
|
|||||||
{
|
{
|
||||||
public static List<ConfSection> Parse(string content)
|
public static List<ConfSection> Parse(string content)
|
||||||
{
|
{
|
||||||
string[] lines = content.Split(new[] { "\r\n" }, StringSplitOptions.None);
|
string[] lines = content.Split('\n');
|
||||||
var sections = new List<ConfSection>();
|
var sections = new List<ConfSection>();
|
||||||
ConfSection? currentGroup = null;
|
ConfSection? currentGroup = null;
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ public class GuiCommand
|
|||||||
["show-commands"] = args => ShowCommands(), // deprecated
|
["show-commands"] = args => ShowCommands(), // deprecated
|
||||||
["show-history"] = args => ShowHistory(), // deprecated
|
["show-history"] = args => ShowHistory(), // deprecated
|
||||||
["show-playlist"] = args => ShowPlaylist(), // deprecated
|
["show-playlist"] = args => ShowPlaylist(), // deprecated
|
||||||
|
["show-command-palette"] = args => ShowCommandPalette(), // deprecated
|
||||||
//["show-command-palette"] = args => ShowCommandPalette(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public void ShowDialog(Type winType)
|
public void ShowDialog(Type winType)
|
||||||
@@ -294,4 +293,9 @@ public class GuiCommand
|
|||||||
public void ShowPlaylist() =>
|
public void ShowPlaylist() =>
|
||||||
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
|
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
|
||||||
"https://github.com/stax76/mpv-scripts#command_palette");
|
"https://github.com/stax76/mpv-scripts#command_palette");
|
||||||
|
|
||||||
|
// deprecated
|
||||||
|
public void ShowCommandPalette() =>
|
||||||
|
Msg.ShowInfo("This feature was moved to a user script,\nwhich can be found here:\n\n" +
|
||||||
|
"https://github.com/stax76/mpv-scripts#command_palette");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ public class Theme
|
|||||||
public Brush? MenuBackground { get; set; }
|
public Brush? MenuBackground { get; set; }
|
||||||
public Brush? MenuHighlight { get; set; }
|
public Brush? MenuHighlight { get; set; }
|
||||||
|
|
||||||
|
public Color BackgroundColor { get; set; }
|
||||||
|
public Color ForegroundColor { get; set; }
|
||||||
|
public Color Foreground2Color { get; set; }
|
||||||
|
public Color HeadingColor { get; set; }
|
||||||
|
public Color MenuBackgroundColor { get; set; }
|
||||||
|
public Color MenuHighlightColor { get; set; }
|
||||||
|
|
||||||
public Brush GetBrush(string key)
|
public Brush GetBrush(string key)
|
||||||
{
|
{
|
||||||
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(Dictionary[key]));
|
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(Dictionary[key]));
|
||||||
@@ -84,6 +91,13 @@ public class Theme
|
|||||||
Current.Heading = Current.GetBrush("heading");
|
Current.Heading = Current.GetBrush("heading");
|
||||||
Current.MenuBackground = Current.GetBrush("menu-background");
|
Current.MenuBackground = Current.GetBrush("menu-background");
|
||||||
Current.MenuHighlight = Current.GetBrush("menu-highlight");
|
Current.MenuHighlight = Current.GetBrush("menu-highlight");
|
||||||
|
|
||||||
|
Current.BackgroundColor = Current.GetColor("background");
|
||||||
|
Current.ForegroundColor = Current.GetColor("foreground");
|
||||||
|
Current.Foreground2Color = Current.GetColor("foreground2");
|
||||||
|
Current.HeadingColor = Current.GetColor("heading");
|
||||||
|
Current.MenuBackgroundColor = Current.GetColor("menu-background");
|
||||||
|
Current.MenuHighlightColor = Current.GetColor("menu-highlight");
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<Theme> Load(string? content)
|
static List<Theme> Load(string? content)
|
||||||
@@ -91,12 +105,12 @@ public class Theme
|
|||||||
List<Theme> list = new List<Theme>();
|
List<Theme> list = new List<Theme>();
|
||||||
Theme? theme = null;
|
Theme? theme = null;
|
||||||
|
|
||||||
foreach (string currentLine in (content ?? "").Split(new[] { '\r', '\n' }))
|
foreach (string currentLine in (content ?? "").Split('\r', '\n'))
|
||||||
{
|
{
|
||||||
string line = currentLine.Trim();
|
string line = currentLine.Trim();
|
||||||
|
|
||||||
if (line.StartsWith("[") && line.EndsWith("]"))
|
if (line.StartsWith("[") && line.EndsWith("]"))
|
||||||
list.Add(theme = new Theme() { Name = line.Substring(1, line.Length - 2).Trim() });
|
list.Add(theme = new Theme() { Name = line[1..^1].Trim() });
|
||||||
|
|
||||||
if (line.Contains('=') && theme != null)
|
if (line.Contains('=') && theme != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
<controls:SearchControl
|
<controls:SearchControl
|
||||||
x:Name="SearchControl"
|
x:Name="SearchControl"
|
||||||
HintText="Find a setting"
|
HintText="Find a setting (Ctrl+F)"
|
||||||
Margin="20,20,0,10"
|
Margin="20,20,0,10"
|
||||||
Text="{Binding SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
Text="{Binding SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
|||||||
|
|
||||||
public static TreeNode? AddNode(IList<TreeNode> nodes, string path)
|
public static TreeNode? AddNode(IList<TreeNode> nodes, string path)
|
||||||
{
|
{
|
||||||
string[] parts = path.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
|
string[] parts = path.Split('/', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
for (int x = 0; x < parts.Length; x++)
|
for (int x = 0; x < parts.Length; x++)
|
||||||
{
|
{
|
||||||
@@ -416,7 +416,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged
|
|||||||
if (e.Key == Key.Escape)
|
if (e.Key == Key.Escape)
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
if (e.Key == Key.F3 || e.Key == Key.F6 || (e.Key == Key.F && Keyboard.IsKeyDown(Key.LeftCtrl)))
|
if (e.Key == Key.F3 || e.Key == Key.F6 || (e.Key == Key.F && Keyboard.Modifiers == ModifierKeys.Control))
|
||||||
{
|
{
|
||||||
Keyboard.Focus(SearchControl.SearchTextBox);
|
Keyboard.Focus(SearchControl.SearchTextBox);
|
||||||
SearchControl.SearchTextBox.SelectAll();
|
SearchControl.SearchTextBox.SelectAll();
|
||||||
|
|||||||
@@ -46,15 +46,16 @@
|
|||||||
/>
|
/>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<ListView Name="MainListView"
|
<ListView
|
||||||
Grid.Row="1"
|
Name="MainListView"
|
||||||
Foreground="{Binding Theme.Foreground}"
|
Grid.Row="1"
|
||||||
Background="{Binding Theme.Background}"
|
Foreground="{Binding Theme.Foreground}"
|
||||||
BorderThickness="0"
|
Background="{Binding Theme.Background}"
|
||||||
MaxHeight="202"
|
BorderThickness="0"
|
||||||
SizeChanged="MainListView_SizeChanged"
|
MaxHeight="202"
|
||||||
MouseUp="MainListView_MouseUp"
|
SizeChanged="MainListView_SizeChanged"
|
||||||
>
|
MouseUp="MainListView_MouseUp"
|
||||||
|
>
|
||||||
|
|
||||||
<ListView.ItemContainerStyle>
|
<ListView.ItemContainerStyle>
|
||||||
<Style TargetType="ListBoxItem">
|
<Style TargetType="ListBoxItem">
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Name="HintTextBlock"
|
Name="HintTextBlock"
|
||||||
Padding="6,1"
|
Padding="6,1"
|
||||||
Text="Find a setting"
|
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Foreground="{Binding Theme.Foreground2}"
|
Foreground="{Binding Theme.Foreground2}"
|
||||||
Background="{Binding Theme.Background}"
|
Background="{Binding Theme.Background}"
|
||||||
@@ -31,6 +30,7 @@
|
|||||||
CaretBrush="{Binding Theme.Foreground}"
|
CaretBrush="{Binding Theme.Foreground}"
|
||||||
GotFocus="SearchTextBox_GotFocus"
|
GotFocus="SearchTextBox_GotFocus"
|
||||||
PreviewMouseUp="SearchTextBox_PreviewMouseUp"
|
PreviewMouseUp="SearchTextBox_PreviewMouseUp"
|
||||||
|
PreviewKeyDown="SearchTextBox_PreviewKeyDown"
|
||||||
Text="{Binding RelativeSource={RelativeSource FindAncestor,
|
Text="{Binding RelativeSource={RelativeSource FindAncestor,
|
||||||
AncestorType={x:Type controls:SearchControl}},
|
AncestorType={x:Type controls:SearchControl}},
|
||||||
Path=Text, UpdateSourceTrigger=PropertyChanged}"
|
Path=Text, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ public partial class SearchControl : UserControl
|
|||||||
|
|
||||||
void UpdateControls()
|
void UpdateControls()
|
||||||
{
|
{
|
||||||
HintTextBlock.Text = Text == "" ? HintText : "";
|
HintTextBlock.Text = string.IsNullOrEmpty(Text) ? HintText : "";
|
||||||
|
|
||||||
if (Text == "" || HideClearButton)
|
if (string.IsNullOrEmpty(Text) || HideClearButton)
|
||||||
SearchClearButton.Visibility = Visibility.Hidden;
|
SearchClearButton.Visibility = Visibility.Hidden;
|
||||||
else
|
else
|
||||||
SearchClearButton.Visibility = Visibility.Visible;
|
SearchClearButton.Visibility = Visibility.Visible;
|
||||||
@@ -69,4 +69,13 @@ public partial class SearchControl : UserControl
|
|||||||
_gotFocus = false;
|
_gotFocus = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Escape && !string.IsNullOrEmpty(Text))
|
||||||
|
{
|
||||||
|
Text = "";
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,59 +19,12 @@
|
|||||||
>
|
>
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<Style x:Key="DataGridFontCentering" TargetType="{x:Type DataGridCell}">
|
|
||||||
<Setter Property="Template">
|
|
||||||
<Setter.Value>
|
|
||||||
<ControlTemplate TargetType="{x:Type DataGridCell}">
|
|
||||||
<Grid Background="{TemplateBinding Background}">
|
|
||||||
<ContentPresenter VerticalAlignment="Center" />
|
|
||||||
</Grid>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style x:Key="HeaderStyle" TargetType="DataGridColumnHeader">
|
<Style x:Key="HeaderStyle" TargetType="DataGridColumnHeader">
|
||||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
||||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
|
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
|
||||||
<Setter Property="MinHeight" Value="22" />
|
<Setter Property="MinHeight" Value="22" />
|
||||||
<Setter Property="Cursor" Value="Hand" />
|
<Setter Property="Cursor" Value="Hand" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style TargetType="Button">
|
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
|
||||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
|
||||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
|
||||||
<Setter Property="Padding" Value="1"/>
|
|
||||||
<Setter Property="Template">
|
|
||||||
<Setter.Value>
|
|
||||||
<ControlTemplate TargetType="{x:Type Button}">
|
|
||||||
<Border x:Name="border"
|
|
||||||
BorderBrush="{DynamicResource PrimaryTextBrush}"
|
|
||||||
BorderThickness="0"
|
|
||||||
Background="{DynamicResource RegionBrush}">
|
|
||||||
|
|
||||||
<ContentPresenter
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
TextElement.FontWeight="Normal">
|
|
||||||
</ContentPresenter>
|
|
||||||
</Border>
|
|
||||||
<ControlTemplate.Triggers>
|
|
||||||
<Trigger Property="IsMouseOver" Value="True">
|
|
||||||
<Setter Property="Background" TargetName="border" Value="{DynamicResource HighlightBrush}"/>
|
|
||||||
</Trigger>
|
|
||||||
<Trigger Property="IsPressed" Value="True">
|
|
||||||
<Setter Property="BorderBrush" TargetName="border" Value="#2C628B"/>
|
|
||||||
</Trigger>
|
|
||||||
<Trigger Property="IsEnabled" Value="False">
|
|
||||||
<Setter Property="Opacity" TargetName="border" Value="0.25"/>
|
|
||||||
</Trigger>
|
|
||||||
</ControlTemplate.Triggers>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -81,7 +34,7 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<controls:SearchControl
|
<controls:SearchControl
|
||||||
HintText="Type ? to get help."
|
HintText="Find a binding (Ctrl+F)"
|
||||||
x:Name="SearchControl"
|
x:Name="SearchControl"
|
||||||
Width="300"
|
Width="300"
|
||||||
Margin="0,20,0,20"
|
Margin="0,20,0,20"
|
||||||
@@ -91,7 +44,6 @@
|
|||||||
<DataGrid
|
<DataGrid
|
||||||
Name="DataGrid"
|
Name="DataGrid"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
CommandManager.PreviewCanExecute="DataGrid_PreviewCanExecute"
|
|
||||||
AutoGenerateColumns="False"
|
AutoGenerateColumns="False"
|
||||||
ColumnHeaderStyle="{StaticResource HeaderStyle}"
|
ColumnHeaderStyle="{StaticResource HeaderStyle}"
|
||||||
Foreground="{Binding Theme.Foreground}"
|
Foreground="{Binding Theme.Foreground}"
|
||||||
@@ -99,29 +51,94 @@
|
|||||||
RowBackground="{Binding Theme.Background}"
|
RowBackground="{Binding Theme.Background}"
|
||||||
HorizontalGridLinesBrush="{Binding Theme.Foreground}"
|
HorizontalGridLinesBrush="{Binding Theme.Foreground}"
|
||||||
VerticalGridLinesBrush="{Binding Theme.Foreground}"
|
VerticalGridLinesBrush="{Binding Theme.Foreground}"
|
||||||
CellStyle="{StaticResource DataGridFontCentering}"
|
CanUserAddRows="False"
|
||||||
|
CanUserSortColumns="False"
|
||||||
|
SelectionUnit="Cell"
|
||||||
|
BeginningEdit="DataGrid_BeginningEdit"
|
||||||
|
SelectedCellsChanged="DataGrid_SelectedCellsChanged"
|
||||||
>
|
>
|
||||||
|
|
||||||
<DataGrid.Resources>
|
<DataGrid.Resources>
|
||||||
<Style BasedOn="{StaticResource {x:Type DataGridColumnHeader}}" TargetType="{x:Type DataGridColumnHeader}">
|
<Style BasedOn="{StaticResource {x:Type DataGridColumnHeader}}" TargetType="{x:Type DataGridColumnHeader}">
|
||||||
<Setter Property="Background" Value="{Binding DataContext.Theme.Background, ElementName=DataGrid}" />
|
<Setter Property="Background" Value="{Binding DataContext.Theme.Background, ElementName=DataGrid}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.MenuHighlightColor}"/>
|
||||||
</DataGrid.Resources>
|
</DataGrid.Resources>
|
||||||
|
|
||||||
|
<DataGrid.CellStyle>
|
||||||
|
<Style TargetType="DataGridCell" >
|
||||||
|
<Setter Property="Padding" Value="2" />
|
||||||
|
<Setter Property="BorderThickness" Value="0" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type DataGridCell}">
|
||||||
|
<Border
|
||||||
|
Padding="{TemplateBinding Padding}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
SnapsToDevicePixels="True"
|
||||||
|
>
|
||||||
|
<ContentPresenter
|
||||||
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||||
|
/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.CellStyle>
|
||||||
|
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Name" Binding="{Binding Path}" MaxWidth="325"/>
|
<DataGridTextColumn
|
||||||
|
Header="Name"
|
||||||
|
Binding="{Binding Path}"
|
||||||
|
MaxWidth="322"
|
||||||
|
/>
|
||||||
|
|
||||||
<DataGridTemplateColumn Header="Input">
|
<DataGridTextColumn
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
Header="Input"
|
||||||
<DataTemplate>
|
Binding="{Binding Input}"
|
||||||
<Button MinHeight="20" Click="ButtonClick">
|
>
|
||||||
<TextBlock Text="{Binding Input}"></TextBlock>
|
|
||||||
</Button>
|
|
||||||
</DataTemplate>
|
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
|
||||||
</DataGridTemplateColumn>
|
|
||||||
|
|
||||||
<DataGridTextColumn Header="Command" Binding="{Binding Command}" MaxWidth="325" />
|
<DataGridTextColumn.CellStyle>
|
||||||
|
<Style TargetType="DataGridCell">
|
||||||
|
<Setter Property="TextBlock.TextAlignment" Value="Center" />
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="Padding" Value="2" />
|
||||||
|
<EventSetter Event="PreviewKeyDown" Handler="DataGridCell_PreviewKeyDown"/>
|
||||||
|
<EventSetter Event="MouseLeftButtonUp" Handler="DataGridCell_MouseLeftButtonUp"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type DataGridCell}">
|
||||||
|
<Border
|
||||||
|
Padding="{TemplateBinding Padding}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
SnapsToDevicePixels="True"
|
||||||
|
>
|
||||||
|
<ContentPresenter
|
||||||
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||||
|
/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" Value="{Binding DataContext.Theme.MenuHighlight, ElementName=DataGrid}" />
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.CellStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
|
||||||
|
<DataGridTextColumn
|
||||||
|
Header="Command"
|
||||||
|
Binding="{Binding Command}"
|
||||||
|
MaxWidth="322"
|
||||||
|
/>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Windows;
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
using MpvNet.Windows.UI;
|
using MpvNet.Windows.UI;
|
||||||
|
|
||||||
namespace MpvNet.Windows.WPF;
|
namespace MpvNet.Windows.WPF;
|
||||||
@@ -14,6 +15,7 @@ public partial class InputWindow : Window
|
|||||||
string StartupContent;
|
string StartupContent;
|
||||||
public List<Binding> Bindings { get; }
|
public List<Binding> Bindings { get; }
|
||||||
public Theme? Theme => Theme.Current;
|
public Theme? Theme => Theme.Current;
|
||||||
|
Binding? _focusedBinding;
|
||||||
|
|
||||||
public InputWindow()
|
public InputWindow()
|
||||||
{
|
{
|
||||||
@@ -34,23 +36,6 @@ public partial class InputWindow : Window
|
|||||||
DataGrid.ItemsSource = CollectionView;
|
DataGrid.ItemsSource = CollectionView;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
|
||||||
{
|
|
||||||
CollectionView.Refresh();
|
|
||||||
|
|
||||||
if (SearchControl.SearchTextBox.Text == "?")
|
|
||||||
{
|
|
||||||
SearchControl.SearchTextBox.Text = "";
|
|
||||||
|
|
||||||
Msg.ShowInfo("Filtering" + BR2 +
|
|
||||||
"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.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Filter(Binding item)
|
bool Filter(Binding item)
|
||||||
{
|
{
|
||||||
if (item.Command == "")
|
if (item.Command == "")
|
||||||
@@ -86,18 +71,43 @@ public partial class InputWindow : Window
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonClick(object sender, RoutedEventArgs e)
|
void ShowLearnWindow(Binding? binding)
|
||||||
{
|
{
|
||||||
Binding? item = ((Button)e.Source).DataContext as Binding;
|
|
||||||
|
|
||||||
if (item == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
LearnWindow window = new LearnWindow();
|
LearnWindow window = new LearnWindow();
|
||||||
window.Owner = this;
|
window.Owner = this;
|
||||||
window.InputItem = item;
|
window.InputItem = binding;
|
||||||
window.ShowDialog();
|
window.ShowDialog();
|
||||||
Keyboard.Focus(SearchControl.SearchTextBox);
|
}
|
||||||
|
|
||||||
|
protected override void OnKeyDown(KeyEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnKeyDown(e);
|
||||||
|
|
||||||
|
if (e.Key == Key.Escape)
|
||||||
|
Close();
|
||||||
|
|
||||||
|
if (e.Key == Key.F3 || e.Key == Key.F6 || (e.Key == Key.F && Keyboard.Modifiers == ModifierKeys.Control))
|
||||||
|
{
|
||||||
|
Keyboard.Focus(SearchControl.SearchTextBox);
|
||||||
|
SearchControl.SearchTextBox.SelectAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
CollectionView.Refresh();
|
||||||
|
|
||||||
|
if (SearchControl.SearchTextBox.Text == "?")
|
||||||
|
{
|
||||||
|
SearchControl.SearchTextBox.Text = "";
|
||||||
|
|
||||||
|
Msg.ShowInfo("Filtering" + BR2 +
|
||||||
|
"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.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_Loaded(object sender, RoutedEventArgs e) => Keyboard.Focus(SearchControl.SearchTextBox);
|
void Window_Loaded(object sender, RoutedEventArgs e) => Keyboard.Focus(SearchControl.SearchTextBox);
|
||||||
@@ -120,26 +130,37 @@ public partial class InputWindow : Window
|
|||||||
Msg.ShowInfo("Changes will be available on next startup.");
|
Msg.ShowInfo("Changes will be available on next startup.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataGrid_PreviewCanExecute(object sender, CanExecuteRoutedEventArgs e)
|
void DataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
||||||
{
|
{
|
||||||
DataGrid grid = (DataGrid)sender;
|
if (e.Column.DisplayIndex == 1)
|
||||||
|
e.Cancel = true;
|
||||||
if (e.Command == DataGrid.DeleteCommand)
|
|
||||||
if (Msg.ShowQuestion($"Confirm to delete: {(grid.SelectedItem as Binding)!.Input} ({(grid.SelectedItem as Binding)!.Path})") != MessageBoxResult.OK)
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnKeyDown(KeyEventArgs e)
|
void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnKeyDown(e);
|
if (e.AddedCells.Count > 0)
|
||||||
|
_focusedBinding = e.AddedCells[0].Item as Binding;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.Key == Key.Escape)
|
void DataGridCell_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
Close();
|
{
|
||||||
|
if (e.Key == Key.Enter)
|
||||||
|
e.Handled = true;
|
||||||
|
|
||||||
if (e.Key == Key.F3 || e.Key == Key.F6 || (e.Key == Key.F && Keyboard.IsKeyDown(Key.LeftCtrl)))
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
Keyboard.Focus(SearchControl.SearchTextBox);
|
case Key.Left:
|
||||||
SearchControl.SearchTextBox.SelectAll();
|
case Key.Up:
|
||||||
|
case Key.Right:
|
||||||
|
case Key.Down:
|
||||||
|
case Key.Tab:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ShowLearnWindow(_focusedBinding);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataGridCell_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) =>
|
||||||
|
ShowLearnWindow(_focusedBinding);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
|
||||||
Title="Learn Input"
|
Title="Learn Input"
|
||||||
Height="150"
|
Height="200"
|
||||||
Width="350"
|
Width="400"
|
||||||
FontSize="16"
|
FontSize="15"
|
||||||
WindowStartupLocation="CenterOwner"
|
WindowStartupLocation="CenterOwner"
|
||||||
ResizeMode="NoResize"
|
ResizeMode="NoResize"
|
||||||
Loaded="Window_Loaded"
|
Loaded="Window_Loaded"
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
Background="{Binding 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"
|
||||||
>
|
>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -30,25 +30,27 @@
|
|||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="MenuTextBlock"
|
|
||||||
Margin="0,10,0,0"
|
Margin="0,10,0,0"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="3"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
/>
|
>Waiting for key/mouse input.</TextBlock>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="KeyTextBlock"
|
x:Name="KeyTextBlock"
|
||||||
|
FontSize="30"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="3"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button x:Name="ConfirmButton" Grid.Row="2" Margin="10,0,10,10" Click="ConfirmButton_Click">Confirm</Button>
|
<Button Name="ConfirmButton" Grid.Row="2" Margin="10,0,5,10" Click="ConfirmButton_Click">Confirm</Button>
|
||||||
<Button x:Name="ClearButton" Grid.Row="2" Margin="0,0,10,10" Click="ClearButton_Click" Grid.Column="1">Clear</Button>
|
<Button Name="ClearButton" Grid.Row="2" Margin="5,0,5,10" Click="ClearButton_Click" Grid.Column="1">Clear</Button>
|
||||||
|
<Button Name="CancelButton" Grid.Row="2" Margin="5,0,10,10" Click="CancelButton_Click" Grid.Column="2">Cancel</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -102,8 +102,11 @@ public partial class LearnWindow : Window
|
|||||||
bool firstEmpty = false;
|
bool firstEmpty = false;
|
||||||
Keys key = (Keys)vk;
|
Keys key = (Keys)vk;
|
||||||
|
|
||||||
if (key == Keys.ControlKey || key == Keys.ShiftKey ||
|
if (key == Keys.ControlKey ||
|
||||||
key == Keys.Menu || key == Keys.None)
|
key == Keys.ShiftKey ||
|
||||||
|
key == Keys.Menu ||
|
||||||
|
key == Keys.None ||
|
||||||
|
key == Keys.Tab)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -189,7 +192,6 @@ public partial class LearnWindow : Window
|
|||||||
void SetKey(string? key)
|
void SetKey(string? key)
|
||||||
{
|
{
|
||||||
NewKey = key!;
|
NewKey = key!;
|
||||||
MenuTextBlock.Text = InputItem?.Path;
|
|
||||||
KeyTextBlock.Text = key;
|
KeyTextBlock.Text = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,6 +231,8 @@ public partial class LearnWindow : Window
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CancelButton_Click(object sender, RoutedEventArgs e) => Close();
|
||||||
|
|
||||||
void Window_MouseWheel(object sender, MouseWheelEventArgs e)
|
void Window_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Delta > 0)
|
if (e.Delta > 0)
|
||||||
@@ -280,15 +284,6 @@ public partial class LearnWindow : Window
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Key == Key.Tab)
|
|
||||||
{
|
|
||||||
OnKeyDown((uint)Keys.Tab);
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string GetModifierText()
|
string GetModifierText()
|
||||||
{
|
{
|
||||||
string ret = "";
|
string ret = "";
|
||||||
|
|||||||
@@ -13,15 +13,17 @@
|
|||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="{x:Type Button}">
|
<ControlTemplate TargetType="{x:Type Button}">
|
||||||
<Border x:Name="border"
|
<Border
|
||||||
CornerRadius="3"
|
x:Name="border"
|
||||||
BorderBrush="{DynamicResource PrimaryTextBrush}"
|
CornerRadius="3"
|
||||||
BorderThickness="1"
|
BorderBrush="{DynamicResource PrimaryTextBrush}"
|
||||||
Background="{DynamicResource BorderBrush}">
|
BorderThickness="1"
|
||||||
|
Background="{DynamicResource BorderBrush}">
|
||||||
|
|
||||||
<ContentPresenter HorizontalAlignment="Center"
|
<ContentPresenter
|
||||||
VerticalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
TextElement.FontWeight="Normal">
|
VerticalAlignment="Center"
|
||||||
|
TextElement.FontWeight="Normal">
|
||||||
</ContentPresenter>
|
</ContentPresenter>
|
||||||
</Border>
|
</Border>
|
||||||
<ControlTemplate.Triggers>
|
<ControlTemplate.Triggers>
|
||||||
|
|||||||
@@ -735,6 +735,9 @@ public partial class MainForm : Form
|
|||||||
|
|
||||||
foreach (Binding binding in App.InputConf.GetMenuBindings())
|
foreach (Binding binding in App.InputConf.GetMenuBindings())
|
||||||
{
|
{
|
||||||
|
if (!binding.IsMenu)
|
||||||
|
continue;
|
||||||
|
|
||||||
Binding tempBinding = binding;
|
Binding tempBinding = binding;
|
||||||
|
|
||||||
var menuItem = MenuHelp.Add(ContextMenu?.Items, tempBinding.Path);
|
var menuItem = MenuHelp.Add(ContextMenu?.Items, tempBinding.Path);
|
||||||
@@ -1209,8 +1212,6 @@ public partial class MainForm : Form
|
|||||||
TaskHelp.Run(WinMpvHelp.CopyMpvNetCom);
|
TaskHelp.Run(WinMpvHelp.CopyMpvNetCom);
|
||||||
WasShown = true;
|
WasShown = true;
|
||||||
StrongReferenceMessenger.Default.Send(new MainWindowIsLoadedMessage());
|
StrongReferenceMessenger.Default.Send(new MainWindowIsLoadedMessage());
|
||||||
//Player.Command("script-message-to mpvnet show-conf-editor");
|
|
||||||
//testwin.ShowDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextMenu_Closed(object sender, System.Windows.RoutedEventArgs e) => MenuAutoResetEvent.Set();
|
void ContextMenu_Closed(object sender, System.Windows.RoutedEventArgs e) => MenuAutoResetEvent.Set();
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ public class Binding : ObservableObject
|
|||||||
|
|
||||||
public bool IsMenu { get; set; }
|
public bool IsMenu { get; set; }
|
||||||
|
|
||||||
|
string _input = "";
|
||||||
|
|
||||||
public Binding()
|
public Binding()
|
||||||
{
|
{
|
||||||
Path = ""; Command = ""; Comment = "";
|
Path = Command = Comment = Input = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Binding(string folder = "",
|
public Binding(string folder = "",
|
||||||
@@ -23,9 +25,15 @@ public class Binding : ObservableObject
|
|||||||
string comment = "")
|
string comment = "")
|
||||||
{
|
{
|
||||||
if (folder != "" && name != "")
|
if (folder != "" && name != "")
|
||||||
|
{
|
||||||
Path = folder + " > " + name;
|
Path = folder + " > " + name;
|
||||||
|
IsMenu = true;
|
||||||
|
}
|
||||||
else if (name != "")
|
else if (name != "")
|
||||||
|
{
|
||||||
Path = name;
|
Path = name;
|
||||||
|
IsMenu = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Path = "";
|
Path = "";
|
||||||
|
|
||||||
@@ -34,11 +42,11 @@ public class Binding : ObservableObject
|
|||||||
Comment = comment == "" ? Path : comment;
|
Comment = comment == "" ? Path : comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
string _input = "";
|
|
||||||
|
|
||||||
public string Input
|
public string Input
|
||||||
{
|
{
|
||||||
get => _input;
|
get => _input;
|
||||||
set => SetProperty(ref _input, value);
|
set => SetProperty(ref _input, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsEmpty() => Path == "" && Command == "" && Comment == "" && Input == "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,20 +195,35 @@ public static class InputHelp
|
|||||||
|
|
||||||
foreach (Binding binding in bindings)
|
foreach (Binding binding in bindings)
|
||||||
{
|
{
|
||||||
string cmd = binding.Command.Trim();
|
if (binding.IsEmpty())
|
||||||
|
{
|
||||||
|
sb.AppendLine();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (binding.Comment != "" &&
|
||||||
|
binding.Command == "" &&
|
||||||
|
binding.Input == "" &&
|
||||||
|
binding.Path == "")
|
||||||
|
{
|
||||||
|
sb.AppendLine("#" + binding.Comment.Trim());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
string command = binding.Command.Trim();
|
||||||
string input = binding.Input.Trim();
|
string input = binding.Input.Trim();
|
||||||
string comment = binding.IsMenu ? "menu: " + binding.Path : binding.Comment.Trim();
|
string comment = binding.IsMenu ? "menu: " + binding.Path : binding.Path.Trim();
|
||||||
input = input == "" ? "_" : input;
|
input = input == "" ? "_" : input;
|
||||||
string line = input.PadRight(10) + " ";
|
string line = input.PadRight(10) + " ";
|
||||||
line += cmd == "" ? "ignore" : cmd;
|
line += command == "" ? "ignore" : command;
|
||||||
|
|
||||||
if (comment != "")
|
if (comment != "")
|
||||||
line = line.PadRight(40) + " # " + comment;
|
line = line.PadRight(40) + " #" + comment;
|
||||||
|
|
||||||
sb.AppendLine(line);
|
sb.AppendLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString().TrimEnd() + BR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Binding> Parse(string content)
|
public static List<Binding> Parse(string content)
|
||||||
@@ -218,14 +233,25 @@ public static class InputHelp
|
|||||||
if (string.IsNullOrEmpty(content))
|
if (string.IsNullOrEmpty(content))
|
||||||
return bindings;
|
return bindings;
|
||||||
|
|
||||||
foreach (string it in content.Split('\r', '\n'))
|
foreach (string it in content.Split('\n'))
|
||||||
{
|
{
|
||||||
string line = it.Trim();
|
string line = it.Trim();
|
||||||
|
|
||||||
if (line.StartsWith("#") || !line.Contains(' '))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Binding binding = new Binding();
|
Binding binding = new Binding();
|
||||||
|
|
||||||
|
if (line == "")
|
||||||
|
{
|
||||||
|
bindings.Add(binding);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.StartsWith("#"))
|
||||||
|
{
|
||||||
|
binding.Comment = line[1..].Trim();
|
||||||
|
bindings.Add(binding);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
binding.Input = line[..line.IndexOf(" ")];
|
binding.Input = line[..line.IndexOf(" ")];
|
||||||
|
|
||||||
if (binding.Input == "_")
|
if (binding.Input == "_")
|
||||||
@@ -260,7 +286,7 @@ public static class InputHelp
|
|||||||
}
|
}
|
||||||
else if (line.Contains('#'))
|
else if (line.Contains('#'))
|
||||||
{
|
{
|
||||||
binding.Comment = line[(line.IndexOf("#") + 1)..].Trim();
|
binding.Path = line[(line.IndexOf("#") + 1)..].Trim();
|
||||||
line = line[..line.IndexOf("#")];
|
line = line[..line.IndexOf("#")];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,6 +351,7 @@ public static class InputHelp
|
|||||||
return defaults;
|
return defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only used by dead command palette
|
||||||
public static List<Binding> GetBindingsFromContent(string content)
|
public static List<Binding> GetBindingsFromContent(string content)
|
||||||
{
|
{
|
||||||
var bindings = new List<Binding>();
|
var bindings = new List<Binding>();
|
||||||
|
|||||||
Reference in New Issue
Block a user