built-in WM_APPCOMMAND support

This commit is contained in:
Frank Skare
2020-05-08 08:26:44 +02:00
parent 726d759589
commit 5b3697fbde
21 changed files with 232 additions and 295 deletions

View File

@@ -2,7 +2,9 @@
5.4.7.2 Beta (not yet released) 5.4.7.2 Beta (not yet released)
============ ============
- WM_APPCOMMAND (mpv calls this media-keys) based input is no longer
directly passed to mpv but rather handled in mpv.net translating
the commands to mpv keys and sent via keypress input command to mpv
5.4.7.1 Beta 5.4.7.1 Beta

View File

@@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DynamicGUI" xmlns:local="clr-namespace:DynamicGUI"
xmlns:UI="clr-namespace:UI" xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignHeight="450"
@@ -17,8 +17,8 @@
Margin="0,10" Margin="0,10"
BorderThickness="0" BorderThickness="0"
IsReadOnly="True" IsReadOnly="True"
Foreground="{x:Static UI:Theme.Heading}" Foreground="{x:Static mpvnet:Theme.Heading}"
Background="{x:Static UI:Theme.Background}" /> Background="{x:Static mpvnet:Theme.Background}" />
<ItemsControl x:Name="ItemsControl"> <ItemsControl x:Name="ItemsControl">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
@@ -32,7 +32,7 @@
FontSize="16" FontSize="16"
FontWeight="Normal" FontWeight="Normal"
VerticalAlignment="Top" VerticalAlignment="Top"
Foreground="{x:Static UI:Theme.Foreground}"/> Foreground="{x:Static mpvnet:Theme.Foreground}"/>
<TextBox x:Name="ItemHelpTextBox" <TextBox x:Name="ItemHelpTextBox"
TextWrapping="WrapWithOverflow" TextWrapping="WrapWithOverflow"
@@ -41,8 +41,8 @@
Margin="10,0,0,0" BorderThickness="0" Margin="10,0,0,0" BorderThickness="0"
IsReadOnly="True" Padding="7,0,0,0" IsReadOnly="True" Padding="7,0,0,0"
MinHeight="0" MinHeight="0"
Foreground="{x:Static UI:Theme.Foreground2}" Foreground="{x:Static mpvnet:Theme.Foreground2}"
Background="{x:Static UI:Theme.Background}"/> Background="{x:Static mpvnet:Theme.Background}"/>
</WrapPanel> </WrapPanel>
</DataTemplate> </DataTemplate>
@@ -54,8 +54,8 @@
BorderThickness="0" BorderThickness="0"
IsReadOnly="True" IsReadOnly="True"
Margin="0,10,0,0" Margin="0,10,0,0"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"/> Background="{x:Static mpvnet:Theme.Background}"/>
<TextBlock x:Name="LinkTextBlock" Margin="0,10"> <TextBlock x:Name="LinkTextBlock" Margin="0,10">
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx> <local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
</TextBlock> </TextBlock>

View File

@@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DynamicGUI" xmlns:local="clr-namespace:DynamicGUI"
xmlns:UI="clr-namespace:UI" xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800"> d:DesignWidth="800">
@@ -16,8 +16,8 @@
Margin="0,10" Margin="0,10"
BorderThickness="0" BorderThickness="0"
IsReadOnly="True" IsReadOnly="True"
Foreground="{x:Static UI:Theme.Heading}" Foreground="{x:Static mpvnet:Theme.Heading}"
Background="{x:Static UI:Theme.Background}"/> Background="{x:Static mpvnet:Theme.Background}"/>
<Grid Margin="0,0,0,10"> <Grid Margin="0,0,0,10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@@ -29,9 +29,9 @@
Width="150" Width="150"
Height="20" Height="20"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}" Background="{x:Static mpvnet:Theme.Background}"
CaretBrush="{x:Static UI:Theme.Foreground}" CaretBrush="{x:Static mpvnet:Theme.Foreground}"
TextChanged="ValueTextBox_TextChanged"/> TextChanged="ValueTextBox_TextChanged"/>
<Button x:Name="Button" <Button x:Name="Button"
@@ -47,8 +47,8 @@
TextWrapping="WrapWithOverflow" TextWrapping="WrapWithOverflow"
BorderThickness="0" BorderThickness="0"
IsReadOnly="True" IsReadOnly="True"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"/> Background="{x:Static mpvnet:Theme.Background}"/>
<TextBlock x:Name="LinkTextBlock" Margin="0,10"> <TextBlock x:Name="LinkTextBlock" Margin="0,10">
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx> <local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>

