Compare commits
102 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57ae0d008b | ||
|
|
e128a4868b | ||
|
|
3875e1c1bf | ||
|
|
dd508907eb | ||
|
|
765854cd10 | ||
|
|
69fe7c091a | ||
|
|
45a2b7f976 | ||
|
|
a8cf3407e7 | ||
|
|
b8163c3c3e | ||
|
|
9d27465492 | ||
|
|
bba71c3782 | ||
|
|
eaa8a3ca6c | ||
|
|
0b28770d1a | ||
|
|
45d3386a88 | ||
|
|
8df330b7aa | ||
|
|
69857e0548 | ||
|
|
b1388e10e5 | ||
|
|
6f7f127279 | ||
|
|
18c8f5783b | ||
|
|
cdf3eb1373 | ||
|
|
e5bcd0fc29 | ||
|
|
b0dc44a98e | ||
|
|
41a14cd3b7 | ||
|
|
b38c7cf834 | ||
|
|
2ee4c1e647 | ||
|
|
2bcf97a97a | ||
|
|
8eaec77b0c | ||
|
|
3161ba1022 | ||
|
|
496bba71d4 | ||
|
|
3e1e822e56 | ||
|
|
b1ea6da39b | ||
|
|
8d54abae4c | ||
|
|
3583aa11ed | ||
|
|
642c36bacf | ||
|
|
0343b32847 | ||
|
|
6e2d11952f | ||
|
|
d0ad69656a | ||
|
|
62789fa036 | ||
|
|
a7fe444067 | ||
|
|
1ef4740b09 | ||
|
|
c5e445da17 | ||
|
|
a52de9039d | ||
|
|
8db8e497a5 | ||
|
|
28c9b2710c | ||
|
|
6ba9b1f05a | ||
|
|
ea5d3e64ee | ||
|
|
636d28ac54 | ||
|
|
6e54286a60 | ||
|
|
b396012934 | ||
|
|
f3909acdfe | ||
|
|
3ed71444a7 | ||
|
|
cab7c6d49b | ||
|
|
368641523a | ||
|
|
42c76d25c6 | ||
|
|
3968fa50f5 | ||
|
|
4d985c7b7c | ||
|
|
235a52a701 | ||
|
|
9a63b660de | ||
|
|
8eb0222873 | ||
|
|
bf8636135a | ||
|
|
33cdee5497 | ||
|
|
564d7b10a0 | ||
|
|
a1a408da1d | ||
|
|
85a3506403 | ||
|
|
e860cf52c4 | ||
|
|
32a46e47e2 | ||
|
|
538e91aaa9 | ||
|
|
94eaf8144f | ||
|
|
404a8f110d | ||
|
|
14f5228754 | ||
|
|
5ec2d1b436 | ||
|
|
32c6ce3a44 | ||
|
|
b86148dfb3 | ||
|
|
26e94fad2b | ||
|
|
c306eb032f | ||
|
|
09944583dd | ||
|
|
8f4ad52469 | ||
|
|
5f4eca21e5 | ||
|
|
b4632a0b6e | ||
|
|
c14a11170d | ||
|
|
723005b28f | ||
|
|
72f25a686e | ||
|
|
b1fb940759 | ||
|
|
1020cd70d1 | ||
|
|
50a2f13dbe | ||
|
|
b1ffb8291f | ||
|
|
dbc8ddaf2b | ||
|
|
b42cb6be05 | ||
|
|
b63363336f | ||
|
|
b0ef161ed9 | ||
|
|
7d31237d5f | ||
|
|
3705e2abbf | ||
|
|
7d73529c83 | ||
|
|
2e59d49ad1 | ||
|
|
f61eef8961 | ||
|
|
efb4c085d5 | ||
|
|
4a045d6a91 | ||
|
|
da1a78cfa3 | ||
|
|
5b3697fbde | ||
|
|
726d759589 | ||
|
|
ed614332f7 | ||
|
|
9d46064dca |
10
.github/ISSUE_TEMPLATE/ask-a-question.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Ask a question
|
||||
about: Ask a question about mpv.net
|
||||
title: ''
|
||||
labels: question
|
||||
assignees: stax76
|
||||
|
||||
---
|
||||
|
||||
This template is meant for usage questions of mpv.net.
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
name: Bug report
|
||||
name: Report a bug
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
name: Feature request
|
||||
name: Request a feature
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
labels: feature request
|
||||
assignees: stax76
|
||||
|
||||
---
|
||||
31
README.md
@@ -1,5 +1,5 @@
|
||||
|
||||

|
||||

|
||||
|
||||
    
