Compare commits

...

12 Commits

Author SHA1 Message Date
Frank Skare
7d31237d5f fix release script 2020-05-11 17:14:23 +02:00
Frank Skare
3705e2abbf 5.4.8.0 2020-05-11 17:08:01 +02:00
Frank Skare
7d73529c83 fix beep sound when closed from taskbar 2020-05-11 12:16:40 +02:00
Frank Skare
2e59d49ad1 2 bugs fixed 2020-05-11 03:51:52 +02:00
Frank Skare
f61eef8961 5.4.7.4 Beta 2020-05-10 07:01:59 +02:00
Frank Skare
efb4c085d5 fix release script 2020-05-08 15:56:54 +02:00
Frank Skare
4a045d6a91 setting media-keys added 2020-05-08 15:32:47 +02:00
Frank Skare
da1a78cfa3 5.4.7.2 Beta 2020-05-08 09:22:19 +02:00
Frank Skare
5b3697fbde built-in WM_APPCOMMAND support 2020-05-08 08:26:44 +02:00
Frank Skare
726d759589 misc 2020-05-07 13:32:23 +02:00
Frank Skare
ed614332f7 misc 2020-05-07 13:21:59 +02:00
Frank Skare
9d46064dca 5.4.7.1 Beta 2020-05-07 11:47:09 +02:00
30 changed files with 478 additions and 542 deletions

View File

@@ -1,10 +1,48 @@
5.4.7.1 Beta (not yet released)
5.4.8.1 Beta (not yet released)
============
5.4.8.0
=======
- fix learn window of input editor (much work)
- fix black one pixel bar on right side
- fix beep sound when closed from taskbar
5.4.7.4 Beta (not yet released)
============
- the media key issue should now be fixed!
- libmpv and youtube-dl update
5.4.7.3 Beta
============
- new setting media-keys added, can be found in the config editor in the input tab.
5.4.7.2 Beta
============
- another attempt to fix a app command issue. WM_APPCOMMAND (mpv calls this media keys)
based input is no longer directly passed to mpv but rather handled in mpv.net directly
translating the native commands to mpv keys and sent via keypress input command to mpv
- another attempt to fix a crash caused by powershell 5.1 not being installed
5.4.7.1 Beta
============
- log error fix, mpv.net does now ignore all log messages because libmpv already
prints the log messages to the the terminal
- the release script now also outputs x86 beta versions so x86 users can test betas
5.4.7.0
=======

View File