View File

@@ -4,14 +4,10 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using UI;
using static libmpv;
using static mpvnet.Core;
using System.Threading.Tasks; using System.Threading.Tasks;
using static mpvnet.Core;
namespace mpvnet namespace mpvnet
{ {
public static class App public static class App

View File

@@ -1,9 +1,13 @@
 
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
public static class ConsoleHelp namespace mpvnet
{ {
public static class ConsoleHelp
{
public static int Padding { get; set; } public static int Padding { get; set; }
public static void WriteError(object obj, string module = "mpv.net") public static void WriteError(object obj, string module = "mpv.net")
@@ -45,4 +49,66 @@ public static class ConsoleHelp
Console.ResetColor(); Console.ResetColor();
Trace.WriteLine(obj); Trace.WriteLine(obj);
} }
}
public class CursorHelp
{
static bool IsVisible = true;
public static void Show()
{
if (!IsVisible)
{
Cursor.Show();
IsVisible = true;
}
}
public static void Hide()
{
if (IsVisible)
{
Cursor.Hide();
IsVisible = false;
}
}
public static bool IsPosDifferent(Point screenPos)
{
return
Math.Abs(screenPos.X - Control.MousePosition.X) > 10 ||
Math.Abs(screenPos.Y - Control.MousePosition.Y) > 10;
}
}
public class mpvHelp
{
public static string WM_APPCOMMAND_to_mpv_key(int value)
{
switch (value)
{
case 51: return "CHANNEL_UP"; // MEDIA_CHANNEL_UP
case 52: return "CHANNEL_DOWN"; // MEDIA_CHANNEL_DOWN
case 49: return "FORWARD"; // MEDIA_FAST_FORWARD
case 50: return "REWIND"; // MEDIA_REWIND
case 46: return "PLAY"; // MEDIA_PLAY
case 14: return "PLAYPAUSE"; // MEDIA_PLAY_PAUSE
case 47: return "PAUSE"; // MEDIA_PAUSE
case 11: return "NEXT"; // MEDIA_NEXTTRACK
case 12: return "PREV"; // MEDIA_PREVIOUSTRACK
case 13: return "STOP"; // MEDIA_STOP
case 48: return "RECORD"; // MEDIA_RECORD
case 1: return "VOLUME_UP"; // VOLUME_UP
case 9: return "VOLUME_DOWN"; // VOLUME_DOWN
case 8: return "MUTE"; // VOLUME_MUTE
case 7: return "HOMEPAGE"; // BROWSER_HOME
case 15: return "MAIL"; // LAUNCH_MAIL
case 6: return "FAVORITES"; // BROWSER_FAVORITES
case 5: return "SEARCH"; // BROWSER_SEARCH
case 33: return "PRINT"; // PRINT
}
return null;
}
}
} }

View File