|
||||
|
||||
@@ -61,6 +61,7 @@ Features
|
||||
- Customizable context menu defined in the same file as the key bindings
|
||||
- Config dialog
|
||||
- Shorcut key editor
|
||||
- Global hotkeys
|
||||
- Many features like the config editor and shortcut key editor are fully searchable
|
||||
- Configuration files that are easy to read and edit
|
||||
- Command palette to quickly find commands and keys
|
||||
@@ -79,8 +80,8 @@ Features
|
||||
- Fast startup performance
|
||||
- Usable as video player, audio player and image viewer with a wide range of supported formats
|
||||
- Built-in decoders, no external codecs have to be installed
|
||||
- Setup as x64, x86, installer, portable, Chocolatey and Scoop
|
||||
- Build-in media streaming via youtube-dl
|
||||
- Setup as x64 installer, portable and Chocolatey
|
||||
- Build-in media streaming (requires youtube-dl being installed)
|
||||
- File associations can be created by the setup and from the player
|
||||
- External audio and subtitle files can be loaded manually or automatically
|
||||
- Screenshot feature
|
||||
@@ -90,19 +91,19 @@ Features
|
||||
- Update check and update routine
|
||||
|
||||
|
||||
## [Support](Manual.md#support)
|
||||
## [Support](docs/Manual.md#support)
|
||||
|
||||
[Support section of the manual.](Manual.md#support)
|
||||
[Support section of the manual.](docs/Manual.md#support)
|
||||
|
||||
|
||||
## [Download](Manual.md#download)
|
||||
## [Download](docs/Manual.md#download)
|
||||
|
||||
[Download section of the manual.](Manual.md#download)
|
||||
[Download section of the manual.](docs/Manual.md#download)
|
||||
|
||||
|
||||
## [Manual](Manual.md)
|
||||
## [Manual](docs/Manual.md)
|
||||
|
||||
[The mpv.net documentation.](Manual.md)
|
||||
[The mpv.net documentation.](docs/Manual.md)
|
||||
|
||||
|
||||
Screenshots
|
||||
@@ -110,39 +111,39 @@ Screenshots
|
||||
|
||||
#### Main Window
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
#### Context Menu
|
||||
|
||||
Context menu using dark mode.
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
#### Config Editor
|
||||
|
||||
Searchable config editor as alternative to edit the conf file manually.
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
#### Terminal
|
||||
|
||||
OSD console and status printed on the terminal.
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
#### Input Editor
|
||||
|
||||
Searchable key and mouse binding editor.
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
#### Command Palette
|
||||
|
||||
Command Palette to find commands and shortcut keys easily.
|
||||
|
||||

|
||||

|
||||
|
||||
113
Release.ps1
@@ -1,113 +0,0 @@
|
||||
|
||||
$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)
|
||||
$vsDir = 'C:\Program Files (x86)\Microsoft Visual Studio\2019'
|
||||
$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'
|
||||
|
||||
if ($versionInfo.FilePrivatePart -eq 0)
|
||||
{
|
||||
& $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 }
|
||||
|
||||
& $inno /Darch=x64 setup.iss
|
||||
if ($LastExitCode) { throw $LastExitCode }
|
||||
|
||||
& $inno /Darch=x86 setup.iss
|
||||
if ($LastExitCode) { throw $LastExitCode }
|
||||
|
||||
$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 }
|
||||
}
|
||||
else
|
||||
{
|
||||
& $msBuild mpv.net.sln -t:Rebuild -p:Configuration=Debug -p:Platform=x64
|
||||
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 }
|
||||
|
||||
$cloudDirectories = 'C:\Users\frank\OneDrive\Public\mpv.net\',
|
||||
'C:\Users\frank\Dropbox\Public\mpv.net\'
|
||||
|
||||
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 + "`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
|
||||
@@ -1,9 +1,173 @@
|
||||
|
||||
5.4.7.1 Beta (not yet released)
|
||||
5.4.9.0 (2021-05-29)
|
||||
====================
|
||||
|
||||
- `window-scale 1` does not work correctly in mpv,
|
||||
so I've removed support for it and added my own implementation:
|
||||
`script-message mpv.net window-scale`.
|
||||
- The CS-Script library was replaced with my own C# scripting implementation.
|
||||
- If a player window border is near to a screen border and the window size
|
||||
changes, the player windows sticks to that near screen border location.
|
||||
Furthermore the `remember-window-position` option remembers a near screen
|
||||
border position instead of remembering the window center position.
|
||||
- Multi monitor fix using different DPI values.
|
||||
- `start-size` option has new options, see config editor and manual.
|
||||
- Improved `script-message mpv.net cycle-audio` OSD info.
|
||||
- The logic for finding the config directory has changed, see manual.
|
||||
- The dotnet script and extension host was a little redesigned, this breaks
|
||||
backward compatibility unfortunately, but I can help fixing existing
|
||||
open source code however. Example scripts and extensions were updated.
|
||||
- Fix console not working due to incorrect mpv.conf value generated
|
||||
(script-opts=console-scale=0).
|
||||
- Settings are stored in the file settings.xml now instead of the Registry.
|
||||
- Video rotation support added.
|
||||
- After using the config editor it's no longer necessary to restart mpv.net.
|
||||
- Improved input editor theming.
|
||||
|
||||
|
||||
5.4.8.8 Beta (2021-05-09)
|
||||
=========================
|
||||
|
||||
- Improved window scaling.
|
||||
- Title property implementation.
|
||||
- Command palette shows commands without assigned menu item.
|
||||
- The code from the included JavaScript file was ported into the core
|
||||
player because JavaScript is currently broken in the builds of shinshiro.
|
||||
- New option `--command=<input command>`, can be used in combination
|
||||
with `process-instance=single` to control mpv.net via command line,
|
||||
for instance to create global hotkeys with AutoHotkey.
|
||||
- New global hotkey feature added using the file global-input.conf.
|
||||
- The global-media-keys option was removed because global-input.conf
|
||||
can be used instead.
|
||||
- MediaInfo 21.3
|
||||
- libmpv shinchiro 2021-04-04
|
||||
|
||||
|
||||
5.4.8.7 Beta (2021-03-09)
|
||||
=========================
|
||||
|
||||
- History feature can be configured to ingore defined strings:
|
||||
script-opt = history-discard=value1;value2
|
||||
- Web stream audio and subtitle track selection.
|
||||
- On Windows 10 1903 and later the default code page was changed to UTF-8.
|
||||
- Support of --version command.
|
||||
- File associations and auto-load-folder can be customized with
|
||||
video-file-extensions, audio-file-extensions and image-file-extensions.
|
||||
- Fix menu not showing key '&'.
|
||||
|
||||
|
||||
5.4.8.6 Beta (2020-12-24)
|
||||
=========================
|
||||
|
||||
- Santa hat shown in december. (#216)
|
||||
- Filename not being always shown in title bar. (#214)
|
||||
- Improved OSD message when cycling audio.
|
||||
- DVD audio and subtitle track selection.
|
||||
- Input keylist can be shown on the command-line with --input-keylist
|
||||
- Profiles can be shown on the command-line with --profile=help
|
||||
- Decoders can be shown on the command-line with --ad=help and --vd=help
|
||||
- Decoders can be shown in the menu under: View > Show Decoders
|
||||
- Demuxers can be shown in the menu under: View > Show Demuxers
|
||||
- Audio devices can be shown in the menu under: View > Show Audio Devices
|
||||
- Audio devices can be shown on the command-line with --audio-device=help
|
||||
- Protocols can be shown in the menu under: View > Show Protocols
|
||||
- Allow mpv.net to start from different startup locations
|
||||
without showing the setup dialog. (#218)
|
||||
- libmpv updated to shinshiro 2020-12-20
|
||||
|
||||
|
||||
5.4.8.5 Beta
|
||||
============
|
||||
|
||||
- Load AviSynth DLL from environment variable AviSynthDLL
|
||||
in order to support AviSynth portable mode.
|
||||
- New option global-media-keys (next, previous, play/pause, stop).
|
||||
- Redesigned PowerShell based setup and setup dialog, it was done
|
||||
because of a bug and upcoming chocolately and winget integration.
|
||||
- Redesigned auto update using different file name, using zip instead
|
||||
of 7zip format now, 7zip distribution will shortly get dropped.
|
||||
- Whenever there is a new startup location, the setup dialog is shown.
|
||||
- libmpv updated to shinshiro 2020-12-06
|
||||
- youtube-dl is no longer included, users have to install it
|
||||
on their own (put it in the startup or a PATH folder).
|
||||
|
||||
|
||||
5.4.8.4 Beta
|
||||
============
|
||||
|
||||
- Blu-rays with dozens of titles showed all titles in the menu
|
||||
which was difficult to choose and extremely slow.
|
||||
- Blu-ray folder paths are auto detected when received
|
||||
from drag & drop and command-line.
|
||||
- Cycle audio was not working for Blu-ray.
|
||||
- Message asking if image is BD or DVD in case image is < 10 GB.
|
||||
|
||||
|
||||
5.4.8.3 Beta
|
||||
============
|
||||
|
||||
- Support Wheel_Left and Wheel_Right. (arnesacnussem)
|
||||
- Default screen was changed from primary to OS default to start
|
||||
from the same screen where the File Explorer window is located.
|
||||
- When mpv.net was started maximized and next was invoked then the
|
||||
window state was changed to normal instead of staying maximized.
|
||||
|
||||
|
||||
5.4.8.2 Beta
|
||||
============
|
||||
|
||||
- CLI --shuffle issue fix.
|
||||
- ISO image files can be opened like any other files, files smaller
|
||||
than 10 GB are handled as DVD and larger as BluRay.
|
||||
- Menu support for BluRay title, audio and subtitle selection.
|
||||
- Property input-key-list can be shown with: View > Show Keys
|
||||
- youtube-dl 2020.06.16.1
|
||||
- libmpv 2020-06-21 shinchiro
|
||||
|
||||
|
||||
5.4.8.1 Beta
|
||||
============
|
||||
|
||||
- fix stdin support
|
||||
|
||||
|
||||
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
|
||||
=======
|
||||
@@ -237,7 +401,7 @@ stable release, no changes since the last beta
|
||||
- libmpv was updated to shinchiro 2019-08-04
|
||||
- in case mpv.net was started from a terminal it sets now the mpv property input-terminal to yes,
|
||||
this means mpv.net will now receive and handle input keys from the terminal
|
||||
- certain command line properties didn't work (input-terminal, terminal, input-file,
|
||||
- certain command-line properties didn't work (input-terminal, terminal, input-file,
|
||||
config, config-dir, input-conf, load-scripts, script, scripts, player-operation-mode)
|
||||
- the about dialog shows now the mpv version and build date
|
||||
- the dialog that asks for a config folder has now a cancel option
|
||||
@@ -248,7 +412,7 @@ stable release, no changes since the last beta
|
||||
- the logo/icon had a very small cosmetic change
|
||||
- the help in the context menu was improved,
|
||||
for quick access consider the command palette (F1 key)
|
||||
- config options specific to mpv.net are now available from the command line
|
||||
- config options specific to mpv.net are now available from the command-line
|
||||
- the input editor no longer has known limitations, 'alt gr' and ctrl+alt are working now
|
||||
- the help in the input editor was simplified and the filter logic was improved
|
||||
- fixed issue in file associations causing mpv.net not to appear in OS default apps
|
||||
@@ -264,10 +428,10 @@ stable release, no changes since the last beta
|
||||
- the search field in the config editor was not always remembered
|
||||
- new setting remember-volume added, saves volume and mute on exit
|
||||
and restores it on start.
|
||||
- it's now enforced that mpv properties on the command line and in
|
||||
- it's now enforced that mpv properties on the command-line and in
|
||||
the mpv.conf config file are lowercase, if not a error is shown
|
||||
- gpu-api vulkan was not working if media files were opened via
|
||||
command line (that included Explorer)
|
||||
command-line (that included Explorer)
|
||||
- new setting minimum-aspect-ratio added, minimum aspect ratio for the window,
|
||||
this was previously hard coded to 1.3
|
||||
- new setting auto-load-folder added, for single files automatically load
|
||||
@@ -382,7 +546,7 @@ stable release, no changes since the last beta
|
||||
thanks to 44vince44 for pointing this out!!!
|
||||
- new Python and C# script examples were added to the wiki and the scripting and
|
||||
extension documentation was improved
|
||||
- invalid command line arguments were ignored, now an error message is shown
|
||||
- invalid command-line arguments were ignored, now an error message is shown
|
||||
- a description on how to start mpv.net from Google Chrome was added to the
|
||||
manual, it's useful to play videos from sites like YouTube, find the
|
||||
description [here](https://github.com/stax76/mpv.net/blob/master/Manual.md#chrome-extension)
|
||||
@@ -428,7 +592,7 @@ stable release, no changes since the last beta
|
||||
|
||||
- drag & drop support for subtitles was added
|
||||
- libmpv was updated
|
||||
- command line support for stdin and URLs was added
|
||||
- command-line support for stdin and URLs was added
|
||||
- there was a crash happening when the player is
|
||||
minimized in the taskbar
|
||||
|
||||
@@ -441,7 +605,7 @@ stable release, no changes since the last beta
|
||||
- the info command (i key) shows the audio format
|
||||
- new options osd-font-size, sub-font, sub-font-size
|
||||
- new color options with dedicated GUI support: sub-color, sub-border-color, sub-back-color
|
||||
- the config editor no longer shows the command line switches
|
||||
- the config editor no longer shows the command-line switches
|
||||
- the github start page was greatly improved
|
||||
- the setup.ps1 PowerShell script was greatly improved in regard of error handling and readability
|
||||
- a [manual to mpv.net](Manual.md) was created
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2017-2020 Frank Skare (stax76)
|
||||
Copyright (C) 2017-2021 mpv.net/mpv/mplayer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and ssociated documentation
|
||||
@@ -10,96 +10,19 @@ Table of contents
|
||||
* [Installation](#installation)
|
||||
* [Support](#support)
|
||||
* [Settings](#settings)
|
||||
* [Input and context menu](#input-and-context-menu)
|
||||
* [Command Line Interface](#command-line-interface)
|
||||
* [Terminal](#terminal)
|
||||
* [mpv.net specific options](#mpvnet-specific-options)
|
||||
* [External Tools](#external-tools)
|
||||
* [Scripting](#scripting)
|
||||
* [Extensions](#extensions)
|
||||
* [Color Theme](#color-theme)
|
||||
* [Advanced Features](#advanced-features)
|
||||
* [Hidden Features](#hidden-features)
|
||||
* [Differences](#differences)
|
||||
* [Differences compared to mpv](#differences-compared-to-mpv)
|
||||
* [Technical Overview](#technical-overview)
|
||||
* [Context Menu](#context-menu)
|
||||
+ [Open > Open Files](#open--open-files)
|
||||
+ [Open > Open URL or file path from clipboard](#open--open-url-or-file-path-from-clipboard)
|
||||
+ [Open > Open DVD/Blu-ray Drive/Folder](#open--open-dvd-blu-ray-drive-folder)
|
||||
+ [Open > Show media search](#open--show-media-search)
|
||||
+ [Open > Load external audio files](#open--load-external-audio-files)
|
||||
+ [Open > Load external subtitle files](#open--load-external-subtitle-files)
|
||||
+ [Play/Pause](#play-pause)
|
||||
+ [Stop](#stop)
|
||||
+ [Toggle Fullscreen](#toggle-fullscreen)
|
||||
+ [Navigate > Previous File](#navigate--previous-file)
|
||||
+ [Navigate > Next File](#navigate--next-file)
|
||||
+ [Navigate > Next Chapter](#navigate--next-chapter)
|
||||
+ [Navigate > Previous Chapter](#navigate--previous-chapter)
|
||||
+ [Navigate > Jump Next Frame](#navigate--jump-next-frame)
|
||||
+ [Navigate > Jump Previous Frame](#navigate--jump-previous-frame)
|
||||
+ [Navigate > Jump](#navigate--jump)
|
||||
+ [Pan & Scan > Increase Size](#pan--scan--increase-size)
|
||||
+ [Pan & Scan > Decrease Size](#pan--scan--decrease-size)
|
||||
+ [Pan & Scan > Move Left](#pan--scan--move-left)
|
||||
+ [Pan & Scan > Move Right](#pan--scan--move-right)
|
||||
+ [Pan & Scan > Move Up](#pan--scan--move-up)
|
||||
+ [Pan & Scan > Move Down](#pan--scan--move-down)
|
||||
+ [Pan & Scan > Decrease Height](#pan--scan--decrease-height)
|
||||
+ [Pan & Scan > Increase Height](#pan--scan--increase-height)
|
||||
+ [Pan & Scan > Reset](#pan--scan--reset)
|
||||
+ [Video > Decrease Contrast](#video--decrease-contrast)
|
||||
+ [Video > Increase Contrast](#video--increase-contrast)
|
||||
+ [Video > Decrease Brightness](#video--decrease-brightness)
|
||||
+ [Video > Increase Brightness](#video--increase-brightness)
|
||||
+ [Video > Decrease Gamma](#video--decrease-gamma)
|
||||
+ [Video > Increase Gamma](#video--increase-gamma)
|
||||
+ [Video > Decrease Saturation](#video--decrease-saturation)
|
||||
+ [Video > Increase Saturation](#video--increase-saturation)
|
||||
+ [Video > Take Screenshot](#video--take-screenshot)
|
||||
+ [Video > Toggle Deinterlace](#video--toggle-deinterlace)
|
||||
+ [Video > Cycle Aspect Ratio](#video--cycle-aspect-ratio)
|
||||
+ [Audio > Cycle/Next](#audio--cycle-next)
|
||||
+ [Audio > Delay +0.1](#audio--delay--01)
|
||||
+ [Audio > Delay -0.1](#audio--delay--01)
|
||||
+ [Subtitle > Cycle/Next](#subtitle--cycle-next)
|
||||
+ [Subtitle > Toggle Visibility](#subtitle--toggle-visibility)
|
||||
+ [Subtitle > Delay -0.1](#subtitle--delay--01)
|
||||
+ [Subtitle > Delay 0.1](#subtitle--delay-01)
|
||||
+ [Subtitle > Move Up](#subtitle--move-up)
|
||||
+ [Subtitle > Move Down](#subtitle--move-down)
|
||||
+ [Subtitle > Decrease Subtitle Font Size](#subtitle--decrease-subtitle-font-size)
|
||||
+ [Subtitle > Increase Subtitle Font Size](#subtitle--increase-subtitle-font-size)
|
||||
+ [Volume > Up](#volume--up)
|
||||
+ [Volume > Down](#volume--down)
|
||||
+ [Volume > Mute](#volume--mute)
|
||||
+ [Speed > -10%](#speed---10-)
|
||||
+ [Speed > 10%](#speed--10-)
|
||||
+ [Speed > Half](#speed--half)
|
||||
+ [Speed > Double](#speed--double)
|
||||
+ [Speed > Reset](#speed--reset)
|
||||
+ [Extensions > Rating > 0stars](#extensions--rating--0stars)
|
||||
+ [View > On Top > Enable](#view--on-top--enable)
|
||||
+ [View > On Top > Disable](#view--on-top--disable)
|
||||
+ [View > File Info](#view--file-info)
|
||||
+ [View > Show Statistics](#view--show-statistics)
|
||||
+ [View > Toggle Statistics](#view--toggle-statistics)
|
||||
+ [View > Toggle OSC Visibility](#view--toggle-osc-visibility)
|
||||
+ [View > Show Playlist](#view--show-playlist)
|
||||
+ [View > Show Audio/Video/Subtitle List](#view--show-audio-video-subtitle-list)
|
||||
+ [Settings > Show Config Editor](#settings--show-config-editor)
|
||||
+ [Settings > Show Input Editor](#settings--show-input-editor)
|
||||
+ [Settings > Open Config Folder](#settings--open-config-folder)
|
||||
+ [Tools > Command Palette](#tools--command-palette)
|
||||
+ [Tools > Show History](#tools--show-history)
|
||||
+ [Tools > Set/clear A-B loop points](#tools--set-clear-a-b-loop-points)
|
||||
+ [Tools > Toggle infinite file looping](#tools--toggle-infinite-file-looping)
|
||||
+ [Tools > Toggle Hardware Decoding](#tools--toggle-hardware-decoding)
|
||||
+ [Tools > Setup](#tools--setup)
|
||||
+ [Help > Show mpv manual](#help--show-mpv-manual)
|
||||
+ [Help > Show mpv.net manual](#help--show-mpvnet-manual)
|
||||
+ [Help > Check for Updates](#help--check-for-updates)
|
||||
+ [Help > About mpv.net](#help--about-mpvnet)
|
||||
+ [Exit](#exit)
|
||||
+ [Exit Watch Later](#exit-watch-later)
|
||||
* [Context Menu Commands](#context-menu)
|
||||
|
||||
|
||||
About
|
||||
@@ -107,9 +30,13 @@ About
|
||||
|
||||
mpv.net is a modern desktop media player for Windows based on the popular mpv player.
|
||||
|
||||
mpv.net is designed to be mpv compatible, almost all mpv features are available because they are all contained in libmpv, this means the official [mpv manual](https://mpv.io/manual/master/) applies to mpv.net.
|
||||
mpv.net is designed to be mpv compatible, almost all mpv features are available
|
||||
because they are all contained in libmpv, this means the official
|
||||
[mpv manual](https://mpv.io/manual/master/) applies to mpv.net.
|
||||
|
||||
mpv focuses on the usage of the command line and the terminal, mpv.net retains the ability to be used from the command line and the terminal and adds a modern Windows GUI on top of it.
|
||||
mpv focuses on the usage of the command line and the terminal,
|
||||
mpv.net retains the ability to be used from the command line and
|
||||
the terminal and adds a modern Windows GUI on top of it.
|
||||
|
||||
|
||||
Download
|
||||
@@ -120,7 +47,7 @@ Download
|
||||
|
||||
### Stable
|
||||
|
||||
[Release page](../../releases)
|
||||
[Release page](../../../releases)
|
||||
|
||||
|
||||
### Beta
|
||||
@@ -135,38 +62,36 @@ Installation
|
||||
|
||||
mpv.net requires the .NET Framework 4.8 and Windows 7 or 10 and a modern graphics card.
|
||||
|
||||
There is a setup and a portable download in the 7zip and Zip archive format.
|
||||
There is a setup exe and a portable zip file download.
|
||||
|
||||
x64 editions have the advantage of being typically better optimized and tested.
|
||||
For internet streaming youtube-dl must be downloaded and installed manually,
|
||||
meaning it must be located in the PATH environment variable or in the startup directory.
|
||||
|
||||
mpvnet.exe is platform agnostic, users that need x86 have to replace 4 native tools:
|
||||
|
||||
### Scoop
|
||||
|
||||
```
|
||||
scoop bucket add extras
|
||||
scoop install mpv.net
|
||||
```
|
||||
|
||||
|
||||
### AppGet
|
||||
|
||||
`appget install mpv-net`
|
||||
|
||||
|
||||
### Chocolatey
|
||||
|
||||
`choco install mpvnet.install`
|
||||
- Everything.dll
|
||||
- mpv-1.dll
|
||||
- MediaInfo.dll
|
||||
- mpvnet.com
|
||||
|
||||
|
||||
#### File Associations
|
||||
|
||||
File Associations can be created using the setup or with the context menu under 'Tools > Setup'.
|
||||
File Associations can be created using the context menu under 'Tools > Setup'.
|
||||
|
||||
After the file associations were registered, go to the Windows settings under 'Settings > Apps > Default apps' or shell execute `ms-settings:defaultapps` and choose mpv.net as default app for Video and optionally for Audio and Images.
|
||||
After the file associations were registered, go to the Windows settings under
|
||||
'Settings > Apps > Default apps' or shell execute `ms-settings:defaultapps` and choose
|
||||
mpv.net as default app for Video and optionally for Audio and Images.
|
||||
|
||||
It's possible to change the default application using the 'Open with' feature of the context menu in File Explorer.
|
||||
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
|
||||
@@ -174,7 +99,8 @@ Support
|
||||
|
||||
Before making a support request, please try a newer [beta version](#beta) first.
|
||||
|
||||
Bugs and feature requests can be made on the github [issue tracker](https://github.com/stax76/mpv.net/issues), feel free to use for anything mpv.net related.
|
||||
Bugs and feature requests can be made on the github [issue tracker](../../../issues),
|
||||
feel free to use for anything mpv.net related, usage questions are welcome.
|
||||
|
||||
Or use the [support thread](https://forum.videohelp.com/threads/392514-mpv-net-a-extendable-media-player-for-windows) in the VideoHelp forum.
|
||||
|
||||
@@ -182,30 +108,41 @@ Or use the [support thread](https://forum.videohelp.com/threads/392514-mpv-net-a
|
||||
Settings
|
||||
--------
|
||||
|
||||
When mpv.net finds no config folder on startup it will ask for a location.
|
||||
mpv.net searches the config folder at:
|
||||
|
||||
If a folder named portable_config next to the mpvnet.exe exists,
|
||||
all config will be loaded from this folder only.
|
||||
1. startup\portable_config
|
||||
2. %APPDATA%\mpv.net
|
||||
|
||||
```Text
|
||||
<startup>\portable_config\
|
||||
```
|
||||
In order to use a custom directory create following file:
|
||||
|
||||
startup\settings-directory.txt
|
||||
|
||||
Put your custom directory in that file.
|
||||
|
||||
The custom directory path can be relative to the startup directory path.
|
||||
|
||||
This custom directory is only used if the portable_config and %APPDATA% directory does not exist.
|
||||
|
||||
mpv specific settings are stored in the file mpv.conf, if no mpv.conf file exists
|
||||
mpv.net generates it with the following defaults:
|
||||
|
||||
<https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpv.conf.txt>
|
||||
[mpv.conf defaults](../../../tree/master/src/Resources/mpv.conf.txt)
|
||||
|
||||
mpv.net specific settings are stored in the file mpvnet.conf.
|
||||
mpv.net specific settings are stored in the file mpvnet.conf,
|
||||
these options are documented [here](#mpvnet-specific-options).
|
||||
|
||||
|
||||
Input and context menu
|
||||
----------------------
|
||||
|
||||
The input (key/mouse) bindings and the context menu definitions are stored in the
|
||||
input.conf file, if it's missing mpv.net generates it with the following defaults:
|
||||
|
||||
<https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt>
|
||||
[input.conf defaults](../../../tree/master/src/Resources/input.conf.txt)
|
||||
|
||||
mpv.net supports almost all mpv settings and features.
|
||||
Global hotkeys are supported via global-input.conf file.
|
||||
|
||||
The config folder can be opened from the context menu (`Settings > Open Config Folder`).
|
||||
The config folder can be opened from the context menu: `Settings > Open Config Folder`
|
||||
|
||||
|
||||
Command Line Interface
|
||||
@@ -230,7 +167,7 @@ To disable the border property:
|
||||
|
||||
Supported are all mpv properties, they are documented here:
|
||||
|
||||
<https://mpv.io/manual/master/#properties>
|
||||
https://mpv.io/manual/master/#properties
|
||||
|
||||
|
||||
mpv.net has a feature to list all properties:
|
||||
@@ -244,13 +181,171 @@ Non property switches are generally not supported in mpv.net!
|
||||
Terminal
|
||||
--------
|
||||
|
||||
When mpv.net is started from a terminal it will output status, error and debug messages to the terminal and accept input keys from the terminal.
|
||||
When mpv.net is started from a terminal it will output status,
|
||||
error and debug messages to the terminal and accept input keys from the terminal.
|
||||
|
||||
In the context menu under _Tools > Setup_ a button can be found to add mpv.net to the path environment variable.
|
||||
In the context menu under _Tools > Setup_ a button can be found to add
|
||||
mpv.net to the path environment variable.
|
||||
|
||||
A common task for the terminal is debugging scripts.
|
||||
|
||||
|
||||
mpv.net specific options
|
||||
------------------------
|
||||
|
||||
mpv.net specific options can be found in the conf editor searching for 'mpv.net'.
|
||||
|
||||
The options are saved in the mpvnet.conf file.
|
||||
|
||||
#### --queue \<files\>
|
||||
|
||||
Adds files to the playlist, requires [--process-instance=single](#--process-instancevalue).
|
||||
[Open with++](#open-with) can be used to add files to the playlist using File Explorer.
|
||||
|
||||
#### --command=\<input command\>
|
||||
|
||||
Sends a input command. Useful to control mpv.net from the command line, for instance
|
||||
to create global hotkeys with AutoHotkey, for that [process-instance=single](#--process-instancevalue)
|
||||
must be used. Spaces have to be escaped with quotes and quotes have to be escaped with double quotes.
|
||||
|
||||
### Audio
|
||||
|
||||
#### --remember-volume=\<yes|no\>
|
||||
|
||||
Save volume and mute on exit and restore it on start. Default: yes
|
||||
|
||||
|
||||
### Screen
|
||||
|
||||
#### --start-size=\<value\>
|
||||
|
||||
Setting to remember the window size.
|
||||
|
||||
**video**
|
||||
Window size is set to video resolution.
|
||||
|
||||
**width-session**
|
||||
Width is remembered in the current session.
|
||||
|
||||
**width-always**
|
||||
Width is always remembered.
|
||||
|
||||
**height-session**
|
||||
Height is remembered in the current session. Default
|
||||
|
||||
**height-always**
|
||||
Height is always remembered.
|
||||
|
||||
**always**
|
||||
Size is always remembered.
|
||||
|
||||
|
||||
#### --start-threshold=\<milliseconds\>
|
||||
|
||||
Threshold in milliseconds to wait for libmpv returning the video
|
||||
resolution before the window is shown, otherwise default dimensions
|
||||
are used as defined by autofit and start-size. Default: 1500
|
||||
|
||||
|
||||
#### --minimum-aspect-ratio=\<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
|
||||
|
||||
|
||||
#### --remember-window-position=\<yes|no\>
|
||||
|
||||
Save the window position on exit. Default: no
|
||||
|
||||
|
||||
### Playback
|
||||
|
||||
#### --auto-load-folder=\<yes|no\>
|
||||
|
||||
For single files automatically load the entire directory into the playlist.
|
||||
Can be suppressed via shift key. Default: yes
|
||||
|
||||
|
||||
### General
|
||||
|
||||
#### --update-check=\<yes|no\>
|
||||
|
||||
Daily check for new version. (requires PowerShell 5 and curl.) Default: no
|
||||
|
||||
|
||||
#### --process-instance=\<value\>
|
||||
|
||||
Defines if more then one mpv.net process is allowed.
|
||||
|
||||
Tip: 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 not only works on process startup but in all mpv.net features that open files and URLs.
|
||||
|
||||
**multi**
|
||||
Create a new process everytime the shell starts mpv.net.
|
||||
|
||||
**single**
|
||||
Force a single process everytime the shell starts mpv.net. Default
|
||||
|
||||
**queue**
|
||||
Force a single process and add files to playlist.
|
||||
|
||||
|
||||
#### --recent-count=\<int\>
|
||||
|
||||
Amount of recent files to be remembered. Default: 15
|
||||
|
||||
|
||||
#### --video-file-extensions=\<string\>
|
||||
|
||||
Video file extensions used to create file associations and used by the auto-load-folder feature.
|
||||
|
||||
|
||||
#### --audio-file-extensions=\<string\>
|
||||
|
||||
Audio file extensions used to create file associations and used by the auto-load-folder feature.
|
||||
|
||||
|
||||
#### --image-file-extensions=\<string\>
|
||||
|
||||
Image file extensions used to create file associations and used by the auto-load-folder feature.
|
||||
|
||||
|
||||
#### --debug-mode=\<yes|no\>
|
||||
|
||||
Enable this only when a developer asks for it. Default: no
|
||||
|
||||
|
||||
### UI
|
||||
|
||||
#### --dark-mode=\<value\>
|
||||
|
||||
Enables a dark theme.
|
||||
|
||||
**always**
|
||||
Default
|
||||
|
||||
**system**
|
||||
Available on Windows 10 or higher.
|
||||
|
||||
**never**
|
||||
|
||||
|
||||
#### ---dark-theme=\<string\>
|
||||
|
||||
Color theme used in dark mode. Default: dark
|
||||
|
||||
[Color Themes](#color-theme)
|
||||
|
||||
|
||||
#### --light-theme=\<string\>
|
||||
|
||||
Color theme used in light mode. Default: light
|
||||
|
||||
[Color Themes](#color-theme)
|
||||
|
||||
|
||||
External Tools
|
||||
--------------
|
||||
|
||||
@@ -267,51 +362,28 @@ This will start the app on system start and have it running in the background. W
|
||||
|
||||
### Open With
|
||||
|
||||
Alternatively he Chrome/Firefox extension [Open With](https://github.com/stax76/mpv.net/issues/119) can be used.
|
||||
Alternatively the Chrome/Firefox extension [Open With](../../../issues/119) can be used.
|
||||
|
||||
|
||||
### 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
|
||||
---------
|
||||
|
||||
There is no debugger support available for the scripting hosts, mpv.net can be started from a terminal,
|
||||
script errors and debug messages are printed then on the terminal.
|
||||
|
||||
|
||||
#### Lua
|
||||
|
||||
File Type: `lua`
|
||||
|
||||
Location: `<config folder>\scripts`
|
||||
|
||||
Lua and JavaScript scripts are loaded before the first media file loads.
|
||||
The Lua script host is built into libmpv.
|
||||
|
||||
There is no debugging support, only error and debug messages printed on the terminal.
|
||||
|
||||
Lua scripts are loaded before the first media file loads.
|
||||
|
||||
[mpv Lua documentation](https://mpv.io/manual/master/#lua-scripting)
|
||||
|
||||
@@ -324,7 +396,11 @@ File Type: `js`
|
||||
|
||||
Location: `<config folder>\scripts`
|
||||
|
||||
Lua and JavaScript scripts are loaded before the first media file loads.
|
||||
The JavaScript script host is built into libmpv.
|
||||
|
||||
There is no debugging support, only error and debug messages printed on the terminal.
|
||||
|
||||
JavaScript scripts are loaded before the first media file loads.
|
||||
|
||||
[mpv JavaScript documentation](https://mpv.io/manual/master/#javascript)
|
||||
|
||||
@@ -337,11 +413,13 @@ File Type: `ps1`
|
||||
|
||||
Location: `<config folder>\scripts-ps`
|
||||
|
||||
The PowerShell scripting host is like extensions not initialized before media files are loaded.
|
||||
The PowerShell scripting host is like extensions not
|
||||
initialized before media files are loaded.
|
||||
|
||||
mpv.net does not define scripting interfaces but instead exposed its complete internals, there are no compatibility guaranties.
|
||||
mpv.net does not define scripting interfaces but instead exposed
|
||||
its complete internals, there are no compatibility guaranties.
|
||||
|
||||
[Example Scripts](scripts)
|
||||
[Example Scripts](../../../tree/master/src/Scripts)
|
||||
|
||||
|
||||
#### C#
|
||||
@@ -350,57 +428,61 @@ File Type: `cs`
|
||||
|
||||
Location: `<config folder>\scripts-cs`
|
||||
|
||||
C# scripting in mpv.net is implemented with a C# [extension](#extensions) and [CS-Script](https://www.cs-script.net/).
|
||||
mpv.net does not define scripting interfaces but instead exposed
|
||||
its complete internals, there are no compatibility guaranties.
|
||||
|
||||
mpv.net does not define scripting interfaces but instead exposed its complete internals, there are no compatibility guaranties.
|
||||
Script code can be written within a C# [extension](../../../tree/master/src/Extensions),
|
||||
that way full code completion and debugger support is available.
|
||||
Once the code was developed and debugged, it can be moved
|
||||
from the extension to a lightweight standalone script.
|
||||
|
||||
Script code can be written within a C# [extension](#extensions), that way full code completion and debugger support is available. Once the code was developed and debugged, the code can be moved from the extension to a lightweight standalone script.
|
||||
The C# scripting host is like [extensions](../../../tree/master/src/Extensions)
|
||||
not initialized before media files are loaded.
|
||||
|
||||
The C# scripting host is like [extensions](#extensions) not initialized before media files are loaded.
|
||||
|
||||
[Example Scripts](scripts)
|
||||
[Example Scripts](../../../tree/master/src/Scripts)
|
||||
|
||||
|
||||
Extensions
|
||||
----------
|
||||
|
||||
Extensions are located in a subfolder _extensions_ in the config folder and the filename must have the same name as the directory:
|
||||
Extensions are located in a subfolder _extensions_ in the config folder
|
||||
and the filename must have the same name as the directory:
|
||||
|
||||
```Text
|
||||
<config folder>\extensions\ExampleExtension\ExampleExtension.dll
|
||||
```
|
||||
|
||||
mpv.net does not define extension interfaces but instead exposed its complete internals, there are no compatibility guaranties.
|
||||
mpv.net does not define extension interfaces but instead exposed
|
||||
its complete internals, there are no compatibility guaranties.
|
||||
|
||||
|
||||
### Walkthrough creating an extension
|
||||
|
||||
- Download and install [Visual Studio Community](https://visualstudio.microsoft.com).
|
||||
- Create a new project of type **Class Library .NET Framework** and ensure the project name ends with **Extension**.
|
||||
- Create a new project of type **Class Library .NET Framework**
|
||||
and ensure the project name ends with **Extension**.
|
||||
- Add a reference to **System.ComponentModel.Composition**.
|
||||
- Add a reference to mpvnet.exe, select the mpvnet reference in the Solution Explorer, open the Properties window and set **Copy Local** to false to prevent mpvnet.exe being copied to the output directory when the project is built.
|
||||
- Now open the project properties and set the output path in the Build tab, extensions are like scripts located in your config folder, example: `<config folder>\extensions\ExampleExtension\ExampleExtension.dll`
|
||||
- Also in the project properties choose the option **Start external program** in the Debug tab and define the path to mpvnet.exe. In the Debug tab you may also define command line arguments like a video file to be played when you start debugging.
|
||||
- Add a reference to mpvnet.exe, select the mpvnet reference
|
||||
in the Solution Explorer, open the Properties window and set
|
||||
**Copy Local** to false to prevent mpvnet.exe being copied
|
||||
to the output directory when the project is built.
|
||||
- Now open the project properties and set the output path in the Build tab,
|
||||
extensions are like scripts located in your config folder, example:
|
||||
`<config folder>\extensions\ExampleExtension\ExampleExtension.dll`
|
||||
- Also in the project properties choose the option **Start external program**
|
||||
in the Debug tab and define the path to mpvnet.exe. In the Debug tab you may also
|
||||
define command line arguments like a video file to be played when you start debugging.
|
||||
|
||||
|
||||
### Sample Code
|
||||
|
||||
#### ScriptingExtension
|
||||
|
||||
The ScriptingExtension implements the C# scripting host using [CS-Script](https://www.cs-script.net/).
|
||||
|
||||
I use this extension as well to develop and debug C# scripts. Once the code was developed and debugged, I move the code from the extension to a standalone script.
|
||||
|
||||
[Source Code](extensions)
|
||||
|
||||
|
||||
#### RatingExtension
|
||||
|
||||
This extension writes a rating to the filename of rated videos when mpv.net shuts down.
|
||||
|
||||
The input.conf defaults contain key bindings for this extension to set ratings.
|
||||
|
||||
[Source Code](extensions)
|
||||
[Source Code](../../../tree/master/src/Extensions)
|
||||
|
||||
|
||||
Color Theme
|
||||
@@ -408,7 +490,7 @@ Color Theme
|
||||
|
||||
mpv.net supports custom color themes, the definition of the built-in themes can be found at:
|
||||
|
||||
<https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/theme.txt>
|
||||
[theme.txt](../../../tree/master/src/Resources/theme.txt)
|
||||
|
||||
|
||||
Custom themes can be saved at:
|
||||
@@ -417,7 +499,8 @@ Custom themes can be saved at:
|
||||
|
||||
The theme.conf file may contain an unlimited amount of themes.
|
||||
|
||||
In the config editor under UI there are the settings dark-theme and light-theme to define the themes used in dark and in light mode.
|
||||
In the config editor under UI there are the settings dark-theme and
|
||||
light-theme to define the themes used in dark and in light mode.
|
||||
|
||||
|
||||
Advanced Features
|
||||
@@ -438,45 +521,48 @@ Python and VapourSynth must be in the path environment variable.
|
||||
Hidden Features
|
||||
---------------
|
||||
|
||||
Selecting multiple files in File Explorer and pressing enter will open the files in mpv.net. Explorer restricts this to maximum 15 files and the order will be random.
|
||||
Selecting multiple files in File Explorer and pressing enter will
|
||||
open the files in mpv.net. Explorer restricts this to maximum 15 files
|
||||
and the order will be random.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
|
||||
Differences
|
||||
-----------
|
||||
Differences compared to mpv
|
||||
---------------------------
|
||||
|
||||
mpv.net is designed to work exactly like mpv, there are a few limitations:
|
||||
|
||||
|
||||
### Window Limitations
|
||||
|
||||
mpv.net implements an own main window which means only mpv window features are supported that have an own implementation in mpv.net.
|
||||
mpv.net implements an own main window which means only mpv window
|
||||
features are supported that have an own implementation in mpv.net.
|
||||
|
||||
A window free mode is currently not supported.
|
||||
A window free mode is currently not supported, the main window is always
|
||||
visible, even when mpv.net is started from the terminal and music is played.
|
||||
|
||||
The documentation of mpvs window features can be found here:
|
||||
|
||||
<https://mpv.io/manual/master/#window>
|
||||
https://mpv.io/manual/master/#window
|
||||
|
||||
|
||||
mpv.net has currently implemented the following window features:
|
||||
|
||||
[screen](https://mpv.io/manual/master/#options-screen)
|
||||
|
||||
[fullscreen](https://mpv.io/manual/master/#options-fullscreen)
|
||||
|
||||
[ontop](https://mpv.io/manual/master/#options-ontop)
|
||||
|
||||
[border](https://mpv.io/manual/master/#options-border)
|
||||
|
||||
[window-minimized](https://mpv.io/manual/master/#options-window-minimized)
|
||||
|
||||
[window-maximized](https://mpv.io/manual/master/#options-window-maximized)
|
||||
- [border](https://mpv.io/manual/master/#options-border)
|
||||
- [fullscreen](https://mpv.io/manual/master/#options-fullscreen)
|
||||
- [ontop](https://mpv.io/manual/master/#options-ontop)
|
||||
- [screen](https://mpv.io/manual/master/#options-screen)
|
||||
- [title](https://mpv.io/manual/master/#options-title)
|
||||
- [window-maximized](https://mpv.io/manual/master/#options-window-maximized)
|
||||
- [window-minimized](https://mpv.io/manual/master/#options-window-minimized)
|
||||
|
||||
|
||||
**Partly implemented are:**
|
||||
@@ -490,14 +576,28 @@ mpv.net has currently implemented the following window features:
|
||||
|
||||
### Command Line Limitations
|
||||
|
||||
mpv.net supports only property switches, it does not support non property switches.
|
||||
mpv.net supports property based mpv command line options which means it supports
|
||||
almost all mpv command line options.
|
||||
|
||||
What is not supported are non property bases options. Non property based options
|
||||
need an own implementation in mpv.net, so far implemented are:
|
||||
|
||||
--ad=help
|
||||
--audio-device=help
|
||||
--input-keylist
|
||||
--profile=help
|
||||
--vd=help
|
||||
--version
|
||||
|
||||
|
||||
### mpv.net specific options
|
||||
|
||||
Options that are specific to mpv.net can be found by entering _mpv.net_ in the search field of the config editor.
|
||||
Options that are specific to mpv.net can be found by entering _mpv.net_
|
||||
in the search field of the config editor, in the manual they are documented
|
||||
[here](#mpvnet-specific-options).
|
||||
|
||||
mpv.net specific options are saved in the file mpvnet.conf and are just as mpv properties available on the command line.
|
||||
mpv.net specific options are saved in the file mpvnet.conf and are just
|
||||
as mpv properties available on the command line.
|
||||
|
||||
|
||||
Technical Overview
|
||||
@@ -505,12 +605,14 @@ Technical Overview
|
||||
|
||||
mpv.net is written in C# 7 and runs on the .NET Framework 4.8.
|
||||
|
||||
The Extension implementation is based on the [Managed Extensibility Framework](https://docs.microsoft.com/en-us/dotnet/framework/mef/).
|
||||
The Extension implementation is based on the
|
||||
[Managed Extensibility Framework](https://docs.microsoft.com/en-us/dotnet/framework/mef/).
|
||||
|
||||
The main window is WinForms based because WinForms allows better libmpv integration compared to WPF, all other windows are WPF based.
|
||||
The main window is WinForms based because WinForms allows better libmpv integration
|
||||
compared to WPF, all other windows are WPF based.
|
||||
|
||||
The config editor adds it's controls dynamically and uses [TOML](https://en.wikipedia.org/wiki/TOML) to define it's
|
||||
content.
|
||||
The config editor adds it's controls dynamically and uses
|
||||
[TOML](https://en.wikipedia.org/wiki/TOML) to define it's content.
|
||||
|
||||
|
||||
Third party components are:
|
||||
@@ -518,41 +620,49 @@ Third party components are:
|
||||
- [libmpv provides the core functionality](https://mpv.io/)
|
||||
- [MediaInfo](https://mediaarea.net/en/MediaInfo)
|
||||
- [Tommy, a single file TOML parser](https://github.com/dezhidki/Tommy)
|
||||
- [CS-Script, scripting with C#](http://www.csscript.net/)
|
||||
- [Everything, a fast file search service](https://www.voidtools.com)
|
||||
|
||||
|
||||
Context Menu
|
||||
------------
|
||||
|
||||
The context menu of mpv.net is defined in the file input.conf which is located in the config directory.
|
||||
The context menu of mpv.net is defined in the file input.conf which is
|
||||
located in the config directory.
|
||||
|
||||
If the input.conf file does not exists mpv.net generates it with the following defaults:
|
||||
|
||||
<https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt>
|
||||
<https://github.com/stax76/mpv.net/tree/master/src/Resources/input.conf.txt>
|
||||
|
||||
input.conf defines mpvs key and mouse bindings and mpv.net uses comments to define the context menu.
|
||||
input.conf defines mpvs key and mouse bindings and mpv.net uses
|
||||
comments to define the context menu.
|
||||
|
||||
|
||||
### Open > Open Files
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
Blu-ray and DVD ISO image files are supported.
|
||||
|
||||
|
||||
### Open > Open URL or file path from clipboard
|
||||
|
||||
Opens files and URLs from the clipboard. How to open URLs directly from the browser from sites like YouTube is described in the [External Tools section](#external-tools).
|
||||
Opens files and URLs from the clipboard. How to open URLs directly
|
||||
from the browser from sites like YouTube is described in the
|
||||
[External Tools section](#external-tools).
|
||||
|
||||
For internet streaming youtube-dl must be downloaded and installed manually,
|
||||
meaning it must be located in the PATH environment variable or in the startup directory.
|
||||
|
||||
### Open > Open DVD/Blu-ray Drive/Folder
|
||||
|
||||
@@ -561,17 +671,22 @@ Opens a DVD/Blu-ray Drive/Folder.
|
||||
|
||||
### Open > Show media search
|
||||
|
||||
mpv.net supports system wide media searches using the Everything indexing service installed by the popular file search tool [Everything](www.voidtools.com).
|
||||
mpv.net supports system wide media searches using the Everything indexing
|
||||
service installed by the popular file search tool [Everything](www.voidtools.com).
|
||||
|
||||
|
||||
### Open > Load external audio files
|
||||
|
||||
Allows to load an external audio file. It's also possible to auto detect external audio files based on the file name, the option for this can be found in the settings under 'Settings > Show Config Editor > Audio > audio-file-auto'.
|
||||
Allows to load an external audio file. It's also possible to auto detect
|
||||
external audio files based on the file name, the option for this can be
|
||||
found in the settings under 'Settings > Show Config Editor > Audio > audio-file-auto'.
|
||||
|
||||
|
||||
### Open > Load external subtitle files
|
||||
|
||||
Allows to load an external subtitle file. It's also possible to auto detect external subtitle files based on the file name, the option for this can be found in the settings under 'Settings > Show Config Editor > Subtitles > sub-auto'.
|
||||
Allows to load an external subtitle file. It's also possible to auto detect
|
||||
external subtitle files based on the file name, the option for this can be
|
||||
found in the settings under 'Settings > Show Config Editor > Subtitles > sub-auto'.
|
||||
|
||||
|
||||
### Play/Pause
|
||||
@@ -878,7 +993,7 @@ Cycles the deinterlace property using the following command:
|
||||
|
||||
Cycles the aspect ratio using the following command:
|
||||
|
||||
`cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1"`
|
||||
`cycle-values video-aspect 16:9 4:3 2.35:1 -1`
|
||||
|
||||
[cycle-values command](https://mpv.io/manual/master/#command-interface-cycle-values)
|
||||
|
||||
@@ -1196,8 +1311,14 @@ Shows the command palette window which allows to quickly find and execute comman
|
||||
|
||||
### Tools > Show History
|
||||
|
||||
Shows a text file that contains the file history. If the file don't exist it asks if the file should be created in the settings folder. Once the file exist then the history is logged. It logges the playback history containing the time and filename.
|
||||
Shows a text file that contains the file history. If the file don't exist
|
||||
it asks if the file should be created in the settings folder. Once the file
|
||||
exist then the history is logged. It logges the playback history containing
|
||||
the time and filename.
|
||||
|
||||
To ignore certain paths:
|
||||
|
||||
script-opt = history-discard=path1;path2
|
||||
|
||||
### Tools > Set/clear A-B loop points
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 212 KiB |
|
Before Width: | Height: | Size: 214 KiB After Width: | Height: | Size: 214 KiB |
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.5 MiB |
|
Before Width: | Height: | Size: 628 KiB After Width: | Height: | Size: 628 KiB |
BIN
docs/img/Menu.jpg
Normal file
|
After Width: | Height: | Size: 603 KiB |
|
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
BIN
docs/img/mpvnet-santa.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
@@ -1,66 +0,0 @@
|
||||
// This extension writes a rating to the filename of rated videos when mpv.net shuts down.
|
||||
|
||||
// The input.conf defaults contain key bindings for this extension to set ratings.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using mpvnet;
|
||||
using static mpvnet.Core;
|
||||
|
||||
namespace RatingExtension // the assembly name must end with 'Extension'
|
||||
{
|
||||
[Export(typeof(IExtension))]
|
||||
public class RatingExtension : IExtension
|
||||
{
|
||||
// dictionory to store the filename and the rating
|
||||
Dictionary<string, int> Dic = new Dictionary<string, int>();
|
||||
|
||||
public RatingExtension() // plugin initialization
|
||||
{
|
||||
core.ClientMessage += ClientMessage; //handles keys defined in input.conf
|
||||
core.Shutdown += Shutdown; // handles MPV_EVENT_SHUTDOWN
|
||||
}
|
||||
|
||||
// handles MPV_EVENT_SHUTDOWN
|
||||
void Shutdown()
|
||||
{
|
||||
foreach (var i in Dic)
|
||||
{
|
||||
string filepath = i.Key;
|
||||
int rating = i.Value;
|
||||
if (String.IsNullOrEmpty(filepath) || !File.Exists(filepath))
|
||||
return;
|
||||
string basename = Path.GetFileNameWithoutExtension(filepath);
|
||||
|
||||
for (int x = 0; x < 6; x++)
|
||||
if (basename.Contains(" (" + x + "stars)"))
|
||||
basename = basename.Replace(" (" + x + "stars)", "");
|
||||
|
||||
basename += $" ({rating}stars)";
|
||||
string newPath = Path.Combine(Path.GetDirectoryName(filepath), basename + Path.GetExtension(filepath));
|
||||
if (filepath.ToLower() != newPath.ToLower())
|
||||
File.Move(filepath, newPath);
|
||||
File.SetLastWriteTime(newPath, DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
//handles keys defined in input.conf
|
||||
void ClientMessage(string[] args)
|
||||
{
|
||||
if (args[0] != "rate-file") return;
|
||||
|
||||
if (int.TryParse(args[1], out int rating))
|
||||
{
|
||||
string path = core.get_property_string("path");
|
||||
if (!File.Exists(path)) return;
|
||||
Dic[path] = rating;
|
||||
core.commandv("show-text", $"Rating: {rating}");
|
||||
}
|
||||
else if (args[1] == "about")
|
||||
Msg.Show("Rating Extension", "This extension writes a rating to the filename of rated videos when mpv.net shuts down.\n\nThe input.conf defaults contain key bindings for this extension to set ratings.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("RatingExtension")]
|
||||
[assembly: AssemblyDescription("RatingExtension")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Frank Skare (stax76)")]
|
||||
[assembly: AssemblyProduct("RatingExtension")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2017-2020 Frank Skare (stax76)")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("55c88710-539d-4402-84c8-31694841c731")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,56 +0,0 @@
|
||||
|
||||
// This extension implements the C# scripting feature of mpv.net which
|
||||
// is based on CS-Script (https://www.cs-script.net).
|
||||
|
||||
// I also use this extension to code scripts in order to have full
|
||||
// code completion and debugger support, once the script code is
|
||||
// finished I move it from the extension to a standalone script.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using mpvnet;
|
||||
using CSScriptLibrary;
|
||||
using static mpvnet.Core;
|
||||
|
||||
// the file name of extensions must end with 'Extension'
|
||||
namespace ScriptingExtension
|
||||
{
|
||||
[Export(typeof(IExtension))]
|
||||
public class ScriptingExtension : IExtension
|
||||
{
|
||||
//Script Script;
|
||||
|
||||
public ScriptingExtension()
|
||||
{
|
||||
//Script = new Script();
|
||||
List<string> files = new List<string>();
|
||||
|
||||
if (Directory.Exists(core.ConfigFolder + "scripts-cs"))
|
||||
files.AddRange(Directory.GetFiles(core.ConfigFolder + "scripts-cs", "*.cs"));
|
||||
|
||||
if (Directory.Exists(Folder.Startup + "scripts"))
|
||||
foreach (string path in Directory.GetFiles(Folder.Startup + "scripts", "*.cs"))
|
||||
files.AddRange(Directory.GetFiles(Folder.Startup + "scripts", "*.cs"));
|
||||
|
||||
if (files.Count == 0)
|
||||
return;
|
||||
|
||||
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
try
|
||||
{
|
||||
CSScriptLibrary.CSScript.Evaluator.LoadCode(File.ReadAllText(file));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
App.ShowException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{94255EF2-C823-4D82-9017-0E993CC0F5A1}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ScriptingExtension</RootNamespace>
|
||||
<AssemblyName>ScriptingExtension</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\mpv.net\bin\x86\Extensions\ScriptingExtension\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>..\..\mpv.net\bin\x86\Extensions\ScriptingExtension\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\mpv.net\bin\x64\Extensions\ScriptingExtension\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>..\..\mpv.net\bin\x64\Extensions\ScriptingExtension\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CSScriptLibrary">
|
||||
<HintPath>.\CSScriptLibrary.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ScriptingExtension.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="script.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\mpv.net\mpv.net.csproj">
|
||||
<Project>{1751f378-8edf-4b62-be6d-304c7c287089}</Project>
|
||||
<Name>mpv.net</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,31 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29123.88
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptingExtension", "ScriptingExtension.csproj", "{55C88710-539D-4402-84C8-31694841C731}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.Build.0 = Debug|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.Build.0 = Debug|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.ActiveCfg = Release|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.Build.0 = Release|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.ActiveCfg = Release|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C8A53BF6-B00A-4215-B9D7-801ADB9C8F60}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,19 +0,0 @@
|
||||
|
||||
using System.IO;
|
||||
|
||||
using mpvnet;
|
||||
using static mpvnet.Core;
|
||||
|
||||
class Script
|
||||
{
|
||||
public Script()
|
||||
{
|
||||
core.Shutdown += Shutdown;
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
foreach (string file in Directory.GetFiles(@"C:\Users\frank\Desktop\aaa"))
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
BIN
img/Avatar.png
|
Before Width: | Height: | Size: 11 KiB |
BIN
img/Menu.png
|
Before Width: | Height: | Size: 1.3 MiB |
51
mpv.net.sln
@@ -1,51 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.28729.10
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mpv.net", "mpv.net\mpv.net.csproj", "{1751F378-8EDF-4B62-BE6D-304C7C287089}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RatingExtension", "extensions\RatingExtension\RatingExtension.csproj", "{55C88710-539D-4402-84C8-31694841C731}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptingExtension", "extensions\ScriptingExtension\ScriptingExtension.csproj", "{94255EF2-C823-4D82-9017-0E993CC0F5A1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x64.Build.0 = Debug|x64
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Debug|x86.Build.0 = Debug|x86
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x64.ActiveCfg = Release|x64
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x64.Build.0 = Release|x64
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x86.ActiveCfg = Release|x86
|
||||
{1751F378-8EDF-4B62-BE6D-304C7C287089}.Release|x86.Build.0 = Release|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x64.Build.0 = Debug|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Debug|x86.Build.0 = Debug|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.ActiveCfg = Release|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x64.Build.0 = Release|x64
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.ActiveCfg = Release|x86
|
||||
{55C88710-539D-4402-84C8-31694841C731}.Release|x86.Build.0 = Release|x86
|
||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x64.Build.0 = Debug|x64
|
||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Debug|x86.Build.0 = Debug|x86
|
||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x64.ActiveCfg = Release|x64
|
||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x64.Build.0 = Release|x64
|
||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x86.ActiveCfg = Release|x86
|
||||
{94255EF2-C823-4D82-9017-0E993CC0F5A1}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8DE9E796-619E-44B8-9576-F4DE028701BF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,64 +0,0 @@
|
||||
<UserControl x:Name="OptionSettingControl1" x:Class="DynamicGUI.OptionSettingControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox x:Name="TitleTextBox"
|
||||
FontSize="24"
|
||||
Margin="0,10"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{x:Static UI:Theme.Heading}"
|
||||
Background="{x:Static UI:Theme.Background}" />
|
||||
|
||||
<ItemsControl x:Name="ItemsControl">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<WrapPanel Orientation="Vertical">
|
||||
<RadioButton x:Name="RadioButton"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Checked}"
|
||||
GroupName="{Binding OptionSetting.Name}"
|
||||
Content="{Binding Text}"
|
||||
FontSize="16"
|
||||
FontWeight="Normal"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"/>
|
||||
|
||||
<TextBox x:Name="ItemHelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
Text="{Binding Help}"
|
||||
Visibility="{Binding Visibility}"
|
||||
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}"/>
|
||||
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<TextBox x:Name="HelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Margin="0,10,0,0"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"/>
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,58 +0,0 @@
|
||||
<UserControl x:Name="StringSettingControl1" x:Class="DynamicGUI.StringSettingControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox x:Name="TitleTextBox"
|
||||
FontSize="24"
|
||||
Margin="0,10"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{x:Static UI:Theme.Heading}"
|
||||
Background="{x:Static UI:Theme.Background}"/>
|
||||
|
||||
<Grid Margin="0,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="ValueTextBox"
|
||||
Text="{Binding Path=Text, ElementName=StringSettingControl1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Width="150"
|
||||
Height="20"
|
||||
HorizontalAlignment="Left"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
CaretBrush="{x:Static UI:Theme.Foreground}"
|
||||
TextChanged="ValueTextBox_TextChanged"/>
|
||||
|
||||
<Button x:Name="Button"
|
||||
Height="20"
|
||||
Grid.Column="1"
|
||||
Visibility="{Binding Path=Text, ElementName=StringSettingControl1}"
|
||||
Margin="5,0,0,0"
|
||||
Width="20"
|
||||
Click="Button_Click">...</Button>
|
||||
</Grid>
|
||||
|
||||
<TextBox x:Name="HelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"/>
|
||||
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,32 +0,0 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
public static string FileName(this string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) return "";
|
||||
int index = path.LastIndexOf('\\');
|
||||
if (index > -1) return path.Substring(index + 1);
|
||||
index = path.LastIndexOf('/');
|
||||
if (index > -1) return path.Substring(index + 1);
|
||||
return path;
|
||||
}
|
||||
|
||||
public static string ShortExt(this string path)
|
||||
{
|
||||
return Path.GetExtension(path).ToLower().TrimStart('.');
|
||||
}
|
||||
|
||||
public static int Int(this string value)
|
||||
{
|
||||
int.TryParse(value, out int result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static float Float(this string value)
|
||||
{
|
||||
float.TryParse(value.Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture, out float result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
public static class ConsoleHelp
|
||||
{
|
||||
public static int Padding { get; set; }
|
||||
|
||||
public static void WriteError(object obj, string module = "mpv.net")
|
||||
{
|
||||
Write(obj, module, ConsoleColor.Red, 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)
|
||||
{
|
||||
Write(obj, module, color, false);
|
||||
}
|
||||
|
||||
public static void Write(object obj, string module, ConsoleColor color, bool useDefaultColor)
|
||||
{
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
string value = obj.ToString();
|
||||
|
||||
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();
|
||||
Trace.WriteLine(obj);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
|
||||
using System;
|
||||
|
||||
public static class NewLine
|
||||
{
|
||||
public static string BR = Environment.NewLine;
|
||||
public static string BR2 = Environment.NewLine + Environment.NewLine;
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
|
||||
using System;
|
||||
using Microsoft.Win32;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public class RegistryHelp
|
||||
{
|
||||
public static string ApplicationKey { get; } = @"HKCU\Software\" + Application.ProductName;
|
||||
|
||||
public static void SetValue(string path, string name, object value)
|
||||
{
|
||||
using (RegistryKey regKey = GetRootKey(path).CreateSubKey(path.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree))
|
||||
regKey.SetValue(name, value);
|
||||
}
|
||||
|
||||
public static string GetString(string path, string name, string defaultValue = "")
|
||||
{
|
||||
object value = GetValue(path, name, defaultValue);
|
||||
return !(value is string) ? defaultValue : value.ToString();
|
||||
}
|
||||
|
||||
public static int GetInt(string path, string name, int defaultValue = 0)
|
||||
{
|
||||
object value = GetValue(path, name, defaultValue);
|
||||
return !(value is int) ? defaultValue : (int)value;
|
||||
}
|
||||
|
||||
public static bool GetBool(string path, string name, bool defaultValue = false)
|
||||
{
|
||||
object val = GetValue(path, name, defaultValue);
|
||||
return val is bool ? (bool)val : defaultValue;
|
||||
}
|
||||
|
||||
public static object GetValue(string path, string name, object defaultValue = null)
|
||||
{
|
||||
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5)))
|
||||
return regKey == null ? null : regKey.GetValue(name, defaultValue);
|
||||
}
|
||||
|
||||
public static void RemoveKey(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void RemoveValue(string path, string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5), true))
|
||||
if (regKey != null)
|
||||
regKey.DeleteValue(name, false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
static RegistryKey GetRootKey(string path)
|
||||
{
|
||||
switch (path.Substring(0, 4))
|
||||
{
|
||||
case "HKLM": return Registry.LocalMachine;
|
||||
case "HKCU": return Registry.CurrentUser;
|
||||
case "HKCR": return Registry.ClassesRoot;
|
||||
default: throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class WinAPI
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool AttachConsole(int dwProcessId);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool FreeConsole();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr LoadLibrary(string path);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern int RegisterWindowMessage(string id);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AllowSetForegroundWindow(int dwProcessId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern void ReleaseCapture();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
|
||||
static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
|
||||
static extern IntPtr GetWindowLong64(IntPtr hWnd, int nIndex);
|
||||
|
||||
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
|
||||
{
|
||||
if (IntPtr.Size == 8)
|
||||
return GetWindowLong64(hWnd, nIndex);
|
||||
else
|
||||
return GetWindowLong32(hWnd, nIndex);
|
||||
}
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
public RECT(Rectangle r)
|
||||
{
|
||||
Left = r.Left;
|
||||
Top = r.Top;
|
||||
Right = r.Right;
|
||||
Bottom = r.Bottom;
|
||||
}
|
||||
|
||||
public RECT(int left, int top, int right, int bottom)
|
||||
{
|
||||
Left = left;
|
||||
Top = top;
|
||||
Right = right;
|
||||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public Rectangle ToRectangle() => Rectangle.FromLTRB(Left, Top, Right, Bottom);
|
||||
public Size Size => new Size(Right - Left, Bottom - Top);
|
||||
public int Width => Right - Left;
|
||||
public int Height => Bottom - Top;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct COPYDATASTRUCT
|
||||
{
|
||||
public IntPtr dwData;
|
||||
public int cbData;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string lpData;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public static class NativeHelp
|
||||
{
|
||||
public static int GetResizeBorder(int v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case 1 /* WMSZ_LEFT */ : return 3;
|
||||
case 3 /* WMSZ_TOP */ : return 2;
|
||||
case 2 /* WMSZ_RIGHT */ : return 3;
|
||||
case 6 /* WMSZ_BOTTOM */ : return 2;
|
||||
case 4 /* WMSZ_TOPLEFT */ : return 1;
|
||||
case 5 /* WMSZ_TOPRIGHT */ : return 1;
|
||||
case 7 /* WMSZ_BOTTOMLEFT */ : return 3;
|
||||
case 8 /* WMSZ_BOTTOMRIGHT */: return 3;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SubtractWindowBorders(IntPtr hwnd, ref WinAPI.RECT rc)
|
||||
{
|
||||
var b = new WinAPI.RECT(0, 0, 0, 0);
|
||||
AddWindowBorders(hwnd, ref b);
|
||||
rc.Left -= b.Left;
|
||||
rc.Top -= b.Top;
|
||||
rc.Right -= b.Right;
|
||||
rc.Bottom -= b.Bottom;
|
||||
}
|
||||
|
||||
public static void AddWindowBorders(IntPtr hwnd, ref WinAPI.RECT rc)
|
||||
{
|
||||
WinAPI.AdjustWindowRect(ref rc, (uint)WinAPI.GetWindowLong(hwnd, -16 /* GWL_STYLE */), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,662 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public class Msg
|
||||
{
|
||||
static string ShownMessages;
|
||||
|
||||
public static string SupportURL { get; set; }
|
||||
|
||||
public static void Show(string mainInstruction, string content = null)
|
||||
{
|
||||
Msg.Show(mainInstruction, content, MsgIcon.Info, MsgButtons.Ok, MsgResult.None);
|
||||
}
|
||||
|
||||
public static void ShowError(string mainInstruction, string content = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (TaskDialog<string> td = new TaskDialog<string>())
|
||||
{
|
||||
td.AllowCancel = false;
|
||||
|
||||
if (string.IsNullOrEmpty(content))
|
||||
{
|
||||
if (mainInstruction.Length < 80)
|
||||
td.MainInstruction = mainInstruction;
|
||||
else
|
||||
td.Content = mainInstruction;
|
||||
}
|
||||
else
|
||||
{
|
||||
td.MainInstruction = mainInstruction;
|
||||
td.Content = content;
|
||||
}
|
||||
|
||||
td.MainIcon = MsgIcon.Error;
|
||||
td.Footer = "[Copy Message](copymsg)";
|
||||
|
||||
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
||||
td.Footer += $" [Contact Support]({SupportURL})";
|
||||
|
||||
td.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.GetType().Name + "\n\n" + e.Message + "\n\n" + e,
|
||||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowException(Exception exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (TaskDialog<string> td = new TaskDialog<string>())
|
||||
{
|
||||
td.MainInstruction = exception.GetType().Name;
|
||||
td.Content = exception.Message;
|
||||
td.MainIcon = MsgIcon.Error;
|
||||
td.ExpandedInformation = exception.StackTrace;
|
||||
td.Footer = "[Copy Message](copymsg)";
|
||||
|
||||
if (!string.IsNullOrEmpty(Msg.SupportURL))
|
||||
td.Footer += $" [Contact Support]({SupportURL})";
|
||||
|
||||
td.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowWarning(string mainInstruction,
|
||||
string content = null,
|
||||
bool onlyOnce = false)
|
||||
{
|
||||
if (onlyOnce && Msg.ShownMessages != null &&
|
||||
Msg.ShownMessages.Contains(mainInstruction + content))
|
||||
return;
|
||||
|
||||
Msg.Show(mainInstruction, content, MsgIcon.Warning, MsgButtons.Ok, MsgResult.None);
|
||||
if (!onlyOnce) return;
|
||||
Msg.ShownMessages += mainInstruction + content;
|
||||
}
|
||||
|
||||
public static MsgResult ShowQuestion(
|
||||
string mainInstruction, MsgButtons buttons = MsgButtons.OkCancel)
|
||||
{
|
||||
return Msg.Show(mainInstruction, null, MsgIcon.None, buttons, MsgResult.None);
|
||||
}
|
||||
|
||||
public static MsgResult ShowQuestion(
|
||||
string mainInstruction, string content, MsgButtons buttons = MsgButtons.OkCancel)
|
||||
{
|
||||
return Msg.Show(mainInstruction, content, MsgIcon.None, buttons, MsgResult.None);
|
||||
}
|
||||
|
||||
public static MsgResult Show(
|
||||
string mainInstruction,
|
||||
string content,
|
||||
MsgIcon icon,
|
||||
MsgButtons buttons,
|
||||
MsgResult defaultButton = MsgResult.None)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (TaskDialog<MsgResult> td = new TaskDialog<MsgResult>())
|
||||
{
|
||||
td.AllowCancel = false;
|
||||
td.DefaultButton = defaultButton;
|
||||
td.MainIcon = icon;
|
||||
|
||||
if (content == null)
|
||||
{
|
||||
if (mainInstruction.Length < 80)
|
||||
td.MainInstruction = mainInstruction;
|
||||
else
|
||||
td.Content = mainInstruction;
|
||||
}
|
||||
else
|
||||
{
|
||||
td.MainInstruction = mainInstruction;
|
||||
td.Content = content;
|
||||
}
|
||||
if (buttons == MsgButtons.OkCancel)
|
||||
{
|
||||
td.AddButton("OK", MsgResult.OK);
|
||||
td.AddButton("Cancel", MsgResult.Cancel);
|
||||
}
|
||||
else
|
||||
td.CommonButtons = buttons;
|
||||
return td.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return (MsgResult)MessageBox.Show(e.GetType().Name + "\n\n" + e.Message + "\n\n" + e,
|
||||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TaskDialog<T> : TaskDialogNative, IDisposable
|
||||
{
|
||||
Dictionary<int, T> IdValueDic;
|
||||
Dictionary<int, string> IdTextDic;
|
||||
List<int> CommandLinkShieldList;
|
||||
IntPtr ButtonArray;
|
||||
IntPtr RadioButtonArray;
|
||||
T SelectedValueValue;
|
||||
string SelectedTextValue;
|
||||
int TimeoutValue;
|
||||
int ExitTickCount;
|
||||
bool Disposed;
|
||||
List<TaskDialogNative.TASKDIALOG_BUTTON> Buttons;
|
||||
List<TaskDialogNative.TASKDIALOG_BUTTON> RadioButtons;
|
||||
TaskDialogNative.TASKDIALOGCONFIG Config;
|
||||
|
||||
const int TDE_CONTENT = 0;
|
||||
const int TDE_EXPANDED_INFORMATION = 1;
|
||||
const int TDE_FOOTER = 2;
|
||||
const int TDE_MAIN_INSTRUCTION = 3;
|
||||
const int TDN_CREATED = 0;
|
||||
const int TDN_NAVIGATED = 1;
|
||||
const int TDN_BUTTON_CLICKED = 2;
|
||||
const int TDN_HYPERLINK_CLICKED = 3;
|
||||
const int TDN_TIMER = 4;
|
||||
const int TDN_DESTROYED = 5;
|
||||
const int TDN_RADIO_BUTTON_CLICKED = 6;
|
||||
const int TDN_DIALOG_CONSTRUCTED = 7;
|
||||
const int TDN_VERIFICATION_CLICKED = 8;
|
||||
const int TDN_HELP = 9;
|
||||
const int TDN_EXPANDO_BUTTON_CLICKED = 10;
|
||||
const int TDM_NAVIGATE_PAGE = 1125;
|
||||
const int TDM_CLICK_BUTTON = 1126;
|
||||
const int TDM_SET_MARQUEE_PROGRESS_BAR = 1127;
|
||||
const int TDM_SET_PROGRESS_BAR_STATE = 1128;
|
||||
const int TDM_SET_PROGRESS_BAR_RANGE = 1129;
|
||||
const int TDM_SET_PROGRESS_BAR_POS = 1130;
|
||||
const int TDM_SET_PROGRESS_BAR_MARQUEE = 1131;
|
||||
const int TDM_SET_ELEMENT_TEXT = 1132;
|
||||
const int TDM_CLICK_RADIO_BUTTON = 1134;
|
||||
const int TDM_ENABLE_BUTTON = 1135;
|
||||
const int TDM_ENABLE_RADIO_BUTTON = 1136;
|
||||
const int TDM_CLICK_VERIFICATION = 1137;
|
||||
const int TDM_UPDATE_ELEMENT_TEXT = 1138;
|
||||
const int TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = 1139;
|
||||
const int TDM_UPDATE_ICON = 1140;
|
||||
|
||||
public TaskDialog()
|
||||
{
|
||||
IdValueDic = new Dictionary<int, T>();
|
||||
IdTextDic = new Dictionary<int, string>();
|
||||
CommandLinkShieldList = new List<int>();
|
||||
Buttons = new List<TaskDialogNative.TASKDIALOG_BUTTON>();
|
||||
RadioButtons = new List<TaskDialogNative.TASKDIALOG_BUTTON>();
|
||||
_SelectedID = -1;
|
||||
Config = new TaskDialogNative.TASKDIALOGCONFIG();
|
||||
Config.cbSize = (uint)Marshal.SizeOf(Config);
|
||||
Config.hwndParent = GetHandle();
|
||||
Config.hInstance = IntPtr.Zero;
|
||||
Config.dwFlags = TaskDialogNative.TASKDIALOG_FLAGS.TDF_ALLOW_DIALOG_CANCELLATION;
|
||||
Config.dwCommonButtons = MsgButtons.None;
|
||||
Config.MainIcon = new TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION(0);
|
||||
Config.FooterIcon = new TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION(0);
|
||||
Config.cxWidth = 0U;
|
||||
Config.cButtons = 0U;
|
||||
Config.cRadioButtons = 0U;
|
||||
Config.pButtons = IntPtr.Zero;
|
||||
Config.pRadioButtons = IntPtr.Zero;
|
||||
Config.nDefaultButton = 0;
|
||||
Config.nDefaultRadioButton = 0;
|
||||
Config.pszWindowTitle = ((AssemblyProductAttribute)Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), true)[0]).Product;
|
||||
Config.pszMainInstruction = "";
|
||||
Config.pszContent = "";
|
||||
Config.pfCallback = new PFTASKDIALOGCALLBACK(this.DialogProc);
|
||||
}
|
||||
|
||||
public IntPtr GetHandle()
|
||||
{
|
||||
StringBuilder lpszFileName = new StringBuilder(260);
|
||||
IntPtr foregroundWindow = TaskDialogNative.GetForegroundWindow();
|
||||
TaskDialogNative.GetWindowModuleFileName(foregroundWindow, lpszFileName, 260U);
|
||||
|
||||
if (Path.GetFileName(lpszFileName.ToString().Replace(".vshost", "")) ==
|
||||
Path.GetFileName(Assembly.GetEntryAssembly().Location))
|
||||
|
||||
return foregroundWindow;
|
||||
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
public bool AllowCancel {
|
||||
set {
|
||||
if (value)
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_ALLOW_DIALOG_CANCELLATION;
|
||||
else
|
||||
Config.dwFlags ^= TaskDialogNative.TASKDIALOG_FLAGS.TDF_ALLOW_DIALOG_CANCELLATION;
|
||||
}
|
||||
}
|
||||
|
||||
public string MainInstruction {
|
||||
get => Config.pszMainInstruction;
|
||||
set => Config.pszMainInstruction = value;
|
||||
}
|
||||
|
||||
public string Content {
|
||||
get => Config.pszContent;
|
||||
set => Config.pszContent = ExpandMarkdownMarkup(value);
|
||||
}
|
||||
|
||||
public string ExpandedInformation {
|
||||
get => Config.pszExpandedInformation;
|
||||
set => Config.pszExpandedInformation = ExpandMarkdownMarkup(value);
|
||||
}
|
||||
|
||||
public string VerificationText {
|
||||
get => Config.pszVerificationText;
|
||||
set => Config.pszVerificationText = value;
|
||||
}
|
||||
|
||||
public MsgResult DefaultButton {
|
||||
get => (MsgResult)Config.nDefaultButton;
|
||||
set => Config.nDefaultButton = (int)value;
|
||||
}
|
||||
|
||||
public string Footer {
|
||||
get => Config.pszFooter;
|
||||
set => Config.pszFooter = ExpandMarkdownMarkup(value);
|
||||
}
|
||||
|
||||
public MsgIcon MainIcon {
|
||||
set => Config.MainIcon = new TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION((int)value);
|
||||
}
|
||||
|
||||
int _SelectedID;
|
||||
|
||||
public int SelectedID {
|
||||
get => _SelectedID;
|
||||
set {
|
||||
foreach (var i in IdValueDic)
|
||||
if (i.Key == value)
|
||||
_SelectedID = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T SelectedValue {
|
||||
get {
|
||||
if (IdValueDic.ContainsKey(SelectedID))
|
||||
return IdValueDic[SelectedID];
|
||||
|
||||
return SelectedValueValue;
|
||||
}
|
||||
set => SelectedValueValue = value;
|
||||
}
|
||||
|
||||
public string SelectedText {
|
||||
get {
|
||||
if (IdTextDic.ContainsKey(SelectedID))
|
||||
return IdTextDic[SelectedID];
|
||||
|
||||
return SelectedTextValue;
|
||||
}
|
||||
set => SelectedTextValue = value;
|
||||
}
|
||||
|
||||
public bool CheckBoxChecked {
|
||||
get => (Config.dwFlags & TaskDialogNative.TASKDIALOG_FLAGS.TDF_VERIFICATION_FLAG_CHECKED)
|
||||
== TaskDialogNative.TASKDIALOG_FLAGS.TDF_VERIFICATION_FLAG_CHECKED;
|
||||
set {
|
||||
if (value)
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_VERIFICATION_FLAG_CHECKED;
|
||||
else
|
||||
Config.dwFlags ^= TaskDialogNative.TASKDIALOG_FLAGS.TDF_VERIFICATION_FLAG_CHECKED;
|
||||
}
|
||||
}
|
||||
|
||||
public MsgButtons CommonButtons {
|
||||
get => Config.dwCommonButtons;
|
||||
set => Config.dwCommonButtons = value;
|
||||
}
|
||||
|
||||
public int Timeout {
|
||||
get => Convert.ToInt32(TimeoutValue / 1000.0);
|
||||
set {
|
||||
TimeoutValue = value * 1000;
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_CALLBACK_TIMER;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddButton(string text, T value)
|
||||
{
|
||||
int n = 1000 + IdValueDic.Count + 1;
|
||||
IdValueDic[n] = value;
|
||||
Buttons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
|
||||
}
|
||||
|
||||
public string ExpandMarkdownMarkup(string value)
|
||||
{
|
||||
if (value.Contains("["))
|
||||
{
|
||||
Regex regex = new Regex(@"\[(.+)\]\((.+)\)");
|
||||
|
||||
if (regex.Match(value).Success)
|
||||
{
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_ENABLE_HYPERLINKS;
|
||||
value = regex.Replace(value, "<a href=\"$2\">$1</a>");
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public void AddCommand(string text, T value)
|
||||
{
|
||||
int n = 1000 + IdValueDic.Count + 1;
|
||||
IdValueDic[n] = value;
|
||||
IdTextDic[n] = text;
|
||||
Buttons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_USE_COMMAND_LINKS;
|
||||
}
|
||||
|
||||
public void AddCommand(string text, string description, T value, bool setShield = false)
|
||||
{
|
||||
int n = 1000 + IdValueDic.Count + 1;
|
||||
IdValueDic[n] = value;
|
||||
|
||||
if (setShield)
|
||||
CommandLinkShieldList.Add(n);
|
||||
|
||||
if (!string.IsNullOrEmpty(description))
|
||||
text += "\n" + description;
|
||||
|
||||
Buttons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
|
||||
Config.dwFlags |= TaskDialogNative.TASKDIALOG_FLAGS.TDF_USE_COMMAND_LINKS;
|
||||
}
|
||||
|
||||
public void AddRadioButton(string text, T value)
|
||||
{
|
||||
int n = 1000 + IdValueDic.Count + 1;
|
||||
IdValueDic[n] = value;
|
||||
RadioButtons.Add(new TaskDialogNative.TASKDIALOG_BUTTON(n, text));
|
||||
}
|
||||
|
||||
public T Show()
|
||||
{
|
||||
MarshalDialogControlStructs();
|
||||
TaskDialogNative.TASKDIALOGCONFIG config = Config;
|
||||
int hr = TaskDialogNative.TaskDialogIndirect(
|
||||
config, out int dummy1, out int dummy2, out bool isChecked);
|
||||
|
||||
if (hr < 0)
|
||||
Marshal.ThrowExceptionForHR(hr);
|
||||
|
||||
CheckBoxChecked = isChecked;
|
||||
|
||||
if (SelectedValue is MsgResult)
|
||||
SelectedValue = (T)(object)SelectedID;
|
||||
|
||||
return SelectedValue;
|
||||
}
|
||||
|
||||
public int DialogProc(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam, IntPtr lpRefData)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case 0: //TDN_CREATED
|
||||
foreach (var i in CommandLinkShieldList)
|
||||
SendMessage(hwnd, TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE, new IntPtr(i), new IntPtr(1));
|
||||
break;
|
||||
case 2: //TDN_BUTTON_CLICKED
|
||||
case 6: //TDN_RADIO_BUTTON_CLICKED
|
||||
if (SelectedValue is MsgResult)
|
||||
_SelectedID = wParam.ToInt32();
|
||||
else
|
||||
SelectedID = wParam.ToInt32();
|
||||
break;
|
||||
case 3: //TDN_HYPERLINK_CLICKED
|
||||
string stringUni = Marshal.PtrToStringUni(lParam);
|
||||
|
||||
if (stringUni.StartsWith("mailto") || stringUni.StartsWith("http"))
|
||||
Process.Start(stringUni);
|
||||
|
||||
if (stringUni == "copymsg")
|
||||
{
|
||||
Thread thread = new Thread((ThreadStart)(() => {
|
||||
Clipboard.SetText(MainInstruction + "\r\n\r\n" + Content + "\r\n\r\n" + ExpandedInformation);
|
||||
MessageBox.Show("Message was copied to clipboard.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}));
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
break;
|
||||
case 4: //TDN_TIMER
|
||||
if (ExitTickCount == 0) ExitTickCount = Environment.TickCount + Timeout * 1000;
|
||||
if (Environment.TickCount > ExitTickCount)
|
||||
TaskDialogNative.SendMessage(hwnd, 1126, new IntPtr(1), IntPtr.Zero);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void MarshalDialogControlStructs()
|
||||
{
|
||||
if (Buttons != null && Buttons.Count > 0)
|
||||
{
|
||||
ButtonArray = TaskDialog<T>.AllocateAndMarshalButtons(Buttons);
|
||||
Config.pButtons = ButtonArray;
|
||||
Config.cButtons = (uint)Buttons.Count;
|
||||
}
|
||||
|
||||
if (RadioButtons == null || RadioButtons.Count <= 0) return;
|
||||
RadioButtonArray = TaskDialog<T>.AllocateAndMarshalButtons(RadioButtons);
|
||||
Config.pRadioButtons = RadioButtonArray;
|
||||
Config.cRadioButtons = (uint)RadioButtons.Count;
|
||||
}
|
||||
|
||||
public static IntPtr AllocateAndMarshalButtons(List<TaskDialogNative.TASKDIALOG_BUTTON> structs)
|
||||
{
|
||||
var initialPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(TASKDIALOG_BUTTON)) * structs.Count);
|
||||
var currentPtr = initialPtr;
|
||||
|
||||
foreach (var button in structs)
|
||||
{
|
||||
Marshal.StructureToPtr(button, currentPtr, false);
|
||||
currentPtr = (IntPtr)(currentPtr.ToInt64() + Marshal.SizeOf(button));
|
||||
}
|
||||
|
||||
return initialPtr;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~TaskDialog()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (Disposed)
|
||||
return;
|
||||
|
||||
Disposed = true;
|
||||
|
||||
if (ButtonArray != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(ButtonArray);
|
||||
ButtonArray = IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (RadioButtonArray != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(RadioButtonArray);
|
||||
RadioButtonArray = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public delegate int PFTASKDIALOGCALLBACK(
|
||||
IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam, IntPtr lpRefData);
|
||||
|
||||
public class TaskDialogNative
|
||||
{
|
||||
[DllImport("comctl32", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
public static extern int TaskDialogIndirect(
|
||||
TaskDialogNative.TASKDIALOGCONFIG pTaskConfig,
|
||||
out int pnButton,
|
||||
out int pnRadioButton,
|
||||
out bool pVerificationFlagChecked);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern uint GetWindowModuleFileName(
|
||||
IntPtr hwnd, StringBuilder lpszFileName, uint cchFileNameMax);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr SendMessage(
|
||||
IntPtr handle, int message, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
|
||||
public class TASKDIALOGCONFIG
|
||||
{
|
||||
public uint cbSize;
|
||||
public IntPtr hwndParent;
|
||||
public IntPtr hInstance;
|
||||
public TaskDialogNative.TASKDIALOG_FLAGS dwFlags;
|
||||
public MsgButtons dwCommonButtons;
|
||||
public string pszWindowTitle;
|
||||
public TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION MainIcon;
|
||||
public string pszMainInstruction;
|
||||
public string pszContent;
|
||||
public uint cButtons;
|
||||
public IntPtr pButtons;
|
||||
public int nDefaultButton;
|
||||
public uint cRadioButtons;
|
||||
public IntPtr pRadioButtons;
|
||||
public int nDefaultRadioButton;
|
||||
public string pszVerificationText;
|
||||
public string pszExpandedInformation;
|
||||
public string pszExpandedControlText;
|
||||
public string pszCollapsedControlText;
|
||||
public TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION FooterIcon;
|
||||
public string pszFooter;
|
||||
public PFTASKDIALOGCALLBACK pfCallback;
|
||||
public IntPtr lpCallbackData;
|
||||
public uint cxWidth;
|
||||
}
|
||||
|
||||
public enum TASKDIALOG_FLAGS
|
||||
{
|
||||
NONE = 0,
|
||||
TDF_ENABLE_HYPERLINKS = 1,
|
||||
TDF_USE_HICON_MAIN = 2,
|
||||
TDF_USE_HICON_FOOTER = 4,
|
||||
TDF_ALLOW_DIALOG_CANCELLATION = 8,
|
||||
TDF_USE_COMMAND_LINKS = 16,
|
||||
TDF_USE_COMMAND_LINKS_NO_ICON = 32,
|
||||
TDF_EXPAND_FOOTER_AREA = 64,
|
||||
TDF_EXPANDED_BY_DEFAULT = 128,
|
||||
TDF_VERIFICATION_FLAG_CHECKED = 256,
|
||||
TDF_SHOW_PROGRESS_BAR = 512,
|
||||
TDF_SHOW_MARQUEE_PROGRESS_BAR = 1024,
|
||||
TDF_CALLBACK_TIMER = 2048,
|
||||
TDF_POSITION_RELATIVE_TO_WINDOW = 4096,
|
||||
TDF_RTL_LAYOUT = 8192,
|
||||
TDF_NO_DEFAULT_RADIO_BUTTON = 16384,
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
|
||||
public struct TASKDIALOGCONFIG_ICON_UNION
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public int hMainIcon;
|
||||
[FieldOffset(0)]
|
||||
public int pszIcon;
|
||||
[FieldOffset(0)]
|
||||
public IntPtr spacer;
|
||||
|
||||
public TASKDIALOGCONFIG_ICON_UNION(int i)
|
||||
{
|
||||
this = new TaskDialogNative.TASKDIALOGCONFIG_ICON_UNION();
|
||||
spacer = IntPtr.Zero;
|
||||
pszIcon = 0;
|
||||
hMainIcon = i;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
|
||||
public struct TASKDIALOG_BUTTON
|
||||
{
|
||||
public int nButtonID;
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string pszButtonText;
|
||||
|
||||
public TASKDIALOG_BUTTON(int n, string txt)
|
||||
{
|
||||
this = new TaskDialogNative.TASKDIALOG_BUTTON();
|
||||
nButtonID = n;
|
||||
pszButtonText = txt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum MsgButtons
|
||||
{
|
||||
None = 0,
|
||||
Ok = 1,
|
||||
Yes = 2,
|
||||
No = 4,
|
||||
YesNo = 6,
|
||||
Cancel = 8,
|
||||
OkCancel = 9,
|
||||
YesNoCancel = 14,
|
||||
Retry = 16,
|
||||
RetryCancel = 24,
|
||||
Close = 32,
|
||||
}
|
||||
|
||||
public enum MsgResult
|
||||
{
|
||||
None,
|
||||
OK,
|
||||
Cancel,
|
||||
Abort,
|
||||
Retry,
|
||||
Ignore,
|
||||
Yes,
|
||||
No,
|
||||
}
|
||||
|
||||
public enum MsgIcon
|
||||
{
|
||||
None = 0,
|
||||
SecurityShieldGray = 65527,
|
||||
SecuritySuccess = 65528,
|
||||
SecurityError = 65529,
|
||||
SecurityWarning = 65530,
|
||||
SecurityShieldBlue = 65531,
|
||||
Shield = 65532,
|
||||
Info = 65533,
|
||||
Error = 65534,
|
||||
Warning = 65535,
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if ($args.Length -ne 2) {
|
||||
Write-Host 'Invalid arguments' -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
|
||||
if (-not (Get-Command curl.exe)) {
|
||||
Write-Host 'Error using curl.exe' -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
|
||||
if ($PSVersionTable.PSVersion.Major -lt 5) {
|
||||
Write-Host 'PowerShell 5.1 not found' -ForegroundColor Red
|
||||
exit
|
||||
}
|
||||
|
||||
Add-Type -AssemblyName Microsoft.VisualBasic
|
||||
|
||||
# Delete directory using recycle bin
|
||||
function Remove-Directory($directory) {
|
||||
if (Test-Path $directory) {
|
||||
[Microsoft.VisualBasic.FileIO.FileSystem]::
|
||||
DeleteDirectory($directory, 'OnlyErrorDialogs', 'SendToRecycleBin')
|
||||
}
|
||||
}
|
||||
|
||||
$currentDir = $args[1];
|
||||
|
||||
$targetDir = (Split-Path $currentDir) + "\new version"
|
||||
Remove-Directory $targetDir
|
||||
$targetFile = $targetDir + '.7z'
|
||||
Remove-Item $targetFile -Force -ErrorAction Ignore
|
||||
|
||||
Write-Host 'Download new version' -ForegroundColor Green
|
||||
curl.exe $args[0] --location --output $targetFile
|
||||
if ($LastExitCode) { throw $LastExitCode }
|
||||
|
||||
Write-Host 'Unpack new version' -ForegroundColor Green
|
||||
& ($currentDir + '\7z\7za.exe') x -y $targetFile -o"$targetDir"
|
||||
if ($LastExitCode) { throw $LastExitCode }
|
||||
|
||||
Write-Host 'Delete downloaded file' -ForegroundColor Green
|
||||
Remove-Item $targetFile -Force -Recurse
|
||||
|
||||
$portableConfigDir = $currentDir + '\portable_config'
|
||||
$portableConfigTempDir = (Split-Path $currentDir) + '\portable config dir temp'
|
||||
Remove-Item $portableConfigTempDir -Force -ErrorAction Ignore
|
||||
|
||||
if (Test-Path $portableConfigDir) {
|
||||
Write-Host 'Backup portable config' -ForegroundColor Green
|
||||
Copy-Item $portableConfigDir $portableConfigTempDir -Recurse -Force
|
||||
}
|
||||
|
||||
Write-Host 'Delete current version' -ForegroundColor Green
|
||||
Remove-Directory $currentDir
|
||||
|
||||
Write-Host 'Rename directory' -ForegroundColor Green
|
||||
Rename-Item $targetDir (Split-Path $currentDir -Leaf)
|
||||
|
||||
if (Test-Path $portableConfigTempDir) {
|
||||
Write-Host 'Restore portable config' -ForegroundColor Green
|
||||
Move-Item $portableConfigTempDir $portableConfigDir -Force
|
||||
}
|
||||
|
||||
Write-Host 'Update is complete' -ForegroundColor Green
|
||||
@@ -1,28 +0,0 @@
|
||||
<Window x:Class="mpvnet.AboutWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
Title="About mpv.net"
|
||||
Height="230"
|
||||
Width="400"
|
||||
FontSize="16"
|
||||
ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}">
|
||||
|
||||
<Grid>
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock FontSize="48" HorizontalAlignment="Center" Margin="0,0,0,10">mpv.net</TextBlock>
|
||||
<TextBlock HorizontalAlignment="Center">Copyright (C) 2017-2020 Frank Skare (stax76)</TextBlock>
|
||||
<TextBlock Name="Version" HorizontalAlignment="Center" />
|
||||
<TextBlock Name="mpvVersion" HorizontalAlignment="Center" />
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,20">MIT License</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
using static mpvnet.Core;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public partial class AboutWindow : Window
|
||||
{
|
||||
public AboutWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Version.Text = $"mpv.net Version {System.Windows.Forms.Application.ProductVersion} ({File.GetLastWriteTime(System.Windows.Forms.Application.ExecutablePath).ToShortDateString()})";
|
||||
mpvVersion.Text = $"{core.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})";
|
||||
}
|
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e) => Close();
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e) => Close();
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<Window x:Class="mpvnet.CommandPaletteWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
Title="Command Palette"
|
||||
Height="295"
|
||||
Width="400"
|
||||
FontSize="13"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Loaded="Window_Loaded">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBox Name="FilterTextBox"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI: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}"
|
||||
MouseUp="ListView_MouseUp">
|
||||
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Path}"></TextBlock>
|
||||
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding Input}"
|
||||
HorizontalAlignment="Right"></TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,66 +0,0 @@
|
||||
<Window xmlns:Controls="clr-namespace:Controls" x:Name="ConfWindow1" x:Class="mpvnet.ConfWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
Title="Config Editor"
|
||||
Height="530"
|
||||
Width="700"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Loaded="ConfWindow1_Loaded">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Controls:SearchTextBoxUserControl
|
||||
x:Name="SearchControl"
|
||||
HintText="Find a setting"
|
||||
Width="250"
|
||||
Margin="0,20,0,0"
|
||||
Grid.ColumnSpan="2"/>
|
||||
|
||||
<ScrollViewer Name="MainScrollViewer"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Margin="0,0,0,10">
|
||||
|
||||
<StackPanel x:Name="MainStackPanel"></StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<StackPanel Margin="20,0,0,0" Grid.Row="1">
|
||||
<ListBox Name="FilterListBox"
|
||||
ItemsSource="{Binding FilterStrings}"
|
||||
BorderThickness="0"
|
||||
SelectionChanged="FilterListBox_SelectionChanged"
|
||||
Foreground="{x:Static UI:Theme.Heading}"
|
||||
Background="{x:Static UI:Theme.Background}">
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" FontSize="16" />
|
||||
</DataTemplate>
|
||||
</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>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,44 +0,0 @@
|
||||
<Window x:Class="mpvnet.EverythingWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
Title="Media File Search"
|
||||
FontSize="13"
|
||||
Height="300"
|
||||
Width="600"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Loaded="Window_Loaded">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBox Name="FilterTextBox"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
PreviewKeyDown="FilterTextBox_PreviewKeyDown"
|
||||
TextChanged="FilterTextBox_TextChanged"/>
|
||||
|
||||
<ListView Name="ListView"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
Grid.Row="1"
|
||||
MouseUp="ListView_MouseUp"
|
||||
PreviewKeyDown="ListView_PreviewKeyDown">
|
||||
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
|
||||
</ListView>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,70 +0,0 @@
|
||||
<Window xmlns:Controls="clr-namespace:Controls" x:Class="mpvnet.InputWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
Title="Input Editor"
|
||||
Height="500"
|
||||
Width="750"
|
||||
FontSize="13"
|
||||
ShowInTaskbar="False"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
Loaded="Window_Loaded"
|
||||
Closed="Window_Closed">
|
||||
|
||||
<Window.Resources>
|
||||
<Style x:Key="DataGrid_Font_Centering" 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>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Controls:SearchTextBoxUserControl
|
||||
HintText="Type ? to get help."
|
||||
x:Name="SearchControl"
|
||||
Width="300"
|
||||
Margin="0,20,0,20"
|
||||
Grid.ColumnSpan="2" />
|
||||
|
||||
<DataGrid x:Name="DataGrid"
|
||||
Grid.Row="1"
|
||||
CommandManager.PreviewCanExecute="DataGrid_PreviewCanExecute"
|
||||
AutoGenerateColumns="False"
|
||||
CellStyle="{StaticResource DataGrid_Font_Centering}" >
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Menu" Binding="{Binding Path}"/>
|
||||
|
||||
<DataGridTemplateColumn Header="Input">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button MinHeight="20" Click="ButtonClick">
|
||||
<TextBlock Text="{Binding Input}"></TextBlock>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTextColumn Header="Command" Binding="{Binding Command}" MaxWidth="330" />
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,50 +0,0 @@
|
||||
<Window x:Class="mpvnet.LearnWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
Title="Learn Input"
|
||||
Height="200"
|
||||
Width="400"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
Loaded="Window_Loaded"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
MouseWheel="Window_MouseWheel"
|
||||
MouseUp="Window_MouseUp"
|
||||
MouseDoubleClick="Window_MouseDoubleClick"
|
||||
TextInput="Window_TextInput">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="40" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock x:Name="MenuTextBlock"
|
||||
Grid.ColumnSpan="2"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="16"></TextBlock>
|
||||
|
||||
<TextBlock x:Name="KeyTextBlock"
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="16" />
|
||||
|
||||
<Button x:Name="ConfirmButton" Grid.Row="2" Click="ConfirmButton_Click">Confirm</Button>
|
||||
<Button x:Name="ClearButton" Grid.Row="2" Click="ClearButton_Click" Grid.Column="1">Clear</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,389 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
|
||||
using WinForms = System.Windows.Forms;
|
||||
using static mpvnet.Core;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public partial class LearnWindow : Window
|
||||
{
|
||||
public CommandItem InputItem { get; set; }
|
||||
string NewKey = "";
|
||||
string KeyChar = "";
|
||||
|
||||
public LearnWindow() => InitializeComponent();
|
||||
|
||||
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
WinForms.Message m = new WinForms.Message();
|
||||
m.HWnd = hwnd;
|
||||
m.Msg = msg;
|
||||
m.WParam = wParam;
|
||||
m.LParam = lParam;
|
||||
ProcessKeyEventArgs(ref m);
|
||||
return m.Result;
|
||||
}
|
||||
|
||||
void OnKeyUp(WinForms.KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == WinForms.Keys.ControlKey || e.KeyCode == WinForms.Keys.ShiftKey ||
|
||||
e.KeyCode == WinForms.Keys.Menu || e.KeyCode == WinForms.Keys.None)
|
||||
|
||||
return;
|
||||
|
||||
string text = "";
|
||||
uint charValue = MapVirtualKey((uint)e.KeyCode, 2);
|
||||
|
||||
if (charValue == 0 || (charValue & 1 << 31) == 1 << 31)
|
||||
text = e.KeyCode.ToString().Trim();
|
||||
else
|
||||
try {
|
||||
text = Convert.ToChar(charValue).ToString().ToLower().Trim();
|
||||
} catch {}
|
||||
|
||||
for (int i = 0; i < 13; i++)
|
||||
if ("D" + i == text)
|
||||
text = text.Substring(1);
|
||||
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
text = KeyChar;
|
||||
wasModified = true;
|
||||
}
|
||||
|
||||
if (text == "#") text = "SHARP";
|
||||
|
||||
if (isAlt && !wasModified)
|
||||
text = "ALT+" + text;
|
||||
|
||||
if (isShift && !wasModified)
|
||||
text = "SHIFT+" + text;
|
||||
|
||||
if (isCtrl && !wasModified)
|
||||
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)
|
||||
{
|
||||
int WM_KEYUP = 0x0101, WM_SYSKEYUP = 0x0105, WM_APPCOMMAND = 0x0319;
|
||||
|
||||
if (m.Msg == WM_KEYUP || m.Msg == WM_SYSKEYUP)
|
||||
OnKeyUp(new WinForms.KeyEventArgs((WinForms.Keys)(unchecked((int)(long)m.WParam)) | ModifierKeys));
|
||||
else if (m.Msg == WM_APPCOMMAND)
|
||||
{
|
||||
if (!core.get_property_bool("input-media-keys"))
|
||||
return;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
source.AddHook(new HwndSourceHook(WndProc));
|
||||
SetKey(InputItem.Input);
|
||||
}
|
||||
|
||||
void ConfirmButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InputItem.Input = NewKey;
|
||||
Close();
|
||||
}
|
||||
|
||||
void ClearButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InputItem.Input = "_";
|
||||
Close();
|
||||
}
|
||||
|
||||
void Window_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (e.Delta > 0)
|
||||
SetKey("WHEEL_UP");
|
||||
else
|
||||
SetKey("WHEEL_DOWN");
|
||||
}
|
||||
|
||||
void Window_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
switch (e.ChangedButton)
|
||||
{
|
||||
case MouseButton.Left:
|
||||
if (BlockMBTN_LEFT)
|
||||
BlockMBTN_LEFT = false;
|
||||
else
|
||||
SetKey("MBTN_LEFT");
|
||||
break;
|
||||
case MouseButton.Middle:
|
||||
SetKey("MBTN_MID");
|
||||
break;
|
||||
case MouseButton.XButton1:
|
||||
SetKey("MBTN_BACK");
|
||||
break;
|
||||
case MouseButton.XButton2:
|
||||
SetKey("MBTN_FORWARD");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool BlockMBTN_LEFT;
|
||||
|
||||
void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left)
|
||||
{
|
||||
SetKey("MBTN_LEFT_DBL");
|
||||
BlockMBTN_LEFT = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Window_TextInput(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
KeyChar = e.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<UserControl x:Class="Controls.SearchTextBoxUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Name="SearchTextBoxUserControl1"
|
||||
Background="{x:Static UI: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}" />
|
||||
|
||||
<TextBox Name="SearchTextBox"
|
||||
Height="25"
|
||||
Padding="1,2,0,0"
|
||||
BorderThickness="2"
|
||||
Background="Transparent"
|
||||
TextChanged="SearchTextBox_TextChanged"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
CaretBrush="{x:Static UI:Theme.Foreground}" />
|
||||
|
||||
<Button Name="SearchClearButton"
|
||||
Background="Transparent"
|
||||
HorizontalAlignment="Right"
|
||||
FontFamily="Marlett"
|
||||
FontSize="10"
|
||||
Width="17"
|
||||
Height="17"
|
||||
Margin="2,0,4,0"
|
||||
Visibility="Hidden"
|
||||
Click="SearchClearButton_Click" >r
|
||||
|
||||
<Button.Style>
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Background" Value="{x:Static UI:Theme.Background}"/>
|
||||
<Setter Property="Foreground" Value="{x:Static UI:Theme.Foreground2}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border BorderThickness="1"
|
||||
BorderBrush="{TemplateBinding Foreground}"
|
||||
SnapsToDevicePixels="True">
|
||||
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{x:Static UI:Theme.Heading}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,33 +0,0 @@
|
||||
<Window x:Class="mpvnet.SetupWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:UI="clr-namespace:UI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
Title="mpv.net Setup"
|
||||
FontSize="13"
|
||||
Foreground="{x:Static UI:Theme.Foreground}"
|
||||
Background="{x:Static UI:Theme.Background}"
|
||||
SizeToContent="WidthAndHeight"
|
||||
WindowStartupLocation="CenterOwner" >
|
||||
|
||||
<Window.Resources>
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Padding" Value="10"></Setter>
|
||||
<Setter Property="Margin" Value="5"></Setter>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<StackPanel Margin="10">
|
||||
<Button Name="RegisterVideo" Click="RegisterVideo_Click">Register video file extensions (requires admin rights)</Button>
|
||||
<Button Name="RegisterAudio" Click="RegisterAudio_Click">Register audio file extensions (requires admin rights)</Button>
|
||||
<Button Name="RegisterImage" Click="RegisterImage_Click">Register image file extensions (requires admin rights)</Button>
|
||||
<Button Name="UnregisterFileAssociations" Click="UnregisterFileAssociations_Click">Unregister file extensions (requires admin rights)</Button>
|
||||
<Button Name="AddToPathEnvVar" Click="AddToPathEnvVar_Click">Add mpv.net to Path environment variable</Button>
|
||||
<Button Name="RemoveFromPathEnvVar" Click="RemoveFromPathEnvVar_Click">Remove mpv.net from Path environment variable</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,64 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public partial class SetupWindow : Window
|
||||
{
|
||||
public SetupWindow() => InitializeComponent();
|
||||
|
||||
void RegisterFileAssociations(string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Process proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = WinForms.Application.ExecutablePath;
|
||||
proc.StartInfo.Arguments = "--reg-file-assoc " + value;
|
||||
proc.StartInfo.Verb = "runas";
|
||||
proc.Start();
|
||||
}
|
||||
|
||||
Process.Start("ms-settings:defaultapps");
|
||||
} catch {}
|
||||
}
|
||||
|
||||
void RegisterVideo_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("video");
|
||||
void RegisterAudio_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("audio");
|
||||
void RegisterImage_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("image");
|
||||
|
||||
void UnregisterFileAssociations_Click(object sender, RoutedEventArgs e) => RegisterFileAssociations("unreg");
|
||||
|
||||
void AddToPathEnvVar_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string var = WinForms.Application.StartupPath + ";";
|
||||
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User);
|
||||
|
||||
if (path.Contains(var))
|
||||
Msg.ShowWarning("Path was already containing mpv.net.");
|
||||
else
|
||||
{
|
||||
Environment.SetEnvironmentVariable("Path", var + path, EnvironmentVariableTarget.User);
|
||||
Msg.Show("mpv.net was successfully added to Path.", (var + path).Replace(";","\n"));
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveFromPathEnvVar_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string var = WinForms.Application.StartupPath + ";";
|
||||
string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User);
|
||||
|
||||
if (path.Contains(var))
|
||||
{
|
||||
Environment.SetEnvironmentVariable("Path", path.Replace(var, ""), EnvironmentVariableTarget.User);
|
||||
Msg.Show("mpv.net was successfully removed from Path.");
|
||||
}
|
||||
else
|
||||
Msg.ShowWarning("Path was not containing mpv.net.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,851 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using UI;
|
||||
using static mpvnet.Core;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
public static MainForm Instance { get; set; }
|
||||
public static IntPtr Hwnd { get; set; }
|
||||
public new ContextMenuStripEx ContextMenu { get; set; }
|
||||
Point LastCursorPosition;
|
||||
int LastCursorChanged;
|
||||
int LastCycleFullscreen;
|
||||
int TaskbarButtonCreatedMessage;
|
||||
int ShownTickCount;
|
||||
|
||||
Taskbar Taskbar;
|
||||
List<string> RecentFiles;
|
||||
bool WasMaximized;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
try
|
||||
{
|
||||
object recent = RegistryHelp.GetValue(App.RegPath, "Recent");
|
||||
|
||||
if (recent is string[] r)
|
||||
RecentFiles = new List<string>(r);
|
||||
else
|
||||
RecentFiles = new List<string>();
|
||||
|
||||
Instance = this;
|
||||
Hwnd = Handle;
|
||||
ConsoleHelp.Padding = 60;
|
||||
core.Init();
|
||||
|
||||
core.Shutdown += Shutdown;
|
||||
core.VideoSizeChanged += VideoSizeChanged;
|
||||
core.FileLoaded += FileLoaded;
|
||||
core.Idle += Idle;
|
||||
core.Seek += () => UpdateProgressBar();
|
||||
|
||||
core.observe_property("window-maximized", PropChangeWindowMaximized);
|
||||
core.observe_property("window-minimized", PropChangeWindowMinimized);
|
||||
core.observe_property_bool("pause", PropChangePause);
|
||||
core.observe_property_bool("fullscreen", PropChangeFullscreen);
|
||||
core.observe_property_bool("ontop", PropChangeOnTop);
|
||||
core.observe_property_bool("border", PropChangeBorder);
|
||||
|
||||
core.observe_property_string("sid", PropChangeSid);
|
||||
core.observe_property_string("aid", PropChangeAid);
|
||||
core.observe_property_string("vid", PropChangeVid);
|
||||
|
||||
core.observe_property_int("edition", PropChangeEdition);
|
||||
core.observe_property_double("window-scale", PropChangeWindowScale);
|
||||
|
||||
if (core.GPUAPI != "vulkan")
|
||||
core.ProcessCommandLine(false);
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += (sender, e) => App.ShowException(e.ExceptionObject);
|
||||
Application.ThreadException += (sender, e) => App.ShowException(e.Exception);
|
||||
Msg.SupportURL = "https://github.com/stax76/mpv.net#support";
|
||||
Text = "mpv.net " + Application.ProductVersion;
|
||||
TaskbarButtonCreatedMessage = WinAPI.RegisterWindowMessage("TaskbarButtonCreated");
|
||||
|
||||
ContextMenu = new ContextMenuStripEx(components);
|
||||
ContextMenu.Opened += ContextMenu_Opened;
|
||||
ContextMenu.Opening += ContextMenu_Opening;
|
||||
|
||||
if (core.Screen == -1)
|
||||
core.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
|
||||
|
||||
int targetIndex = core.Screen;
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
|
||||
if (targetIndex < 0)
|
||||
targetIndex = 0;
|
||||
|
||||
if (targetIndex > screens.Length - 1)
|
||||
targetIndex = screens.Length - 1;
|
||||
|
||||
Screen screen = screens[Array.IndexOf(screens, screens[targetIndex])];
|
||||
Rectangle target = screen.Bounds;
|
||||
Left = target.X + (target.Width - Width) / 2;
|
||||
Top = target.Y + (target.Height - Height) / 2;
|
||||
|
||||
if (!core.Border)
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
|
||||
int posX = RegistryHelp.GetInt(App.RegPath, "PosX");
|
||||
int posY = RegistryHelp.GetInt(App.RegPath, "PosY");
|
||||
|
||||
if (posX != 0 && posY != 0 && App.RememberPosition)
|
||||
{
|
||||
Left = posX - Width / 2;
|
||||
Top = posY - Height / 2;
|
||||
}
|
||||
|
||||
if (core.WindowMaximized)
|
||||
{
|
||||
SetFormPosAndSize(1, true);
|
||||
WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
|
||||
if (core.WindowMinimized)
|
||||
{
|
||||
SetFormPosAndSize(1, true);
|
||||
WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Msg.ShowException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public MenuItem FindMenuItem(string text) => FindMenuItem(text, ContextMenu.Items);
|
||||
|
||||
void Shutdown() => BeginInvoke(new Action(() => Close()));
|
||||
|
||||
void Idle()
|
||||
{
|
||||
BeginInvoke(new Action(() => Text = "mpv.net " + Application.ProductVersion));
|
||||
}
|
||||
|
||||
bool WasShown() => ShownTickCount != 0 && Environment.TickCount > ShownTickCount + 500;
|
||||
|
||||
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
|
||||
|
||||
void VideoSizeChanged() => BeginInvoke(new Action(() => SetFormPosAndSize()));
|
||||
|
||||
void PropChangeFullscreen(bool value) => BeginInvoke(new Action(() => CycleFullscreen(value)));
|
||||
|
||||
void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
|
||||
|
||||
bool IsFullscreen => WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None;
|
||||
|
||||
bool IsMouseInOSC()
|
||||
{
|
||||
Point pos = PointToClient(Control.MousePosition);
|
||||
float top = 0;
|
||||
|
||||
if (FormBorderStyle == FormBorderStyle.None)
|
||||
top = ClientSize.Height * 0.1f;
|
||||
|
||||
return pos.Y > ClientSize.Height * 0.85 || pos.Y < top;
|
||||
}
|
||||
|
||||
void ContextMenu_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
lock (core.MediaTracks)
|
||||
{
|
||||
MenuItem trackMenuItem = FindMenuItem("Track");
|
||||
|
||||
if (trackMenuItem != null)
|
||||
{
|
||||
trackMenuItem.DropDownItems.Clear();
|
||||
|
||||
MediaTrack[] audTracks = core.MediaTracks.Where(track => track.Type == "a").ToArray();
|
||||
MediaTrack[] subTracks = core.MediaTracks.Where(track => track.Type == "s").ToArray();
|
||||
MediaTrack[] vidTracks = core.MediaTracks.Where(track => track.Type == "v").ToArray();
|
||||
MediaTrack[] ediTracks = core.MediaTracks.Where(track => track.Type == "e").ToArray();
|
||||
|
||||
foreach (MediaTrack track in vidTracks)
|
||||
{
|
||||
MenuItem mi = new MenuItem(track.Text);
|
||||
mi.Action = () => core.commandv("set", "vid", track.ID.ToString());
|
||||
mi.Checked = core.Vid == track.ID.ToString();
|
||||
trackMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
|
||||
if (vidTracks.Length > 0)
|
||||
trackMenuItem.DropDownItems.Add(new ToolStripSeparator());
|
||||
|
||||
foreach (MediaTrack track in audTracks)
|
||||
{
|
||||
MenuItem mi = new MenuItem(track.Text);
|
||||
mi.Action = () => core.commandv("set", "aid", track.ID.ToString());
|
||||
mi.Checked = core.Aid == track.ID.ToString();
|
||||
trackMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
|
||||
if (subTracks.Length > 0)
|
||||
trackMenuItem.DropDownItems.Add(new ToolStripSeparator());
|
||||
|
||||
foreach (MediaTrack track in subTracks)
|
||||
{
|
||||
MenuItem mi = new MenuItem(track.Text);
|
||||
mi.Action = () => core.commandv("set", "sid", track.ID.ToString());
|
||||
mi.Checked = core.Sid == track.ID.ToString();
|
||||
trackMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
|
||||
if (subTracks.Length > 0)
|
||||
{
|
||||
MenuItem mi = new MenuItem("S: No subtitles");
|
||||
mi.Action = () => core.commandv("set", "sid", "no");
|
||||
mi.Checked = core.Sid == "no";
|
||||
trackMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
|
||||
if (ediTracks.Length > 0)
|
||||
trackMenuItem.DropDownItems.Add(new ToolStripSeparator());
|
||||
|
||||
foreach (MediaTrack track in ediTracks)
|
||||
{
|
||||
MenuItem mi = new MenuItem(track.Text);
|
||||
mi.Action = () => core.commandv("set", "edition", track.ID.ToString());
|
||||
mi.Checked = core.Edition == track.ID;
|
||||
trackMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lock (core.Chapters)
|
||||
{
|
||||
MenuItem chaptersMenuItem = FindMenuItem("Chapters");
|
||||
|
||||
if (chaptersMenuItem != null)
|
||||
{
|
||||
chaptersMenuItem.DropDownItems.Clear();
|
||||
|
||||
foreach (var i in core.Chapters)
|
||||
{
|
||||
MenuItem mi = new MenuItem(i.Key);
|
||||
mi.ShortcutKeyDisplayString = TimeSpan.FromSeconds(i.Value).ToString().Substring(0, 8) + " ";
|
||||
mi.Action = () => core.commandv("seek", i.Value.ToString(CultureInfo.InvariantCulture), "absolute");
|
||||
chaptersMenuItem.DropDownItems.Add(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem recent = FindMenuItem("Recent");
|
||||
|
||||
if (recent != null)
|
||||
{
|
||||
recent.DropDownItems.Clear();
|
||||
|
||||
foreach (string path in RecentFiles)
|
||||
MenuItem.Add(recent.DropDownItems, path, () => core.LoadFiles(new[] { path }, true, Control.ModifierKeys.HasFlag(Keys.Control)));
|
||||
|
||||
recent.DropDownItems.Add(new ToolStripSeparator());
|
||||
MenuItem mi = new MenuItem("Clear List");
|
||||
mi.Action = () => RecentFiles.Clear();
|
||||
recent.DropDownItems.Add(mi);
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem FindMenuItem(string text, ToolStripItemCollection items)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item is MenuItem mi)
|
||||
{
|
||||
if (mi.Text.StartsWith(text) && mi.Text.Trim() == text)
|
||||
return mi;
|
||||
|
||||
if (mi.DropDownItems.Count > 0)
|
||||
{
|
||||
MenuItem val = FindMenuItem(text, mi.DropDownItems);
|
||||
if (val != null) return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void SetFormPosAndSize(double scale = 1, bool force = false)
|
||||
{
|
||||
if (!force)
|
||||
{
|
||||
if (WindowState != FormWindowState.Normal)
|
||||
return;
|
||||
|
||||
if (core.Fullscreen)
|
||||
{
|
||||
CycleFullscreen(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Screen screen = Screen.FromControl(this);
|
||||
int autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * core.Autofit);
|
||||
|
||||
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);
|
||||
|
||||
Size videoSize = core.VideoSize;
|
||||
int height = videoSize.Height;
|
||||
|
||||
if (core.WasInitialSizeSet || scale != 1)
|
||||
height = ClientSize.Height;
|
||||
else
|
||||
{
|
||||
int savedHeight = RegistryHelp.GetInt(App.RegPath, "Height");
|
||||
|
||||
if (App.StartSize == "always" && savedHeight != 0)
|
||||
height = savedHeight;
|
||||
else
|
||||
if (App.StartSize != "video")
|
||||
height = autoFitHeight;
|
||||
|
||||
core.WasInitialSizeSet = true;
|
||||
}
|
||||
|
||||
height = Convert.ToInt32(height * scale);
|
||||
int width = Convert.ToInt32(height * videoSize.Width / (double)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);
|
||||
}
|
||||
|
||||
if (height > maxHeight * core.AutofitLarger)
|
||||
{
|
||||
height = Convert.ToInt32(maxHeight * core.AutofitLarger);
|
||||
width = Convert.ToInt32(height * videoSize.Width / (double)videoSize.Height);
|
||||
}
|
||||
|
||||
if (width > maxWidth)
|
||||
{
|
||||
width = maxWidth;
|
||||
height = Convert.ToInt32(width * videoSize.Height / (double)videoSize.Width);
|
||||
}
|
||||
|
||||
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
||||
var rect = new WinAPI.RECT(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
|
||||
NativeHelp.AddWindowBorders(Handle, ref rect);
|
||||
int left = middlePos.X - rect.Width / 2;
|
||||
int top = middlePos.Y - rect.Height / 2;
|
||||
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
int minLeft = screens.Select(val => val.WorkingArea.X).Min();
|
||||
int maxRight = screens.Select(val => val.WorkingArea.Right).Max();
|
||||
int minTop = screens.Select(val => val.WorkingArea.Y).Min();
|
||||
int maxBottom = screens.Select(val => val.WorkingArea.Bottom).Max();
|
||||
|
||||
if (left < minLeft)
|
||||
left = minLeft;
|
||||
|
||||
if (left + rect.Width > maxRight)
|
||||
left = maxRight - rect.Width;
|
||||
|
||||
if (top < minTop)
|
||||
top = minTop;
|
||||
|
||||
if (top + rect.Height > maxBottom)
|
||||
top = maxBottom - rect.Height;
|
||||
|
||||
WinAPI.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */,
|
||||
left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||
}
|
||||
|
||||
public void CycleFullscreen(bool enabled)
|
||||
{
|
||||
LastCycleFullscreen = Environment.TickCount;
|
||||
core.Fullscreen = enabled;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
if (WindowState != FormWindowState.Maximized || FormBorderStyle != FormBorderStyle.None)
|
||||
{
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
WindowState = FormWindowState.Maximized;
|
||||
|
||||
if (WasMaximized)
|
||||
{
|
||||
Rectangle b = Screen.FromControl(this).Bounds;
|
||||
uint SWP_SHOWWINDOW = 0x0040;
|
||||
IntPtr HWND_TOP= IntPtr.Zero;
|
||||
WinAPI.SetWindowPos(Handle, HWND_TOP, b.X, b.Y, b.Width, b.Height, SWP_SHOWWINDOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WindowState == FormWindowState.Maximized && FormBorderStyle == FormBorderStyle.None)
|
||||
{
|
||||
if (WasMaximized)
|
||||
WindowState = FormWindowState.Maximized;
|
||||
else
|
||||
WindowState = FormWindowState.Normal;
|
||||
|
||||
if (core.Border)
|
||||
FormBorderStyle = FormBorderStyle.Sizable;
|
||||
else
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
|
||||
SetFormPosAndSize();
|
||||
SaveWindowProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildMenu()
|
||||
{
|
||||
string content = File.ReadAllText(core.InputConfPath);
|
||||
var items = CommandItem.GetItems(content);
|
||||
|
||||
if (!content.Contains("#menu:"))
|
||||
{
|
||||
var defaultItems = CommandItem.GetItems(Properties.Resources.input_conf);
|
||||
|
||||
foreach (CommandItem item in items)
|
||||
foreach (CommandItem defaultItem in defaultItems)
|
||||
if (item.Command == defaultItem.Command)
|
||||
defaultItem.Input = item.Input;
|
||||
|
||||
items = defaultItems;
|
||||
}
|
||||
|
||||
foreach (CommandItem item in items)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.Path))
|
||||
continue;
|
||||
|
||||
string path = item.Path.Replace("&", "&&");
|
||||
|
||||
MenuItem menuItem = ContextMenu.Add(path, () => {
|
||||
try {
|
||||
core.command(item.Command);
|
||||
} catch (Exception ex) {
|
||||
Msg.ShowException(ex);
|
||||
}
|
||||
});
|
||||
|
||||
if (menuItem != null)
|
||||
menuItem.ShortcutKeyDisplayString = item.Input + " ";
|
||||
}
|
||||
}
|
||||
|
||||
void FileLoaded()
|
||||
{
|
||||
string path = core.get_property_string("path");
|
||||
|
||||
BeginInvoke(new Action(() => {
|
||||
if (path.Contains("://"))
|
||||
Text = core.get_property_string("media-title") + " - mpv.net " + Application.ProductVersion;
|
||||
else if (path.Contains(":\\") || path.StartsWith("\\\\"))
|
||||
Text = path.FileName() + " - mpv.net " + Application.ProductVersion;
|
||||
else
|
||||
Text = "mpv.net " + Application.ProductVersion;
|
||||
|
||||
int interval = (int)(core.Duration.TotalMilliseconds / 100);
|
||||
|
||||
if (interval < 100)
|
||||
interval = 100;
|
||||
|
||||
if (interval > 1000)
|
||||
interval = 1000;
|
||||
|
||||
ProgressTimer.Interval = interval;
|
||||
UpdateProgressBar();
|
||||
}));
|
||||
|
||||
if (RecentFiles.Contains(path))
|
||||
RecentFiles.Remove(path);
|
||||
|
||||
RecentFiles.Insert(0, path);
|
||||
|
||||
while (RecentFiles.Count > App.RecentCount)
|
||||
RecentFiles.RemoveAt(App.RecentCount);
|
||||
}
|
||||
|
||||
void SaveWindowProperties()
|
||||
{
|
||||
if (WindowState == FormWindowState.Normal)
|
||||
{
|
||||
RegistryHelp.SetValue(App.RegPath, "PosX", Left + Width / 2);
|
||||
RegistryHelp.SetValue(App.RegPath, "PosY", Top + Height / 2);
|
||||
RegistryHelp.SetValue(App.RegPath, "Height", ClientSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
protected override CreateParams CreateParams {
|
||||
get {
|
||||
CreateParams cp = base.CreateParams;
|
||||
cp.Style |= 0x00020000 /* WS_MINIMIZEBOX */;
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
//Debug.WriteLine(m);
|
||||
|
||||
switch (m.Msg)
|
||||
{
|
||||
case 0x201: // WM_LBUTTONDOWN
|
||||
case 0x202: // WM_LBUTTONUP
|
||||
case 0x207: // WM_MBUTTONDOWN
|
||||
case 0x208: // WM_MBUTTONUP
|
||||
case 0x20b: // WM_XBUTTONDOWN
|
||||
case 0x20c: // WM_XBUTTONUP
|
||||
case 0x20A: // WM_MOUSEWHEEL
|
||||
case 0x100: // WM_KEYDOWN
|
||||
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);
|
||||
|
||||
if (m.Msg == 0x319) // WM_APPCOMMAND
|
||||
return;
|
||||
break;
|
||||
case 0x0200: // WM_MOUSEMOVE
|
||||
if (Environment.TickCount - LastCycleFullscreen > 500)
|
||||
{
|
||||
Point pos = PointToClient(Cursor.Position);
|
||||
core.command($"mouse {pos.X} {pos.Y}");
|
||||
}
|
||||
|
||||
if (CursorHelp.IsPosDifferent(LastCursorPosition))
|
||||
CursorHelp.Show();
|
||||
break;
|
||||
case 0x2a3: // WM_MOUSELEAVE
|
||||
//osc won't auto hide after mouse left window in borderless mode
|
||||
core.command($"mouse {ClientSize.Width / 2} {ClientSize.Height / 3}");
|
||||
break;
|
||||
case 0x203: // WM_LBUTTONDBLCLK
|
||||
{
|
||||
Point pos = PointToClient(Cursor.Position);
|
||||
core.command($"mouse {pos.X} {pos.Y} 0 double");
|
||||
}
|
||||
break;
|
||||
case 0x02E0: // WM_DPICHANGED
|
||||
{
|
||||
if (!WasShown())
|
||||
break;
|
||||
|
||||
WinAPI.RECT rect = Marshal.PtrToStructure<WinAPI.RECT>(m.LParam);
|
||||
WinAPI.SetWindowPos(Handle, IntPtr.Zero, rect.Left, rect.Top, rect.Width, rect.Height, 0);
|
||||
}
|
||||
break;
|
||||
case 0x0214: // WM_SIZING
|
||||
{
|
||||
var rc = Marshal.PtrToStructure<WinAPI.RECT>(m.LParam);
|
||||
var r = rc;
|
||||
NativeHelp.SubtractWindowBorders(Handle, ref r);
|
||||
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
|
||||
Size s = core.VideoSize;
|
||||
|
||||
if (s == Size.Empty)
|
||||
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_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());
|
||||
|
||||
if (corner >= 0)
|
||||
corners[corner] -= d_corners[corner];
|
||||
|
||||
Marshal.StructureToPtr<WinAPI.RECT>(new WinAPI.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
|
||||
m.Result = new IntPtr(1);
|
||||
}
|
||||
return;
|
||||
case 0x004A: // WM_COPYDATA
|
||||
{
|
||||
var copyData = (WinAPI.COPYDATASTRUCT)m.GetLParam(typeof(WinAPI.COPYDATASTRUCT));
|
||||
string[] files = copyData.lpData.Split('\n');
|
||||
string mode = files[0];
|
||||
files = files.Skip(1).ToArray();
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case "single":
|
||||
core.LoadFiles(files, true, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
break;
|
||||
case "queue":
|
||||
foreach (string file in files)
|
||||
core.commandv("loadfile", file, "append");
|
||||
break;
|
||||
}
|
||||
|
||||
Activate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (m.Msg == TaskbarButtonCreatedMessage && core.TaskbarProgress)
|
||||
{
|
||||
Taskbar = new Taskbar(Handle);
|
||||
ProgressTimer.Start();
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
void CursorTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (CursorHelp.IsPosDifferent(LastCursorPosition))
|
||||
{
|
||||
LastCursorPosition = Control.MousePosition;
|
||||
LastCursorChanged = Environment.TickCount;
|
||||
}
|
||||
else if (Environment.TickCount - LastCursorChanged > 1500 &&
|
||||
!IsMouseInOSC() && ClientRectangle.Contains(PointToClient(MousePosition)) &&
|
||||
Form.ActiveForm == this && !ContextMenu.Visible)
|
||||
|
||||
CursorHelp.Hide();
|
||||
}
|
||||
|
||||
void ProgressTimer_Tick(object sender, EventArgs e) => UpdateProgressBar();
|
||||
|
||||
void UpdateProgressBar()
|
||||
{
|
||||
if (core.TaskbarProgress && Taskbar != null)
|
||||
Taskbar.SetValue(core.get_property_number("time-pos"), core.Duration.TotalSeconds);
|
||||
}
|
||||
|
||||
void PropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value));
|
||||
|
||||
void PropChangeAid(string value) => core.Aid = value;
|
||||
|
||||
void PropChangeSid(string value) => core.Sid = value;
|
||||
|
||||
void PropChangeVid(string value) => core.Vid = value;
|
||||
|
||||
void PropChangeEdition(int value) => core.Edition = value;
|
||||
|
||||
void PropChangeWindowScale(double value)
|
||||
{
|
||||
if (value != 1)
|
||||
{
|
||||
BeginInvoke(new Action(() => SetFormPosAndSize(value)));
|
||||
core.command("no-osd set window-scale 1");
|
||||
}
|
||||
}
|
||||
|
||||
void PropChangeWindowMaximized()
|
||||
{
|
||||
if (!WasShown())
|
||||
return;
|
||||
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
core.WindowMaximized = core.get_property_bool("window-maximized");
|
||||
|
||||
if (core.WindowMaximized && WindowState != FormWindowState.Maximized)
|
||||
WindowState = FormWindowState.Maximized;
|
||||
else if (!core.WindowMaximized && WindowState == FormWindowState.Maximized)
|
||||
WindowState = FormWindowState.Normal;
|
||||
}));
|
||||
}
|
||||
|
||||
void PropChangeWindowMinimized()
|
||||
{
|
||||
if (!WasShown())
|
||||
return;
|
||||
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
core.WindowMinimized = core.get_property_bool("window-minimized");
|
||||
|
||||
if (core.WindowMinimized && WindowState != FormWindowState.Minimized)
|
||||
WindowState = FormWindowState.Minimized;
|
||||
else if (!core.WindowMinimized && WindowState == FormWindowState.Minimized)
|
||||
WindowState = FormWindowState.Normal;
|
||||
}));
|
||||
}
|
||||
|
||||
void PropChangeBorder(bool enabled) {
|
||||
core.Border = enabled;
|
||||
|
||||
BeginInvoke(new Action(() => {
|
||||
if (!IsFullscreen)
|
||||
{
|
||||
if (core.Border && FormBorderStyle == FormBorderStyle.None)
|
||||
FormBorderStyle = FormBorderStyle.Sizable;
|
||||
|
||||
if (!core.Border && FormBorderStyle == FormBorderStyle.Sizable)
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void PropChangePause(bool enabled)
|
||||
{
|
||||
if (Taskbar != null && core.TaskbarProgress)
|
||||
{
|
||||
if (enabled)
|
||||
Taskbar.SetState(TaskbarStates.Paused);
|
||||
else
|
||||
Taskbar.SetState(TaskbarStates.Normal);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
if (core.GPUAPI != "vulkan")
|
||||
core.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold);
|
||||
|
||||
LastCycleFullscreen = Environment.TickCount;
|
||||
SetFormPosAndSize();
|
||||
}
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
|
||||
if (core.GPUAPI == "vulkan")
|
||||
core.ProcessCommandLine(false);
|
||||
|
||||
ToolStripRendererEx.ForegroundColor = Theme.Current.GetWinFormsColor("menu-foreground");
|
||||
ToolStripRendererEx.BackgroundColor = Theme.Current.GetWinFormsColor("menu-background");
|
||||
ToolStripRendererEx.SelectionColor = Theme.Current.GetWinFormsColor("menu-highlight");
|
||||
ToolStripRendererEx.BorderColor = Theme.Current.GetWinFormsColor("menu-border");
|
||||
ToolStripRendererEx.CheckedColor = Theme.Current.GetWinFormsColor("menu-checked");
|
||||
|
||||
BuildMenu();
|
||||
ContextMenuStrip = ContextMenu;
|
||||
WPF.WPF.Init();
|
||||
System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
|
||||
Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y);
|
||||
UpdateCheck.DailyCheck();
|
||||
core.LoadScripts();
|
||||
Task.Run(() => App.Extension = new Extension());
|
||||
ShownTickCount = Environment.TickCount;
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
{
|
||||
base.OnActivated(e);
|
||||
Message m = new Message() { Msg = 0x0202 }; // WM_LBUTTONUP
|
||||
WinAPI.SendMessage(MainForm.Instance.Handle, m.Msg, m.WParam, m.LParam);
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
if (core.IsLogoVisible)
|
||||
core.ShowLogo();
|
||||
|
||||
if (FormBorderStyle != FormBorderStyle.None)
|
||||
{
|
||||
if (WindowState == FormWindowState.Maximized)
|
||||
WasMaximized = true;
|
||||
else if (WindowState == FormWindowState.Normal)
|
||||
WasMaximized = false;
|
||||
}
|
||||
|
||||
if (WasShown())
|
||||
{
|
||||
if (WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
core.set_property_string("window-minimized", "yes");
|
||||
}
|
||||
else if (WindowState == FormWindowState.Normal)
|
||||
{
|
||||
core.set_property_string("window-maximized", "no");
|
||||
core.set_property_string("window-minimized", "no");
|
||||
}
|
||||
else if (WindowState == FormWindowState.Maximized)
|
||||
{
|
||||
core.set_property_string("window-maximized", "yes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
base.OnFormClosing(e);
|
||||
SaveWindowProperties();
|
||||
RegistryHelp.SetValue(App.RegPath, "Recent", RecentFiles.ToArray());
|
||||
|
||||
if (core.IsQuitNeeded)
|
||||
core.commandv("quit");
|
||||
|
||||
if (!core.ShutdownAutoResetEvent.WaitOne(10000))
|
||||
Msg.ShowError("Shutdown thread failed to complete within 10 seconds.");
|
||||
|
||||
PowerShell.Shutdown();
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (WindowState == FormWindowState.Normal &&
|
||||
e.Button == MouseButtons.Left && !IsMouseInOSC())
|
||||
{
|
||||
var HTCAPTION = new IntPtr(2);
|
||||
WinAPI.ReleaseCapture();
|
||||
WinAPI.PostMessage(Handle, 0xA1 /* WM_NCLBUTTONDOWN */, HTCAPTION, IntPtr.Zero);
|
||||
}
|
||||
|
||||
if (Width - e.Location.X < 10 && e.Location.Y < 10)
|
||||
core.commandv("quit");
|
||||
}
|
||||
|
||||
protected override void OnDragEnter(DragEventArgs e)
|
||||
{
|
||||
base.OnDragEnter(e);
|
||||
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop) || e.Data.GetDataPresent(DataFormats.Text))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
|
||||
protected override void OnDragDrop(DragEventArgs e)
|
||||
{
|
||||
base.OnDragDrop(e);
|
||||
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
core.LoadFiles(e.Data.GetData(DataFormats.FileDrop) as String[], true, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
|
||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||
core.LoadFiles(new[] { e.Data.GetData(DataFormats.Text).ToString() }, true, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
}
|
||||
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
CursorHelp.Show();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
if (Control.ModifierKeys == Keys.Alt)
|
||||
e.SuppressKeyPress = true; // prevent beep using alt key
|
||||
|
||||
base.OnKeyDown(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
48
setup.iss
@@ -1,48 +0,0 @@
|
||||
|
||||
#define MyAppName "mpv.net"
|
||||
#define MyAppExeName "mpvnet.exe"
|
||||
|
||||
#ifndef arch
|
||||
#define arch "x64"
|
||||
#endif
|
||||
|
||||
#if arch == "x64"
|
||||
#define MyAppSourceDir "mpv.net\bin\x64"
|
||||
#define MyAppVersion GetFileVersion("mpv.net\bin\x64\mpvnet.exe")
|
||||
#else
|
||||
#define MyAppSourceDir "mpv.net\bin\x86"
|
||||
#define MyAppVersion GetFileVersion("mpv.net\bin\x86\mpvnet.exe")
|
||||
#endif
|
||||
|
||||
[Setup]
|
||||
AppId={{9AA2B100-BEF3-44D0-B819-D8FC3C4D557D}}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
AppPublisher=Frank Skare (stax76)
|
||||
|
||||
#if arch == "x64"
|
||||
ArchitecturesInstallIn64BitMode=x64
|
||||
#endif
|
||||
|
||||
Compression=lzma2
|
||||
DefaultDirName={commonpf}\{#MyAppName}
|
||||
OutputBaseFilename=mpv.net-setup-{#arch}-{#MyAppVersion}
|
||||
OutputDir={#GetEnv('USERPROFILE')}\Desktop
|
||||
DefaultGroupName={#MyAppName}
|
||||
SetupIconFile=mpv.net\mpvnet.ico
|
||||
UninstallDisplayIcon={app}\{#MyAppExeName}
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
|
||||
[Files]
|
||||
Source: "{#MyAppSourceDir}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "{#MyAppSourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs;
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "Associate video file extensions?"; Flags: postinstall unchecked runascurrentuser runhidden nowait; Parameters: "--reg-file-assoc video"
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "Associate audio file extensions?"; Flags: postinstall unchecked runascurrentuser runhidden nowait; Parameters: "--reg-file-assoc audio"
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "Associate image file extensions?"; Flags: postinstall unchecked runascurrentuser runhidden nowait; Parameters: "--reg-file-assoc image"
|
||||
|
||||
[UninstallRun]
|
||||
Filename: "{app}\{#MyAppExeName}"; Flags: runascurrentuser runhidden; Parameters: "--reg-file-assoc unreg"
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
using Tommy;
|
||||
using mpvnet;
|
||||
|
||||
namespace DynamicGUI
|
||||
{
|
||||
@@ -61,10 +61,10 @@ namespace DynamicGUI
|
||||
baseSetting.File = setting["file"];
|
||||
baseSetting.Filter = setting["filter"];
|
||||
|
||||
if (setting.HasKey("help")) baseSetting.Help = setting["help"];
|
||||
if (setting.HasKey("url")) baseSetting.URL = setting["url"];
|
||||
if (setting.HasKey("help")) baseSetting.Help = setting["help"];
|
||||
if (setting.HasKey("url")) baseSetting.URL = setting["url"];
|
||||
if (setting.HasKey("width")) baseSetting.Width = setting["width"];
|
||||
if (setting.HasKey("type")) baseSetting.Type = setting["type"];
|
||||
if (setting.HasKey("type")) baseSetting.Type = setting["type"];
|
||||
|
||||
settingsList.Add(baseSetting);
|
||||
}
|
||||
@@ -74,26 +74,29 @@ namespace DynamicGUI
|
||||
|
||||
public class ConfItem
|
||||
{
|
||||
public string Name { get; set; } = "";
|
||||
public string Value { get; set; } = "";
|
||||
public string Comment { get; set; } = "";
|
||||
public string LineComment { get; set; } = "";
|
||||
public string Section { get; set; } = "";
|
||||
public string File { get; set; } = "";
|
||||
public string LineComment { get; set; } = "";
|
||||
public string Name { get; set; } = "";
|
||||
public string Section { get; set; } = "";
|
||||
public string Value { get; set; } = "";
|
||||
|
||||
public bool IsSectionItem { get; set; }
|
||||
public SettingBase SettingBase { get; set; }
|
||||
}
|
||||
|
||||
public abstract class SettingBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string File { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string Help { get; set; }
|
||||
public string Default { get; set; }
|
||||
public string URL { get; set; }
|
||||
public string File { get; set; }
|
||||
public string Filter { get; set; }
|
||||
public string Help { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string StartValue { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string URL { get; set; }
|
||||
public string Value { get; set; }
|
||||
|
||||
public int Width { get; set; }
|
||||
public ConfItem ConfItem { get; set; }
|
||||
}
|
||||
@@ -147,7 +150,7 @@ namespace DynamicGUI
|
||||
{
|
||||
void HyperLinkEx_RequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(e.Uri.AbsoluteUri);
|
||||
ProcessHelp.ShellExecute(e.Uri.AbsoluteUri);
|
||||
}
|
||||
|
||||
public void SetURL(string url)
|
||||
73
src/DynamicGUI/OptionSettingControl.xaml
Normal file
@@ -0,0 +1,73 @@
|
||||
<UserControl
|
||||
x:Name="OptionSettingControl1" x:Class="DynamicGUI.OptionSettingControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
mc:Ignorable="d"
|
||||
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox
|
||||
x:Name="TitleTextBox"
|
||||
FontSize="24"
|
||||
Margin="0,10"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{Binding Theme.Heading}"
|
||||
Background="{Binding Theme.Background}"
|
||||
/>
|
||||
|
||||
<ItemsControl x:Name="ItemsControl">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<WrapPanel Orientation="Vertical">
|
||||
<RadioButton
|
||||
x:Name="RadioButton"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding Checked}"
|
||||
GroupName="{Binding OptionSetting.Name}"
|
||||
Content="{Binding Text}"
|
||||
FontSize="16"
|
||||
FontWeight="Normal"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Foreground}"
|
||||
/>
|
||||
|
||||
<TextBox
|
||||
x:Name="ItemHelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
Text="{Binding Help}"
|
||||
Visibility="{Binding Visibility}"
|
||||
Margin="10,0,0,0" BorderThickness="0"
|
||||
IsReadOnly="True" Padding="7,0,0,0"
|
||||
MinHeight="0"
|
||||
Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Foreground2}"
|
||||
Background="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Theme.Background}"
|
||||
/>
|
||||
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<TextBox
|
||||
x:Name="HelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Margin="0,10,0,0"
|
||||
Foreground="{Binding Theme.Foreground}"
|
||||
Background="{Binding Theme.Background}"
|
||||
/>
|
||||
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -2,6 +2,8 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
using mpvnet;
|
||||
|
||||
namespace DynamicGUI
|
||||
{
|
||||
public partial class OptionSettingControl : UserControl, ISettingControl
|
||||
@@ -12,6 +14,7 @@ namespace DynamicGUI
|
||||
{
|
||||
OptionSetting = optionSetting;
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
TitleTextBox.Text = optionSetting.Name;
|
||||
|
||||
if (string.IsNullOrEmpty(optionSetting.Help))
|
||||
@@ -26,6 +29,10 @@ namespace DynamicGUI
|
||||
Link.SetURL(optionSetting.URL);
|
||||
}
|
||||
|
||||
public Theme Theme {
|
||||
get => Theme.Current;
|
||||
}
|
||||
|
||||
string _SearchableText;
|
||||
|
||||
public string SearchableText {
|
||||
65
src/DynamicGUI/StringSettingControl.xaml
Normal file
@@ -0,0 +1,65 @@
|
||||
<UserControl
|
||||
x:Name="StringSettingControl1" x:Class="DynamicGUI.StringSettingControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800">
|
||||
|
||||
<Grid Margin="20,0">
|
||||
<StackPanel>
|
||||
<TextBox
|
||||
x:Name="TitleTextBox"
|
||||
FontSize="24"
|
||||
Margin="0,10"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{Binding Theme.Heading}"
|
||||
Background="{Binding Theme.Background}"
|
||||
/>
|
||||
|
||||
<Grid Margin="0,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox
|
||||
x:Name="ValueTextBox"
|
||||
Text="{Binding Path=Text, ElementName=StringSettingControl1, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Width="150"
|
||||
Height="20"
|
||||
HorizontalAlignment="Left"
|
||||
Foreground="{Binding Theme.Foreground}"
|
||||
Background="{Binding Theme.Background}"
|
||||
CaretBrush="{Binding Theme.Foreground}"
|
||||
TextChanged="ValueTextBox_TextChanged"
|
||||
/>
|
||||
|
||||
<Button
|
||||
x:Name="Button"
|
||||
Height="20"
|
||||
Grid.Column="1"
|
||||
Margin="5,0,0,0"
|
||||
Width="20"
|
||||
Click="Button_Click"
|
||||
>...</Button>
|
||||
</Grid>
|
||||
|
||||
<TextBox
|
||||
x:Name="HelpTextBox"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
BorderThickness="0"
|
||||
IsReadOnly="True"
|
||||
Foreground="{Binding Theme.Foreground}"
|
||||
Background="{Binding Theme.Background}"
|
||||
/>
|
||||
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,9 +1,11 @@
|
||||
|
||||
using mpvnet;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
||||
namespace DynamicGUI
|
||||
@@ -16,6 +18,7 @@ namespace DynamicGUI
|
||||
{
|
||||
StringSetting = stringSetting;
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
TitleTextBox.Text = stringSetting.Name;
|
||||
HelpTextBox.Text = stringSetting.Help;
|
||||
ValueTextBox.Text = StringSetting.Value;
|
||||
@@ -32,6 +35,10 @@ namespace DynamicGUI
|
||||
LinkTextBlock.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public Theme Theme {
|
||||
get => Theme.Current;
|
||||
}
|
||||
|
||||
string _SearchableText;
|
||||
|
||||
public string SearchableText {
|
||||
@@ -381,7 +381,8 @@ namespace Tommy
|
||||
|
||||
public override TomlNode this[string key] {
|
||||
get {
|
||||
if (RawTable.TryGetValue(key, out var result)) return result;
|
||||
if (RawTable.TryGetValue(key, out var result))
|
||||
return result;
|
||||
|
||||
var lazy = new TomlLazy(this);
|
||||
RawTable[key] = lazy;
|
||||
135
src/Extensions/RatingExtension/RatingExtension.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
|
||||
// This extension writes a rating to the filename of rated videos when mpv.net shuts down.
|
||||
|
||||
// The input.conf setup:
|
||||
|
||||
// KP0 script-message rate-file 0 #menu: Extensions > Rating > 0stars
|
||||
// KP1 script-message rate-file 1 #menu: Extensions > Rating > 1stars
|
||||
// KP2 script-message rate-file 2 #menu: Extensions > Rating > 2stars
|
||||
// KP3 script-message rate-file 3 #menu: Extensions > Rating > 3stars
|
||||
// KP4 script-message rate-file 4 #menu: Extensions > Rating > 4stars
|
||||
// KP5 script-message rate-file 5 #menu: Extensions > Rating > 5stars
|
||||
// _ ignore #menu: Extensions > Rating > -
|
||||
// _ script-message rate-file about #menu: Extensions > Rating > About
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
|
||||
using mpvnet;
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace RatingExtension // the assembly name must end with 'Extension'!
|
||||
{
|
||||
[Export(typeof(IExtension))]
|
||||
public class RatingExtension : IExtension
|
||||
{
|
||||
//Script script = new Script();
|
||||
|
||||
// dictionory to store the filename and the rating
|
||||
Dictionary<string, int> Dic = new Dictionary<string, int>();
|
||||
|
||||
string FileToDelete;
|
||||
DateTime DeleteTime;
|
||||
|
||||
public RatingExtension() // plugin initialization
|
||||
{
|
||||
Core.ClientMessage += ClientMessage; //handles keys defined in input.conf
|
||||
Core.Shutdown += Shutdown; // handles MPV_EVENT_SHUTDOWN
|
||||
}
|
||||
|
||||
// handles MPV_EVENT_SHUTDOWN
|
||||
void Shutdown()
|
||||
{
|
||||
foreach (var i in Dic)
|
||||
{
|
||||
string filepath = i.Key;
|
||||
int rating = i.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(filepath) || !File.Exists(filepath))
|
||||
return;
|
||||
|
||||
string basename = Path.GetFileNameWithoutExtension(filepath);
|
||||
|
||||
for (int x = 0; x < 6; x++)
|
||||
if (basename.Contains(" (" + x + "stars)"))
|
||||
basename = basename.Replace(" (" + x + "stars)", "");
|
||||
|
||||
basename += $" ({rating}stars)";
|
||||
|
||||
string newPath = Path.Combine(Path.GetDirectoryName(filepath),
|
||||
basename + Path.GetExtension(filepath));
|
||||
|
||||
if (filepath.ToLower() != newPath.ToLower())
|
||||
File.Move(filepath, newPath);
|
||||
|
||||
File.SetLastWriteTime(newPath, DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
//handles keys defined in input.conf
|
||||
void ClientMessage(string[] args)
|
||||
{
|
||||
if (args[0] != "rate-file")
|
||||
return;
|
||||
|
||||
if (int.TryParse(args[1], out int rating))
|
||||
{
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (!File.Exists(path))
|
||||
return;
|
||||
|
||||
if (rating == 0 || rating == 1)
|
||||
Delete(rating);
|
||||
else
|
||||
{
|
||||
Dic[path] = rating;
|
||||
Core.commandv("show-text", $"Rating: {rating}");
|
||||
}
|
||||
}
|
||||
else if (args[1] == "about")
|
||||
MessageBox.Show($"This extension writes a rating to the filename of rated videos " +
|
||||
"when mpv.net shuts down." + BR2 +
|
||||
"The input.conf defaults contain key bindings for this extension to set ratings.",
|
||||
"Rating Extension");
|
||||
}
|
||||
|
||||
void Delete(int rating)
|
||||
{
|
||||
if (rating == 0)
|
||||
{
|
||||
FileToDelete = Core.get_property_string("path");
|
||||
DeleteTime = DateTime.Now;
|
||||
Core.commandv("show-text", "Press 1 to delete file", "5000");
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeSpan ts = DateTime.Now - DeleteTime;
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (FileToDelete == path && ts.TotalSeconds < 5 && File.Exists(FileToDelete))
|
||||
{
|
||||
Core.command("playlist-remove current");
|
||||
int pos = Core.get_property_int("playlist-pos");
|
||||
|
||||
if (pos == -1)
|
||||
{
|
||||
int count = Core.get_property_int("playlist-count");
|
||||
|
||||
if (count > 0)
|
||||
Core.set_property_int("playlist-pos", count - 1);
|
||||
}
|
||||
|
||||
Thread.Sleep(2000);
|
||||
FileSystem.DeleteFile(FileToDelete, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,46 +13,33 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\mpv.net\bin\x86\Extensions\RatingExtension\</OutputPath>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>..\..\mpv.net\bin\x86\Extensions\RatingExtension\</OutputPath>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\mpv.net\bin\x64\Extensions\RatingExtension\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>..\..\mpv.net\bin\x64\Extensions\RatingExtension\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
@@ -63,9 +50,10 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="RatingExtension.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ScriptDevelopment.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\mpv.net\mpv.net.csproj">
|
||||
<ProjectReference Include="..\..\mpv.net.csproj">
|
||||
<Project>{1751f378-8edf-4b62-be6d-304c7c287089}</Project>
|
||||
<Name>mpv.net</Name>
|
||||
<Private>False</Private>
|
||||
42
src/Extensions/RatingExtension/ScriptDevelopment.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
//// This script adds dynamic menu items for profile switching.
|
||||
|
||||
//// In input.conf add a menu item called 'Profiles'
|
||||
|
||||
//using mpvnet;
|
||||
//using System.ComponentModel;
|
||||
//using System.Linq;
|
||||
|
||||
//class Script
|
||||
//{
|
||||
// MainForm MainForm;
|
||||
// CorePlayer Core;
|
||||
|
||||
// public Script()
|
||||
// {
|
||||
// Core = Global.Core;
|
||||
// MainForm = MainForm.Instance;
|
||||
// MainForm.ContextMenu.Opening += ContextMenu_Opening;
|
||||
// }
|
||||
|
||||
// void ContextMenu_Opening(object sender, CancelEventArgs e)
|
||||
// {
|
||||
// MenuItem menuItem = MainForm.FindMenuItem("My Menu");
|
||||
|
||||
// if (menuItem == null)
|
||||
// {
|
||||
// Terminal.WriteError("Profiles menu item not found.", "switch-profile-context-menu.cs");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// menuItem.DropDownItems.Clear();
|
||||
// var editionTracks = Core.MediaTracks.Where(track => track.Type == "e");
|
||||
|
||||
// foreach (int i in new[] {1, 2, 3})
|
||||
// {
|
||||
// MenuItem mi = new MenuItem(i.ToString());
|
||||
// mi.Action = () => { Core.commandv("show-text", i.ToString()); };
|
||||
// menuItem.DropDownItems.Add(mi);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -4,32 +4,22 @@ 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.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public static class App
|
||||
{
|
||||
public static string[] VideoTypes { get; } = "264 265 asf avc avi avs flv h264 h265 hevc m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm wmv y4m".Split(' ');
|
||||
public static string[] AudioTypes { get; } = "mp3 mp2 ac3 ogg opus flac wav w64 m4a dts dtsma dtshr dtshd eac3 thd thd+ac3 mka aac mpa".Split(' ');
|
||||
public static string[] ImageTypes { get; } = {"jpg", "bmp", "gif", "png"};
|
||||
public static string[] SubtitleTypes { get; } = { "srt", "ass", "idx", "sup", "ttxt", "ssa", "smi" };
|
||||
|
||||
public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName;
|
||||
public static string ConfPath { get => core.ConfigFolder + "mpvnet.conf"; }
|
||||
public static string ConfPath { get => Core.ConfigFolder + "mpvnet.conf"; }
|
||||
public static string ProcessInstance { get; set; } = "single";
|
||||
public static string DarkMode { get; set; } = "always";
|
||||
public static string DarkTheme { get; set; } = "dark";
|
||||
public static string LightTheme { get; set; } = "light";
|
||||
public static string StartSize { get; set; } = "previous";
|
||||
public static string StartSize { get; set; } = "height-session";
|
||||
|
||||
public static bool RememberPosition { get; set; }
|
||||
public static bool RememberWindowPosition { get; set; }
|
||||
public static bool DebugMode { get; set; }
|
||||
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
|
||||
public static bool RememberVolume { get; set; } = true;
|
||||
@@ -48,19 +38,30 @@ namespace mpvnet
|
||||
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
|
||||
}
|
||||
|
||||
static AppSettings _Settings;
|
||||
|
||||
public static AppSettings Settings {
|
||||
get {
|
||||
if (_Settings == null)
|
||||
_Settings = SettingsManager.Load();
|
||||
|
||||
return _Settings;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
string dummy = core.ConfigFolder;
|
||||
var dummy2 = core.Conf;
|
||||
var useless1 = Core.ConfigFolder;
|
||||
var useless2 = Core.Conf;
|
||||
|
||||
foreach (var i in Conf)
|
||||
ProcessProperty(i.Key, i.Value, true);
|
||||
|
||||
if (App.DebugMode)
|
||||
if (DebugMode)
|
||||
{
|
||||
try
|
||||
{
|
||||
string filePath = core.ConfigFolder + "mpvnet-debug.log";
|
||||
string filePath = Core.ConfigFolder + "mpvnet-debug.log";
|
||||
|
||||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
@@ -77,59 +78,72 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
InitTheme();
|
||||
|
||||
Core.Shutdown += Shutdown;
|
||||
Core.Initialized += Initialized;
|
||||
}
|
||||
|
||||
public static void InitTheme()
|
||||
{
|
||||
string themeContent = null;
|
||||
|
||||
if (File.Exists(core.ConfigFolder + "theme.conf"))
|
||||
themeContent = File.ReadAllText(core.ConfigFolder + "theme.conf");
|
||||
if (File.Exists(Core.ConfigFolder + "theme.conf"))
|
||||
themeContent = File.ReadAllText(Core.ConfigFolder + "theme.conf");
|
||||
|
||||
Theme.Init(
|
||||
themeContent,
|
||||
Properties.Resources.theme,
|
||||
IsDarkMode ? DarkTheme : LightTheme);
|
||||
|
||||
core.Shutdown += Shutdown;
|
||||
core.Initialized += Initialized;
|
||||
ToolStripRendererEx.ForegroundColor = Theme.Current.GetWinFormsColor("menu-foreground");
|
||||
ToolStripRendererEx.BackgroundColor = Theme.Current.GetWinFormsColor("menu-background");
|
||||
ToolStripRendererEx.SelectionColor = Theme.Current.GetWinFormsColor("menu-highlight");
|
||||
ToolStripRendererEx.BorderColor = Theme.Current.GetWinFormsColor("menu-border");
|
||||
ToolStripRendererEx.CheckedColor = Theme.Current.GetWinFormsColor("menu-checked");
|
||||
}
|
||||
|
||||
public static void RunAction(Action action)
|
||||
public static void RunTask(Action action)
|
||||
{
|
||||
Task.Run(() => {
|
||||
try
|
||||
{
|
||||
try {
|
||||
action.Invoke();
|
||||
Debug.WriteLine(Environment.TickCount);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
ShowException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static string Version {
|
||||
get {
|
||||
return "Copyright (C) 2000-2021 mpv.net/mpv/mplayer\n" +
|
||||
$"mpv.net {Application.ProductVersion} ({File.GetLastWriteTime(Application.ExecutablePath).ToShortDateString()})\n" +
|
||||
$"{Core.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})\nffmpeg {Core.get_property_string("ffmpeg-version")}\nMIT License";
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowException(object obj)
|
||||
{
|
||||
if (obj is Exception e)
|
||||
{
|
||||
if (App.IsStartedFromTerminal)
|
||||
ConsoleHelp.WriteError(e.ToString());
|
||||
else
|
||||
Msg.ShowException(e);
|
||||
}
|
||||
if (IsStartedFromTerminal)
|
||||
Terminal.WriteError(obj.ToString());
|
||||
else
|
||||
{
|
||||
if (App.IsStartedFromTerminal)
|
||||
ConsoleHelp.WriteError(obj.ToString());
|
||||
if (obj is Exception e)
|
||||
Msg.ShowException(e);
|
||||
else
|
||||
Msg.ShowError(obj.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowError(string title, string msg)
|
||||
public static void ShowError(string title, string msg = null)
|
||||
{
|
||||
if (App.IsStartedFromTerminal)
|
||||
if (IsStartedFromTerminal)
|
||||
{
|
||||
ConsoleHelp.WriteError(title);
|
||||
ConsoleHelp.WriteError(msg);
|
||||
if (title != null)
|
||||
Terminal.WriteError(title);
|
||||
|
||||
if (msg != null)
|
||||
Terminal.WriteError(msg);
|
||||
}
|
||||
else
|
||||
Msg.ShowError(title, msg);
|
||||
@@ -139,18 +153,17 @@ namespace mpvnet
|
||||
{
|
||||
if (RememberVolume)
|
||||
{
|
||||
core.set_property_int("volume", RegistryHelp.GetInt(App.RegPath, "Volume", 70));
|
||||
core.set_property_string("mute", RegistryHelp.GetString(App.RegPath, "Mute", "no"));
|
||||
Core.set_property_int("volume", Settings.Volume);
|
||||
Core.set_property_string("mute", Settings.Mute);
|
||||
}
|
||||
}
|
||||
|
||||
static void Shutdown()
|
||||
{
|
||||
if (RememberVolume)
|
||||
{
|
||||
RegistryHelp.SetValue(App.RegPath, "Volume", core.get_property_int("volume"));
|
||||
RegistryHelp.SetValue(App.RegPath, "Mute", core.get_property_string("mute"));
|
||||
}
|
||||
Settings.Volume = Core.get_property_int("volume");
|
||||
Settings.Mute = Core.get_property_string("mute");
|
||||
|
||||
SettingsManager.Save(Settings);
|
||||
}
|
||||
|
||||
static Dictionary<string, string> _Conf;
|
||||
@@ -174,7 +187,7 @@ namespace mpvnet
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "remember-position": RememberPosition = value == "yes"; return true;
|
||||
case "remember-window-position": RememberWindowPosition = value == "yes"; return true;
|
||||
case "debug-mode": DebugMode = value == "yes"; return true;
|
||||
case "remember-volume": RememberVolume = value == "yes"; return true;
|
||||
case "queue": Queue = value == "yes"; return true;
|
||||
@@ -183,14 +196,17 @@ namespace mpvnet
|
||||
case "start-size": StartSize = value; return true;
|
||||
case "process-instance": ProcessInstance = value; return true;
|
||||
case "dark-mode": DarkMode = value; return true;
|
||||
case "start-threshold": StartThreshold = value.Int(); return true;
|
||||
case "recent-count": RecentCount = value.Int(); return true;
|
||||
case "minimum-aspect-ratio": MinimumAspectRatio = value.Float(); return true;
|
||||
case "start-threshold": StartThreshold = value.ToInt(); return true;
|
||||
case "recent-count": RecentCount = value.ToInt(); return true;
|
||||
case "minimum-aspect-ratio": MinimumAspectRatio = value.ToFloat(); return true;
|
||||
case "dark-theme": DarkTheme = value.Trim('\'', '"'); return true;
|
||||
case "light-theme": LightTheme = value.Trim('\'', '"'); return true;
|
||||
case "video-file-extensions": CorePlayer.VideoTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
|
||||
case "audio-file-extensions": CorePlayer.AudioTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
|
||||
case "image-file-extensions": CorePlayer.ImageTypes = value.Split(" ,;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); return true;
|
||||
default:
|
||||
if (writeError)
|
||||
ConsoleHelp.WriteError($"unknown mpvnet.conf property: {name}");
|
||||
Terminal.WriteError($"unknown mpvnet.conf property: {name}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
84
src/Misc/CSharpScriptHost.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
using Microsoft.CSharp;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
class CSharpScriptHost
|
||||
{
|
||||
static List<object> References = new List<object>();
|
||||
|
||||
public static void ExecuteScriptsInFolder(string folder)
|
||||
{
|
||||
if (Directory.Exists(folder))
|
||||
foreach (string file in Directory.GetFiles(folder, "*.cs"))
|
||||
App.RunTask(() => Execute(file));
|
||||
}
|
||||
|
||||
static void Execute(string file)
|
||||
{
|
||||
string code = File.ReadAllText(file);
|
||||
string filename = Path.GetFileNameWithoutExtension(file) + " " + GetMD5(code) + ".dll";
|
||||
string outputFile = Path.Combine(Path.GetTempPath(), filename);
|
||||
|
||||
if (!File.Exists(outputFile))
|
||||
Compile(outputFile, file);
|
||||
|
||||
if (File.Exists(outputFile))
|
||||
{
|
||||
object instance = Assembly.LoadFile(outputFile).CreateInstance("Script");
|
||||
|
||||
if (instance != null)
|
||||
References.Add(instance);
|
||||
else
|
||||
Terminal.WriteError("Failed to initialize script.", outputFile.FileName());
|
||||
}
|
||||
}
|
||||
|
||||
public static void Compile(string outputFile, string file)
|
||||
{
|
||||
CSharpCodeProvider provider = new CSharpCodeProvider();
|
||||
CompilerParameters parameters = new CompilerParameters();
|
||||
|
||||
string[] dependencies = {
|
||||
Folder.Startup + "mpvnet.exe",
|
||||
"Microsoft.VisualBasic.dll",
|
||||
"System.Core.dll", "System.Data.dll", "System.dll", "System.Drawing.dll", "System.Web.dll",
|
||||
"System.Windows.Forms.dll", "System.Xaml.dll", "System.Xml.dll", "System.Xml.Linq.dll",
|
||||
"WPF\\PresentationCore.dll", "WPF\\PresentationFramework.dll", "WPF\\WindowsBase.dll"
|
||||
};
|
||||
|
||||
foreach (string i in dependencies)
|
||||
parameters.ReferencedAssemblies.Add(i);
|
||||
|
||||
parameters.OutputAssembly = outputFile;
|
||||
CompilerResults results = provider.CompileAssemblyFromFile(parameters, file);
|
||||
|
||||
var errors = results.Errors.Cast<CompilerError>().Select(i => "Line Number " +
|
||||
i.Line + "\n" + "Error Number: " + i.ErrorNumber + "\n" + i.ErrorText);
|
||||
|
||||
if (errors.Count() > 0)
|
||||
Terminal.WriteError(string.Join(BR2, errors), Path.GetFileName(file));
|
||||
}
|
||||
|
||||
static string GetMD5(string code)
|
||||
{
|
||||
using (MD5 md5 = MD5.Create())
|
||||
{
|
||||
byte[] inputBuffer = Encoding.UTF8.GetBytes(code);
|
||||
byte[] hashBuffer = md5.ComputeHash(inputBuffer);
|
||||
return BitConverter.ToString(md5.ComputeHash(inputBuffer)).Replace("-", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +1,59 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows;
|
||||
|
||||
using VB = Microsoft.VisualBasic;
|
||||
|
||||
using static NewLine;
|
||||
using static mpvnet.Core;
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Commands
|
||||
{
|
||||
public static void Execute(string id, string[] args)
|
||||
public static void Execute(string id, string[] args = null)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case "open-files": OpenFiles(args); break;
|
||||
case "update-check": UpdateCheck.CheckOnline(true); break;
|
||||
case "open-url": OpenURL(); break;
|
||||
case "open-optical-media": Open_DVD_Or_BD_Folder(); break;
|
||||
case "manage-file-associations": // deprecated 2019
|
||||
case "show-setup-dialog": ShowDialog(typeof(SetupWindow)); break;
|
||||
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
|
||||
case "cycle-audio": CycleAudio(); break;
|
||||
case "execute-mpv-command": Msg.ShowError("Command was removed, reset input.conf."); break;
|
||||
case "load-audio": LoadAudio(); break;
|
||||
case "load-sub": LoadSubtitle(); break;
|
||||
case "execute-mpv-command": ExecuteMpvCommand(); break;
|
||||
case "show-history": ShowHistory(); break;
|
||||
case "show-media-search": ShowDialog(typeof(EverythingWindow)); break;
|
||||
case "show-command-palette": ShowDialog(typeof(CommandPaletteWindow)); break;
|
||||
case "show-about": ShowDialog(typeof(AboutWindow)); break;
|
||||
case "show-conf-editor": ShowDialog(typeof(ConfWindow)); break;
|
||||
case "show-input-editor": ShowDialog(typeof(InputWindow)); break;
|
||||
case "open-conf-folder": Process.Start(core.ConfigFolder); break;
|
||||
case "shell-execute": Process.Start(args[0]); break;
|
||||
case "show-info": ShowInfo(); break;
|
||||
case "open-conf-folder": ProcessHelp.ShellExecute(Core.ConfigFolder); break;
|
||||
case "open-files": OpenFiles(args); break;
|
||||
case "open-optical-media": Open_DVD_Or_BD_Folder(); break;
|
||||
case "open-url": OpenURL(); break;
|
||||
case "playlist-first": PlaylistFirst(); break;
|
||||
case "playlist-last": PlaylistLast(); break;
|
||||
case "show-profiles": ShowProfiles(); break;
|
||||
case "show-properties": ShowProperties(); break;
|
||||
case "scale-window": ScaleWindow(float.Parse(args[0], CultureInfo.InvariantCulture)); break;
|
||||
case "shell-execute": ProcessHelp.ShellExecute(args[0]); break;
|
||||
case "show-about": ShowDialog(typeof(AboutWindow)); break;
|
||||
case "show-audio-devices": ShowTextWithEditor("audio-device-list", Core.get_property_osd_string("audio-device-list")); break;
|
||||
case "show-command-palette": ShowDialog(typeof(CommandPaletteWindow)); break;
|
||||
case "show-commands": ShowCommands(); break;
|
||||
case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019
|
||||
case "show-conf-editor": ShowDialog(typeof(ConfWindow)); break;
|
||||
case "show-decoders": ShowTextWithEditor("decoder-list", mpvHelp.GetDecoders()); break;
|
||||
case "show-demuxers": ShowTextWithEditor("demuxer-lavf-list", mpvHelp.GetDemuxers()); break;
|
||||
case "show-history": ShowHistory(); break;
|
||||
case "show-info": ShowInfo(); break;
|
||||
case "show-input-editor": ShowDialog(typeof(InputWindow)); break;
|
||||
case "show-keys": ShowTextWithEditor("input-key-list", Core.get_property_string("input-key-list").Replace(",", BR)); break;
|
||||
case "show-media-search": ShowDialog(typeof(EverythingWindow)); break;
|
||||
case "show-playlist": ShowPlaylist(); break;
|
||||
case "show-profiles": ShowTextWithEditor("profile-list", mpvHelp.GetProfiles()); break;
|
||||
case "show-properties": ShowProperties(); break;
|
||||
case "show-protocols": ShowTextWithEditor("protocol-list", mpvHelp.GetProtocols()); break;
|
||||
case "show-setup-dialog": ShowDialog(typeof(SetupWindow)); break;
|
||||
case "show-text": ShowText(args[0], Convert.ToInt32(args[1]), Convert.ToInt32(args[2])); break;
|
||||
case "update-check": UpdateCheck.CheckOnline(true); break;
|
||||
case "window-scale": WindowScale(float.Parse(args[0], CultureInfo.InvariantCulture)); break;
|
||||
|
||||
default: Msg.ShowError($"No command '{id}' found."); break;
|
||||
}
|
||||
}
|
||||
@@ -74,29 +83,32 @@ namespace mpvnet
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var d = new OpenFileDialog() { Multiselect = true })
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
core.LoadFiles(d.FileNames, loadFolder, append);
|
||||
Core.LoadFiles(d.FileNames, loadFolder, append);
|
||||
}));
|
||||
}
|
||||
|
||||
public static void Open_DVD_Or_BD_Folder()
|
||||
{
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var d = new FolderBrowserDialog())
|
||||
using (var dialog = new FolderBrowserDialog())
|
||||
{
|
||||
d.Description = "Select a DVD or Blu-ray folder.";
|
||||
d.ShowNewFolderButton = false;
|
||||
dialog.Description = "Select a DVD or Blu-ray folder.";
|
||||
dialog.ShowNewFolderButton = false;
|
||||
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (Directory.Exists(d.SelectedPath + "\\BDMV"))
|
||||
Core.command("stop");
|
||||
Thread.Sleep(500);
|
||||
|
||||
if (Directory.Exists(dialog.SelectedPath + "\\BDMV"))
|
||||
{
|
||||
core.set_property_string("bluray-device", d.SelectedPath);
|
||||
core.LoadFiles(new[] { @"bd://" }, false, false);
|
||||
Core.set_property_string("bluray-device", dialog.SelectedPath);
|
||||
Core.LoadFiles(new[] { @"bd://" }, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
core.set_property_string("dvd-device", d.SelectedPath);
|
||||
core.LoadFiles(new[] { @"dvd://" }, false, false);
|
||||
Core.set_property_string("dvd-device", dialog.SelectedPath);
|
||||
Core.LoadFiles(new[] { @"dvd://" }, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,31 +117,31 @@ namespace mpvnet
|
||||
|
||||
public static void PlaylistFirst()
|
||||
{
|
||||
int pos = core.get_property_int("playlist-pos");
|
||||
int pos = Core.get_property_int("playlist-pos");
|
||||
|
||||
if (pos != 0)
|
||||
core.set_property_int("playlist-pos", 0);
|
||||
Core.set_property_int("playlist-pos", 0);
|
||||
}
|
||||
|
||||
public static void PlaylistLast()
|
||||
{
|
||||
int pos = core.get_property_int("playlist-pos");
|
||||
int count = core.get_property_int("playlist-count");
|
||||
int pos = Core.get_property_int("playlist-pos");
|
||||
int count = Core.get_property_int("playlist-count");
|
||||
|
||||
if (pos < count - 1)
|
||||
core.set_property_int("playlist-pos", count - 1);
|
||||
Core.set_property_int("playlist-pos", count - 1);
|
||||
}
|
||||
|
||||
public static void ShowHistory()
|
||||
{
|
||||
if (File.Exists(core.ConfigFolder + "history.txt"))
|
||||
Process.Start(core.ConfigFolder + "history.txt");
|
||||
if (File.Exists(Core.ConfigFolder + "history.txt"))
|
||||
ProcessHelp.ShellExecute(Core.ConfigFolder + "history.txt");
|
||||
else
|
||||
{
|
||||
if (Msg.ShowQuestion("Create history.txt file in config folder?",
|
||||
"mpv.net will write the date, time and filename of opened files to it.") == MsgResult.OK)
|
||||
"mpv.net will write the date, time and filename of opened files to it.") == DialogResult.OK)
|
||||
|
||||
File.WriteAllText(core.ConfigFolder + "history.txt", "");
|
||||
File.WriteAllText(Core.ConfigFolder + "history.txt", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,19 +151,19 @@ namespace mpvnet
|
||||
{
|
||||
string performer, title, album, genre, date, duration, text = "";
|
||||
long fileSize = 0;
|
||||
string path = core.get_property_string("path");
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (path.Contains("://"))
|
||||
path = core.get_property_string("media-title");
|
||||
path = Core.get_property_string("media-title");
|
||||
|
||||
int width = core.get_property_int("video-params/w");
|
||||
int height = core.get_property_int("video-params/h");
|
||||
int width = Core.get_property_int("video-params/w");
|
||||
int height = Core.get_property_int("video-params/h");
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
fileSize = new FileInfo(path).Length;
|
||||
|
||||
if (App.AudioTypes.Contains(path.ShortExt()))
|
||||
if (CorePlayer.AudioTypes.Contains(path.Ext()))
|
||||
{
|
||||
using (MediaInfo mediaInfo = new MediaInfo(path))
|
||||
{
|
||||
@@ -169,13 +181,13 @@ namespace mpvnet
|
||||
if (date != "") text += "Year: " + date + "\n";
|
||||
if (duration != "") text += "Length: " + duration + "\n";
|
||||
text += "Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n";
|
||||
text += "Type: " + path.ShortExt().ToUpper();
|
||||
text += "Type: " + path.Ext().ToUpper();
|
||||
|
||||
core.commandv("show-text", text, "5000");
|
||||
Core.commandv("show-text", text, "5000");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (App.ImageTypes.Contains(path.ShortExt()))
|
||||
else if (CorePlayer.ImageTypes.Contains(path.Ext()))
|
||||
{
|
||||
using (MediaInfo mediaInfo = new MediaInfo(path))
|
||||
{
|
||||
@@ -183,18 +195,18 @@ namespace mpvnet
|
||||
"Width: " + mediaInfo.GetInfo(MediaInfoStreamKind.Image, "Width") + "\n" +
|
||||
"Height: " + mediaInfo.GetInfo(MediaInfoStreamKind.Image, "Height") + "\n" +
|
||||
"Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n" +
|
||||
"Type: " + path.ShortExt().ToUpper();
|
||||
"Type: " + path.Ext().ToUpper();
|
||||
|
||||
core.commandv("show-text", text, "5000");
|
||||
Core.commandv("show-text", text, "5000");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TimeSpan position = TimeSpan.FromSeconds(core.get_property_number("time-pos"));
|
||||
TimeSpan duration2 = TimeSpan.FromSeconds(core.get_property_number("duration"));
|
||||
string videoFormat = core.get_property_string("video-format").ToUpper();
|
||||
string audioCodec = core.get_property_string("audio-codec-name").ToUpper();
|
||||
TimeSpan position = TimeSpan.FromSeconds(Core.get_property_number("time-pos"));
|
||||
TimeSpan duration2 = TimeSpan.FromSeconds(Core.get_property_number("duration"));
|
||||
string videoFormat = Core.get_property_string("video-format").ToUpper();
|
||||
string audioCodec = Core.get_property_string("audio-codec-name").ToUpper();
|
||||
|
||||
text = path.FileName() + "\n" +
|
||||
FormatTime(position.TotalMinutes) + ":" +
|
||||
@@ -208,7 +220,7 @@ namespace mpvnet
|
||||
|
||||
text += $"{videoFormat}\n{audioCodec}";
|
||||
|
||||
core.commandv("show-text", text, "5000");
|
||||
Core.commandv("show-text", text, "5000");
|
||||
string FormatTime(double value) => ((int)value).ToString("00");
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -217,31 +229,19 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
public static void ExecuteMpvCommand() // deprecated 2019
|
||||
{
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegistryHelp.GetString(App.RegPath, "RecentExecutedCommand"));
|
||||
|
||||
if (string.IsNullOrEmpty(command))
|
||||
return;
|
||||
|
||||
RegistryHelp.SetValue(App.RegPath, "RecentExecutedCommand", command);
|
||||
core.command(command, false);
|
||||
}));
|
||||
}
|
||||
|
||||
public static void OpenURL()
|
||||
{
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
string clipboard = System.Windows.Forms.Clipboard.GetText();
|
||||
|
||||
if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) || clipboard.Contains("\n"))
|
||||
if (string.IsNullOrEmpty(clipboard) || (!clipboard.Contains("://") && !File.Exists(clipboard)) ||
|
||||
clipboard.Contains("\n"))
|
||||
{
|
||||
App.ShowError("No URL found", "The clipboard does not contain a valid URL or file.");
|
||||
return;
|
||||
}
|
||||
|
||||
core.LoadFiles(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
Core.LoadFiles(new [] { clipboard }, false, Control.ModifierKeys.HasFlag(Keys.Control));
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace mpvnet
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var d = new OpenFileDialog())
|
||||
{
|
||||
string path = core.get_property_string("path");
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (File.Exists(path))
|
||||
d.InitialDirectory = Path.GetDirectoryName(path);
|
||||
@@ -259,7 +259,7 @@ namespace mpvnet
|
||||
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
foreach (string filename in d.FileNames)
|
||||
core.commandv("sub-add", filename);
|
||||
Core.commandv("sub-add", filename);
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -269,66 +269,43 @@ namespace mpvnet
|
||||
InvokeOnMainThread(new Action(() => {
|
||||
using (var d = new OpenFileDialog())
|
||||
{
|
||||
string path = core.get_property_string("path");
|
||||
string path = Core.get_property_string("path");
|
||||
if (File.Exists(path))
|
||||
d.InitialDirectory = Path.GetDirectoryName(path);
|
||||
d.Multiselect = true;
|
||||
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
foreach (string i in d.FileNames)
|
||||
core.commandv("audio-add", i);
|
||||
Core.commandv("audio-add", i);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static void CycleAudio()
|
||||
{
|
||||
string path = core.get_property_string("path");
|
||||
MediaTrack[] audioTracks = Core.MediaTracks.Where(track => track.Type == "a").ToArray();
|
||||
int len = audioTracks.Length;
|
||||
|
||||
if (!File.Exists(path))
|
||||
return;
|
||||
|
||||
using (MediaInfo mi = new MediaInfo(path))
|
||||
if (len < 1)
|
||||
{
|
||||
MediaTrack[] audTracks = core.MediaTracks.Where(track => track.Type == "a").ToArray();
|
||||
Core.commandv("show-text", "No audio tracks");
|
||||
return;
|
||||
}
|
||||
|
||||
if (audTracks.Length < 2)
|
||||
return;
|
||||
int aid = Core.get_property_int("aid");
|
||||
|
||||
int aid = core.get_property_int("aid");
|
||||
aid += 1;
|
||||
|
||||
if (aid > audTracks.Length)
|
||||
if (len > 1)
|
||||
{
|
||||
if (++aid > len)
|
||||
aid = 1;
|
||||
|
||||
core.commandv("set", "aid", aid.ToString());
|
||||
core.commandv("show-text", audTracks[aid - 1].Text.Substring(3), "5000");
|
||||
Core.commandv("set", "aid", aid.ToString());
|
||||
}
|
||||
|
||||
Core.commandv("show-text", aid + "/" + len + ": " + audioTracks[aid - 1].Text.Substring(3), "5000");
|
||||
}
|
||||
|
||||
static void ShowProfiles()
|
||||
{
|
||||
string code = @"
|
||||
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort name))
|
||||
{
|
||||
$item.name
|
||||
''
|
||||
|
||||
foreach ($option in $item.options)
|
||||
{
|
||||
' ' + $option.key + ' = ' + $option.value
|
||||
}
|
||||
|
||||
''
|
||||
}";
|
||||
|
||||
string json = core.get_property_string("profile-list");
|
||||
string file = Path.GetTempPath() + @"\mpv profile-list.txt";
|
||||
File.WriteAllText(file, BR + PowerShell.InvokeAndReturnString(code, "json", json));
|
||||
Process.Start(file);
|
||||
}
|
||||
|
||||
static void ShowCommands()
|
||||
public static void ShowCommands()
|
||||
{
|
||||
string code = @"
|
||||
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort name))
|
||||
@@ -349,18 +326,57 @@ namespace mpvnet
|
||||
}
|
||||
}";
|
||||
|
||||
string json = core.get_property_string("command-list");
|
||||
string file = Path.GetTempPath() + @"\mpv command-list.txt";
|
||||
File.WriteAllText(file, PowerShell.InvokeAndReturnString(code, "json", json) + BR);
|
||||
Process.Start(file);
|
||||
string json = Core.get_property_string("command-list");
|
||||
ShowTextWithEditor("command-list", PowerShell.InvokeAndReturnString(code, "json", json));
|
||||
}
|
||||
|
||||
static void ShowProperties()
|
||||
public static void ShowProperties()
|
||||
{
|
||||
string file = Path.GetTempPath() + @"\mpv property-list.txt";
|
||||
var props = core.get_property_string("property-list").Split(',').OrderBy(prop => prop);
|
||||
File.WriteAllText(file, BR + string.Join(BR, props) + BR);
|
||||
Process.Start(file);
|
||||
var props = Core.get_property_string("property-list").Split(',').OrderBy(prop => prop);
|
||||
ShowTextWithEditor("property-list", string.Join(BR, props));
|
||||
}
|
||||
|
||||
public static void ShowTextWithEditor(string name, string text)
|
||||
{
|
||||
string file = Path.GetTempPath() + $"\\{name}.txt";
|
||||
File.WriteAllText(file, BR + text.Trim() + BR);
|
||||
ProcessHelp.ShellExecute(file);
|
||||
}
|
||||
|
||||
public static void ScaleWindow(float factor) => Core.RaiseScaleWindow(factor);
|
||||
|
||||
public static void WindowScale(float value) => Core.RaiseWindowScale(value);
|
||||
|
||||
public static void ShowText(string text, int duration = 0, int fontSize = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text))
|
||||
return;
|
||||
|
||||
if (duration == 0)
|
||||
duration = Core.get_property_int("osd-duration");
|
||||
|
||||
if (fontSize == 0)
|
||||
fontSize = Core.get_property_int("osd-font-size");
|
||||
|
||||
Core.command("show-text \"${osd-ass-cc/0}{\\\\fs" + fontSize +
|
||||
"}${osd-ass-cc/1}" + text + "\" " + duration);
|
||||
}
|
||||
|
||||
public static void ShowPlaylist(string[] args = null)
|
||||
{
|
||||
int duration = 5000;
|
||||
|
||||
if (args?.Length == 1)
|
||||
duration = Convert.ToInt32(args[0]);
|
||||
|
||||
var size = Core.get_property_number("osd-font-size");
|
||||
Core.set_property_number("osd-font-size", 40);
|
||||
Core.command("show-text ${playlist} " + duration);
|
||||
|
||||
App.RunTask(() => {
|
||||
Thread.Sleep(6000);
|
||||
Core.set_property_number("osd-font-size", size);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.ComponentModel.Composition.Hosting;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
using static mpvnet.Core;
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -33,14 +33,14 @@ namespace mpvnet
|
||||
if (knownExtensions.Contains(Path.GetFileName(extDir)))
|
||||
catalog.Catalogs.Add(new DirectoryCatalog(extDir, Path.GetFileName(extDir) + ".dll"));
|
||||
else
|
||||
ConsoleHelp.WriteError("Failed to load extension:\n\n" + extDir +
|
||||
"\n\nOnly extensions that ship with mpv.net are allowed in <startup>\\extensions" +
|
||||
"\n\nUser extensions have to use <config folder>\\extensions" +
|
||||
"\n\nNever copy or install a new mpv.net version over a old mpv.net version.");
|
||||
Terminal.WriteError("Failed to load extension:" + BR2 + extDir +
|
||||
BR2 + "Only extensions that ship with mpv.net are allowed in <startup>\\extensions" +
|
||||
BR2 + "User extensions have to use <config folder>\\extensions" +
|
||||
BR2 + "Never copy or install a new mpv.net version over a old mpv.net version.");
|
||||
}
|
||||
}
|
||||
|
||||
dir = core.ConfigFolder + "extensions";
|
||||
dir = Core.ConfigFolder + "extensions";
|
||||
|
||||
if (Directory.Exists(dir))
|
||||
foreach (string extDir in Directory.GetDirectories(dir))
|
||||
116
src/Misc/ExtensionMethods.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
public static class TestStringExtension
|
||||
{
|
||||
public static bool ContainsEx(this string instance, string value)
|
||||
{
|
||||
if (instance != null && value != null)
|
||||
return instance.Contains(value);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool StartsWithEx(this string instance, string value)
|
||||
{
|
||||
if (instance != null && value != null)
|
||||
return instance.StartsWith(value);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConvertToStringExtension
|
||||
{
|
||||
public static string ToUpperEx(this string instance)
|
||||
{
|
||||
if (instance != null)
|
||||
return instance.ToUpperInvariant();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string ToLowerEx(this string instance)
|
||||
{
|
||||
if (instance != null)
|
||||
return instance.ToLowerInvariant();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string TrimEx(this string instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return "";
|
||||
|
||||
return instance.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConvertStringExtension
|
||||
{
|
||||
public static int ToInt(this string instance)
|
||||
{
|
||||
int.TryParse(instance, out int result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static float ToFloat(this string instance)
|
||||
{
|
||||
float.TryParse(instance.Replace(",", "."), NumberStyles.Float,
|
||||
CultureInfo.InvariantCulture, out float result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PathStringExtension
|
||||
{
|
||||
// return extension with lower case and without dot.
|
||||
public static string Ext(this string instance)
|
||||
{
|
||||
if (instance == null)
|
||||
return "";
|
||||
|
||||
return Path.GetExtension(instance).TrimStart('.').ToLower();
|
||||
}
|
||||
|
||||
public static string FileName(this string instance)
|
||||
{
|
||||
if (string.IsNullOrEmpty(instance))
|
||||
return "";
|
||||
|
||||
int index = instance.LastIndexOf('\\');
|
||||
|
||||
if (index > -1)
|
||||
return instance.Substring(index + 1);
|
||||
|
||||
index = instance.LastIndexOf('/');
|
||||
|
||||
if (index > -1)
|
||||
return instance.Substring(index + 1);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
// Ensure trailing directory separator char
|
||||
public static string AddSep(this string instance)
|
||||
{
|
||||
if (string.IsNullOrEmpty(instance))
|
||||
return "";
|
||||
|
||||
if (!instance.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
instance = instance + Path.DirectorySeparatorChar;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static bool IsIdenticalFolder(this string instance, string testFolder)
|
||||
{
|
||||
if (string.IsNullOrEmpty(instance) || string.IsNullOrEmpty(testFolder))
|
||||
return false;
|
||||
|
||||
return instance.ToLowerInvariant().AddSep() == testFolder.ToLowerInvariant().AddSep();
|
||||
}
|
||||
}
|
||||
13
src/Misc/Global.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Global
|
||||
{
|
||||
public static string BR = Environment.NewLine;
|
||||
public static string BR2 = Environment.NewLine + Environment.NewLine;
|
||||
|
||||
public static CorePlayer Core { get; } = new CorePlayer();
|
||||
}
|
||||
}
|
||||
191
src/Misc/GlobalHotkey.cs
Normal file
@@ -0,0 +1,191 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
class GlobalHotkey
|
||||
{
|
||||
public static Dictionary<int, string> Commands { get; set; }
|
||||
static int ID;
|
||||
static IntPtr HWND;
|
||||
|
||||
public static void RegisterGlobalHotkeys(IntPtr hwnd)
|
||||
{
|
||||
HWND = hwnd;
|
||||
string path = Core.ConfigFolder + "global-input.conf";
|
||||
|
||||
if (!File.Exists(path))
|
||||
return;
|
||||
|
||||
foreach (string i in File.ReadAllLines(path))
|
||||
{
|
||||
string line = i.Trim();
|
||||
|
||||
if (line.StartsWith("#") || !line.Contains(" "))
|
||||
continue;
|
||||
|
||||
ProcessGlobalHotkeyLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
static void ProcessGlobalHotkeyLine(string line)
|
||||
{
|
||||
string key = line.Substring(0, line.IndexOf(" "));
|
||||
string command = line.Substring(line.IndexOf(" ") + 1);
|
||||
string[] parts = key.Split('+');
|
||||
KeyModifiers mod = KeyModifiers.None;
|
||||
int vk;
|
||||
|
||||
for (int i = 0; i < parts.Length - 1; i++)
|
||||
{
|
||||
string umod = parts[i].ToUpper();
|
||||
|
||||
if (umod == "ALT") mod |= KeyModifiers.Alt;
|
||||
if (umod == "CTRL") mod |= KeyModifiers.Ctrl;
|
||||
if (umod == "SHIFT") mod |= KeyModifiers.Shift;
|
||||
if (umod == "WIN") mod |= KeyModifiers.Win;
|
||||
}
|
||||
|
||||
key = parts[parts.Length - 1];
|
||||
|
||||
if (key.Length == 1)
|
||||
{
|
||||
short result = VkKeyScanEx(key[0], GetKeyboardLayout(0));
|
||||
|
||||
int hi = result >> 8;
|
||||
int lo = result & 0xFF;
|
||||
|
||||
if (lo == -1)
|
||||
return;
|
||||
|
||||
vk = lo;
|
||||
|
||||
if ((hi & 1) == 1) mod |= KeyModifiers.Shift;
|
||||
if ((hi & 2) == 2) mod |= KeyModifiers.Ctrl;
|
||||
if ((hi & 4) == 4) mod |= KeyModifiers.Alt;
|
||||
}
|
||||
else
|
||||
vk = mpv_to_VK(key);
|
||||
|
||||
if (Commands == null)
|
||||
Commands = new Dictionary<int, string>();
|
||||
|
||||
if (vk > 0)
|
||||
{
|
||||
Commands[ID] = command.Trim();
|
||||
bool success = RegisterHotKey(HWND, ID++, mod, vk);
|
||||
|
||||
if (!success)
|
||||
Terminal.WriteError(line + ": " + new Win32Exception().Message + "\n", "global-input.conf");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Execute(int id)
|
||||
{
|
||||
if (Commands.ContainsKey(id))
|
||||
Core.command(Commands[id]);
|
||||
}
|
||||
|
||||
static int mpv_to_VK(string value)
|
||||
{
|
||||
switch (value.ToUpperEx())
|
||||
{
|
||||
case "NEXT" : return 0xB0; // VK_MEDIA_NEXT_TRACK
|
||||
case "PREV" : return 0xB1; // VK_MEDIA_PREV_TRACK
|
||||
case "STOP" : return 0xB2; // VK_MEDIA_STOP
|
||||
case "PLAYPAUSE" : return 0xB3; // VK_MEDIA_PLAY_PAUSE
|
||||
case "SLEEP" : return 0x5F; // VK_SLEEP
|
||||
case "RIGHT" : return 0x27; // VK_RIGHT
|
||||
case "UP" : return 0x26; // VK_UP
|
||||
case "LEFT" : return 0x25; // VK_LEFT
|
||||
case "DOWN" : return 0x28; // VK_DOWN
|
||||
case "PGUP" : return 0x21; // VK_PRIOR
|
||||
case "PGDWN" : return 0x22; // VK_NEXT
|
||||
case "PAUSE" : return 0x13; // VK_PAUSE
|
||||
case "PRINT" : return 0x2A; // VK_PRINT
|
||||
case "HOME" : return 0x24; // VK_HOME
|
||||
case "INS" : return 0x2D; // VK_INSERT
|
||||
case "KP_INS" : return 0x2D; // VK_INSERT
|
||||
case "DEL" : return 0x2E; // VK_DELETE
|
||||
case "KP_DEL" : return 0x2E; // VK_DELETE
|
||||
case "END" : return 0x23; // VK_END
|
||||
case "F1" : return 0x70; // VK_F1
|
||||
case "F2" : return 0x71; // VK_F2
|
||||
case "F3" : return 0x72; // VK_F3
|
||||
case "F4" : return 0x73; // VK_F4
|
||||
case "F5" : return 0x74; // VK_F5
|
||||
case "F6" : return 0x75; // VK_F6
|
||||
case "F7" : return 0x76; // VK_F7
|
||||
case "F8" : return 0x77; // VK_F8
|
||||
case "F9" : return 0x78; // VK_F9
|
||||
case "F10" : return 0x79; // VK_F10
|
||||
case "F11" : return 0x7A; // VK_F11
|
||||
case "F12" : return 0x7B; // VK_F12
|
||||
case "F13" : return 0x7C; // VK_F13
|
||||
case "F14" : return 0x7D; // VK_F14
|
||||
case "F15" : return 0x7E; // VK_F15
|
||||
case "F16" : return 0x7F; // VK_F16
|
||||
case "F17" : return 0x80; // VK_F17
|
||||
case "F18" : return 0x81; // VK_F18
|
||||
case "F19" : return 0x82; // VK_F19
|
||||
case "F20" : return 0x83; // VK_F20
|
||||
case "F21" : return 0x84; // VK_F21
|
||||
case "F22" : return 0x85; // VK_F22
|
||||
case "F23" : return 0x86; // VK_F23
|
||||
case "F24" : return 0x87; // VK_F24
|
||||
case "ENTER" : return 0x0D; // VK_RETURN
|
||||
case "KP_ENTER" : return 0x0D; // VK_RETURN
|
||||
case "TAB" : return 0x09; // VK_TAB
|
||||
case "MENU" : return 0x5D; // VK_APPS
|
||||
case "CANCEL" : return 0x03; // VK_CANCEL
|
||||
case "BS" : return 0x08; // VK_BACK
|
||||
case "KP_DEC" : return 0x6E; // VK_DECIMAL
|
||||
case "ESC" : return 0x1B; // VK_ESCAPE
|
||||
case "KP0" : return 0x60; // VK_NUMPAD0
|
||||
case "KP1" : return 0x61; // VK_NUMPAD1
|
||||
case "KP2" : return 0x62; // VK_NUMPAD2
|
||||
case "KP3" : return 0x63; // VK_NUMPAD3
|
||||
case "KP4" : return 0x64; // VK_NUMPAD4
|
||||
case "KP5" : return 0x65; // VK_NUMPAD5
|
||||
case "KP6" : return 0x66; // VK_NUMPAD6
|
||||
case "KP7" : return 0x67; // VK_NUMPAD7
|
||||
case "KP8" : return 0x68; // VK_NUMPAD8
|
||||
case "KP9" : return 0x69; // VK_NUMPAD9
|
||||
case "FAVORITES" : return 0xAB; // VK_BROWSER_FAVORITES
|
||||
case "SEARCH" : return 0xAA; // VK_BROWSER_SEARCH
|
||||
case "MAIL" : return 0xB4; // VK_LAUNCH_MAIL
|
||||
case "VOLUME_UP" : return 0xAF; // VK_VOLUME_UP
|
||||
case "VOLUME_DOWN": return 0xAE; // VK_VOLUME_DOWN
|
||||
case "MUTE" : return 0xAD; // VK_VOLUME_MUTE
|
||||
case "SPACE" : return 0x20; // VK_SPACE
|
||||
case "IDEOGRAPHIC_SPACE": return 0x20; // VK_SPACE
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
static extern short VkKeyScanEx(char ch, IntPtr dwhkl);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern IntPtr GetKeyboardLayout(uint idThread);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
static extern bool RegisterHotKey(IntPtr hWnd, int id, KeyModifiers fsModifiers, int vk);
|
||||
|
||||
[Flags]
|
||||
enum KeyModifiers
|
||||
{
|
||||
None = 0,
|
||||
Alt = 1,
|
||||
Ctrl = 2,
|
||||
Shift = 4,
|
||||
Win = 8
|
||||
}
|
||||
}
|
||||
}
|
||||
189
src/Misc/Help.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public static class ProcessHelp
|
||||
{
|
||||
public static void Execute(string file, string arguments = null)
|
||||
{
|
||||
using (Process proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = file;
|
||||
proc.StartInfo.Arguments = arguments;
|
||||
proc.StartInfo.UseShellExecute = false;
|
||||
proc.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShellExecute(string file, string arguments = null)
|
||||
{
|
||||
using (Process proc = new Process())
|
||||
{
|
||||
proc.StartInfo.FileName = file;
|
||||
proc.StartInfo.Arguments = arguments;
|
||||
proc.StartInfo.UseShellExecute = true;
|
||||
proc.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 GetProfiles()
|
||||
{
|
||||
string code = @"
|
||||
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort name))
|
||||
{
|
||||
$item.name
|
||||
''
|
||||
|
||||
foreach ($option in $item.options)
|
||||
{
|
||||
' ' + $option.key + ' = ' + $option.value
|
||||
}
|
||||
|
||||
''
|
||||
}";
|
||||
|
||||
string json = Core.get_property_string("profile-list");
|
||||
return PowerShell.InvokeAndReturnString(code, "json", json).Trim();
|
||||
}
|
||||
|
||||
public static string GetDecoders()
|
||||
{
|
||||
string code = @"
|
||||
foreach ($item in ($json | ConvertFrom-Json | foreach { $_ } | sort codec))
|
||||
{
|
||||
$item.codec + ' - ' + $item.description
|
||||
}";
|
||||
|
||||
string json = Core.get_property_string("decoder-list");
|
||||
return PowerShell.InvokeAndReturnString(code, "json", json).Trim();
|
||||
}
|
||||
|
||||
public static string GetProtocols()
|
||||
{
|
||||
string list = Core.get_property_string("protocol-list");
|
||||
return string.Join(BR, list.Split(',').OrderBy(a => a));
|
||||
}
|
||||
|
||||
public static string GetDemuxers()
|
||||
{
|
||||
string list = Core.get_property_string("demuxer-lavf-list");
|
||||
return string.Join(BR, list.Split(',').OrderBy(a => a));
|
||||
}
|
||||
}
|
||||
|
||||
public class RegistryHelp
|
||||
{
|
||||
public static string ApplicationKey { get; } = @"HKCU\Software\" + Application.ProductName;
|
||||
|
||||
public static void SetInt(string name, object value)
|
||||
{
|
||||
SetValue(ApplicationKey, name, value);
|
||||
}
|
||||
|
||||
public static void SetString(string name, string value)
|
||||
{
|
||||
SetValue(ApplicationKey, name, value);
|
||||
}
|
||||
|
||||
public static void SetValue(string name, object value)
|
||||
{
|
||||
using (RegistryKey regKey = GetRootKey(ApplicationKey).CreateSubKey(ApplicationKey.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree))
|
||||
regKey.SetValue(name, value);
|
||||
}
|
||||
|
||||
public static void SetValue(string path, string name, object value)
|
||||
{
|
||||
using (RegistryKey regKey = GetRootKey(path).CreateSubKey(path.Substring(5), RegistryKeyPermissionCheck.ReadWriteSubTree))
|
||||
regKey.SetValue(name, value);
|
||||
}
|
||||
|
||||
public static string GetString(string name, string defaultValue = "")
|
||||
{
|
||||
object value = GetValue(ApplicationKey, name, defaultValue);
|
||||
return !(value is string) ? defaultValue : value.ToString();
|
||||
}
|
||||
|
||||
public static int GetInt(string name, int defaultValue = 0)
|
||||
{
|
||||
object value = GetValue(ApplicationKey, name, defaultValue);
|
||||
return !(value is int) ? defaultValue : (int)value;
|
||||
}
|
||||
|
||||
public static object GetValue(string name) => GetValue(ApplicationKey, name, null);
|
||||
|
||||
public static object GetValue(string path, string name, object defaultValue = null)
|
||||
{
|
||||
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5)))
|
||||
return regKey == null ? null : regKey.GetValue(name, defaultValue);
|
||||
}
|
||||
|
||||
public static void RemoveKey(string path)
|
||||
{
|
||||
try {
|
||||
GetRootKey(path).DeleteSubKeyTree(path.Substring(5), false);
|
||||
} catch { }
|
||||
}
|
||||
|
||||
public static void RemoveValue(string path, string name)
|
||||
{
|
||||
try {
|
||||
using (RegistryKey regKey = GetRootKey(path).OpenSubKey(path.Substring(5), true))
|
||||
if (regKey != null)
|
||||
regKey.DeleteValue(name, false);
|
||||
} catch { }
|
||||
}
|
||||
|
||||
static RegistryKey GetRootKey(string path)
|
||||
{
|
||||
switch (path.Substring(0, 4))
|
||||
{
|
||||
case "HKLM": return Registry.LocalMachine;
|
||||
case "HKCU": return Registry.CurrentUser;
|
||||
case "HKCR": return Registry.ClassesRoot;
|
||||
default: throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ 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;
|
||||
@@ -14,7 +13,7 @@ using System.Windows.Forms;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
using static mpvnet.Core;
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -43,6 +42,34 @@ namespace mpvnet
|
||||
int IComparer<string>.Compare(string x, string y) => IComparerOfString_Compare(x, y);
|
||||
}
|
||||
|
||||
public class Input
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public class FileAssociation
|
||||
{
|
||||
static string ExePath = Application.ExecutablePath;
|
||||
@@ -69,38 +96,19 @@ namespace mpvnet
|
||||
RegistryHelp.SetValue($@"HKCR\" + "." + ext, null, ExeFilenameNoExt + "." + ext);
|
||||
RegistryHelp.SetValue($@"HKCR\" + "." + ext + @"\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, "");
|
||||
|
||||
if (App.VideoTypes.Contains(ext))
|
||||
if (CorePlayer.VideoTypes.Contains(ext))
|
||||
RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "video");
|
||||
|
||||
if (App.AudioTypes.Contains(ext))
|
||||
if (CorePlayer.AudioTypes.Contains(ext))
|
||||
RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "audio");
|
||||
|
||||
if (App.ImageTypes.Contains(ext))
|
||||
if (CorePlayer.ImageTypes.Contains(ext))
|
||||
RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "image");
|
||||
|
||||
RegistryHelp.SetValue($@"HKCR\" + ExeFilenameNoExt + "." + ext + @"\shell\open\command", null, $"\"{ExePath}\" \"%1\"");
|
||||
RegistryHelp.SetValue(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Unregister()
|
||||
{
|
||||
RegistryHelp.RemoveKey($@"HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename);
|
||||
RegistryHelp.RemoveKey($@"HKCR\Applications\" + ExeFilename);
|
||||
RegistryHelp.RemoveKey($@"HKLM\SOFTWARE\Clients\Media\mpv.net");
|
||||
RegistryHelp.RemoveKey($@"HKCR\SystemFileAssociations\video\OpenWithList\" + ExeFilename);
|
||||
RegistryHelp.RemoveKey($@"HKCR\SystemFileAssociations\audio\OpenWithList\" + ExeFilename);
|
||||
RegistryHelp.RemoveValue(@"HKLM\SOFTWARE\RegisteredApplications", "mpv.net");
|
||||
|
||||
foreach (string id in Registry.ClassesRoot.GetSubKeyNames())
|
||||
{
|
||||
if (id.StartsWith(ExeFilenameNoExt + "."))
|
||||
Registry.ClassesRoot.DeleteSubKeyTree(id);
|
||||
|
||||
RegistryHelp.RemoveValue($@"HKCR\Software\Classes\{id}\OpenWithProgIDs", ExeFilenameNoExt + id);
|
||||
RegistryHelp.RemoveValue($@"HKLM\Software\Classes\{id}\OpenWithProgIDs", ExeFilenameNoExt + id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MediaTrack
|
||||
@@ -116,6 +124,7 @@ namespace mpvnet
|
||||
|
||||
public string Path { get; set; } = "";
|
||||
public string Command { get; set; } = "";
|
||||
public string Display { get { return string.IsNullOrEmpty(Path) ? Command : Path; } }
|
||||
|
||||
public CommandItem() { }
|
||||
|
||||
@@ -188,45 +197,35 @@ namespace mpvnet
|
||||
public static ObservableCollection<CommandItem> Items {
|
||||
get {
|
||||
if (_Items is null)
|
||||
_Items = GetItems(File.ReadAllText(core.InputConfPath));
|
||||
_Items = GetItems(File.ReadAllText(Core.InputConfPath));
|
||||
|
||||
return _Items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 + @"\";
|
||||
public static string Startup { get; } = Application.StartupPath.AddSep();
|
||||
public static string AppData { get; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).AddSep();
|
||||
|
||||
public static string CustomSettings {
|
||||
get {
|
||||
string linkFile = Startup + "settings-directory.txt";
|
||||
|
||||
if (File.Exists(linkFile))
|
||||
{
|
||||
string linkTarget = File.ReadAllText(linkFile).Trim();
|
||||
|
||||
if (linkTarget.StartsWithEx("."))
|
||||
linkTarget = Startup + linkTarget;
|
||||
|
||||
if (Directory.Exists(linkTarget))
|
||||
return linkTarget.AddSep();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
src/Misc/Msg.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
public class Msg
|
||||
{
|
||||
public static void ShowInfo(object title, object content = null)
|
||||
{
|
||||
Show(title, content, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
public static void ShowError(object title, object content = null)
|
||||
{
|
||||
Show(title, content, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
public static void ShowWarning(object title, object content = null)
|
||||
{
|
||||
Show(title, content, MessageBoxIcon.Warning);
|
||||
}
|
||||
|
||||
public static DialogResult ShowQuestion(object title, object content = null,
|
||||
MessageBoxButtons buttons = MessageBoxButtons.OKCancel)
|
||||
{
|
||||
return Show(title, content, MessageBoxIcon.Question, buttons);
|
||||
}
|
||||
|
||||
public static void ShowException(Exception exception)
|
||||
{
|
||||
Show(exception, null, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
public static DialogResult Show(object title, object content, MessageBoxIcon icon,
|
||||
MessageBoxButtons buttons = MessageBoxButtons.OK)
|
||||
{
|
||||
string msg = (title?.ToString().TrimEx() + BR2 + content?.ToString().TrimEx()).Trim();
|
||||
return MessageBox.Show(msg, Application.ProductName, buttons, icon);
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,8 @@ using System.Linq;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Runspaces;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using static mpvnet.Core;
|
||||
using static NewLine;
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -20,13 +18,13 @@ namespace mpvnet
|
||||
public bool Print { get; set; }
|
||||
public List<string> Scripts { get; } = new List<string>();
|
||||
public List<KeyValuePair<string, object>> Variables = new List<KeyValuePair<string, object>>();
|
||||
public string[] Parameters { get; }
|
||||
public string[] Arguments { get; }
|
||||
public event Action<string, object[]> Event;
|
||||
public event Action<string, object> PropertyChanged;
|
||||
public List<KeyValuePair<string, ScriptBlock>> EventHandlers = new List<KeyValuePair<string, ScriptBlock>>();
|
||||
public List<KeyValuePair<string, ScriptBlock>> PropChangedHandlers = new List<KeyValuePair<string, ScriptBlock>>();
|
||||
|
||||
public static List<PowerShell> Instances { get; } = new List<PowerShell>();
|
||||
public static List<PowerShell> References { get; } = new List<PowerShell>();
|
||||
|
||||
public object Invoke() => Invoke(null, null);
|
||||
|
||||
@@ -42,8 +40,8 @@ namespace mpvnet
|
||||
foreach (string script in Scripts)
|
||||
Pipeline.Commands.AddScript(script);
|
||||
|
||||
if (Parameters != null)
|
||||
foreach (string param in Parameters)
|
||||
if (Arguments != null)
|
||||
foreach (string param in Arguments)
|
||||
foreach (Command command in Pipeline.Commands)
|
||||
command.Parameters.Add(null, param);
|
||||
|
||||
@@ -91,7 +89,7 @@ namespace mpvnet
|
||||
var output = sender as PipelineReader<PSObject>;
|
||||
|
||||
while (output.Count > 0)
|
||||
ConsoleHelp.Write(output.Read(), Module);
|
||||
Terminal.Write(output.Read(), Module);
|
||||
}
|
||||
|
||||
public void Error_DataReady(object sender, EventArgs e)
|
||||
@@ -99,7 +97,7 @@ namespace mpvnet
|
||||
var output = sender as PipelineReader<Object>;
|
||||
|
||||
while (output.Count > 0)
|
||||
ConsoleHelp.WriteError(output.Read(), Module);
|
||||
Terminal.WriteError(output.Read(), Module);
|
||||
}
|
||||
|
||||
public void RedirectStreams(PSEventJob job)
|
||||
@@ -111,25 +109,25 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
public void commandv(params string[] args) => core.commandv(args);
|
||||
public void commandv(params string[] args) => Core.commandv(args);
|
||||
|
||||
public void command(string command) => core.command(command);
|
||||
public void command(string command) => Core.command(command);
|
||||
|
||||
public bool get_property_bool(string name) => core.get_property_bool(name);
|
||||
public bool get_property_bool(string name) => Core.get_property_bool(name);
|
||||
|
||||
public void set_property_bool(string name, bool value) => core.set_property_bool(name, value);
|
||||
public void set_property_bool(string name, bool value) => Core.set_property_bool(name, value);
|
||||
|
||||
public int get_property_int(string name) => core.get_property_int(name);
|
||||
public int get_property_int(string name) => Core.get_property_int(name);
|
||||
|
||||
public void set_property_int(string name, int value) => core.set_property_int(name, value);
|
||||
public void set_property_int(string name, int value) => Core.set_property_int(name, value);
|
||||
|
||||
public double get_property_number(string name) => core.get_property_number(name);
|
||||
public double get_property_number(string name) => Core.get_property_number(name);
|
||||
|
||||
public void set_property_number(string name, double value) => core.set_property_number(name, value);
|
||||
public void set_property_number(string name, double value) => Core.set_property_number(name, value);
|
||||
|
||||
public string get_property_string(string name) => core.get_property_string(name);
|
||||
public string get_property_string(string name) => Core.get_property_string(name);
|
||||
|
||||
public void set_property_string(string name, string value) => core.set_property_string(name, value);
|
||||
public void set_property_string(string name, string value) => Core.set_property_string(name, value);
|
||||
|
||||
public void observe_property(string name, string type, ScriptBlock sb)
|
||||
{
|
||||
@@ -138,19 +136,19 @@ namespace mpvnet
|
||||
switch (type)
|
||||
{
|
||||
case "bool": case "boolean":
|
||||
core.observe_property_bool(name, (value) => Task.Run(() => PropertyChanged.Invoke(name, value)));
|
||||
Core.observe_property_bool(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value)));
|
||||
break;
|
||||
case "string":
|
||||
core.observe_property_string(name, (value) => Task.Run(() => PropertyChanged.Invoke(name, value)));
|
||||
Core.observe_property_string(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value)));
|
||||
break;
|
||||
case "int": case "integer":
|
||||
core.observe_property_int(name, (value) => Task.Run(() => PropertyChanged.Invoke(name, value)));
|
||||
Core.observe_property_int(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value)));
|
||||
break;
|
||||
case "float": case "double":
|
||||
core.observe_property_double(name, (value) => Task.Run(() => PropertyChanged.Invoke(name, value)));
|
||||
Core.observe_property_double(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value)));
|
||||
break;
|
||||
case "nil": case "none": case "native":
|
||||
core.observe_property(name, () => Task.Run(() => PropertyChanged.Invoke(name, null)));
|
||||
Core.observe_property(name, () => App.RunTask(() => PropertyChanged.Invoke(name, null)));
|
||||
break;
|
||||
default:
|
||||
App.ShowError("Invalid Type", "Valid types are: bool or boolean, string, int or integer, float or double, nil or none or native");
|
||||
@@ -165,59 +163,59 @@ namespace mpvnet
|
||||
switch (name)
|
||||
{
|
||||
case "log-message":
|
||||
core.LogMessageAsync += (level, msg) => Event.Invoke("log-message", new object[] { level, msg });
|
||||
Core.LogMessageAsync += (level, msg) => Event.Invoke("log-message", new object[] { level, msg });
|
||||
break;
|
||||
|
||||
case "end-file":
|
||||
core.EndFileAsync += (reason) => Event.Invoke("end-file", new object[] { reason });
|
||||
Core.EndFileAsync += reason => Event.Invoke("end-file", new object[] { reason });
|
||||
break;
|
||||
|
||||
case "client-message":
|
||||
core.ClientMessageAsync += (args) => Event.Invoke("client-message", args);
|
||||
Core.ClientMessageAsync += args => Event.Invoke("client-message", args);
|
||||
break;
|
||||
|
||||
case "shutdown":
|
||||
core.Shutdown += () => Event.Invoke("shutdown", null);
|
||||
Core.Shutdown += () => Event.Invoke("shutdown", null);
|
||||
break;
|
||||
|
||||
case "get-property-reply":
|
||||
core.GetPropertyReplyAsync += () => Event.Invoke("get-property-reply", null);
|
||||
Core.GetPropertyReplyAsync += () => Event.Invoke("get-property-reply", null);
|
||||
break;
|
||||
|
||||
case "set-property-reply":
|
||||
core.SetPropertyReplyAsync += () => Event.Invoke("set-property-reply", null);
|
||||
Core.SetPropertyReplyAsync += () => Event.Invoke("set-property-reply", null);
|
||||
break;
|
||||
|
||||
case "command-reply":
|
||||
core.CommandReplyAsync += () => Event.Invoke("command-reply", null);
|
||||
Core.CommandReplyAsync += () => Event.Invoke("command-reply", null);
|
||||
break;
|
||||
|
||||
case "start-file":
|
||||
core.StartFileAsync += () => Event.Invoke("start-file", null);
|
||||
Core.StartFileAsync += () => Event.Invoke("start-file", null);
|
||||
break;
|
||||
|
||||
case "file-loaded":
|
||||
core.FileLoadedAsync += () => Event.Invoke("file-loaded", null);
|
||||
Core.FileLoadedAsync += () => Event.Invoke("file-loaded", null);
|
||||
break;
|
||||
|
||||
case "idle":
|
||||
core.IdleAsync += () => Event.Invoke("idle", null);
|
||||
Core.IdleAsync += () => Event.Invoke("idle", null);
|
||||
break;
|
||||
|
||||
case "video-reconfig":
|
||||
core.VideoReconfigAsync += () => Event.Invoke("video-reconfig", null);
|
||||
Core.VideoReconfigAsync += () => Event.Invoke("video-reconfig", null);
|
||||
break;
|
||||
|
||||
case "audio-reconfig":
|
||||
core.AudioReconfigAsync += () => Event.Invoke("audio-reconfig", null);
|
||||
Core.AudioReconfigAsync += () => Event.Invoke("audio-reconfig", null);
|
||||
break;
|
||||
|
||||
case "seek":
|
||||
core.SeekAsync += () => Event.Invoke("seek", null);
|
||||
Core.SeekAsync += () => Event.Invoke("seek", null);
|
||||
break;
|
||||
|
||||
case "playback-restart":
|
||||
core.PlaybackRestartAsync += () => Event.Invoke("playback-restart", null);
|
||||
Core.PlaybackRestartAsync += () => Event.Invoke("playback-restart", null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -225,19 +223,13 @@ namespace mpvnet
|
||||
void Output_DataAdded(object sender, DataAddedEventArgs e)
|
||||
{
|
||||
var output = sender as PSDataCollection<PSObject>;
|
||||
ConsoleHelp.Write(output[e.Index], Module);
|
||||
Terminal.Write(output[e.Index], Module);
|
||||
}
|
||||
|
||||
void Error_DataAdded(object sender, DataAddedEventArgs e)
|
||||
{
|
||||
var error = sender as PSDataCollection<ErrorRecord>;
|
||||
ConsoleHelp.WriteError(error[e.Index], Module);
|
||||
}
|
||||
|
||||
public static void Shutdown()
|
||||
{
|
||||
foreach (PowerShell ps in Instances)
|
||||
ps.Runspace.Dispose();
|
||||
Terminal.WriteError(error[e.Index], Module);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
using static mpvnet.Core;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
static class Program
|
||||
@@ -21,19 +19,21 @@ namespace mpvnet
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
if (App.IsStartedFromTerminal)
|
||||
WinAPI.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
|
||||
|
||||
if (core.ConfigFolder == "")
|
||||
return;
|
||||
Native.AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/);
|
||||
|
||||
string[] args = Environment.GetCommandLineArgs().Skip(1).ToArray();
|
||||
|
||||
if (args.Length == 2 && args[0] == "--reg-file-assoc")
|
||||
if (args.Length >= 2 && args[0] == "--reg-file-assoc")
|
||||
{
|
||||
if (args[1] == "audio") FileAssociation.Register(App.AudioTypes);
|
||||
if (args[1] == "video") FileAssociation.Register(App.VideoTypes);
|
||||
if (args[1] == "image") FileAssociation.Register(App.ImageTypes);
|
||||
if (args[1] == "unreg") FileAssociation.Unregister();
|
||||
if (args[1] == "audio")
|
||||
FileAssociation.Register(CorePlayer.AudioTypes);
|
||||
else if (args[1] == "video")
|
||||
FileAssociation.Register(CorePlayer.VideoTypes);
|
||||
else if (args[1] == "image")
|
||||
FileAssociation.Register(CorePlayer.ImageTypes);
|
||||
else
|
||||
FileAssociation.Register(args.Skip(1).ToArray());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,17 +42,22 @@ namespace mpvnet
|
||||
|
||||
if ((App.ProcessInstance == "single" || App.ProcessInstance == "queue") && !isFirst)
|
||||
{
|
||||
List<string> files = new List<string>();
|
||||
files.Add(App.ProcessInstance);
|
||||
List<string> args2 = new List<string>();
|
||||
args2.Add(App.ProcessInstance);
|
||||
|
||||
foreach (string arg in args)
|
||||
{
|
||||
if (!arg.StartsWith("--") && (arg == "-" || arg.Contains("://") ||
|
||||
arg.Contains(":\\") || arg.StartsWith("\\\\")))
|
||||
|
||||
files.Add(arg);
|
||||
args2.Add(arg);
|
||||
else if (arg == "--queue")
|
||||
files[0] = "queue";
|
||||
args2[0] = "queue";
|
||||
else if (arg.StartsWith("--command="))
|
||||
{
|
||||
args2[0] = "command";
|
||||
args2.Add(arg.Substring(10));
|
||||
}
|
||||
}
|
||||
|
||||
Process[] procs = Process.GetProcessesByName("mpvnet");
|
||||
@@ -63,15 +68,15 @@ namespace mpvnet
|
||||
{
|
||||
if (proc.MainWindowHandle != IntPtr.Zero)
|
||||
{
|
||||
WinAPI.AllowSetForegroundWindow(proc.Id);
|
||||
var data = new WinAPI.COPYDATASTRUCT();
|
||||
data.lpData = string.Join("\n", files.ToArray());
|
||||
Native.AllowSetForegroundWindow(proc.Id);
|
||||
var data = new Native.COPYDATASTRUCT();
|
||||
data.lpData = string.Join("\n", args2.ToArray());
|
||||
data.cbData = data.lpData.Length * 2 + 1;
|
||||
WinAPI.SendMessage(proc.MainWindowHandle, 0x004A /*WM_COPYDATA*/, IntPtr.Zero, ref data);
|
||||
Native.SendMessage(proc.MainWindowHandle, 0x004A /*WM_COPYDATA*/, IntPtr.Zero, ref data);
|
||||
mutex.Dispose();
|
||||
|
||||
if (App.IsStartedFromTerminal)
|
||||
WinAPI.FreeConsole();
|
||||
Native.FreeConsole();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -87,7 +92,7 @@ namespace mpvnet
|
||||
Application.Run(new MainForm());
|
||||
|
||||
if (App.IsStartedFromTerminal)
|
||||
WinAPI.FreeConsole();
|
||||
Native.FreeConsole();
|
||||
|
||||
mutex.Dispose();
|
||||
}
|
||||
56
src/Misc/Settings.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
[Serializable()]
|
||||
public class AppSettings
|
||||
{
|
||||
public int LastUpdateCheck;
|
||||
public int Volume = 70;
|
||||
public List<string> RecentFiles = new List<string>();
|
||||
public Point WindowLocation;
|
||||
public Point WindowPosition;
|
||||
public Size WindowSize;
|
||||
public string ConfigEditorSearch = "";
|
||||
public string Mute = "no";
|
||||
public string UpdateCheckVersion = "";
|
||||
}
|
||||
|
||||
class SettingsManager
|
||||
{
|
||||
public static string SettingsFile {
|
||||
get => Core.ConfigFolder + "settings.xml";
|
||||
}
|
||||
|
||||
public static AppSettings Load()
|
||||
{
|
||||
if (!File.Exists(SettingsFile))
|
||||
return new AppSettings();
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(AppSettings));
|
||||
|
||||
using (FileStream fs = new FileStream(SettingsFile, FileMode.Open))
|
||||
return (AppSettings)serializer.Deserialize(fs);
|
||||
}
|
||||
|
||||
public static void Save(object obj)
|
||||
{
|
||||
using (XmlTextWriter writer = new XmlTextWriter(SettingsFile, Encoding.UTF8))
|
||||
{
|
||||
writer.Formatting = Formatting.Indented;
|
||||
writer.Indentation = 4;
|
||||
XmlSerializer serializer = new XmlSerializer(obj.GetType());
|
||||
serializer.Serialize(writer, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
50
src/Misc/Terminal.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public static class Terminal
|
||||
{
|
||||
static int Padding { get; } = 60;
|
||||
|
||||
public static void WriteError(object obj, string module = "mpv.net")
|
||||
{
|
||||
Write(obj, module, ConsoleColor.DarkRed, 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;
|
||||
|
||||
string value = obj.ToString();
|
||||
|
||||
if (!string.IsNullOrEmpty(module))
|
||||
module = "[" + module + "] ";
|
||||
|
||||
if (useDefaultColor)
|
||||
Console.ResetColor();
|
||||
else
|
||||
Console.ForegroundColor = color;
|
||||
|
||||
value = module + value;
|
||||
|
||||
if (value.Length < Padding)
|
||||
value = value.PadRight(Padding);
|
||||
|
||||
if (color == ConsoleColor.Red || color == ConsoleColor.DarkRed)
|
||||
Console.Error.WriteLine(value);
|
||||
else
|
||||
Console.WriteLine(value);
|
||||
|
||||
Console.ResetColor();
|
||||
Trace.WriteLine(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace UI
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Theme
|
||||
{
|
||||
@@ -14,10 +14,10 @@ namespace UI
|
||||
|
||||
public static Theme Current { get; set; }
|
||||
|
||||
public static Brush Foreground { get; set; }
|
||||
public static Brush Foreground2 { get; set; }
|
||||
public static Brush Background { get; set; }
|
||||
public static Brush Heading { get; set; }
|
||||
public Brush Foreground { get; set; }
|
||||
public Brush Foreground2 { get; set; }
|
||||
public Brush Background { get; set; }
|
||||
public Brush Heading { get; set; }
|
||||
|
||||
public System.Drawing.Color GetWinFormsColor(string key)
|
||||
{
|
||||
@@ -31,6 +31,8 @@ namespace UI
|
||||
|
||||
public static void Init(string customContent, string defaultContent, string activeTheme)
|
||||
{
|
||||
Current = null;
|
||||
|
||||
DefaultThemes = Load(defaultContent);
|
||||
CustomThemes = Load(customContent);
|
||||
|
||||
@@ -45,7 +47,7 @@ namespace UI
|
||||
if (!theme.Dictionary.ContainsKey(key))
|
||||
{
|
||||
isKeyMissing = true;
|
||||
ConsoleHelp.WriteError($"Theme '{activeTheme}' misses '{key}'");
|
||||
Terminal.WriteError($"Theme '{activeTheme}' misses '{key}'");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -65,10 +67,10 @@ namespace UI
|
||||
if (Current == null)
|
||||
Current = DefaultThemes[0];
|
||||
|
||||
Foreground = Current.GetBrush("foreground");
|
||||
Foreground2 = Current.GetBrush("foreground2");
|
||||
Background = Current.GetBrush("background");
|
||||
Heading = Current.GetBrush("heading");
|
||||
Current.Foreground = Current.GetBrush("foreground");
|
||||
Current.Foreground2 = Current.GetBrush("foreground2");
|
||||
Current.Background = Current.GetBrush("background");
|
||||
Current.Heading = Current.GetBrush("heading");
|
||||
}
|
||||
|
||||
static List<Theme> Load(string content)
|
||||
@@ -1,12 +1,13 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using static mpvnet.Core;
|
||||
using static mpvnet.Global;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -14,9 +15,7 @@ namespace mpvnet
|
||||
{
|
||||
public static void DailyCheck()
|
||||
{
|
||||
if (App.UpdateCheck && RegistryHelp.GetInt(RegistryHelp.ApplicationKey, "UpdateCheckLast")
|
||||
!= DateTime.Now.DayOfYear)
|
||||
|
||||
if (App.UpdateCheck && App.Settings.LastUpdateCheck != DateTime.Now.DayOfYear)
|
||||
CheckOnline();
|
||||
}
|
||||
|
||||
@@ -26,36 +25,42 @@ namespace mpvnet
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
RegistryHelp.SetValue(RegistryHelp.ApplicationKey, "UpdateCheckLast", DateTime.Now.DayOfYear);
|
||||
App.Settings.LastUpdateCheck = DateTime.Now.DayOfYear;
|
||||
client.DefaultRequestHeaders.Add("User-Agent", "mpv.net");
|
||||
var response = await client.GetAsync("https://api.github.com/repos/stax76/mpv.net/releases/latest");
|
||||
response.EnsureSuccessStatusCode();
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
Match match = Regex.Match(content, @"""mpv\.net-portable-x64-([\d\.]+)\.7z""");
|
||||
Match match = Regex.Match(content, @"""mpv\.net-([\d\.]+)-portable\.zip""");
|
||||
|
||||
if (!match.Success)
|
||||
{
|
||||
App.ShowError("Update check is currently not available.");
|
||||
return;
|
||||
}
|
||||
|
||||
Version onlineVersion = Version.Parse(match.Groups[1].Value);
|
||||
Version currentVersion = Assembly.GetEntryAssembly().GetName().Version;
|
||||
|
||||
if (onlineVersion <= currentVersion)
|
||||
{
|
||||
if (showUpToDateMessage)
|
||||
Msg.Show($"{Application.ProductName} is up to date.");
|
||||
Msg.ShowInfo($"{Application.ProductName} is up to date.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((RegistryHelp.GetString(RegistryHelp.ApplicationKey, "UpdateCheckVersion")
|
||||
!= onlineVersion.ToString() || showUpToDateMessage) && Msg.ShowQuestion(
|
||||
$"New version {onlineVersion} is available, update now?") == MsgResult.OK)
|
||||
if ((App.Settings.UpdateCheckVersion != onlineVersion.ToString() ||
|
||||
showUpToDateMessage) && Msg.ShowQuestion(
|
||||
$"New version {onlineVersion} is available, update now?") == DialogResult.OK)
|
||||
{
|
||||
string arch = IntPtr.Size == 8 ? "64" : "86";
|
||||
string url = $"https://github.com/stax76/mpv.net/releases/download/{onlineVersion}/mpv.net-portable-x{arch}-{onlineVersion}.7z";
|
||||
string url = $"https://github.com/stax76/mpv.net/releases/download/{onlineVersion}/mpv.net-{onlineVersion}-portable.zip";
|
||||
|
||||
using (Process proc = new Process())
|
||||
{
|
||||
proc.StartInfo.UseShellExecute = true;
|
||||
proc.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||
proc.StartInfo.FileName = "PowerShell";
|
||||
proc.StartInfo.Arguments = $"-NoLogo -NoExit -File \"{Folder.Startup + "Update.ps1"}\" \"{url}\" \"{Application.StartupPath.TrimEnd('\\')}\"";
|
||||
proc.StartInfo.FileName = "powershell.exe";
|
||||
proc.StartInfo.Arguments = $"-NoExit -ExecutionPolicy Bypass -File \"{Folder.Startup + "Setup\\update.ps1"}\" \"{url}\" \"{Folder.Startup.TrimEnd(Path.DirectorySeparatorChar)}\"";
|
||||
|
||||
if (Folder.Startup.Contains("Program Files"))
|
||||
proc.StartInfo.Verb = "runas";
|
||||
@@ -63,16 +68,16 @@ namespace mpvnet
|
||||
proc.Start();
|
||||
}
|
||||
|
||||
core.command("quit");
|
||||
Core.command("quit");
|
||||
}
|
||||
|
||||
RegistryHelp.SetValue(RegistryHelp.ApplicationKey, "UpdateCheckVersion", onlineVersion.ToString());
|
||||
App.Settings.UpdateCheckVersion = onlineVersion.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (showUpToDateMessage)
|
||||
Msg.ShowException(ex);
|
||||
App.ShowException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
159
src/Native/Native.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Native
|
||||
{
|
||||
static Version Windows_10_1607 = new Version(10, 0, 14393); // Windows 10 1607
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool AttachConsole(int dwProcessId);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool FreeConsole();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr LoadLibrary(string path);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr FindWindowEx(
|
||||
IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern IntPtr PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||
public static extern int RegisterWindowMessage(string id);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AllowSetForegroundWindow(int dwProcessId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern void ReleaseCapture();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int GetDpiForWindow(IntPtr hwnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AdjustWindowRect(ref RECT lpRect, uint dwStyle, bool bMenu);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AdjustWindowRectExForDpi(
|
||||
ref RECT lpRect, uint dwStyle, bool bMenu, uint dwExStyle, uint dpi);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool SetWindowPos(
|
||||
IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
|
||||
static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
|
||||
static extern IntPtr GetWindowLong64(IntPtr hWnd, int nIndex);
|
||||
|
||||
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
|
||||
{
|
||||
if (IntPtr.Size == 8)
|
||||
return GetWindowLong64(hWnd, nIndex);
|
||||
else
|
||||
return GetWindowLong32(hWnd, nIndex);
|
||||
}
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
public RECT(Rectangle r)
|
||||
{
|
||||
Left = r.Left;
|
||||
Top = r.Top;
|
||||
Right = r.Right;
|
||||
Bottom = r.Bottom;
|
||||
}
|
||||
|
||||
public RECT(int left, int top, int right, int bottom)
|
||||
{
|
||||
Left = left;
|
||||
Top = top;
|
||||
Right = right;
|
||||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public Rectangle ToRectangle() => Rectangle.FromLTRB(Left, Top, Right, Bottom);
|
||||
public Size Size => new Size(Right - Left, Bottom - Top);
|
||||
public int Width => Right - Left;
|
||||
public int Height => Bottom - Top;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct COPYDATASTRUCT
|
||||
{
|
||||
public IntPtr dwData;
|
||||
public int cbData;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string lpData;
|
||||
}
|
||||
|
||||
public static int GetResizeBorder(int v)
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case 1 /* WMSZ_LEFT */ : return 3;
|
||||
case 3 /* WMSZ_TOP */ : return 2;
|
||||
case 2 /* WMSZ_RIGHT */ : return 3;
|
||||
case 6 /* WMSZ_BOTTOM */ : return 2;
|
||||
case 4 /* WMSZ_TOPLEFT */ : return 1;
|
||||
case 5 /* WMSZ_TOPRIGHT */ : return 1;
|
||||
case 7 /* WMSZ_BOTTOMLEFT */ : return 3;
|
||||
case 8 /* WMSZ_BOTTOMRIGHT */ : return 3;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SubtractWindowBorders(IntPtr hwnd, ref RECT rc, int dpi)
|
||||
{
|
||||
RECT r = new RECT(0, 0, 0, 0);
|
||||
AddWindowBorders(hwnd, ref r, dpi);
|
||||
rc.Left -= r.Left;
|
||||
rc.Top -= r.Top;
|
||||
rc.Right -= r.Right;
|
||||
rc.Bottom -= r.Bottom;
|
||||
}
|
||||
|
||||
public static void AddWindowBorders(IntPtr hwnd, ref RECT rc, int dpi)
|
||||
{
|
||||
uint windowStyle = (uint)GetWindowLong(hwnd, -16); // GWL_STYLE
|
||||
uint windowStyleEx = (uint)GetWindowLong(hwnd, -20); // GWL_EXSTYLE
|
||||
|
||||
if (Environment.OSVersion.Version >= Windows_10_1607)
|
||||
AdjustWindowRectExForDpi(ref rc, windowStyle, false, windowStyleEx, (uint)dpi);
|
||||
else
|
||||
AdjustWindowRect(ref rc, windowStyle, false);
|
||||
}
|
||||
|
||||
public static int GetDPI(IntPtr hwnd)
|
||||
{
|
||||
if (Environment.OSVersion.Version >= Windows_10_1607 && hwnd != IntPtr.Zero)
|
||||
return GetDpiForWindow(hwnd);
|
||||
else
|
||||
using (Graphics gx = Graphics.FromHwnd(hwnd))
|
||||
return GetDeviceCaps(gx.GetHdc(), 88 /*LOGPIXELSX*/);
|
||||
}
|
||||
}
|
||||
}
|
||||
131
src/Native/StockIcon.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class StockIcon
|
||||
{
|
||||
[DllImport("shell32.dll")]
|
||||
public static extern int SHGetStockIconInfo(SHSTOCKICONID siid, SHSTOCKICONFLAGS uFlags, ref SHSTOCKICONINFO info);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool DestroyIcon(IntPtr handle);
|
||||
|
||||
public static IntPtr GetIcon(SHSTOCKICONID identifier, SHSTOCKICONFLAGS flags)
|
||||
{
|
||||
SHSTOCKICONINFO info = new SHSTOCKICONINFO();
|
||||
info.cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(SHSTOCKICONINFO)));
|
||||
Marshal.ThrowExceptionForHR(SHGetStockIconInfo(identifier, flags, ref info));
|
||||
return info.hIcon;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
public struct SHSTOCKICONINFO
|
||||
{
|
||||
public uint cbSize;
|
||||
public IntPtr hIcon;
|
||||
int iSysImageIndex;
|
||||
int iIcon;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
||||
string szPath;
|
||||
}
|
||||
|
||||
public enum SHSTOCKICONFLAGS : uint
|
||||
{
|
||||
SHGSI_ICONLOCATION = 0,
|
||||
SHGSI_ICON = 0x000000100,
|
||||
SHGSI_SYSICONINDEX = 0x000004000,
|
||||
SHGSI_LINKOVERLAY = 0x000008000,
|
||||
SHGSI_SELECTED = 0x000010000,
|
||||
SHGSI_LARGEICON = 0x000000000,
|
||||
SHGSI_SMALLICON = 0x000000001,
|
||||
SHGSI_SHELLICONSIZE = 0x000000004
|
||||
}
|
||||
|
||||
public enum SHSTOCKICONID : uint
|
||||
{
|
||||
DocumentNotAssociated = 0,
|
||||
DocumentAssociated = 1,
|
||||
Application = 2,
|
||||
Folder = 3,
|
||||
FolderOpen = 4,
|
||||
Drive525 = 5,
|
||||
Drive35 = 6,
|
||||
DriveRemove = 7,
|
||||
DriveFixed = 8,
|
||||
DriveNetwork = 9,
|
||||
DriveNetworkDisabled = 10,
|
||||
DriveCD = 11,
|
||||
DriveRAM = 12,
|
||||
World = 13,
|
||||
Server = 15,
|
||||
Printer = 16,
|
||||
MyNetwork = 17,
|
||||
Find = 22,
|
||||
Help = 23,
|
||||
Share = 28,
|
||||
Link = 29,
|
||||
SlowFile = 30,
|
||||
Recycler = 31,
|
||||
RecyclerFull = 32,
|
||||
MediaCDAudio = 40,
|
||||
Lock = 47,
|
||||
AutoList = 49,
|
||||
PrinterNet = 50,
|
||||
ServerShare = 51,
|
||||
PrinterFax = 52,
|
||||
PrinterFaxNet = 53,
|
||||
PrinterFile = 54,
|
||||
Stack = 55,
|
||||
MediaSVCD = 56,
|
||||
StuffedFolder = 57,
|
||||
DriveUnknown = 58,
|
||||
DriveDVD = 59,
|
||||
MediaDVD = 60,
|
||||
MediaDVDRAM = 61,
|
||||
MediaDVDRW = 62,
|
||||
MediaDVDR = 63,
|
||||
MediaDVDROM = 64,
|
||||
MediaCDAudioPlus = 65,
|
||||
MediaCDRW = 66,
|
||||
MediaCDR = 67,
|
||||
MediaCDBurn = 68,
|
||||
MediaBlankCD = 69,
|
||||
MediaCDROM = 70,
|
||||
AudioFiles = 71,
|
||||
ImageFiles = 72,
|
||||
VideoFiles = 73,
|
||||
MixedFiles = 74,
|
||||
FolderBack = 75,
|
||||
FolderFront = 76,
|
||||
Shield = 77,
|
||||
Warning = 78,
|
||||
Info = 79,
|
||||
Error = 80,
|
||||
Key = 81,
|
||||
Software = 82,
|
||||
Rename = 83,
|
||||
Delete = 84,
|
||||
MediaAudioDVD = 85,
|
||||
MediaMovieDVD = 86,
|
||||
MediaEnhancedCD = 87,
|
||||
MediaEnhancedDVD = 88,
|
||||
MediaHDDVD = 89,
|
||||
MediaBluRay = 90,
|
||||
MediaVCD = 91,
|
||||
MediaDVDPlusR = 92,
|
||||
MediaDVDPlusRW = 93,
|
||||
DesktopPC = 94,
|
||||
MobilePC = 95,
|
||||
Users = 96,
|
||||
MediaSmartMedia = 97,
|
||||
MediaCompactFlash = 98,
|
||||
DeviceCellPhone = 99,
|
||||
DeviceCamera = 100,
|
||||
DeviceVideoCamera = 101,
|
||||
DeviceAudioPlayer = 102,
|
||||
NetworkConnect = 103,
|
||||
Internet = 104,
|
||||
ZipFile = 105,
|
||||
Settings = 106
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class Taskbar
|
||||
// ITaskbarList2
|
||||
[PreserveSig] void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
|
||||
// ITaskbarList3
|
||||
[PreserveSig] void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal);
|
||||
[PreserveSig] void SetProgressValue(IntPtr hwnd, ulong ullCompleted, ulong ullTotal);
|
||||
[PreserveSig] void SetProgressState(IntPtr hwnd, TaskbarStates state);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Taskbar
|
||||
|
||||
public void SetValue(double progressValue, double progressMax)
|
||||
{
|
||||
Instance.SetProgressValue(Handle, (UInt64)progressValue, (UInt64)progressMax);
|
||||
Instance.SetProgressValue(Handle, (ulong)progressValue, (ulong)progressMax);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,12 @@ public class libmpv
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern mpv_error mpv_command_string(IntPtr mpvHandle, [MarshalAs(UnmanagedType.LPUTF8Str)] string command);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern mpv_error mpv_command_ret(IntPtr mpvHandle, IntPtr strings, IntPtr node);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void mpv_free_node_contents(IntPtr node);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr mpv_error_string(mpv_error error);
|
||||
|
||||
@@ -42,16 +48,16 @@ public class libmpv
|
||||
public static extern mpv_error mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref byte[] data);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern mpv_error mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref Int64 data);
|
||||
public static extern mpv_error mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref long data);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern mpv_error mpv_set_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref double data);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern mpv_error mpv_observe_property(IntPtr mpvHandle, UInt64 reply_userdata, [MarshalAs(UnmanagedType.LPUTF8Str)] string name, mpv_format format);
|
||||
public static extern mpv_error mpv_observe_property(IntPtr mpvHandle, ulong reply_userdata, [MarshalAs(UnmanagedType.LPUTF8Str)] string name, mpv_format format);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_unobserve_property(IntPtr mpvHandle, UInt64 registered_reply_userdata);
|
||||
public static extern int mpv_unobserve_property(IntPtr mpvHandle, ulong registered_reply_userdata);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void mpv_free(IntPtr data);
|
||||
@@ -163,7 +169,7 @@ public class libmpv
|
||||
{
|
||||
public mpv_event_id event_id;
|
||||
public int error;
|
||||
public UInt64 reply_userdata;
|
||||
public ulong reply_userdata;
|
||||
public IntPtr data;
|
||||
}
|
||||
|
||||
@@ -189,22 +195,16 @@ public class libmpv
|
||||
public int error;
|
||||
}
|
||||
|
||||
public static IntPtr AllocateUtf8ArrayWithSentinel(string[] arr, out IntPtr[] byteArrayPointers)
|
||||
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
||||
public struct mpv_node
|
||||
{
|
||||
int numberOfStrings = arr.Length + 1; // add extra element for extra null pointer last (sentinel)
|
||||
byteArrayPointers = new IntPtr[numberOfStrings];
|
||||
IntPtr rootPointer = Marshal.AllocCoTaskMem(IntPtr.Size * numberOfStrings);
|
||||
|
||||
for (int index = 0; index < arr.Length; index++)
|
||||
{
|
||||
var bytes = GetUtf8Bytes(arr[index]);
|
||||
IntPtr unmanagedPointer = Marshal.AllocHGlobal(bytes.Length);
|
||||
Marshal.Copy(bytes, 0, unmanagedPointer, bytes.Length);
|
||||
byteArrayPointers[index] = unmanagedPointer;
|
||||
}
|
||||
|
||||
Marshal.Copy(byteArrayPointers, 0, rootPointer, numberOfStrings);
|
||||
return rootPointer;
|
||||
[FieldOffset(0)] public IntPtr str;
|
||||
[FieldOffset(0)] public int flag;
|
||||
[FieldOffset(0)] public long int64;
|
||||
[FieldOffset(0)] public double dbl;
|
||||
[FieldOffset(0)] public IntPtr list;
|
||||
[FieldOffset(0)] public IntPtr ba;
|
||||
[FieldOffset(8)] public mpv_format format;
|
||||
}
|
||||
|
||||
public static string[] ConvertFromUtf8Strings(IntPtr utf8StringArray, int stringCount)
|
||||
@@ -8,9 +8,9 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyTitle("mpv.net")]
|
||||
[assembly: AssemblyDescription("mpv based media player")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Frank Skare (stax76)")]
|
||||
[assembly: AssemblyCompany("mpv.net/mpv/mplayer")]
|
||||
[assembly: AssemblyProduct("mpv.net")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2017-2020 Frank Skare (stax76)")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2000-2021 mpv.net/mpv/mplayer")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@@ -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.9.0")]
|
||||
[assembly: AssemblyFileVersion("5.4.9.0")]
|
||||
@@ -80,18 +80,20 @@ namespace mpvnet.Properties {
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to
|
||||
/// # 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:
|
||||
/// # This file defines the key and mouse bindings and the context menu of mpv.net.
|
||||
///
|
||||
/// # https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/inputConf.txt
|
||||
/// # A input and config editor can be found in the context menu under 'Settings'.
|
||||
///
|
||||
/// # The defaults of mpv can be found at:
|
||||
/// # The mpv.conf defaults of mpv.net contain: 'input-default-bindings = no'
|
||||
/// # which disables the input defaults of mpv.
|
||||
///
|
||||
/// # https://github.com/mpv-player/mpv/blob/master/etc/input.conf
|
||||
/// # Every line in this file begins with a space character to make search easier,
|
||||
/// # if you want to know if 'o' has already a binding you can search for ' o '.
|
||||
///
|
||||
/// # mpv.net's defaults of mpv.conf contain: 'input-default-bindings = no'
|
||||
/// # which disables mpv's i [rest of string was truncated]";.
|
||||
/// # input test mode:
|
||||
/// # mpvnet --input-test
|
||||
///
|
||||
/// # The [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string input_conf {
|
||||
get {
|
||||
@@ -108,9 +110,8 @@ namespace mpvnet.Properties {
|
||||
///keep-open-pause = no
|
||||
///osd-duration = 2000
|
||||
///osd-playing-msg = '${filename}'
|
||||
///script-opts = osc-scalewindowed=1.5,osc-hidetimeout=2000,console-scale=1
|
||||
///script-opts = osc-scalewindowed=1.5,osc-hidetimeout=2000,osc-greenandgrumpy=yes,console-scale=1
|
||||
///screenshot-directory = '~~desktop/'
|
||||
///hwdec = yes
|
||||
///
|
||||
///[protocol.https]
|
||||
///osd-playing-msg = '${media-title}'
|
||||
@@ -132,6 +133,16 @@ namespace mpvnet.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap mpvnet_santa {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("mpvnet_santa", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to
|
||||
///[dark]
|
||||
@@ -127,6 +127,9 @@
|
||||
<data name="mpvnet" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\mpvnet.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="mpvnet_santa" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\mpvnet-santa.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="mpv_conf" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\mpv.conf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
55
src/Release.ps1
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
$tmpDir = 'D:\Work'
|
||||
$exePath = $PSScriptRoot + '\bin\mpvnet.exe'
|
||||
$versionInfo = [Diagnostics.FileVersionInfo]::GetVersionInfo($exePath)
|
||||
$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)
|
||||
{
|
||||
& $inno $PSScriptRoot\setup.iss
|
||||
if ($LastExitCode) { throw $LastExitCode }
|
||||
|
||||
$targetDir = $tmpDir + "\mpv.net-$($versionInfo.FileVersion)-portable"
|
||||
Copy-Item $PSScriptRoot\bin $targetDir -Recurse -Exclude 'System.Management.Automation.xml', 'settings-directory.txt'
|
||||
& $7z a -tzip -mx9 "$targetDir.zip" -r "$targetDir\*"
|
||||
if ($LastExitCode) { throw $LastExitCode }
|
||||
}
|
||||
else
|
||||
{
|
||||
$targetDir = "$tmpDir\mpv.net-$($versionInfo.FileVersion)-portable-beta"
|
||||
Copy-Item $PSScriptRoot\bin $targetDir -Recurse -Exclude 'System.Management.Automation.xml', 'settings-directory.txt'
|
||||
& $7z a -tzip -mx9 "$targetDir.zip" -r "$targetDir\*"
|
||||
if ($LastExitCode) { throw $LastExitCode }
|
||||
UploadBeta "$targetDir.zip"
|
||||
|
||||
foreach ($cloudDirectory in $cloudDirectories)
|
||||
{
|
||||
Invoke-Item $cloudDirectory
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host 'successfully finished' -ForegroundColor Green
|
||||
@@ -204,6 +204,14 @@ options = [{ name = "no", help = "Don't automatically load external audio fil
|
||||
{ name = "fuzzy", help = "Load all audio files containing media filename." },
|
||||
{ name = "all", help = "Load all audio files in the current and audio-file-paths directories." }]
|
||||
|
||||
[[settings]]
|
||||
name = "audio-device"
|
||||
file = "mpv"
|
||||
filter = "Audio"
|
||||
type = "string"
|
||||
url = "https://mpv.io/manual/master/#options-audio-device"
|
||||
help = "<name> Use the given audio device. This consists of the audio output name, e.g. alsa, followed by /, followed by the audio output specific device name. The default value for this option is auto, which tries every audio output in preference order with the default device.\nAvailable devices can be found in the mpv.net context menu under:\nView > Show Audio Devices"
|
||||
|
||||
[[settings]]
|
||||
name = "slang"
|
||||
file = "mpv"
|
||||
@@ -314,13 +322,13 @@ 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"
|
||||
file = "mpv"
|
||||
filter = "Screen"
|
||||
help = "<int> Minimum window height in percent. Default: 30"
|
||||
help = "<int> Minimum window height in percent. Default: 10"
|
||||
|
||||
[[settings]]
|
||||
name = "autofit-larger"
|
||||
@@ -331,12 +339,15 @@ help = "<int> Maximum window height in percent. Default: 80"
|
||||
[[settings]]
|
||||
name = "start-size"
|
||||
file = "mpvnet"
|
||||
default = "previous"
|
||||
default = "height-session"
|
||||
filter = "Screen"
|
||||
help = "Setting to remember the window height. (mpv.net specific setting)"
|
||||
options = [{ name = "video", help = "Window size is set to video resolution" },
|
||||
{ name = "previous", help = "Window size is remembered but only in the current session" },
|
||||
{ name = "always", help = "Window size is always remembered"}]
|
||||
help = "Setting to remember the window size. (mpv.net specific setting)"
|
||||
options = [{ name = "video", help = "Window size is set to video resolution" },
|
||||
{ name = "width-session", help = "Width is remembered in the current session" },
|
||||
{ name = "width-always", help = "Width is always remembered" },
|
||||
{ name = "height-session", help = "Height is remembered in the current session" },
|
||||
{ name = "height-always", help = "Height is always remembered" },
|
||||
{ name = "always", help = "Size is always remembered" }]
|
||||
|
||||
[[settings]]
|
||||
name = "start-threshold"
|
||||
@@ -348,10 +359,10 @@ 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"
|
||||
name = "remember-window-position"
|
||||
file = "mpvnet"
|
||||
default = "no"
|
||||
filter = "Screen"
|
||||
@@ -553,6 +564,27 @@ file = "mpvnet"
|
||||
filter = "General"
|
||||
help = "<int> Amount of recent files to be remembered. Default: 15 (mpv.net specific setting)"
|
||||
|
||||
[[settings]]
|
||||
name = "video-file-extensions"
|
||||
file = "mpvnet"
|
||||
filter = "General"
|
||||
width = 500
|
||||
help = "Video file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific setting)"
|
||||
|
||||
[[settings]]
|
||||
name = "audio-file-extensions"
|
||||
file = "mpvnet"
|
||||
filter = "General"
|
||||
width = 500
|
||||
help = "Audio file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific setting)"
|
||||
|
||||
[[settings]]
|
||||
name = "image-file-extensions"
|
||||
file = "mpvnet"
|
||||
filter = "General"
|
||||
width = 500
|
||||
help = "Image file extensions used to create file associations and used by the auto-load-folder feature. (mpv.net specific setting)"
|
||||
|
||||
[[settings]]
|
||||
name = "debug-mode"
|
||||
file = "mpvnet"
|
||||
@@ -576,12 +608,12 @@ options = [{ name = "always" },
|
||||
name = "dark-theme"
|
||||
file = "mpvnet"
|
||||
filter = "UI"
|
||||
url = "https://github.com/stax76/mpv.net/blob/master/Manual.md#color-theme"
|
||||
url = "https://github.com/stax76/mpv.net/blob/master/docs/Manual.md#color-theme"
|
||||
help = "Color theme used in dark mode. Default: dark"
|
||||
|
||||
[[settings]]
|
||||
name = "light-theme"
|
||||
file = "mpvnet"
|
||||
filter = "UI"
|
||||
url = "https://github.com/stax76/mpv.net/blob/master/Manual.md#color-theme"
|
||||
url = "https://github.com/stax76/mpv.net/blob/master/docs/Manual.md#color-theme"
|
||||
help = "Color theme used in light mode. Default: light"
|
||||
@@ -1,22 +1,30 @@
|
||||
|
||||
# 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:
|
||||
# This file defines the key and mouse bindings and the context menu of mpv.net.
|
||||
|
||||
# https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt
|
||||
# A input and config editor can be found in the context menu under 'Settings'.
|
||||
|
||||
# The defaults of mpv can be found at:
|
||||
# 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 search easier,
|
||||
# if you want to know if 'o' has already a binding you can search for ' o '.
|
||||
|
||||
# input test mode:
|
||||
# mpvnet --input-test
|
||||
|
||||
# The input key list can be found in the context menu under: View > Show Keys
|
||||
|
||||
# mpv.net input.conf defaults:
|
||||
# https://github.com/stax76/mpv.net/blob/master/src/Resources/input.conf.txt
|
||||
|
||||
# mpv input.conf defaults:
|
||||
# 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
|
||||
# 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
|
||||
|
||||
# mpv input commands: https://mpv.io/manual/master/#list-of-input-commands
|
||||
|
||||
# run mpv.net in input test mode with: mpvnet --input-test
|
||||
# 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
|
||||
@@ -36,8 +44,8 @@
|
||||
_ ignore #menu: -
|
||||
Enter cycle fullscreen #menu: Toggle Fullscreen
|
||||
|
||||
F11 playlist-prev #menu: Navigate > Previous File
|
||||
F12 playlist-next #menu: Navigate > Next File
|
||||
F11 playlist-prev; set pause no #menu: Navigate > Previous File
|
||||
F12 playlist-next; set pause no #menu: Navigate > Next File
|
||||
_ ignore #menu: Navigate > -
|
||||
Home script-message mpv.net playlist-first #menu: Navigate > First File
|
||||
End script-message mpv.net playlist-last #menu: Navigate > Last File
|
||||
@@ -48,15 +56,16 @@
|
||||
. frame-step #menu: Navigate > Jump Next Frame
|
||||
, frame-back-step #menu: Navigate > Jump Previous Frame
|
||||
_ ignore #menu: Navigate > -
|
||||
Right seek 7 #menu: Navigate > Jump 7 sec forward
|
||||
Left seek -7 #menu: Navigate > Jump 7 sec backward
|
||||
Right seek 5 #menu: Navigate > Jump 5 sec forward
|
||||
Left seek -5 #menu: Navigate > Jump 5 sec backward
|
||||
_ ignore #menu: Navigate > -
|
||||
Up seek 40 #menu: Navigate > Jump 40 sec forward
|
||||
Down seek -40 #menu: Navigate > Jump 40 sec backward
|
||||
Up seek 30 #menu: Navigate > Jump 30 sec forward
|
||||
Down seek -30 #menu: Navigate > Jump 30 sec backward
|
||||
_ ignore #menu: Navigate > -
|
||||
Ctrl+Right seek 300 #menu: Navigate > Jump 5 min forward
|
||||
Ctrl+Left seek -300 #menu: Navigate > Jump 5 min backward
|
||||
_ ignore #menu: Navigate > -
|
||||
_ ignore #menu: Navigate > Titles
|
||||
_ ignore #menu: Navigate > Chapters
|
||||
|
||||
Ctrl++ add video-zoom 0.1 #menu: Pan & Scan > Increase Size
|
||||
@@ -87,7 +96,7 @@
|
||||
_ ignore #menu: Video > -
|
||||
Ctrl+s async screenshot #menu: Video > Take Screenshot
|
||||
d cycle deinterlace #menu: Video > Toggle Deinterlace
|
||||
a cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1" #menu: Video > Cycle Aspect Ratio
|
||||
a cycle-values video-aspect 16:9 4:3 2.35:1 -1 #menu: Video > Cycle Aspect Ratio
|
||||
|
||||
KP7 script-message mpv.net cycle-audio #menu: Audio > Cycle/Next
|
||||
_ ignore #menu: Audio > -
|
||||
@@ -121,31 +130,33 @@
|
||||
_ ignore #menu: Speed > -
|
||||
BS set speed 1 #menu: Speed > Reset
|
||||
|
||||
KP0 script-message rate-file 0 #menu: Extensions > Rating > 0stars
|
||||
KP1 script-message rate-file 1 #menu: Extensions > Rating > 1stars
|
||||
KP2 script-message rate-file 2 #menu: Extensions > Rating > 2stars
|
||||
KP3 script-message rate-file 3 #menu: Extensions > Rating > 3stars
|
||||
KP4 script-message rate-file 4 #menu: Extensions > Rating > 4stars
|
||||
KP5 script-message rate-file 5 #menu: Extensions > Rating > 5stars
|
||||
_ ignore #menu: Extensions > Rating > -
|
||||
_ script-message rate-file about #menu: Extensions > Rating > About
|
||||
|
||||
Ctrl+t set ontop yes #menu: View > On Top > Enable
|
||||
Ctrl+T set ontop no #menu: View > On Top > Disable
|
||||
Alt++ no-osd set window-scale 1.2 #menu: View > Window Size > Enlarge
|
||||
Alt+- no-osd set window-scale 0.8 #menu: View > Window Size > Shrink
|
||||
Alt++ script-message mpv.net scale-window 1.2 #menu: View > Zoom > Enlarge
|
||||
Alt+- script-message mpv.net scale-window 0.8 #menu: View > Zoom > Shrink
|
||||
_ ignore #menu: View > Zoom > -
|
||||
Alt+0 script-message mpv.net window-scale 0.5 #menu: View > Zoom > 50 %
|
||||
Alt+1 script-message mpv.net window-scale 1.0 #menu: View > Zoom > 100 %
|
||||
Alt+2 script-message mpv.net window-scale 2.0 #menu: View > Zoom > 200 %
|
||||
Alt+3 script-message mpv.net window-scale 3.0 #menu: View > Zoom > 300 %
|
||||
b cycle border #menu: View > Toggle Border
|
||||
i script-message mpv.net show-info #menu: View > File/Stream Info
|
||||
t script-binding stats/display-stats #menu: View > Show Statistics
|
||||
T script-binding stats/display-stats-toggle #menu: View > Toggle Statistics
|
||||
Del script-binding osc/visibility #menu: View > Toggle OSC Visibility
|
||||
F8 script-binding show-playlist #menu: View > Show Playlist
|
||||
F9 show-text ${track-list} 5000 #menu: View > Show Audio/Video/Subtitle List
|
||||
p show-progress #menu: View > Show Progress
|
||||
Ctrl+p script-message mpv.net show-profiles #menu: View > Show Profiles
|
||||
Shift+p script-message mpv.net show-properties #menu: View > Show Properties
|
||||
Ctrl+r cycle-values video-rotate 90 180 270 0 #menu: View > Rotate Video
|
||||
_ script-message mpv.net show-audio-devices #menu: View > Show Audio Devices
|
||||
Shift+c script-message mpv.net show-commands #menu: View > Show Commands
|
||||
` script-binding console/enable #menu: View > Show Console
|
||||
_ script-message mpv.net show-decoders #menu: View > Show Decoders
|
||||
_ script-message mpv.net show-demuxers #menu: View > Show Demuxers
|
||||
_ script-message mpv.net show-keys #menu: View > Show Keys
|
||||
F8 script-message mpv.net show-playlist #menu: View > Show Playlist
|
||||
Ctrl+p script-message mpv.net show-profiles #menu: View > Show Profiles
|
||||
p show-progress #menu: View > Show Progress
|
||||
Shift+p script-message mpv.net show-properties #menu: View > Show Properties
|
||||
_ script-message mpv.net show-protocols #menu: View > Show Protocols
|
||||
F9 show-text ${track-list} 5000 #menu: View > Show Tracks
|
||||
|
||||
c script-message mpv.net show-conf-editor #menu: Settings > Show Config Editor
|
||||
Ctrl+i script-message mpv.net show-input-editor #menu: Settings > Show Input Editor
|
||||
@@ -154,16 +165,16 @@
|
||||
F1 script-message mpv.net show-command-palette #menu: Tools > Show All Commands
|
||||
h script-message mpv.net show-history #menu: Tools > Show History
|
||||
l ab-loop #menu: Tools > Set/clear A-B loop points
|
||||
L cycle-values loop-file "inf" "no" #menu: Tools > Toggle infinite file looping
|
||||
_ cycle shuffle #menu: Tools > Toggle Shuffle
|
||||
Ctrl+h cycle-values hwdec "auto" "no" #menu: Tools > Toggle Hardware Decoding
|
||||
L cycle-values loop-file inf no #menu: Tools > Toggle infinite file looping
|
||||
_ playlist-shuffle #menu: Tools > Shuffle Playlist
|
||||
Ctrl+h cycle-values hwdec auto no #menu: Tools > Toggle Hardware Decoding
|
||||
_ script-message mpv.net show-setup-dialog #menu: Tools > Setup...
|
||||
|
||||
_ script-message mpv.net shell-execute https://mpv.io #menu: Help > Website mpv
|
||||
_ script-message mpv.net shell-execute https://github.com/stax76/mpv.net #menu: Help > Website mpv.net
|
||||
_ ignore #menu: Help > -
|
||||
_ script-message mpv.net shell-execute https://mpv.io/manual/stable/ #menu: Help > Manual mpv
|
||||
_ script-message mpv.net shell-execute https://github.com/stax76/mpv.net/blob/master/Manual.md #menu: Help > Manual mpv.net
|
||||
_ script-message mpv.net shell-execute https://github.com/stax76/mpv.net/blob/master/docs/Manual.md #menu: Help > Manual mpv.net
|
||||
_ ignore #menu: Help > -
|
||||
_ script-message mpv.net update-check #menu: Help > Check for Updates
|
||||
_ script-message mpv.net show-about #menu: Help > About mpv.net
|
||||
@@ -180,9 +191,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
|
||||
@@ -8,7 +8,6 @@ osd-duration = 2000
|
||||
osd-playing-msg = '${filename}'
|
||||
script-opts = osc-scalewindowed=1.5,osc-hidetimeout=2000,console-scale=1
|
||||
screenshot-directory = '~~desktop/'
|
||||
hwdec = yes
|
||||
|
||||
[protocol.https]
|
||||
osd-playing-msg = '${media-title}'
|
||||
BIN
src/Resources/mpvnet-santa.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
63
src/Scripts/C-Sharp/delete-current-file.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
// C# Script that deletes the current file
|
||||
|
||||
// In input.conf add:
|
||||
|
||||
// KP0 script-message delete-current-file ask #menu: Script > Delete current file > Ask
|
||||
// KP1 script-message delete-current-file confirm #menu: Script > Delete current file > Confirm
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
|
||||
using mpvnet;
|
||||
|
||||
class Script
|
||||
{
|
||||
string FileToDelete;
|
||||
DateTime DeleteTime;
|
||||
CorePlayer Core;
|
||||
|
||||
public Script()
|
||||
{
|
||||
Core = Global.Core;
|
||||
Core.ClientMessage += ClientMessage;
|
||||
}
|
||||
|
||||
void ClientMessage(string[] args)
|
||||
{
|
||||
if (args == null || args.Length != 2 || args[0] != "delete-current-file")
|
||||
return;
|
||||
|
||||
if (args[1] == "ask")
|
||||
{
|
||||
FileToDelete = Core.get_property_string("path");
|
||||
DeleteTime = DateTime.Now;
|
||||
Core.commandv("show-text", "Press 1 to delete file", "5000");
|
||||
}
|
||||
else if (args[1] == "confirm")
|
||||
{
|
||||
TimeSpan ts = DateTime.Now - DeleteTime;
|
||||
string path = Core.get_property_string("path");
|
||||
|
||||
if (FileToDelete == path && ts.TotalSeconds < 5 && File.Exists(FileToDelete))
|
||||
{
|
||||
Core.command("playlist-remove current");
|
||||
int pos = Core.get_property_int("playlist-pos");
|
||||
|
||||
if (pos == -1)
|
||||
{
|
||||
int count = Core.get_property_int("playlist-count");
|
||||
|
||||
if (count > 0)
|
||||
Core.set_property_int("playlist-pos", count - 1);
|
||||
}
|
||||
|
||||
Thread.Sleep(2000);
|
||||
FileSystem.DeleteFile(FileToDelete, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ class Script
|
||||
{
|
||||
string content = "ctrl+w script-message my-message-1 my-argument-1";
|
||||
string sectionName = Assembly.GetExecutingAssembly().GetName().Name;
|
||||
Core core = Core.core;
|
||||
CorePlayer core = Global.Core;
|
||||
core.commandv("define-section", sectionName, content, "force");
|
||||
core.commandv("enable-section", sectionName);
|
||||
core.ClientMessage += ClientMessage;
|
||||
@@ -22,7 +22,7 @@ class Script
|
||||
switch (args[0])
|
||||
{
|
||||
case "my-message-1":
|
||||
Msg.Show(args[1]);
|
||||
Msg.ShowInfo(args[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||