@@ -166,7 +166,9 @@ After the file associations were registered, go to the Windows settings under 'S
It's possible to change the default application using the 'Open with' feature of the context menu in File Explorer.
[Open with++](#open-with) can be used to extend the File Explorer context menu to get menu items for 'Play with mpv.net' and 'Add to mpv.net playlist'.
[Open with++](#open-with) can be used to extend the File Explorer context menu to get menu items for [Play with mpv.net](https://github.com/stax76/OpenWithPlusPlus#play-with-mpvnet) and [Add to mpv.net playlist](https://github.com/stax76/OpenWithPlusPlus#add-to-mpvnet-playlist).
When multiple files are selected in File Explorer and enter is pressed then the files are opened in mpv.net in random order, this works with maximum 15 files.
Support
@@ -272,30 +274,7 @@ Alternatively he Chrome/Firefox extension [Open With](https://github.com/stax76/
### Open with++
Open with++ allows to customize the File Explorer context menu to add menu items 'Play with mpv.net' and 'Add to mpv.net playlist'.
https://github.com/stax76/OpenWithPlusPlus
https://github.com/stax76/OpenWithPlusPlus#mpvnet
https://github.com/stax76/OpenWithPlusPlus#add-to-mpvnet-playlist
### MediaInfo.NET
MediaInfo.NET is a media info GUI.
https://github.com/stax76/MediaInfo.NET
To start a external application mpv has the run input command (it does not use shell execute).
If the path has spaces then it must be enclosed in quotes and then double backslashes must be used for escaping or alternatively forward slashes.
`_ run D:\Software\MediaInfoNET.exe "${path}" #menu: Tools > Open file with MediaInfo.NET`
`_ run "D:\\Soft ware\\MediaInfoNET.exe" "${path}" #menu: Tools > Open file with MediaInfo.NET`
`_ run "D:/Soft ware/MediaInfoNET.exe" "${path}" #menu: Tools > Open file with MediaInfo.NET`
[Open with++](https://github.com/stax76/OpenWithPlusPlus) can be used to extend the File Explorer context menu to get menu items for [Play with mpv.net](https://github.com/stax76/OpenWithPlusPlus#play-with-mpvnet) and [Add to mpv.net playlist](https://github.com/stax76/OpenWithPlusPlus#add-to-mpvnet-playlist).
Scripting
@@ -442,7 +421,7 @@ Selecting multiple files in File Explorer and pressing enter will open the files
Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist. This works in all mpv.net features that open files or URLs.
Pressing the shift key while opening a single file will suppress loading all files in the folder.
Pressing the shift key while opening a single file will suppress loading all files of the folder into the playlist.
In fullscreen mode clicking the top right corner closes the player.
@@ -538,9 +517,7 @@ input.conf defines mpvs key and mouse bindings and mpv.net uses comments to defi
The Open Files menu entry is one way to open files in mpv.net, it supports multi selection.
Another way to open files is the command line, it is used by the File Explorer if file associations exist.
When mpv.net is started from a terminal, mpv.net outputs status and debug messages on the terminal.
Another way to open files is the command line which is used by File Explorer for existing associations.
A third way is to drag and drop files on the main window.

View File

@@ -1,39 +1,6 @@
$ErrorActionPreference = 'Stop'
$include = @(
'*.cs',
'*.csproj',
'*.iss',
'*.js',
'*.lua',
'*.ps1',
'*.resx',
'*.sln',
'*.txt',
'*.xaml'
)
$files = Get-ChildItem -Path $PSScriptRoot -Recurse -File -Include $include
foreach ($file in $files)
{
$lines = Get-Content $file
foreach ($line in $lines)
{
foreach ($char in $line.ToCharArray())
{
$codePoint = [int]$char
if ($codePoint -gt 127)
{
throw "Non ASCII char $char in file '$($file.FullName)' in line: $line"
}
}
}
}
$desktopDir = [Environment]::GetFolderPath('Desktop')
$exePath = $PSScriptRoot + '\mpv.net\bin\x64\mpvnet.exe'
$versionInfo = [Diagnostics.FileVersionInfo]::GetVersionInfo($exePath)
@@ -42,6 +9,29 @@ $msBuild = $vsDir + '\Community\MSBuild\Current\Bin\MSBuild.exe'
$inno = 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe'
$7z = 'C:\Program Files\7-Zip\7z.exe'
$cloudDirectories = 'C:\Users\frank\OneDrive\Public\mpv.net\',
'C:\Users\frank\Dropbox\Public\mpv.net\'
function UploadBeta($sourceFile)
{
foreach ($cloudDirectory in $cloudDirectories)
{
if (-not (Test-Path $cloudDirectory))
{
throw $cloudDirectory
}
$targetFile = $cloudDirectory + (Split-Path $sourceFile -Leaf)
if (Test-Path $targetFile)
{
throw $targetFile
}
Copy-Item $sourceFile $targetFile
}
}
if ($versionInfo.FilePrivatePart -eq 0)
{
& $msBuild mpv.net.sln -t:Rebuild -p:Configuration=Debug -p:Platform=x64
@@ -58,56 +48,50 @@ if ($versionInfo.FilePrivatePart -eq 0)
$targetDir = $desktopDir + "\mpv.net-portable-x64-$($versionInfo.FileVersion)"
Copy-Item .\mpv.net\bin\x64 $targetDir -Recurse -Exclude System.Management.Automation.xml
& $7z a -t7z -mx9 "$targetDir.7z" -r "$targetDir\*"
if ($LastExitCode) { throw $LastExitCode }
& $7z a -tzip -mx9 "$targetDir.zip" -r "$targetDir\*"
if ($LastExitCode) { throw $LastExitCode }
$targetDir = $desktopDir + "\mpv.net-portable-x86-$($versionInfo.FileVersion)"
Copy-Item .\mpv.net\bin\x86 $targetDir -Recurse -Exclude System.Management.Automation.xml
& $7z a -t7z -mx9 "$targetDir.7z" -r "$targetDir\*"
if ($LastExitCode) { throw $LastExitCode }
& $7z a -tzip -mx9 "$targetDir.zip" -r "$targetDir\*"
if ($LastExitCode) { throw $LastExitCode }
Set-Clipboard ($versionInfo.FileVersion + "`n`nChangelog:`n`n" +
'https://github.com/stax76/mpv.net/blob/master/Changelog.md' + "`n`nDownload:`n`n" +
'https://github.com/stax76/mpv.net/blob/master/Manual.md#stable')
}
else
{
& $msBuild mpv.net.sln -t:Rebuild -p:Configuration=Debug -p:Platform=x64
if ($LastExitCode) { throw $LastExitCode }
& $msBuild mpv.net.sln -t:Rebuild -p:Configuration=Debug -p:Platform=x86
if ($LastExitCode) { throw $LastExitCode }
$targetDir = "$desktopDir\mpv.net-portable-x64-$($versionInfo.FileVersion)-beta"
Copy-Item .\mpv.net\bin\x64 $targetDir -Recurse -Exclude System.Management.Automation.xml
& $7z a -t7z -mx9 "$targetDir.7z" -r "$targetDir\*"
if ($LastExitCode) { throw $LastExitCode }
UploadBeta "$targetDir.7z"
$cloudDirectories = 'C:\Users\frank\OneDrive\Public\mpv.net\',
'C:\Users\frank\Dropbox\Public\mpv.net\'
$targetDir = $desktopDir + "\mpv.net-portable-x86-$($versionInfo.FileVersion)-beta"
Copy-Item .\mpv.net\bin\x86 $targetDir -Recurse -Exclude System.Management.Automation.xml
& $7z a -t7z -mx9 "$targetDir.7z" -r "$targetDir\*"
if ($LastExitCode) { throw $LastExitCode }
UploadBeta "$targetDir.7z"
foreach ($cloudDirectory in $cloudDirectories)
{
if (-not (Test-Path $cloudDirectory))
{
throw $cloudDirectory
}
$targetFile = $cloudDirectory + (Split-Path $targetDir -Leaf) + '.7z'
if (Test-Path $targetFile)
{
throw $targetFile
}
Copy-Item ($targetDir + '.7z') $targetFile
Invoke-Item $cloudDirectory
}
Set-Clipboard ($versionInfo.FileVersion + " Beta`n`nChangelog:`n`n" +
'https://github.com/stax76/mpv.net/blob/master/Changelog.md' + "`n`nDownload:`n`n" +
'https://github.com/stax76/mpv.net/blob/master/Manual.md#beta')
}
Set-Clipboard ($versionInfo.FileVersion + "`n`n" +
'https://github.com/stax76/mpv.net/blob/master/Changelog.md' + "`n`n" +
'https://github.com/stax76/mpv.net#download')
Write-Host 'successfully finished' -ForegroundColor Green

View File

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

View File

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

View File

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

View File

@@ -1,48 +1,111 @@

using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
public static class ConsoleHelp
namespace mpvnet
{
public static int Padding { get; set; }
public static void WriteError(object obj, string module = "mpv.net")
public static class ConsoleHelp
{
Write(obj, module, ConsoleColor.Red, false);
}
public static int Padding { get; set; }
public static void Write(object obj, string module = "mpv.net")
{
Write(obj, module, ConsoleColor.Black, true);
}
public static void WriteError(object obj, string module = "mpv.net")
{
Write(obj, module, ConsoleColor.Red, false);
}
public static void Write(object obj, string module, ConsoleColor color)
{
Write(obj, module, color, false);
}
public static void Write(object obj, string module = "mpv.net")
{
Write(obj, module, ConsoleColor.Black, true);
}
public static void Write(object obj, string module, ConsoleColor color, bool useDefaultColor)
{
if (obj == null)
return;
public static void Write(object obj, string module, ConsoleColor color)
{
Write(obj, module, color, false);
}
string value = obj.ToString();
public static void Write(object obj, string module, ConsoleColor color, bool useDefaultColor)
{
if (obj == null)
return;
if (!string.IsNullOrEmpty(module))
module = "[" + module + "] ";
string value = obj.ToString();
if (useDefaultColor)
if (!string.IsNullOrEmpty(module))
module = "[" + module + "] ";
if (useDefaultColor)
Console.ResetColor();
else
Console.ForegroundColor = color;
value = module + value;
if (Padding > 0 && value.Length < Padding)
value = value.PadRight(Padding);
Console.WriteLine(value);
Console.ResetColor();
else
Console.ForegroundColor = color;
Trace.WriteLine(obj);
}
}
value = module + value;
public class CursorHelp
{
static bool IsVisible = true;
if (Padding > 0 && value.Length < Padding)
value = value.PadRight(Padding);
public static void Show()
{
if (!IsVisible)
{
Cursor.Show();
IsVisible = true;
}
}
Console.WriteLine(value);
Console.ResetColor();
Trace.WriteLine(obj);
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 5: return "SEARCH"; // BROWSER_SEARCH
case 6: return "FAVORITES"; // BROWSER_FAVORITES
case 7: return "HOMEPAGE"; // BROWSER_HOME
case 15: return "MAIL"; // LAUNCH_MAIL
case 33: return "PRINT"; // PRINT
case 11: return "NEXT"; // MEDIA_NEXTTRACK
case 12: return "PREV"; // MEDIA_PREVIOUSTRACK
case 13: return "STOP"; // MEDIA_STOP
case 14: return "PLAYPAUSE"; // MEDIA_PLAY_PAUSE
case 46: return "PLAY"; // MEDIA_PLAY
case 47: return "PAUSE"; // MEDIA_PAUSE
case 48: return "RECORD"; // MEDIA_RECORD
case 49: return "FORWARD"; // MEDIA_FAST_FORWARD
case 50: return "REWIND"; // MEDIA_REWIND
case 51: return "CHANNEL_UP"; // MEDIA_CHANNEL_UP
case 52: return "CHANNEL_DOWN"; // MEDIA_CHANNEL_DOWN
}
return null;
}
}
}

View File

@@ -1,10 +1,8 @@

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
@@ -195,36 +193,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 static string Startup { get; } = Application.StartupPath + @"\";

View File

@@ -233,12 +233,6 @@ namespace mpvnet
var error = sender as PSDataCollection<ErrorRecord>;
ConsoleHelp.WriteError(error[e.Index], Module);
}
public static void Shutdown()
{
foreach (PowerShell ps in Instances)
ps.Runspace.Dispose();
}
}
public class PowerShellException : Exception