@@ -195,36 +195,6 @@ namespace mpvnet
} }
} }
public class CursorHelp
{
static bool IsVisible = true;
public static void Show()
{
if (!IsVisible)
{
Cursor.Show();
IsVisible = true;
}
}
public static void Hide()
{
if (IsVisible)
{
Cursor.Hide();
IsVisible = false;
}
}
public static bool IsPosDifferent(Point screenPos)
{
return
Math.Abs(screenPos.X - Control.MousePosition.X) > 10 ||
Math.Abs(screenPos.Y - Control.MousePosition.Y) > 10;
}
}
public class Folder public class Folder
{ {
public static string Startup { get; } = Application.StartupPath + @"\"; public static string Startup { get; } = Application.StartupPath + @"\";

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Media; using System.Windows.Media;
namespace UI namespace mpvnet
{ {
public class Theme public class Theme
{ {

View File

@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:UI="clr-namespace:UI" xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="About mpv.net" Title="About mpv.net"
@@ -13,8 +13,8 @@
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
ResizeMode="NoResize" ResizeMode="NoResize"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"> Background="{x:Static mpvnet:Theme.Background}">
<Grid> <Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">

View File

@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:UI="clr-namespace:UI" xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="Command Palette" Title="Command Palette"
@@ -21,15 +21,15 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBox Name="FilterTextBox" <TextBox Name="FilterTextBox"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}" Background="{x:Static mpvnet:Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown" PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"/> TextChanged="FilterTextBox_TextChanged"/>
<ListView Name="ListView" <ListView Name="ListView"
Grid.Row="1" Grid.Row="1"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}" Background="{x:Static mpvnet:Theme.Background}"
MouseUp="ListView_MouseUp"> MouseUp="ListView_MouseUp">
<ListView.ItemContainerStyle> <ListView.ItemContainerStyle>

View File

@@ -3,14 +3,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:UI="clr-namespace:UI" xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="Config Editor" Title="Config Editor"
Height="530" Height="530"
Width="700" Width="700"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}" Background="{x:Static mpvnet:Theme.Background}"
ShowInTaskbar="False" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Loaded="ConfWindow1_Loaded"> Loaded="ConfWindow1_Loaded">
@@ -47,8 +47,8 @@
ItemsSource="{Binding FilterStrings}" ItemsSource="{Binding FilterStrings}"
BorderThickness="0" BorderThickness="0"
SelectionChanged="FilterListBox_SelectionChanged" SelectionChanged="FilterListBox_SelectionChanged"
Foreground="{x:Static UI:Theme.Heading}" Foreground="{x:Static mpvnet:Theme.Heading}"
Background="{x:Static UI:Theme.Background}"> Background="{x:Static mpvnet:Theme.Background}">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
@@ -57,10 +57,10 @@
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<TextBlock Name="OpenSettingsTextBlock" Margin="0,30,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static UI:Theme.Heading}" MouseUp="OpenSettingsTextBlock_MouseUp">Open config folder</TextBlock> <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 UI:Theme.Heading}" MouseUp="PreviewTextBlock_MouseUp">Preview mpv.conf</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 UI:Theme.Heading}" MouseUp="ShowManualTextBlock_MouseUp">Show mpv manual</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 UI:Theme.Heading}" MouseUp="SupportTextBlock_MouseUp">Show support forum</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>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Window> </Window>

View File

@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:UI="clr-namespace:UI" xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="Media File Search" Title="Media File Search"
@@ -21,14 +21,14 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBox Name="FilterTextBox" <TextBox Name="FilterTextBox"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}" Background="{x:Static mpvnet:Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown" PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"/> TextChanged="FilterTextBox_TextChanged"/>
<ListView Name="ListView" <ListView Name="ListView"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}" Background="{x:Static mpvnet:Theme.Background}"
Grid.Row="1" Grid.Row="1"
MouseUp="ListView_MouseUp" MouseUp="ListView_MouseUp"
PreviewKeyDown="ListView_PreviewKeyDown"> PreviewKeyDown="ListView_PreviewKeyDown">

View File

@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:UI="clr-namespace:UI" xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="Input Editor" Title="Input Editor"
@@ -11,8 +11,8 @@
Width="750" Width="750"
FontSize="13" FontSize="13"
ShowInTaskbar="False" ShowInTaskbar="False"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}" Background="{x:Static mpvnet:Theme.Background}"
Loaded="Window_Loaded" Loaded="Window_Loaded"
Closed="Window_Closed"> Closed="Window_Closed">

View File