View File

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

View File

@@ -1,4 +1,5 @@
using System;

using System;
namespace mpvnet
{
@@ -35,4 +36,4 @@ namespace mpvnet
WinAPI.AdjustWindowRect(ref rc, (uint)WinAPI.GetWindowLong(hwnd, -16 /* GWL_STYLE */), false);
}
}
}
}

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.7.0")]
[assembly: AssemblyFileVersion("5.4.7.0")]
[assembly: AssemblyVersion("5.4.8.0")]
[assembly: AssemblyFileVersion("5.4.8.0")]

View File

@@ -314,7 +314,7 @@ options = [{ name = "yes" },
name = "autofit"
file = "mpv"
filter = "Screen"
help = "<int> Initial window height in percent. Default: 50"
help = "<int> Initial window height in percent. Default: 60"
[[settings]]
name = "autofit-smaller"
@@ -348,7 +348,7 @@ help = "Threshold in milliseconds to wait for libmpv returning the video resolut
name = "minimum-aspect-ratio"
file = "mpvnet"
filter = "Screen"
help = "<float> Minimum aspect ratio for the window. Default: 1.2 (mpv.net specific setting)"
help = "<float> Minimum aspect ratio, if the AR is smaller than the defined value then the window AR is set to 16/9. This avoids a square window for Music with cover art. Default: 1.2 (mpv.net specific setting)"
[[settings]]
name = "remember-position"

View File

@@ -1,22 +1,31 @@
# This file defines the key and mouse bindings and the context menu
# of mpv.net. A input and config editor can be found in mpv.nets
# context menu under 'Settings'. The defaults of this file can be found at:
# https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt
# The defaults of mpv can be found at:
# https://github.com/mpv-player/mpv/blob/master/etc/input.conf
# mpv.net's defaults of mpv.conf contain: 'input-default-bindings = no'
# which disables mpv's input defaults. Every line in this file begins with a
# This file defines the key and mouse bindings and the context menu of mpv.net.
# A convenient input and config editor can be found in the context menu of mpv.net
# under 'Settings'.
# The mpv.conf defaults of mpv.net contain: 'input-default-bindings = no'
# which disables the input defaults of mpv. Every line in this file begins with a
# space character to make it easier to do a text search, so if you want to know
# if 'o' has already a binding you can do a text search on ' o '.
# mpv input commands: https://mpv.io/manual/master/#list-of-input-commands
# input test mode:
# mpvnet --input-test
# run mpv.net in input test mode with: mpvnet --input-test
# input key list:
# mpv --input-keylist
# mpv.net input.conf defaults:
# https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt
# mpv input.conf defaults:
# https://github.com/mpv-player/mpv/blob/master/etc/input.conf
# mpv input commands:
# https://mpv.io/manual/master/#list-of-input-commands
# mpv input options:
# https://mpv.io/manual/master/#input
o script-message mpv.net open-files #menu: Open > Open Files...
u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard
@@ -180,9 +189,6 @@
Stop stop
Forward seek 60
Rewind seek -60
Mute cycle mute
Volume_Up add volume 10
Volume_Down add volume -10
Wheel_Up add volume 10
Wheel_Down add volume -10
Wheel_Left add volume -10

View File

@@ -3,7 +3,7 @@
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:UI="clr-namespace:UI"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="About mpv.net"
@@ -13,8 +13,8 @@
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
Foreground="{x:Static UI:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}">
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}">
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">

View File

@@ -3,7 +3,7 @@
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:UI="clr-namespace:UI"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="Command Palette"
@@ -21,15 +21,15 @@
</Grid.RowDefinitions>
<TextBox Name="FilterTextBox"
Foreground="{x:Static UI:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"/>
<ListView Name="ListView"
Grid.Row="1"
Foreground="{x:Static UI:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
MouseUp="ListView_MouseUp">
<ListView.ItemContainerStyle>

View File

@@ -3,14 +3,14 @@
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:UI="clr-namespace:UI"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="Config Editor"
Height="530"
Width="700"
Foreground="{x:Static UI:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"
Loaded="ConfWindow1_Loaded">
@@ -47,8 +47,8 @@
ItemsSource="{Binding FilterStrings}"
BorderThickness="0"
SelectionChanged="FilterListBox_SelectionChanged"
Foreground="{x:Static UI:Theme.Heading}"
Background="{x:Static UI:Theme.Background}">
Foreground="{x:Static mpvnet:Theme.Heading}"
Background="{x:Static mpvnet:Theme.Background}">
<ListBox.ItemTemplate>
<DataTemplate>
@@ -57,10 +57,10 @@
</ListBox.ItemTemplate>
</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="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="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="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="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>
</StackPanel>
</Grid>
</Window>

View File

@@ -3,7 +3,7 @@
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:UI="clr-namespace:UI"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="Media File Search"
@@ -21,14 +21,14 @@
</Grid.RowDefinitions>
<TextBox Name="FilterTextBox"
Foreground="{x:Static UI:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
PreviewKeyDown="FilterTextBox_PreviewKeyDown"
TextChanged="FilterTextBox_TextChanged"/>
<ListView Name="ListView"
Foreground="{x:Static UI:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
Grid.Row="1"
MouseUp="ListView_MouseUp"
PreviewKeyDown="ListView_PreviewKeyDown">

View File

@@ -161,4 +161,4 @@ namespace mpvnet
}
}
}
}
}

View File