@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:UI="clr-namespace:UI" xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="Learn Input" Title="Learn Input"
@@ -12,8 +12,8 @@
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
ResizeMode="NoResize" ResizeMode="NoResize"
Loaded="Window_Loaded" Loaded="Window_Loaded"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}" Background="{x:Static mpvnet:Theme.Background}"
MouseWheel="Window_MouseWheel" MouseWheel="Window_MouseWheel"
MouseUp="Window_MouseUp" MouseUp="Window_MouseUp"
MouseDoubleClick="Window_MouseDoubleClick" MouseDoubleClick="Window_MouseDoubleClick"

View File

@@ -1,12 +1,12 @@
 
using System; using System;
using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Interop; using System.Windows.Interop;
using WinForms = System.Windows.Forms; using WinForms = System.Windows.Forms;
using static mpvnet.Core;
namespace mpvnet namespace mpvnet
{ {
@@ -64,9 +64,9 @@ namespace mpvnet
case WinForms.Keys.NumPad9: case WinForms.Keys.NumPad9:
text = "KP" + e.KeyCode.ToString()[6]; break; text = "KP" + e.KeyCode.ToString()[6]; break;
case WinForms.Keys.Space: case WinForms.Keys.Space:
text = "Space"; break; text = "SPACE"; break;
case WinForms.Keys.Enter: case WinForms.Keys.Enter:
text = "Enter"; break; text = "ENTER"; break;
case WinForms.Keys.Tab: case WinForms.Keys.Tab:
text = "TAB"; break; text = "TAB"; break;
case WinForms.Keys.Back: case WinForms.Keys.Back:
@@ -76,7 +76,7 @@ namespace mpvnet
case WinForms.Keys.Insert: case WinForms.Keys.Insert:
text = "INS"; break; text = "INS"; break;
case WinForms.Keys.Home: case WinForms.Keys.Home:
text = "Home"; break; text = "HOME"; break;
case WinForms.Keys.End: case WinForms.Keys.End:
text = "END"; break; text = "END"; break;
case WinForms.Keys.PageUp: case WinForms.Keys.PageUp:
@@ -86,37 +86,37 @@ namespace mpvnet
case WinForms.Keys.Escape: case WinForms.Keys.Escape:
text = "ESC"; break; text = "ESC"; break;
case WinForms.Keys.PrintScreen: case WinForms.Keys.PrintScreen:
text = "Print"; break; text = "PRINT"; break;
case WinForms.Keys.Play: case WinForms.Keys.Play:
text = "Play"; break; text = "PLAY"; break;
case WinForms.Keys.Pause: case WinForms.Keys.Pause:
text = "Pause"; break; text = "PAUSE"; break;
case WinForms.Keys.MediaPlayPause: case WinForms.Keys.MediaPlayPause:
text = "PlayPause"; break; text = "PLAYPAUSE"; break;
case WinForms.Keys.MediaStop: case WinForms.Keys.MediaStop:
text = "Stop"; break; text = "STOP"; break;
case WinForms.Keys.MediaNextTrack: case WinForms.Keys.MediaNextTrack:
text = "Next"; break; text = "NEXT"; break;
case WinForms.Keys.MediaPreviousTrack: case WinForms.Keys.MediaPreviousTrack:
text = "Prev"; break; text = "PREV"; break;
case WinForms.Keys.VolumeUp:
text = "Volume_Up"; break;
case WinForms.Keys.VolumeDown:
text = "Volume_Down"; break;
case WinForms.Keys.VolumeMute: case WinForms.Keys.VolumeMute:
text = "Mute"; break; text = "MUTE"; break;
case WinForms.Keys.BrowserHome: case WinForms.Keys.BrowserHome:
text = "Homepage"; break; text = "HOMEPAGE"; break;
case WinForms.Keys.LaunchMail: case WinForms.Keys.LaunchMail:
text = "Mail"; break; text = "MAIL"; break;
case WinForms.Keys.BrowserFavorites: case WinForms.Keys.BrowserFavorites:
text = "Favorites"; break; text = "FAVORITES"; break;
case WinForms.Keys.BrowserSearch: case WinForms.Keys.BrowserSearch:
text = "Search"; break; text = "SEARCH"; break;
case WinForms.Keys.Sleep: case WinForms.Keys.Sleep:
text = "Sleep"; break; text = "SLEEP"; break;
case WinForms.Keys.Cancel: case WinForms.Keys.Cancel:
text = "Cancel"; break; text = "CANCEL"; break;
case WinForms.Keys.VolumeUp:
text = ""; break;
case WinForms.Keys.VolumeDown:
text = ""; break;
} }
bool wasModified = false; bool wasModified = false;
@@ -131,7 +131,8 @@ namespace mpvnet
wasModified = true; wasModified = true;
} }
if (text == "#") text = "SHARP"; if (text == "#")
text = "SHARP";
if (isAlt && !wasModified) if (isAlt && !wasModified)
text = "ALT+" + text; text = "ALT+" + text;
@@ -146,14 +147,11 @@ namespace mpvnet
SetKey(text); SetKey(text);
} }
DateTime LastKeyUp;
void SetKey(string key) void SetKey(string key)
{ {
NewKey = key; NewKey = key;
MenuTextBlock.Text = InputItem.Path; MenuTextBlock.Text = InputItem.Path;
KeyTextBlock.Text = key; KeyTextBlock.Text = key;
LastKeyUp = DateTime.Now;
} }
[DllImport("user32.dll")] [DllImport("user32.dll")]
@@ -184,143 +182,16 @@ namespace mpvnet
OnKeyUp(new WinForms.KeyEventArgs((WinForms.Keys)(unchecked((int)(long)m.WParam)) | ModifierKeys)); OnKeyUp(new WinForms.KeyEventArgs((WinForms.Keys)(unchecked((int)(long)m.WParam)) | ModifierKeys));
else if (m.Msg == WM_APPCOMMAND) else if (m.Msg == WM_APPCOMMAND)
{ {
if (!core.get_property_bool("input-media-keys")) string value = mpvHelp.WM_APPCOMMAND_to_mpv_key((int)(m.LParam.ToInt64() >> 16 & ~0xf000));
return;
var value = (AppCommand)(m.LParam.ToInt64() >> 16 & ~0xf000); if (value != null)
SetKey(value);
switch (value)
{
case AppCommand.APPCOMMAND_MEDIA_CHANNEL_DOWN:
SetKey("CHANNEL_DOWN");
break;
case AppCommand.APPCOMMAND_MEDIA_CHANNEL_UP:
SetKey("CHANNEL_UP");
break;
case AppCommand.APPCOMMAND_MEDIA_FAST_FORWARD:
SetKey("FORWARD");
break;
case AppCommand.APPCOMMAND_MEDIA_REWIND:
SetKey("REWIND");
break;
case AppCommand.APPCOMMAND_MEDIA_PAUSE:
SetKey("PAUSE");
break;
case AppCommand.APPCOMMAND_MEDIA_PLAY:
SetKey("PLAY");
break;
case AppCommand.APPCOMMAND_MEDIA_PLAY_PAUSE:
SetKey("PLAYPAUSE");
break;
case AppCommand.APPCOMMAND_MEDIA_NEXTTRACK:
SetKey("NEXT");
break;
case AppCommand.APPCOMMAND_MEDIA_PREVIOUSTRACK:
SetKey("PREV");
break;
case AppCommand.APPCOMMAND_MEDIA_RECORD:
SetKey("RECORD");
break;
case AppCommand.APPCOMMAND_MEDIA_STOP:
SetKey("STOP");
break;
case AppCommand.APPCOMMAND_VOLUME_UP:
SetKey("VOLUME_UP");
break;
case AppCommand.APPCOMMAND_VOLUME_DOWN:
SetKey("VOLUME_DOWN");
break;
case AppCommand.APPCOMMAND_VOLUME_MUTE:
SetKey("MUTE");
break;
case AppCommand.APPCOMMAND_BROWSER_HOME:
SetKey("HOMEPAGE");
break;
case AppCommand.APPCOMMAND_LAUNCH_MAIL:
SetKey("MAIL");
break;
case AppCommand.APPCOMMAND_BROWSER_FAVORITES:
SetKey("FAVORITES");
break;
case AppCommand.APPCOMMAND_BROWSER_SEARCH:
SetKey("SEARCH");
break;
case AppCommand.APPCOMMAND_PRINT:
SetKey("PRINT");
break;
} }
} }
}
internal enum AppCommand
{
APPCOMMAND_BASS_BOOST = 20,
APPCOMMAND_BASS_DOWN = 19,
APPCOMMAND_BASS_UP = 21,
APPCOMMAND_BROWSER_BACKWARD = 1,
APPCOMMAND_BROWSER_FAVORITES = 6,
APPCOMMAND_BROWSER_FORWARD = 2,
APPCOMMAND_BROWSER_HOME = 7,
APPCOMMAND_BROWSER_REFRESH = 3,
APPCOMMAND_BROWSER_SEARCH = 5,
APPCOMMAND_BROWSER_STOP = 4,
APPCOMMAND_CLOSE = 31,
APPCOMMAND_COPY = 36,
APPCOMMAND_CORRECTION_LIST = 45,
APPCOMMAND_CUT = 37,
APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE = 43,
APPCOMMAND_FIND = 28,
APPCOMMAND_FORWARD_MAIL = 40,
APPCOMMAND_HELP = 27,
APPCOMMAND_LAUNCH_APP1 = 17,
APPCOMMAND_LAUNCH_APP2 = 18,
APPCOMMAND_LAUNCH_MAIL = 15,
APPCOMMAND_LAUNCH_MEDIA_SELECT = 16,
APPCOMMAND_MEDIA_CHANNEL_DOWN = 52,
APPCOMMAND_MEDIA_CHANNEL_UP = 51,
APPCOMMAND_MEDIA_FAST_FORWARD = 49,
APPCOMMAND_MEDIA_NEXTTRACK = 11,
APPCOMMAND_MEDIA_PAUSE = 47,
APPCOMMAND_MEDIA_PLAY = 46,
APPCOMMAND_MEDIA_PLAY_PAUSE = 14,
APPCOMMAND_MEDIA_PREVIOUSTRACK = 12,
APPCOMMAND_MEDIA_RECORD = 48,
APPCOMMAND_MEDIA_REWIND = 50,
APPCOMMAND_MEDIA_STOP = 13,
APPCOMMAND_MIC_ON_OFF_TOGGLE = 44,
APPCOMMAND_MICROPHONE_VOLUME_DOWN = 25,
APPCOMMAND_MICROPHONE_VOLUME_MUTE = 24,
APPCOMMAND_MICROPHONE_VOLUME_UP = 26,
APPCOMMAND_NEW = 29,
APPCOMMAND_OPEN = 30,
APPCOMMAND_PASTE = 38,
APPCOMMAND_PRINT = 33,
APPCOMMAND_REDO = 35,
APPCOMMAND_REPLY_TO_MAIL = 39,
APPCOMMAND_SAVE = 32,
APPCOMMAND_SEND_MAIL = 41,
APPCOMMAND_SPELL_CHECK = 42,
APPCOMMAND_TREBLE_DOWN = 22,
APPCOMMAND_TREBLE_UP = 23,
APPCOMMAND_UNDO = 34,
APPCOMMAND_VOLUME_DOWN = 9,
APPCOMMAND_VOLUME_MUTE = 8,
APPCOMMAND_VOLUME_UP = 10
}
[DllImport("user32.dll", CharSet = CharSet.Auto)] [DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern short GetKeyState(int keyCode); public static extern short GetKeyState(int keyCode);
[DllImport("user32.dll")]
static extern short VkKeyScan(char c);
[DllImport("user32.dll", SetLastError = true)]
static extern int ToAscii(uint uVirtKey,
uint uScanCode,
byte[] lpKeyState,
out uint lpChar,
uint flags);
void Window_Loaded(object sender, RoutedEventArgs e) void Window_Loaded(object sender, RoutedEventArgs e)
{ {
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);

View File

@@ -1,6 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:UI="clr-namespace:UI"> xmlns:mpvnet="clr-namespace:mpvnet">
<Style TargetType="TextBox"> <Style TargetType="TextBox">
<Setter Property="Template"> <Setter Property="Template">
@@ -26,7 +26,7 @@
<Setter Property="BorderBrush" TargetName="border" Value="#FF7EB4EA"/> <Setter Property="BorderBrush" TargetName="border" Value="#FF7EB4EA"/>
</Trigger> </Trigger>
<Trigger Property="IsFocused" Value="true"> <Trigger Property="IsFocused" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{x:Static UI:Theme.Heading}"/> <Setter Property="BorderBrush" TargetName="border" Value="{x:Static mpvnet:Theme.Heading}"/>
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
@@ -49,8 +49,8 @@
x:Name="normal" x:Name="normal"
Width="18" Width="18"
Height="18" Height="18"
Fill="{x:Static UI:Theme.Background}" Fill="{x:Static mpvnet:Theme.Background}"
Stroke="{x:Static UI:Theme.Heading}" Stroke="{x:Static mpvnet:Theme.Heading}"
StrokeThickness="2" /> StrokeThickness="2" />
<Ellipse <Ellipse
x:Name="Checked1" x:Name="Checked1"

View File

@@ -3,20 +3,20 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:UI="clr-namespace:UI" xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignHeight="450"
d:DesignWidth="800"> d:DesignWidth="800">
<Grid Name="SearchTextBoxUserControl1" <Grid Name="SearchTextBoxUserControl1"
Background="{x:Static UI:Theme.Background}"> Background="{x:Static mpvnet:Theme.Background}">
<TextBlock Name="HintTextBlock" <TextBlock Name="HintTextBlock"
Margin="5,2" Margin="5,2"
Text="Find a setting" Text="Find a setting"
VerticalAlignment="Center" VerticalAlignment="Center"
Foreground="{x:Static UI:Theme.Foreground2}" Foreground="{x:Static mpvnet:Theme.Foreground2}"
Background="{x:Static UI:Theme.Background}" /> Background="{x:Static mpvnet:Theme.Background}" />
<TextBox Name="SearchTextBox" <TextBox Name="SearchTextBox"
Height="25" Height="25"
@@ -24,8 +24,8 @@
BorderThickness="2" BorderThickness="2"
Background="Transparent" Background="Transparent"
TextChanged="SearchTextBox_TextChanged" TextChanged="SearchTextBox_TextChanged"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
CaretBrush="{x:Static UI:Theme.Foreground}" /> CaretBrush="{x:Static mpvnet:Theme.Foreground}" />
<Button Name="SearchClearButton" <Button Name="SearchClearButton"
Background="Transparent" Background="Transparent"
@@ -40,8 +40,8 @@
<Button.Style> <Button.Style>
<Style TargetType="Button"> <Style TargetType="Button">
<Setter Property="Background" Value="{x:Static UI:Theme.Background}"/> <Setter Property="Background" Value="{x:Static mpvnet:Theme.Background}"/>
<Setter Property="Foreground" Value="{x:Static UI:Theme.Foreground2}"/> <Setter Property="Foreground" Value="{x:Static mpvnet:Theme.Foreground2}"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
@@ -58,7 +58,7 @@
<Style.Triggers> <Style.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{x:Static UI:Theme.Heading}"/> <Setter Property="Foreground" Value="{x:Static mpvnet:Theme.Heading}"/>
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>

View File

@@ -3,13 +3,13 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:UI="clr-namespace:UI" xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d" mc:Ignorable="d"
Title="mpv.net Setup" Title="mpv.net Setup"
FontSize="13" FontSize="13"
Foreground="{x:Static UI:Theme.Foreground}" Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}" Background="{x:Static mpvnet:Theme.Background}"
SizeToContent="WidthAndHeight" SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner" > WindowStartupLocation="CenterOwner" >

View File

@@ -11,7 +11,6 @@ using System.Globalization;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using UI;
using static mpvnet.Core; using static mpvnet.Core;
namespace mpvnet namespace mpvnet
@@ -24,6 +23,7 @@ namespace mpvnet
Point LastCursorPosition; Point LastCursorPosition;
int LastCursorChanged; int LastCursorChanged;
int LastCycleFullscreen; int LastCycleFullscreen;
int LastAppCommand;
int TaskbarButtonCreatedMessage; int TaskbarButtonCreatedMessage;
int ShownTickCount; int ShownTickCount;
@@ -517,12 +517,28 @@ namespace mpvnet
case 0x101: // WM_KEYUP case 0x101: // WM_KEYUP
case 0x104: // WM_SYSKEYDOWN case 0x104: // WM_SYSKEYDOWN
case 0x105: // WM_SYSKEYUP case 0x105: // WM_SYSKEYUP
case 0x319: // WM_APPCOMMAND {
if (core.WindowHandle != IntPtr.Zero) bool skip = m.Msg == 0x100 && LastAppCommand != 0 &&
m.Result = WinAPI.SendMessage(core.WindowHandle, m.Msg, m.WParam, m.LParam); (Environment.TickCount - LastAppCommand) < 1000;
if (m.Msg == 0x319) // WM_APPCOMMAND if (core.WindowHandle != IntPtr.Zero && !skip)
m.Result = WinAPI.SendMessage(core.WindowHandle, m.Msg, m.WParam, m.LParam);
}
break;
case 0x319: // WM_APPCOMMAND
{
string value = mpvHelp.WM_APPCOMMAND_to_mpv_key((int)(m.LParam.ToInt64() >> 16 & ~0xf000));
if (value != null)
{
core.command("keypress " + value);
m.Result = new IntPtr(1);
LastAppCommand = Environment.TickCount;
return; return;
}
}
break; break;
case 0x0200: // WM_MOUSEMOVE case 0x0200: // WM_MOUSEMOVE
if (Environment.TickCount - LastCycleFullscreen > 500) if (Environment.TickCount - LastCycleFullscreen > 500)