@@ -3,7 +3,7 @@
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:UI="clr-namespace:UI"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="Input Editor"
@@ -11,8 +11,8 @@
Width="750"
FontSize="13"
ShowInTaskbar="False"
Foreground="{x:Static UI:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
Loaded="Window_Loaded"
Closed="Window_Closed">

View File

@@ -3,7 +3,7 @@
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:UI="clr-namespace:UI"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="Learn Input"
@@ -12,12 +12,11 @@
WindowStartupLocation="CenterOwner"
ResizeMode="NoResize"
Loaded="Window_Loaded"
Foreground="{x:Static UI:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
MouseWheel="Window_MouseWheel"
MouseUp="Window_MouseUp"
MouseDoubleClick="Window_MouseDoubleClick"
TextInput="Window_TextInput">
MouseDoubleClick="Window_MouseDoubleClick" PreviewKeyDown="Window_PreviewKeyDown">
<Grid>
<Grid.RowDefinitions>

View File

@@ -1,12 +1,12 @@

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using WinForms = System.Windows.Forms;
using static mpvnet.Core;
using System.Windows.Forms;
namespace mpvnet
{
@@ -14,13 +14,68 @@ namespace mpvnet
{
public CommandItem InputItem { get; set; }
string NewKey = "";
string KeyChar = "";
uint MAPVK_VK_TO_VSC = 0;
int VK_MENU = 0x12;
int VK_LMENU = 0xA4;
int VK_RMENU = 0xA5;
int VK_CONTROL = 0x11;
int VK_LCONTROL = 0xA2;
int VK_RCONTROL = 0xA3;
public LearnWindow() => InitializeComponent();
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern short GetKeyState(int keyCode);
[DllImport("user32.dll")]
static extern uint MapVirtualKey(uint uCode, uint uMapType);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
static extern int ToUnicode(uint wVirtKey, uint wScanCode, byte[] lpKeyState,
StringBuilder pwszBuff, int cchBuff, uint wFlags);
[DllImport("user32.dll")]
static extern bool GetKeyboardState(byte[] lpKeyState);
string ToUnicode(uint vk)
{
byte[] keys = new byte[256];
if (!GetKeyboardState(keys))
return "";
if ((keys[VK_CONTROL] & 0x80) != 0 && (keys[VK_MENU] & 0x80) == 0)
keys[VK_LCONTROL] = keys[VK_RCONTROL] = keys[VK_CONTROL] = 0;
uint scanCode = MapVirtualKey(vk, MAPVK_VK_TO_VSC);
string ret = ToUnicode(vk, scanCode, keys);
if (ret.Length == 1 && (int)ret[0] < 32)
return "";
if (ret == "" && (keys[VK_MENU] & 0x80) != 0)
{
keys[VK_LMENU] = keys[VK_RMENU] = keys[VK_MENU] = 0;
ret = ToUnicode(vk, scanCode, keys);
}
return ret;
}
public string ToUnicode(uint vk, uint scanCode, byte[] keys)
{
StringBuilder sb = new StringBuilder(10);
ToUnicode(vk, scanCode, keys, sb, sb.Capacity, 0);
return sb.ToString();
}
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
WinForms.Message m = new WinForms.Message();
Message m = new Message();
m.HWnd = hwnd;
m.Msg = msg;
m.WParam = wParam;
@@ -29,298 +84,116 @@ namespace mpvnet
return m.Result;
}
void OnKeyUp(WinForms.KeyEventArgs e)
void OnKeyDown(uint vk)
{
if (e.KeyCode == WinForms.Keys.ControlKey || e.KeyCode == WinForms.Keys.ShiftKey ||
e.KeyCode == WinForms.Keys.Menu || e.KeyCode == WinForms.Keys.None)
Keys key = (Keys)vk;
if (key == Keys.ControlKey || key == Keys.ShiftKey ||
key == Keys.Menu || key == Keys.None)
return;
string text = "";
uint charValue = MapVirtualKey((uint)e.KeyCode, 2);
string text = ToUnicode(vk);
if (charValue == 0 || (charValue & 1 << 31) == 1 << 31)
text = e.KeyCode.ToString().Trim();
else
try {
text = Convert.ToChar(charValue).ToString().ToLower().Trim();
} catch {}
if ((int)key > 111 && (int)key < 136)
text = "F" + ((int)key - 111);
for (int i = 0; i < 13; i++)
if ("D" + i == text)
text = text.Substring(1);
if ((int)key > 95 && (int)key < 106)
text = "KP" + ((int)key - 96);
switch (e.KeyCode)
switch (text)
{
case WinForms.Keys.NumPad0:
case WinForms.Keys.NumPad1:
case WinForms.Keys.NumPad2:
case WinForms.Keys.NumPad3:
case WinForms.Keys.NumPad4:
case WinForms.Keys.NumPad5:
case WinForms.Keys.NumPad6:
case WinForms.Keys.NumPad7:
case WinForms.Keys.NumPad8:
case WinForms.Keys.NumPad9:
text = "KP" + e.KeyCode.ToString()[6]; break;
case WinForms.Keys.Space:
text = "Space"; break;
case WinForms.Keys.Enter:
text = "Enter"; break;
case WinForms.Keys.Tab:
text = "TAB"; break;
case WinForms.Keys.Back:
text = "BS"; break;
case WinForms.Keys.Delete:
text = "DEL"; break;
case WinForms.Keys.Insert:
text = "INS"; break;
case WinForms.Keys.Home:
text = "Home"; break;
case WinForms.Keys.End:
text = "END"; break;
case WinForms.Keys.PageUp:
text = "PGUP"; break;
case WinForms.Keys.PageDown:
text = "PGDWN"; break;
case WinForms.Keys.Escape:
text = "ESC"; break;
case WinForms.Keys.PrintScreen:
text = "Print"; break;
case WinForms.Keys.Play:
text = "Play"; break;
case WinForms.Keys.Pause:
text = "Pause"; break;
case WinForms.Keys.MediaPlayPause:
text = "PlayPause"; break;
case WinForms.Keys.MediaStop:
text = "Stop"; break;
case WinForms.Keys.MediaNextTrack:
text = "Next"; break;
case WinForms.Keys.MediaPreviousTrack:
text = "Prev"; break;
case WinForms.Keys.VolumeUp:
text = "Volume_Up"; break;
case WinForms.Keys.VolumeDown:
text = "Volume_Down"; break;
case WinForms.Keys.VolumeMute:
text = "Mute"; break;
case WinForms.Keys.BrowserHome:
text = "Homepage"; break;
case WinForms.Keys.LaunchMail:
text = "Mail"; break;
case WinForms.Keys.BrowserFavorites:
text = "Favorites"; break;
case WinForms.Keys.BrowserSearch:
text = "Search"; break;
case WinForms.Keys.Sleep:
text = "Sleep"; break;
case WinForms.Keys.Cancel:
text = "Cancel"; break;
case "#": text = "SHARP"; break;
case "´´": text = "´"; break;
case "``": text = "`"; break;
case "^^": text = "^"; break;
}
bool wasModified = false;
bool isAlt = GetKeyState(18) < (short)0;
bool isShift = GetKeyState(16) < (short)0;
bool isCtrl = GetKeyState(17) < (short)0;
if (text.Length == 1 && KeyChar != text)
switch (key)
{
text = KeyChar;
wasModified = true;
case Keys.Left: text = "LEFT"; break;
case Keys.Up: text = "UP"; break;
case Keys.Right: text = "RIGHT"; break;
case Keys.Down: text = "DOWN"; break;
case Keys.Space: text = "SPACE"; break;
case Keys.Enter: text = "ENTER"; break;
case Keys.Tab: text = "TAB"; break;
case Keys.Back: text = "BS"; break;
case Keys.Delete: text = "DEL"; break;
case Keys.Insert: text = "INS"; break;
case Keys.Home: text = "HOME"; break;
case Keys.End: text = "END"; break;
case Keys.PageUp: text = "PGUP"; break;
case Keys.PageDown: text = "PGDWN"; break;
case Keys.Escape: text = "ESC"; break;
case Keys.Sleep: text = "SLEEP"; break;
case Keys.Cancel: text = "CANCEL"; break;
case Keys.PrintScreen: text = "PRINT"; break;
case Keys.BrowserFavorites: text = "FAVORITES"; break;
case Keys.BrowserSearch: text = "SEARCH"; break;
case Keys.BrowserHome: text = "HOMEPAGE"; break;
case Keys.LaunchMail: text = "MAIL"; break;
case Keys.Play: text = "PLAY"; break;
case Keys.Pause: text = "PAUSE"; break;
case Keys.MediaPlayPause: text = "PLAYPAUSE"; break;
case Keys.MediaStop: text = "STOP"; break;
case Keys.MediaNextTrack: text = "NEXT"; break;
case Keys.MediaPreviousTrack: text = "PREV"; break;
case Keys.VolumeUp:
case Keys.VolumeDown:
case Keys.VolumeMute:
text = ""; break;
}
if (text == "#") text = "SHARP";
bool isAlt = GetKeyState(18) < 0;
bool isShift = GetKeyState(16) < 0;
bool isCtrl = GetKeyState(17) < 0;
if (isAlt && !wasModified)
bool isLetter = (int)key > 64 && (int)key < 91;
if (isLetter && isShift)
text = text.ToUpper();
string keyString = ToUnicode(vk);
if (isAlt && !isCtrl)
text = "ALT+" + text;
if (isShift && !wasModified)
if (isShift && keyString == "")
text = "SHIFT+" + text;
if (isCtrl && !wasModified)
if (isCtrl && !(keyString != "" && isCtrl && isAlt))
text = "CTRL+" + text;
if (!string.IsNullOrEmpty(text))
SetKey(text);
}
DateTime LastKeyUp;
void SetKey(string key)
{
NewKey = key;
MenuTextBlock.Text = InputItem.Path;
KeyTextBlock.Text = key;
LastKeyUp = DateTime.Now;
}
[DllImport("user32.dll")]
static extern uint MapVirtualKey(uint uCode, uint uMapType);
public static WinForms.Keys ModifierKeys {
get {
WinForms.Keys keys = WinForms.Keys.None;
if (GetKeyState(17) < (short)0)
keys |= WinForms.Keys.Control;
if (GetKeyState(16) < (short)0)
keys |= WinForms.Keys.Shift;
if (GetKeyState(18) < (short)0)
keys |= WinForms.Keys.Alt;
return keys;
}
}
void ProcessKeyEventArgs(ref WinForms.Message m)
void ProcessKeyEventArgs(ref Message m)
{
int WM_KEYUP = 0x0101, WM_SYSKEYUP = 0x0105, WM_APPCOMMAND = 0x0319;
int WM_KEYDOWN = 0x100;
int WM_SYSKEYDOWN = 0x104;
int WM_APPCOMMAND = 0x319;
if (m.Msg == WM_KEYUP || m.Msg == WM_SYSKEYUP)
OnKeyUp(new WinForms.KeyEventArgs((WinForms.Keys)(unchecked((int)(long)m.WParam)) | ModifierKeys));
if (m.Msg == WM_KEYDOWN || m.Msg == WM_SYSKEYDOWN)
OnKeyDown((uint)m.WParam.ToInt64());
else if (m.Msg == WM_APPCOMMAND)
{
if (!core.get_property_bool("input-media-keys"))
return;
string value = mpvHelp.WM_APPCOMMAND_to_mpv_key((int)(m.LParam.ToInt64() >> 16 & ~0xf000));
var value = (AppCommand)(m.LParam.ToInt64() >> 16 & ~0xf000);
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;
}
if (value != null)
SetKey(value);
}
}
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)]
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)
{
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
@@ -381,9 +254,13 @@ namespace mpvnet
}
}
void Window_TextInput(object sender, TextCompositionEventArgs e)
void Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
KeyChar = e.Text;
if (e.Key == Key.Tab)
{
OnKeyDown((uint)Keys.Tab);
e.Handled = true;
}
}
}
}

View File

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

View File

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

View File

@@ -3,13 +3,13 @@
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:UI="clr-namespace:UI"
xmlns:mpvnet="clr-namespace:mpvnet"
mc:Ignorable="d"
Title="mpv.net Setup"
FontSize="13"
Foreground="{x:Static UI:Theme.Foreground}"
Background="{x:Static UI:Theme.Background}"
Foreground="{x:Static mpvnet:Theme.Foreground}"
Background="{x:Static mpvnet:Theme.Background}"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner" >

View File

@@ -11,7 +11,6 @@ using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;
using UI;
using static mpvnet.Core;
namespace mpvnet
@@ -24,6 +23,7 @@ namespace mpvnet
Point LastCursorPosition;
int LastCursorChanged;
int LastCycleFullscreen;
int LastAppCommand;
int TaskbarButtonCreatedMessage;
int ShownTickCount;
@@ -300,7 +300,7 @@ namespace mpvnet
if (core.VideoSize.Height == 0 || core.VideoSize.Width == 0 ||
core.VideoSize.Width / (float)core.VideoSize.Height < App.MinimumAspectRatio)
core.VideoSize = new Size((int)(autoFitHeight * (16 / 9.0)), autoFitHeight);
core.VideoSize = new Size((int)(autoFitHeight * (16 / 9f)), autoFitHeight);
Size videoSize = core.VideoSize;
int height = videoSize.Height;
@@ -321,26 +321,26 @@ namespace mpvnet
}
height = Convert.ToInt32(height * scale);
int width = Convert.ToInt32(height * videoSize.Width / (double)videoSize.Height);
int width = height * videoSize.Width / videoSize.Height;
int maxHeight = screen.WorkingArea.Height - (Height - ClientSize.Height);
int maxWidth = screen.WorkingArea.Width - (Width - ClientSize.Width);
if (height < maxHeight * core.AutofitSmaller)
{
height = Convert.ToInt32(maxHeight * core.AutofitSmaller);
width = Convert.ToInt32(height * videoSize.Width / (double)videoSize.Height);
width = Convert.ToInt32(height * videoSize.Width / videoSize.Height);
}
if (height > maxHeight * core.AutofitLarger)
{
height = Convert.ToInt32(maxHeight * core.AutofitLarger);
width = Convert.ToInt32(height * videoSize.Width / (double)videoSize.Height);
width = Convert.ToInt32(height * videoSize.Width / videoSize.Height);
}
if (width > maxWidth)
{
width = maxWidth;
height = Convert.ToInt32(width * videoSize.Height / (double)videoSize.Width);
height = (int)Math.Ceiling(width * videoSize.Height / (double)videoSize.Width);
}
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
@@ -517,12 +517,26 @@ namespace mpvnet
case 0x101: // WM_KEYUP
case 0x104: // WM_SYSKEYDOWN
case 0x105: // WM_SYSKEYUP
case 0x319: // WM_APPCOMMAND
if (core.WindowHandle != IntPtr.Zero)
m.Result = WinAPI.SendMessage(core.WindowHandle, m.Msg, m.WParam, m.LParam);
{
bool skip = m.Msg == 0x100 && LastAppCommand != 0 &&
(Environment.TickCount - LastAppCommand) < 1000;
if (m.Msg == 0x319) // WM_APPCOMMAND
return;
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;
}
}
break;
case 0x0200: // WM_MOUSEMOVE
if (Environment.TickCount - LastCycleFullscreen > 500)
@@ -565,8 +579,18 @@ namespace mpvnet
s = new Size(16, 9);
float aspect = s.Width / (float)s.Height;
int d_w = Convert.ToInt32(c_h * aspect - c_w);
int d_h = Convert.ToInt32(c_w / aspect - c_h);
int d_w = (int)(c_h * aspect - c_w);
int d_h = (int)(c_w / aspect - c_h);
Debug.WriteLine(d_w);
Debug.WriteLine(d_h);
int d_w2 = (int)(c_h * aspect - c_w);
int d_h2 = (int)(c_w / aspect - c_h);
Debug.WriteLine(d_w2);
Debug.WriteLine(d_h2);
int[] d_corners = { d_w, d_h, -d_w, -d_h };
int[] corners = { rc.Left, rc.Top, rc.Right, rc.Bottom };
int corner = NativeHelp.GetResizeBorder(m.WParam.ToInt32());
@@ -607,7 +631,9 @@ namespace mpvnet
ProgressTimer.Start();
}
base.WndProc(ref m);
// beep sound when closed using taskbar due to exception
if (!IsDisposed)
base.WndProc(ref m);
}
void CursorTimer_Tick(object sender, EventArgs e)
@@ -795,8 +821,6 @@ namespace mpvnet
if (!core.ShutdownAutoResetEvent.WaitOne(10000))
Msg.ShowError("Shutdown thread failed to complete within 10 seconds.");
PowerShell.Shutdown();
}
protected override void OnMouseDown(MouseEventArgs e)
@@ -842,8 +866,9 @@ namespace mpvnet
protected override void OnKeyDown(KeyEventArgs e)
{
// prevent beep using alt key
if (Control.ModifierKeys == Keys.Alt)
e.SuppressKeyPress = true; // prevent beep using alt key
e.SuppressKeyPress = true;
base.OnKeyDown(e);
}