View File

@@ -164,7 +164,7 @@
<DependentUpon>MainForm.cs</DependentUpon> <DependentUpon>MainForm.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Misc\Misc.cs" /> <Compile Include="Misc\Misc.cs" />
<Compile Include="mpv\Core.cs" /> <Compile Include="mpv\core.cs" />
<Compile Include="Misc\Commands.cs" /> <Compile Include="Misc\Commands.cs" />
<Compile Include="Native\Native.cs" /> <Compile Include="Native\Native.cs" />
<Compile Include="Native\NativeHelp.cs" /> <Compile Include="Native\NativeHelp.cs" />

View File

@@ -149,9 +149,11 @@ namespace mpvnet
public void ProcessProperty(string name, string value) public void ProcessProperty(string name, string value)
{ {
if (name.Any(char.IsUpper)) foreach (char i in name)
if (char.IsUpper(i))
Msg.ShowError("Uppercase char detected: " + name, Msg.ShowError("Uppercase char detected: " + name,
"mpv properties using the command line and the mpv.conf config file are required to be lowercase."); "mpv properties using the command line and the mpv.conf " +
"config file are required to be lowercase.");
switch (name) switch (name)
{ {

View File

@@ -0,0 +1,14 @@
# Shows the current file in File Explorer
# In input.conf add: <key> script-message show-in-file-explorer
$code = {
if ($args[0] -eq 'show-in-file-explorer')
{
# probably works only with shell execute for which powershell has no built-in support
[Diagnostics.Process]::Start('explorer.exe', '/n, /select, "' + $mp.get_property_string('path') + '"')
}
}
$mp.register_event("client-message", $code)