View File

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

View File

@@ -117,7 +117,7 @@ namespace mpvnet
if (Handle == IntPtr.Zero)
throw new Exception("error mpv_create");
mpv_request_log_messages(Handle, "info");
mpv_request_log_messages(Handle, "terminal-default");
Task.Run(() => EventLoop());
@@ -130,7 +130,6 @@ namespace mpvnet
set_property_string("wid", MainForm.Hwnd.ToString());
set_property_string("osc", "yes");
set_property_string("input-media-keys", "yes");
set_property_string("force-window", "yes");
set_property_string("config-dir", ConfigFolder);
set_property_string("config", "yes");
@@ -149,9 +148,11 @@ namespace mpvnet
public void ProcessProperty(string name, string value)
{
if (name.Any(char.IsUpper))
Msg.ShowError("Uppercase char detected: " + name,
"mpv properties using the command line and the mpv.conf config file are required to be lowercase.");
foreach (char i in name)
if (char.IsUpper(i))
Msg.ShowError("Uppercase char detected: " + name,
"mpv properties using the command line and the mpv.conf " +
"config file are required to be lowercase.");
switch (name)
{
@@ -169,7 +170,7 @@ namespace mpvnet
break;
case "fs":
case "fullscreen": Fullscreen = value == "yes"; break;
case "border": Border = value == "yes"; break;
case "border": Border = value == "yes"; break;
case "window-maximized": WindowMaximized = value == "yes"; break;
case "window-minimized": WindowMinimized = value == "yes"; break;
case "taskbar-progress": TaskbarProgress = value == "yes"; break;
@@ -397,14 +398,9 @@ namespace mpvnet
{
var data = (mpv_event_log_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_log_message));
if (LogMessage != null || LogMessageAsync != null ||
data.log_level == mpv_log_level.MPV_LOG_LEVEL_FATAL)
if (LogMessage != null || LogMessageAsync != null)
{
string msg = $"[{ConvertFromUtf8(data.prefix)}] {ConvertFromUtf8(data.text)}";
if (data.log_level == mpv_log_level.MPV_LOG_LEVEL_FATAL)
App.RunAction(() => App.ShowError("Fatal Error", msg));
InvokeAsync<mpv_log_level, string>(LogMessageAsync, data.log_level, msg);
LogMessage?.Invoke(data.log_level, msg);
}

View File

@@ -1,6 +1,4 @@
Set-Variable wasPaused $false -Option AllScope
$code = {
$isMinimized = $args[0]
$isPaused = $mp.get_property_bool('pause')
@@ -10,17 +8,17 @@ $code = {
if (-not $isPaused)
{
$mp.set_property_bool('pause', $true)
$wasPaused = $true
$script:wasPaused = $true
}
}
else
{
if ($wasPaused -and $isPaused)
if ($script:wasPaused -and $isPaused)
{
$mp.set_property_bool('pause', $false)
}
$wasPaused = $false
$script:wasPaused = $false
}
}

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)