Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7b908a5c4 | ||
|
|
1080d0afd7 | ||
|
|
77ba7f105c | ||
|
|
07b6d4379e | ||
|
|
8a6659b1bf | ||
|
|
e7d41ff626 | ||
|
|
f2c526348d | ||
|
|
b4d2a7e86d | ||
|
|
98f8e7090a | ||
|
|
aeb5958be6 | ||
|
|
1d16861b0b | ||
|
|
4366c47a09 | ||
|
|
fc3dd45b72 | ||
|
|
66cf3a9b2f | ||
|
|
a9c2150c47 | ||
|
|
b77bbd5aec | ||
|
|
92b58873e2 | ||
|
|
c8214b2d94 | ||
|
|
f77defecfd | ||
|
|
6fec4bada7 | ||
|
|
c508761c36 | ||
|
|
3fd1285ad8 | ||
|
|
91a67c29a7 | ||
|
|
c8ce0b6dfc |
@@ -1,5 +1,6 @@
|
||||
Imports System.ComponentModel.Composition
|
||||
Imports System.IO
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Imports mpvnet
|
||||
Imports mpvnet.StaticUsing
|
||||
@@ -13,7 +14,8 @@ Public Class CSScriptAddon
|
||||
Sub New()
|
||||
Dim scriptDir = mp.mpvConfFolderPath + "scripts"
|
||||
If Not Directory.Exists(scriptDir) Then Return
|
||||
Dim csFiles = Directory.GetFiles(scriptDir, "*.cs")
|
||||
Dim csFiles = Directory.GetFiles(scriptDir, "*.cs").ToList
|
||||
csFiles.AddRange(Directory.GetFiles(Application.StartupPath + "\\Scripts", "*.cs"))
|
||||
If csFiles.Count = 0 Then Return
|
||||
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom
|
||||
|
||||
@@ -21,7 +23,7 @@ Public Class CSScriptAddon
|
||||
Try
|
||||
CSScriptLibrary.CSScript.Evaluator.LoadCode(File.ReadAllText(i))
|
||||
Catch ex As Exception
|
||||
MsgError(ex.ToString)
|
||||
MainForm.Instance.ShowMsgBox(ex.ToString(), MessageBoxIcon.Error)
|
||||
End Try
|
||||
Next
|
||||
End Sub
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
||||
187
README.md
187
README.md
@@ -6,29 +6,57 @@ mpv and mpv.net have a learning curve and are only suitable for experienced user
|
||||
|
||||
mpv manual: https://mpv.io/manual/master/
|
||||
|
||||
Table of contents
|
||||
-------
|
||||
|
||||
- [Features](#features)
|
||||
- [Context Menu](#context-menu)
|
||||
- [Settings](#settings)
|
||||
- [C# Scripting](#cs-scripting)
|
||||
- [Python Scripting](#python-scripting)
|
||||
- [PowerShell Scripting](#powershell-scripting)
|
||||
- [Support](#Support)
|
||||
- [Changelog](#changelog)
|
||||
|
||||
### Features
|
||||
|
||||
- Customizable context menu defined in the same file as the keybindings
|
||||
- Addons support for using .NET languages
|
||||
- C# scripts implemented with CS-Script
|
||||
- mpv's OSC, IPC, Lua/JS, conf files and more
|
||||
- Addon API for .NET languages
|
||||
- 5 different scripting languages are supported, Python scripting implemented with IronPython, C# implemented with CS-Script, Lua and JavaScript implemented in libmpv and PowerShell
|
||||
- mpv's OSC, IPC, conf files and more
|
||||
|
||||

|
||||
|
||||
### Context Menu
|
||||
|
||||
The context menu can be customized via input.conf file located at:
|
||||
```
|
||||
C:\Users\username\AppData\Roaming\mpv\input.conf
|
||||
```
|
||||
if it's missing mpv.net generates it with the following defaults:
|
||||
|
||||
C:\Users\Frank\AppData\Roaming\mpv\input.conf
|
||||
https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt
|
||||
|
||||
if it misses mpv.net generates it with the following defaults:
|
||||
### Settings
|
||||
|
||||
https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input_conf.txt
|
||||
mpv.net shares the settings with mpv, settings have to be edited in a config file called mpv.conf located at:
|
||||
```
|
||||
C:\Users\username\AppData\Roaming\mpv\mpv.conf
|
||||
```
|
||||
if it's missing mpv.net generates it with the following defaults:
|
||||
|
||||
https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpv.conf.txt
|
||||
|
||||
### C# Scripting
|
||||
|
||||
A simple C# script located at: C:\Users\Frank\AppData\Roaming\mpv\scripts\test.cs
|
||||
|
||||
A simple C# script located at:
|
||||
```
|
||||
C:\Users\username\AppData\Roaming\mpv\scripts\fullscreen.cs
|
||||
```
|
||||
or
|
||||
```
|
||||
startup\scripts\fullscreen.cs
|
||||
```
|
||||
```
|
||||
using mpvnet;
|
||||
|
||||
@@ -36,19 +64,124 @@ class Script
|
||||
{
|
||||
public Script()
|
||||
{
|
||||
var fs = mpv.GetStringProp("fullscreen");
|
||||
mpv.Command("show-text", "fullscreen: " + fs);
|
||||
mpv.ObserveBoolProp("fullscreen", FullscreenChange);
|
||||
var fs = mp.get_property_string("fullscreen");
|
||||
mp.commandv("show-text", "fullscreen: " + fs);
|
||||
mp.observe_property_bool("fullscreen", FullscreenChange);
|
||||
}
|
||||
|
||||
void FullscreenChange(bool val)
|
||||
{
|
||||
mpv.Command("show-text", "fullscreen: " + val.ToString());
|
||||
mp.commandv("show-text", "fullscreen: " + val.ToString());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Changes
|
||||
### Python Scripting
|
||||
|
||||
A simple Python script located at:
|
||||
```
|
||||
C:\Users\user\AppData\Roaming\mpv\scripts\seek-show-position.py
|
||||
```
|
||||
or
|
||||
```
|
||||
startup\scripts\seek-show-position.py
|
||||
```
|
||||
```
|
||||
# when seeking displays position and
|
||||
# duration like so: 70:00 / 80:00
|
||||
# which is different from mpv which
|
||||
# uses 01:10:00 / 01:20:00
|
||||
|
||||
import math
|
||||
|
||||
def seek():
|
||||
mp.commandv('show-text',
|
||||
format(mp.get_property_number("time-pos")) + " / " + format(mp.get_property_number("duration")))
|
||||
|
||||
def format(f):
|
||||
sec = round(f)
|
||||
|
||||
if sec < 0:
|
||||
sec = 0
|
||||
|
||||
pos_min_floor = math.floor(sec / 60)
|
||||
sec_rest = sec - pos_min_floor * 60
|
||||
return add_zero(pos_min_floor) + ":" + add_zero(sec_rest)
|
||||
|
||||
def add_zero(val):
|
||||
val = round(val)
|
||||
return "" + str(int(val)) if (val > 9) else "0" + str(int(val))
|
||||
|
||||
mp.register_event("seek", seek) # or use: mp.Seek += seek
|
||||
```
|
||||
|
||||
### PowerShell Scripting
|
||||
|
||||
A simple PowerShell script located at:
|
||||
```
|
||||
C:\Users\user\AppData\Roaming\mpv\scripts\seek.ps1
|
||||
```
|
||||
or
|
||||
```
|
||||
startup\scripts\seek.ps1
|
||||
```
|
||||
```
|
||||
$position = [mp]::get_property_number("time-pos");
|
||||
[mp]::commandv("show-text", $position.ToString() + " seconds")
|
||||
```
|
||||
Please note that PowerShell don't allow assigning to events and mpv.net uses as workaround a matching script filename, a list of available events can be found in the mpv manual or in the file mp.cs in the mpv.net source code.
|
||||
|
||||
### Support
|
||||
|
||||
<https://forum.doom9.org/showthread.php?t=174841>
|
||||
|
||||
<https://forum.videohelp.com/threads/392514-mpv-net-a-extendable-media-player-for-windows>
|
||||
|
||||
<https://github.com/stax76/mpv.net/issues>
|
||||
|
||||
### Changelog
|
||||
|
||||
### soon
|
||||
|
||||
- all info and error messages are shown now on the main window thread having the main window as parent
|
||||
|
||||
### 1.8
|
||||
|
||||
- new config editor added
|
||||
|
||||
### 1.7
|
||||
|
||||
- showing the conf files mpv.net uses now the app that is registered for txt files, before it just shell executed the conf file which only worked if conf files were associated with an application
|
||||
- leaving fullscreen mode the previous window size and position wasn't restored
|
||||
- when the source video aspect ratio changes the height is kept and the width is adjusted and a check is performed to assure the window is within screen bounds
|
||||
|
||||
### 1.6
|
||||
|
||||
- a crash caused by WM_APPCOMMAND (multimedia keyboards) commands was fixed
|
||||
- support for the 'screen' property was added, it should work both from mpv.conf (screen = 1) and from command line (--screen=1)
|
||||
- per monitor DPI awareness and better multi monitor support was added
|
||||
|
||||
### 1.5
|
||||
|
||||
- the info command supports now info for music files instead of showing an exception on music files
|
||||
- added support for WM_APPCOMMAND API to support media keyboards
|
||||
- fixed Alt key input not working
|
||||
- mpv.net API methods renamed to match the names used in the Lua/JS API
|
||||
|
||||
### 1.4
|
||||
|
||||
- the last thread sync fix wasn't working well, the delayed shutdown should be gone for good now
|
||||
- libmpv updated
|
||||
|
||||
### 1.3
|
||||
|
||||
- besides Lua/JavaScript/C#/Python there is now PowerShell supported as fifth scripting language
|
||||
|
||||
- in case there isn't yet a mpv.conf file mpv.net creates the file with certain default settings that were previously set on every mpv.net start. This was changed to provide transparency on which settings mpv.net uses. These default settings can be seen here: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpv.conf.txt
|
||||
|
||||
### 1.2
|
||||
|
||||
- a thread synchonisation bug which caused the shutdown to be delayed or frozen was fixed, it also caused the Shutdown event not to fire which caused the rating plugin not to work
|
||||
|
||||
### 1.1
|
||||
|
||||
@@ -57,30 +190,4 @@ class Script
|
||||
|
||||
### 1.0
|
||||
|
||||
- much more feature packed context menu
|
||||
|
||||
### 0.2.5
|
||||
|
||||
- mpv lib updated to 2019-02-24
|
||||
- UI glitch fixed the appeared when started in fullscreen mode
|
||||
- fixed default video output mode which caused video playback to fail
|
||||
|
||||
### 0.2.4
|
||||
|
||||
- changed minimum runtime to .NET 4.7.2
|
||||
- fixed mpv.net not working with new mpv lib
|
||||
- the track name in the title bar was sometimes wrong
|
||||
- mpv lib updated to 2018-12-16
|
||||
- quit-watch-later added to context menu (Shift+Q) to exit and resume at the last position
|
||||
- ab loop added to menu
|
||||
- added the possibility to modify mpv.conf settings using the context menu
|
||||
- added link to the manual and default keys to the menu
|
||||
|
||||
### 0.2.2
|
||||
|
||||
- history feature added
|
||||
- mpv lib updated
|
||||
|
||||
### 0.2.1
|
||||
|
||||
- right-click in fullscreen in the right-left corner closes the app
|
||||
- much more feature packed context menu
|
||||
@@ -51,8 +51,8 @@ namespace RatingAddon
|
||||
if (args?.Length != 2 || args[0] != "rate-file" || ! int.TryParse(args[1], out rating))
|
||||
return;
|
||||
|
||||
Dic[mp.GetStringProp("path")] = rating;
|
||||
mp.Command("show-text", $"Rating: {rating}");
|
||||
Dic[mp.get_property_string("path")] = rating;
|
||||
mp.commandv("show-text", $"Rating: {rating}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,6 @@ using System.ComponentModel.Composition.Hosting;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using static mpvnet.StaticUsing;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Addon
|
||||
@@ -42,7 +40,7 @@ namespace mpvnet
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MsgError(e.ToString());
|
||||
MainForm.Instance.ShowMsgBox(e.ToString(), MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using static mpvnet.StaticUsing;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class Command
|
||||
@@ -22,21 +21,20 @@ namespace mpvnet
|
||||
if (commands == null)
|
||||
{
|
||||
commands = new List<Command>();
|
||||
var type = typeof(Command);
|
||||
var methods = type.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
|
||||
Type type = typeof(Command);
|
||||
MethodInfo[] methods = type.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
|
||||
|
||||
foreach (var i in methods)
|
||||
{
|
||||
var parameters = i.GetParameters();
|
||||
ParameterInfo[] parameters = i.GetParameters();
|
||||
|
||||
if (parameters == null || parameters.Length != 1 || parameters[0].ParameterType != typeof(string[]))
|
||||
continue;
|
||||
|
||||
var cmd = new Command() { Name = i.Name.Replace("_","-"), Action = (Action<string[]>)i.CreateDelegate(typeof(Action<string[]>)) };
|
||||
Command cmd = new Command() { Name = i.Name.Replace("_","-"), Action = (Action<string[]>)i.CreateDelegate(typeof(Action<string[]>)) };
|
||||
commands.Add(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
@@ -62,24 +60,17 @@ namespace mpvnet
|
||||
|
||||
public static void show_keys(string[] args)
|
||||
{
|
||||
Process.Start(mp.InputConfPath);
|
||||
}
|
||||
|
||||
private static void CreateMpvConf()
|
||||
{
|
||||
if (!File.Exists(mp.mpvConfPath))
|
||||
{
|
||||
if (!Directory.Exists(mp.mpvConfFolderPath))
|
||||
Directory.CreateDirectory(mp.mpvConfFolderPath);
|
||||
|
||||
File.WriteAllText(mp.mpvConfPath, "# https://mpv.io/manual/master/#configuration-files");
|
||||
}
|
||||
Process.Start(NativeHelp.GetAssociatedApplication(".txt"), mp.InputConfPath);
|
||||
}
|
||||
|
||||
public static void show_prefs(string[] args)
|
||||
{
|
||||
CreateMpvConf();
|
||||
Process.Start(mp.mpvConfPath);
|
||||
Process.Start(NativeHelp.GetAssociatedApplication(".txt"), mp.mpvConfPath);
|
||||
}
|
||||
|
||||
public static void show_conf_editor(string[] args)
|
||||
{
|
||||
Process.Start(Application.StartupPath + "\\mpvSettingsEditor.exe");
|
||||
}
|
||||
|
||||
public static void history(string[] args)
|
||||
@@ -89,7 +80,7 @@ namespace mpvnet
|
||||
if (File.Exists(fp))
|
||||
Process.Start(fp);
|
||||
else
|
||||
if (MsgQuestion("Create history.txt file in config folder?\r\n\r\nmpv.net will write the date, time and filename of opened files to it.") == DialogResult.OK)
|
||||
if (MainForm.Instance.ShowMsgBox("Create history.txt file in config folder?\n\nmpv.net will write the date, time and filename of opened files to it.", MessageBoxIcon.Question) == DialogResult.OK)
|
||||
File.WriteAllText(fp, "");
|
||||
}
|
||||
|
||||
@@ -100,67 +91,81 @@ namespace mpvnet
|
||||
|
||||
public static void set_setting(string[] args)
|
||||
{
|
||||
CreateMpvConf();
|
||||
|
||||
bool changed = false;
|
||||
string fp = mp.mpvConfPath;
|
||||
var confLines = File.ReadAllLines(fp);
|
||||
var lines = File.ReadAllLines(mp.mpvConfPath);
|
||||
|
||||
for (int i = 0; i < confLines.Length; i++)
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
if (confLines[i].Left("=").Trim() == args[0])
|
||||
if (lines[i].Contains("=") &&
|
||||
lines[i].Substring(0, lines[i].IndexOf("=")).Trim("# ".ToCharArray()) == args[0])
|
||||
{
|
||||
confLines[i] = args[0] + "=" + args[1];
|
||||
lines[i] = args[0] + " = " + args[1];
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
File.WriteAllText(fp, String.Join(Environment.NewLine, confLines));
|
||||
}
|
||||
File.WriteAllText(mp.mpvConfPath, String.Join(Environment.NewLine, lines));
|
||||
else
|
||||
{
|
||||
File.WriteAllText(fp,
|
||||
File.ReadAllText(fp) + Environment.NewLine + args[0] + "=" + args[1]);
|
||||
}
|
||||
File.WriteAllText(mp.mpvConfPath, File.ReadAllText(mp.mpvConfPath) + Environment.NewLine + args[0] + " = " + args[1]);
|
||||
|
||||
MsgInfo("Please restart mpv.net");
|
||||
MainForm.Instance.ShowMsgBox("Please restart mpv.net", MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
public static void show_info(string[] args)
|
||||
{
|
||||
var fi = new FileInfo(mp.GetStringProp("path"));
|
||||
var fileInfo = new FileInfo(mp.get_property_string("path"));
|
||||
|
||||
using (var mi = new MediaInfo(fi.FullName))
|
||||
using (var mediaInfo = new MediaInfo(fileInfo.FullName))
|
||||
{
|
||||
var w = mi.GetInfo(MediaInfoStreamKind.Video, "Width");
|
||||
var h = mi.GetInfo(MediaInfoStreamKind.Video, "Height");
|
||||
var pos = TimeSpan.FromSeconds(mp.GetIntProp("time-pos"));
|
||||
var dur = TimeSpan.FromSeconds(mp.GetIntProp("duration"));
|
||||
string mibr = mi.GetInfo(MediaInfoStreamKind.Video, "BitRate");
|
||||
string width = mediaInfo.GetInfo(MediaInfoStreamKind.Video, "Width");
|
||||
|
||||
if (mibr == "")
|
||||
mibr = "0";
|
||||
if (width == "")
|
||||
{
|
||||
string performer = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Performer");
|
||||
string title = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Title");
|
||||
string album = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Album");
|
||||
string genre = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Genre");
|
||||
string date = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Recorded_Date");
|
||||
string duration = mediaInfo.GetInfo(MediaInfoStreamKind.Audio, "Duration/String");
|
||||
|
||||
var br = Convert.ToInt32(mibr) / 1000.0 / 1000.0;
|
||||
var vf = mp.GetStringProp("video-format").ToUpper();
|
||||
var fn = fi.Name;
|
||||
string text = "";
|
||||
|
||||
if (fn.Length > 60)
|
||||
fn = fn.Insert(59, "\r\n");
|
||||
if (performer != "") text += "Artist: " + performer + "\n";
|
||||
if (title != "") text += "Title: " + title + "\n";
|
||||
if (album != "") text += "Album: " + album + "\n";
|
||||
if (genre != "") text += "Genre: " + genre + "\n";
|
||||
if (date != "") text += "Year: " + date + "\n";
|
||||
if (duration != "") text += "Length: " + duration + "\n";
|
||||
|
||||
var info =
|
||||
FormatTime(pos.TotalMinutes) + ":" +
|
||||
FormatTime(pos.Seconds) + " / " +
|
||||
FormatTime(dur.TotalMinutes) + ":" +
|
||||
FormatTime(dur.Seconds) + "\n" +
|
||||
((int)(fi.Length / 1024 / 1024)).ToString() +
|
||||
$" MB - {w} x {h}\n{vf} - {br.ToString("f1")} Mb/s" + "\n" + fn;
|
||||
mp.commandv("show-text", text, "5000");
|
||||
}
|
||||
else
|
||||
{
|
||||
string height = mediaInfo.GetInfo(MediaInfoStreamKind.Video, "Height");
|
||||
TimeSpan position = TimeSpan.FromSeconds(mp.get_property_number("time-pos"));
|
||||
TimeSpan duration = TimeSpan.FromSeconds(mp.get_property_number("duration"));
|
||||
string bitrate = mediaInfo.GetInfo(MediaInfoStreamKind.Video, "BitRate");
|
||||
|
||||
mp.Command("show-text", info, "5000");
|
||||
if (bitrate == "")
|
||||
bitrate = "0";
|
||||
|
||||
string FormatTime(double value) => ((int)(Math.Floor(value))).ToString("00");
|
||||
var bitrate2 = Convert.ToDouble(bitrate) / 1000.0 / 1000.0;
|
||||
var videoCodec = mp.get_property_string("video-format").ToUpper();
|
||||
var filename = fileInfo.Name;
|
||||
|
||||
var text =
|
||||
FormatTime(position.TotalMinutes) + ":" +
|
||||
FormatTime(position.Seconds) + " / " +
|
||||
FormatTime(duration.TotalMinutes) + ":" +
|
||||
FormatTime(duration.Seconds) + "\n" +
|
||||
Convert.ToInt32(fileInfo.Length / 1024 / 1024).ToString() +
|
||||
$" MB - {width} x {height}\n{videoCodec} - {bitrate2.ToString("f1")} Mb/s" + "\n" + filename;
|
||||
|
||||
mp.commandv("show-text", text, "5000");
|
||||
}
|
||||
|
||||
string FormatTime(double value) => ((int)value).ToString("00");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
7
mpv.net/MainForm.Designer.cs
generated
7
mpv.net/MainForm.Designer.cs
generated
@@ -42,17 +42,16 @@
|
||||
// MainForm
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(288F, 288F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.BackColor = System.Drawing.Color.Black;
|
||||
this.ClientSize = new System.Drawing.Size(1553, 1000);
|
||||
this.ClientSize = new System.Drawing.Size(1012, 615);
|
||||
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "MainForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "mpv.net";
|
||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using static mpvnet.StaticUsing;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace mpvnet
|
||||
|
||||
private Point LastCursorPosChanged;
|
||||
private int LastCursorChangedTickCount;
|
||||
private bool IsCloseRequired = true;
|
||||
private bool IgnoreDpiChanged = true;
|
||||
|
||||
public ContextMenuStripEx CMS;
|
||||
|
||||
@@ -27,45 +27,124 @@ namespace mpvnet
|
||||
try
|
||||
{
|
||||
Application.ThreadException += Application_ThreadException;
|
||||
SetFormPosSize();
|
||||
Instance = this;
|
||||
Hwnd = Handle;
|
||||
ChangeFullscreen((mp.mpvConv.ContainsKey("fullscreen") && mp.mpvConv["fullscreen"] == "yes") || (mp.mpvConv.ContainsKey("fs") && mp.mpvConv["fs"] == "yes"));
|
||||
CMS = new ContextMenuStripEx(components);
|
||||
CMS.Opened += CMS_Opened;
|
||||
ContextMenuStrip = CMS;
|
||||
BuildMenu();
|
||||
Text += " " + Application.ProductVersion;
|
||||
|
||||
if (mp.mpvConf.ContainsKey("screen"))
|
||||
SetScreen(Convert.ToInt32(mp.mpvConf["screen"]));
|
||||
else
|
||||
SetScreen(Screen.PrimaryScreen);
|
||||
|
||||
ChangeFullscreen((mp.mpvConf.ContainsKey("fullscreen") && mp.mpvConf["fullscreen"] == "yes") ||
|
||||
(mp.mpvConf.ContainsKey("fs") && mp.mpvConf["fs"] == "yes"));
|
||||
|
||||
ProcessCommandLineEarly();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception e)
|
||||
{
|
||||
HandleException(ex);
|
||||
MainForm.Instance.ShowMsgBox(e.ToString(), MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
protected void SetScreen(int targetIndex)
|
||||
{
|
||||
Screen[] screens = Screen.AllScreens;
|
||||
if (targetIndex < 0 || targetIndex > screens.Length - 1) return;
|
||||
SetScreen(screens[Array.IndexOf(screens, screens[targetIndex])]);
|
||||
}
|
||||
|
||||
protected void SetScreen(Screen screen)
|
||||
{
|
||||
Rectangle target = screen.Bounds;
|
||||
Left = target.X + Convert.ToInt32((target.Width - Width) / 2.0);
|
||||
Top = target.Y + Convert.ToInt32((target.Height - Height) / 2.0);
|
||||
SetStartFormPositionAndSize();
|
||||
}
|
||||
|
||||
void SetStartFormPositionAndSize()
|
||||
{
|
||||
if (IsFullscreen || mp.VideoSize.Width == 0) return;
|
||||
Screen screen = Screen.FromControl(this);
|
||||
int height = Convert.ToInt32(screen.Bounds.Height * 0.6);
|
||||
int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.Height);
|
||||
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
||||
var rect = new Native.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;
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||
}
|
||||
|
||||
void SetFormPositionAndSizeKeepHeight()
|
||||
{
|
||||
if (IsFullscreen || mp.VideoSize.Width == 0) return;
|
||||
Screen screen = Screen.FromControl(this);
|
||||
int height = ClientSize.Height;
|
||||
int width = Convert.ToInt32(height * mp.VideoSize.Width / (double)mp.VideoSize.Height);
|
||||
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
||||
var rect = new Native.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;
|
||||
|
||||
if (left < screens[0].Bounds.Left)
|
||||
left = screens[0].Bounds.Left;
|
||||
|
||||
int maxLeft = screens[0].Bounds.Left + screens.Select((sc) => sc.Bounds.Width).Sum() - rect.Width - SystemInformation.CaptionHeight;
|
||||
|
||||
if (left > maxLeft)
|
||||
left = maxLeft;
|
||||
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, left, top, rect.Width, rect.Height, 4 /* SWP_NOZORDER */);
|
||||
}
|
||||
|
||||
protected void ProcessCommandLineEarly()
|
||||
{
|
||||
var args = Environment.GetCommandLineArgs().Skip(1);
|
||||
|
||||
foreach (string i in args)
|
||||
{
|
||||
if (i.StartsWith("--"))
|
||||
{
|
||||
if (i.Contains("="))
|
||||
{
|
||||
string left = i.Substring(2, i.IndexOf("=") - 2);
|
||||
string right = i.Substring(left.Length + 3);
|
||||
|
||||
if (left == "screen")
|
||||
SetScreen(Convert.ToInt32(right));
|
||||
|
||||
ChangeFullscreen((left == "fs" || left == "fullscreen") && right == "yes");
|
||||
}
|
||||
else
|
||||
{
|
||||
string switchName = i.Substring(2);
|
||||
|
||||
switch (switchName)
|
||||
{
|
||||
case "fs":
|
||||
case "fullscreen":
|
||||
ChangeFullscreen(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildMenu()
|
||||
{
|
||||
if (!File.Exists(mp.InputConfPath))
|
||||
foreach (var i in File.ReadAllText(mp.InputConfPath).Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (!Directory.Exists(mp.mpvConfFolderPath))
|
||||
Directory.CreateDirectory(mp.mpvConfFolderPath);
|
||||
|
||||
File.WriteAllText(mp.InputConfPath, Properties.Resources.input_conf);
|
||||
}
|
||||
|
||||
foreach (var i in File.ReadAllText(mp.InputConfPath).SplitLinesNoEmpty())
|
||||
{
|
||||
if (!i.Contains("#menu:"))
|
||||
continue;
|
||||
|
||||
var left = i.Left("#menu:").Trim();
|
||||
|
||||
if (left.StartsWith("#"))
|
||||
continue;
|
||||
|
||||
var cmd = left.Right(" ").Trim();
|
||||
var menu = i.Right("#menu:").Trim();
|
||||
var key = menu.Left(";").Trim();
|
||||
var path = menu.Right(";").Trim();
|
||||
if (!i.Contains("#menu:")) continue;
|
||||
var left = i.Substring(0, i.IndexOf("#menu:")).Trim();
|
||||
if (left.StartsWith("#")) continue;
|
||||
var cmd = left.Substring(left.IndexOf(" ") + 1).Trim();
|
||||
var menu = i.Substring(i.IndexOf("#menu:") + "#menu:".Length).Trim();
|
||||
var key = menu.Substring(0, menu.IndexOf(";")).Trim();
|
||||
var path = menu.Substring(menu.IndexOf(";") + 1).Trim();
|
||||
|
||||
if (path == "" || cmd == "")
|
||||
continue;
|
||||
@@ -73,11 +152,11 @@ namespace mpvnet
|
||||
var menuItem = CMS.Add(path, () => {
|
||||
try
|
||||
{
|
||||
mp.CommandString(cmd, false);
|
||||
mp.command_string(cmd);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MsgError(e.ToString());
|
||||
MainForm.Instance.ShowMsgBox(e.ToString(), MessageBoxIcon.Error);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -93,19 +172,25 @@ namespace mpvnet
|
||||
|
||||
private string LastHistory;
|
||||
|
||||
private void mpv_PlaybackRestart()
|
||||
private void mp_PlaybackRestart()
|
||||
{
|
||||
var fn = mp.GetStringProp("filename");
|
||||
BeginInvoke(new Action(() => { Text = fn + " - mpv.net " + Application.ProductVersion; }));
|
||||
var fp = mp.mpvConfFolderPath + "history.txt";
|
||||
var filename = mp.get_property_string("filename");
|
||||
BeginInvoke(new Action(() => { Text = filename + " - mpv.net " + Application.ProductVersion; }));
|
||||
var historyFilepath = mp.mpvConfFolderPath + "history.txt";
|
||||
|
||||
if (LastHistory != fn && File.Exists(fp))
|
||||
if (LastHistory != filename && File.Exists(historyFilepath))
|
||||
{
|
||||
File.AppendAllText(fp, DateTime.Now.ToString() + " " + Path.GetFileNameWithoutExtension(fn) + "\r\n");
|
||||
LastHistory = fn;
|
||||
File.AppendAllText(historyFilepath, DateTime.Now.ToString() + " " +
|
||||
Path.GetFileNameWithoutExtension(filename) + "\r\n");
|
||||
LastHistory = filename;
|
||||
}
|
||||
}
|
||||
|
||||
private void Mp_Idle()
|
||||
{
|
||||
BeginInvoke(new Action(() => { Text = "mpv.net " + Application.ProductVersion; }));
|
||||
}
|
||||
|
||||
private void CM_Popup(object sender, EventArgs e)
|
||||
{
|
||||
CursorHelp.Show();
|
||||
@@ -113,31 +198,22 @@ namespace mpvnet
|
||||
|
||||
private void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
||||
{
|
||||
HandleException(e.Exception);
|
||||
ShowMsgBox(e.Exception.ToString(), MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
void HandleException(Exception e)
|
||||
private void mp_VideoSizeChanged()
|
||||
{
|
||||
MsgError(e.ToString());
|
||||
BeginInvoke(new Action(() => SetFormPositionAndSizeKeepHeight()));
|
||||
}
|
||||
|
||||
private void Mpv_VideoSizeChanged()
|
||||
private void mp_Shutdown()
|
||||
{
|
||||
BeginInvoke(new Action(() => SetFormPosSize()));
|
||||
BeginInvoke(new Action(() => Close()));
|
||||
}
|
||||
|
||||
private void Mpv_AfterShutdown()
|
||||
{
|
||||
if (IsCloseRequired)
|
||||
Invoke(new Action(() => Close()));
|
||||
}
|
||||
public bool IsFullscreen => WindowState == FormWindowState.Maximized;
|
||||
|
||||
public bool IsFullscreen
|
||||
{
|
||||
get => WindowState == FormWindowState.Maximized;
|
||||
}
|
||||
|
||||
void MpvChangeFullscreen(bool value)
|
||||
void mp_ChangeFullscreen(bool value)
|
||||
{
|
||||
BeginInvoke(new Action(() => ChangeFullscreen(value)));
|
||||
}
|
||||
@@ -146,14 +222,17 @@ namespace mpvnet
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
WindowState = FormWindowState.Maximized;
|
||||
if (FormBorderStyle != FormBorderStyle.None)
|
||||
{
|
||||
FormBorderStyle = FormBorderStyle.None;
|
||||
WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = FormWindowState.Normal;
|
||||
FormBorderStyle = FormBorderStyle.Sizable;
|
||||
SetFormPosSize();
|
||||
SetFormPositionAndSizeKeepHeight();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,9 +248,26 @@ namespace mpvnet
|
||||
if (mp.MpvWindowHandle != IntPtr.Zero)
|
||||
Native.SendMessage(mp.MpvWindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
case 0x319: // WM_APPCOMMAND
|
||||
if (mp.MpvWindowHandle != IntPtr.Zero)
|
||||
Native.PostMessage(mp.MpvWindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
case 0x0104: // WM_SYSKEYDOWN:
|
||||
if (mp.MpvWindowHandle != IntPtr.Zero)
|
||||
Native.SendMessage(mp.MpvWindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
case 0x0105: // WM_SYSKEYUP:
|
||||
if (mp.MpvWindowHandle != IntPtr.Zero)
|
||||
Native.SendMessage(mp.MpvWindowHandle, m.Msg, m.WParam, m.LParam);
|
||||
break;
|
||||
case 0x203: // Native.WM.LBUTTONDBLCLK
|
||||
if (!IsMouseInOSC())
|
||||
mp.CommandString("cycle fullscreen");
|
||||
mp.command_string("cycle fullscreen");
|
||||
break;
|
||||
case 0x02E0: // WM_DPICHANGED
|
||||
if (IgnoreDpiChanged) break;
|
||||
var r2 = Marshal.PtrToStructure<Native.RECT>(m.LParam);
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0);
|
||||
break;
|
||||
case 0x0214: // WM_SIZING
|
||||
var rc = Marshal.PtrToStructure<Native.RECT>(m.LParam);
|
||||
@@ -179,8 +275,8 @@ namespace mpvnet
|
||||
NativeHelp.SubtractWindowBorders(Handle, ref r);
|
||||
int c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
|
||||
float aspect = mp.VideoSize.Width / (float)mp.VideoSize.Height;
|
||||
int d_w = (int)(c_h * aspect - c_w);
|
||||
int d_h = (int)(c_w / aspect - c_h);
|
||||
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());
|
||||
@@ -196,24 +292,6 @@ namespace mpvnet
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
void SetFormPosSize()
|
||||
{
|
||||
if (IsFullscreen || mp.VideoSize.Width == 0) return;
|
||||
var wa = Screen.GetWorkingArea(this);
|
||||
int h = (int)(wa.Height * 0.6);
|
||||
int w = (int)(h * mp.VideoSize.Width / (float)mp.VideoSize.Height);
|
||||
Point middlePos = new Point(Left + Width / 2, Top + Height / 2);
|
||||
var r = new Native.RECT(new Rectangle(0, 0, w, h));
|
||||
NativeHelp.AddWindowBorders(Handle, ref r);
|
||||
int l = middlePos.X - r.Width / 2;
|
||||
int t = middlePos.Y - r.Height / 2;
|
||||
if (l < 0) l = 0;
|
||||
if (t < 0) t = 0;
|
||||
if (l + r.Width > wa.Width ) l = wa.Width - r.Width;
|
||||
if (t + r.Height > wa.Height ) t = wa.Height - r.Height;
|
||||
Native.SetWindowPos(Handle, IntPtr.Zero /* HWND_TOP */, l, t, r.Width, r.Height, 4 /* SWP_NOZORDER */);
|
||||
}
|
||||
|
||||
protected override void OnDragEnter(DragEventArgs e)
|
||||
{
|
||||
base.OnDragEnter(e);
|
||||
@@ -234,7 +312,6 @@ namespace mpvnet
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
// window-dragging
|
||||
if (WindowState == FormWindowState.Normal &&
|
||||
e.Button == MouseButtons.Left &&
|
||||
e.Y < ClientSize.Height * 0.9)
|
||||
@@ -249,27 +326,18 @@ namespace mpvnet
|
||||
var p2 = PointToScreen(e.Location);
|
||||
|
||||
if (Math.Abs(p1.X - p2.X) < 10 && Math.Abs(p1.Y - p2.Y) < 10)
|
||||
mp.Command("quit");
|
||||
mp.commandv("quit");
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
// send mouse command to make OSC show
|
||||
mp.CommandString($"mouse {e.X} {e.Y}");
|
||||
mp.command_string($"mouse {e.X} {e.Y}");
|
||||
|
||||
if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
|
||||
CursorHelp.Show();
|
||||
}
|
||||
|
||||
protected override void OnFormClosed(FormClosedEventArgs e)
|
||||
{
|
||||
base.OnFormClosed(e);
|
||||
IsCloseRequired = false;
|
||||
mp.Command("quit");
|
||||
}
|
||||
|
||||
bool IsMouseInOSC()
|
||||
{
|
||||
return PointToClient(Control.MousePosition).Y > ClientSize.Height * 0.9;
|
||||
@@ -290,13 +358,43 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs ea)
|
||||
public DialogResult ShowMsgBox(string message, MessageBoxIcon icon)
|
||||
{
|
||||
var buttons = MessageBoxButtons.OK;
|
||||
if (icon == MessageBoxIcon.Question) buttons = MessageBoxButtons.OKCancel;
|
||||
|
||||
var fn = new Func<DialogResult>(() => MessageBox.Show(
|
||||
message, Application.ProductName, buttons, MessageBoxIcon.Information));
|
||||
|
||||
return (DialogResult)Invoke(fn);
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
mp.Init();
|
||||
mp.ObserveBoolProp("fullscreen", MpvChangeFullscreen);
|
||||
mp.Shutdown += Mpv_AfterShutdown;
|
||||
mp.VideoSizeChanged += Mpv_VideoSizeChanged;
|
||||
mp.PlaybackRestart += mpv_PlaybackRestart;
|
||||
mp.observe_property_bool("fullscreen", mp_ChangeFullscreen);
|
||||
mp.Shutdown += mp_Shutdown;
|
||||
mp.VideoSizeChanged += mp_VideoSizeChanged;
|
||||
mp.PlaybackRestart += mp_PlaybackRestart;
|
||||
mp.Idle += Mp_Idle;
|
||||
}
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
CMS = new ContextMenuStripEx(components);
|
||||
CMS.Opened += CMS_Opened;
|
||||
ContextMenuStrip = CMS;
|
||||
BuildMenu();
|
||||
IgnoreDpiChanged = false;
|
||||
}
|
||||
|
||||
protected override void OnFormClosed(FormClosedEventArgs e)
|
||||
{
|
||||
base.OnFormClosed(e);
|
||||
mp.commandv("quit");
|
||||
mp.AutoResetEvent.WaitOne(3000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,8 +214,7 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
|
||||
if (e.Item is ToolStripMenuItem && !(e.Item.Owner is MenuStrip))
|
||||
{
|
||||
var r = e.TextRectangle;
|
||||
|
||||
Rectangle rect = e.TextRectangle;
|
||||
var dropDown = e.ToolStrip as ToolStripDropDownMenu;
|
||||
|
||||
if (dropDown == null || dropDown.ShowImageMargin || dropDown.ShowCheckMargin)
|
||||
@@ -223,7 +222,7 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
else
|
||||
TextOffset = Convert.ToInt32(e.Item.Height * 0.2);
|
||||
|
||||
e.TextRectangle = new Rectangle(TextOffset, Convert.ToInt32((e.Item.Height - r.Height) / 2.0), r.Width, r.Height);
|
||||
e.TextRectangle = new Rectangle(TextOffset, Convert.ToInt32((e.Item.Height - rect.Height) / 2.0), rect.Width, rect.Height);
|
||||
}
|
||||
|
||||
base.OnRenderItemText(e);
|
||||
@@ -279,31 +278,22 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
|
||||
public void DrawButton(ToolStripItemRenderEventArgs e)
|
||||
{
|
||||
var g = e.Graphics;
|
||||
var r = new Rectangle(Point.Empty, e.Item.Size);
|
||||
var r2 = new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1);
|
||||
var gx = e.Graphics;
|
||||
var rect = new Rectangle(Point.Empty, e.Item.Size);
|
||||
var rect2 = new Rectangle(rect.X, rect.Y, rect.Width - 1, rect.Height - 1);
|
||||
|
||||
using (Pen pen = new Pen(ColorBorder))
|
||||
{
|
||||
g.DrawRectangle(pen, r2);
|
||||
}
|
||||
|
||||
r2.Inflate(-1, -1);
|
||||
gx.DrawRectangle(pen, rect2);
|
||||
|
||||
rect2.Inflate(-1, -1);
|
||||
var tsb = e.Item as ToolStripButton;
|
||||
|
||||
if (!(tsb == null) && tsb.Checked)
|
||||
{
|
||||
if (tsb != null && tsb.Checked)
|
||||
using (SolidBrush brush = new SolidBrush(ColorChecked))
|
||||
{
|
||||
g.FillRectangle(brush, r2);
|
||||
}
|
||||
}
|
||||
gx.FillRectangle(brush, rect2);
|
||||
else
|
||||
using (SolidBrush brush = new SolidBrush(ColorBottom))
|
||||
{
|
||||
g.FillRectangle(brush, r2);
|
||||
}
|
||||
gx.FillRectangle(brush, rect2);
|
||||
}
|
||||
|
||||
protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
|
||||
@@ -332,7 +322,7 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
|
||||
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
|
||||
{
|
||||
var x = Convert.ToInt32(e.ImageRectangle.Height * 0.2);
|
||||
int x = Convert.ToInt32(e.ImageRectangle.Height * 0.2);
|
||||
e.Graphics.DrawImage(e.Image, new Point(x, x));
|
||||
}
|
||||
|
||||
@@ -341,28 +331,21 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
|
||||
if (e.Item.IsOnDropDown)
|
||||
{
|
||||
e.Graphics.Clear(ColorBackground);
|
||||
var right = e.Item.Width - Convert.ToInt32(TextOffset / 5.0);
|
||||
var top = e.Item.Height / 2;
|
||||
int right = e.Item.Width - Convert.ToInt32(TextOffset / 5.0);
|
||||
int top = e.Item.Height / 2;
|
||||
top -= 1;
|
||||
var b = e.Item.Bounds;
|
||||
|
||||
using (Pen p = new Pen(Color.Gray))
|
||||
{
|
||||
e.Graphics.DrawLine(p, new Point(TextOffset, top), new Point(right, top));
|
||||
}
|
||||
}
|
||||
else if (e.Vertical)
|
||||
{
|
||||
var b = e.Item.Bounds;
|
||||
|
||||
var bounds = e.Item.Bounds;
|
||||
using (Pen p = new Pen(SystemColors.ControlDarkDark))
|
||||
{
|
||||
e.Graphics.DrawLine(p,
|
||||
Convert.ToInt32(b.Width / 2.0),
|
||||
Convert.ToInt32(b.Height * 0.15),
|
||||
Convert.ToInt32(b.Width / 2.0),
|
||||
Convert.ToInt32(b.Height * 0.85));
|
||||
}
|
||||
Convert.ToInt32(bounds.Width / 2.0),
|
||||
Convert.ToInt32(bounds.Height * 0.15),
|
||||
Convert.ToInt32(bounds.Width / 2.0),
|
||||
Convert.ToInt32(bounds.Height * 0.85));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -383,21 +366,24 @@ public struct HSLColor
|
||||
|
||||
private double hue;
|
||||
|
||||
public int Hue {
|
||||
public int Hue
|
||||
{
|
||||
get => System.Convert.ToInt32(hue * 240);
|
||||
set => hue = CheckRange(value / 240.0);
|
||||
}
|
||||
|
||||
private double saturation;
|
||||
|
||||
public int Saturation {
|
||||
public int Saturation
|
||||
{
|
||||
get => System.Convert.ToInt32(saturation * 240);
|
||||
set => saturation = CheckRange(value / 240.0);
|
||||
}
|
||||
|
||||
private double luminosity;
|
||||
|
||||
public int Luminosity {
|
||||
public int Luminosity
|
||||
{
|
||||
get => System.Convert.ToInt32(luminosity * 240);
|
||||
set => luminosity = CheckRange(value / 240.0);
|
||||
}
|
||||
@@ -408,7 +394,6 @@ public struct HSLColor
|
||||
value = 0;
|
||||
else if (value > 1)
|
||||
value = 1;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -438,9 +423,8 @@ public struct HSLColor
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp2 = GetTemp2(this);
|
||||
var temp1 = 2.0 * luminosity - temp2;
|
||||
|
||||
double temp2 = GetTemp2(this);
|
||||
double temp1 = 2.0 * luminosity - temp2;
|
||||
r = GetColorComponent(temp1, temp2, hue + 1.0 / 3.0);
|
||||
g = GetColorComponent(temp1, temp2, hue);
|
||||
b = GetColorComponent(temp1, temp2, hue - 1.0 / 3.0);
|
||||
@@ -473,7 +457,6 @@ public struct HSLColor
|
||||
temp3 += 1;
|
||||
else if (temp3 > 1)
|
||||
temp3 -= 1;
|
||||
|
||||
return temp3;
|
||||
}
|
||||
|
||||
@@ -500,7 +483,7 @@ public struct HSLColor
|
||||
|
||||
public void SetRGB(int red, int green, int blue)
|
||||
{
|
||||
var hc = HSLColor.Convert(Color.FromArgb(red, green, blue));
|
||||
HSLColor hc = HSLColor.Convert(Color.FromArgb(red, green, blue));
|
||||
hue = hc.hue;
|
||||
saturation = hc.saturation;
|
||||
luminosity = hc.luminosity;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
@@ -26,21 +27,13 @@ namespace mpvnet
|
||||
int IComparer<string>.Compare(string x, string y) => IComparerOfString_Compare(x, y);
|
||||
}
|
||||
|
||||
public class StaticUsing
|
||||
{
|
||||
public static void MsgInfo(string message)
|
||||
{
|
||||
MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
//public class OSVersion
|
||||
//{
|
||||
// public static float Windows7 { get; } = 6.1f;
|
||||
// public static float Windows8 { get; } = 6.2f;
|
||||
// public static float Windows81 { get; } = 6.3f;
|
||||
// public static float Windows10 { get; } = 10f;
|
||||
|
||||
public static void MsgError(string message)
|
||||
{
|
||||
MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
public static DialogResult MsgQuestion(string message)
|
||||
{
|
||||
return MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
||||
}
|
||||
}
|
||||
// public static float Current => Environment.OSVersion.Version.Major + Environment.OSVersion.Version.Minor / 10f;
|
||||
//}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -30,6 +32,9 @@ namespace mpvnet
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
|
||||
|
||||
[DllImport("Shlwapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
public static extern uint AssocQueryString(uint flags, uint str, string pszAssoc, string pszExtra, StringBuilder pszOut, ref uint pcchOut);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
@@ -54,25 +59,10 @@ namespace mpvnet
|
||||
Bottom = bottom;
|
||||
}
|
||||
|
||||
public Rectangle ToRectangle()
|
||||
{
|
||||
return Rectangle.FromLTRB(Left, Top, Right, Bottom);
|
||||
}
|
||||
|
||||
public Size Size
|
||||
{
|
||||
get => new Size(Right - Left, Bottom - Top);
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get => Right - Left;
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get => Bottom - Top;
|
||||
}
|
||||
public Rectangle ToRectangle() { return 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
@@ -34,5 +36,25 @@ namespace mpvnet
|
||||
{
|
||||
Native.AdjustWindowRect(ref rc, (uint)Native.GetWindowLongPtrW(hwnd, -16 /* GWL_STYLE */), false);
|
||||
}
|
||||
|
||||
public static string GetAssociatedApplication(string ext)
|
||||
{
|
||||
uint returnValue = 0U;
|
||||
// ASSOCF_VERIFY, ASSOCSTR_EXECUTABLE
|
||||
if (1 == Native.AssocQueryString(0x40, 2, ext, null, null, ref returnValue))
|
||||
{
|
||||
if (returnValue > 0)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(Convert.ToInt32(returnValue));
|
||||
// ASSOCF_VERIFY, ASSOCSTR_EXECUTABLE
|
||||
if (0 == Native.AssocQueryString(0x40, 2, ext, null, sb, ref returnValue))
|
||||
{
|
||||
var ret = sb.ToString();
|
||||
if (File.Exists(ret)) return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
128
mpv.net/PowerShellScript.cs
Normal file
128
mpv.net/PowerShellScript.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Management.Automation.Runspaces;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class PowerShellScript
|
||||
{
|
||||
public static object Execute(string code, string[] parameters)
|
||||
{
|
||||
using (Runspace runspace = RunspaceFactory.CreateRunspace())
|
||||
{
|
||||
runspace.ApartmentState = ApartmentState.STA;
|
||||
runspace.ThreadOptions = PSThreadOptions.UseCurrentThread;
|
||||
runspace.Open();
|
||||
|
||||
using (Pipeline pipeline = runspace.CreatePipeline())
|
||||
{
|
||||
pipeline.Commands.AddScript(
|
||||
@"Using namespace mpvnet;
|
||||
Using namespace System;
|
||||
[System.Reflection.Assembly]::LoadWithPartialName(""mpvnet"")");
|
||||
|
||||
pipeline.Commands.AddScript(code);
|
||||
|
||||
try
|
||||
{
|
||||
var ret = pipeline.Invoke(parameters);
|
||||
|
||||
if (ret.Count > 0)
|
||||
return ret[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Pipeline pipeline2 = runspace.CreatePipeline())
|
||||
{
|
||||
pipeline2.Commands.AddScript("$PSVersionTable.PSVersion.Major * 10 +" +
|
||||
"$PSVersionTable.PSVersion.Minor");
|
||||
|
||||
if (Convert.ToInt32(pipeline2.Invoke()[0].ToString()) < 51)
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
MainForm.Instance.ShowMsgBox("PowerShell Setup Problem\n\nEnsure you have at least PowerShell 5.1 installed.", MessageBoxIcon.Error);
|
||||
return null;
|
||||
}
|
||||
MainForm.Instance.ShowMsgBox(ex.ToString(), MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void Init(string filePath)
|
||||
{
|
||||
foreach (var eventInfo in typeof(mp).GetEvents())
|
||||
{
|
||||
if (eventInfo.Name.ToLower() ==
|
||||
Path.GetFileNameWithoutExtension(filePath).ToLower().Replace("-", ""))
|
||||
{
|
||||
PowerShellEventObject eventObject = new PowerShellEventObject();
|
||||
MethodInfo mi;
|
||||
eventObject.FilePath = filePath;
|
||||
|
||||
if (eventInfo.EventHandlerType == typeof(Action))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.Invoke));
|
||||
}
|
||||
else if (eventInfo.EventHandlerType == typeof(Action<EndFileEventMode>))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeEndFileEventMode));
|
||||
}
|
||||
else if (eventInfo.EventHandlerType == typeof(Action<string[]>))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(PowerShellEventObject.InvokeStrings));
|
||||
}
|
||||
else
|
||||
throw new Exception();
|
||||
|
||||
eventObject.EventInfo = eventInfo;
|
||||
Delegate handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, eventObject, mi);
|
||||
eventObject.Delegate = handler;
|
||||
eventInfo.AddEventHandler(eventObject, handler);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Task.Run(() =>
|
||||
{
|
||||
PowerShellScript.Execute(File.ReadAllText(filePath), new string[] {});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class PowerShellEventObject
|
||||
{
|
||||
public EventInfo EventInfo { get; set; }
|
||||
public Delegate Delegate { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public void Invoke()
|
||||
{
|
||||
Task.Run(() => { PowerShellScript.Execute(File.ReadAllText(FilePath), new string[] { }); });
|
||||
}
|
||||
|
||||
public void InvokeEndFileEventMode(EndFileEventMode arg)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
PowerShellScript.Execute(File.ReadAllText(FilePath), new string[] { arg.ToString() });
|
||||
});
|
||||
}
|
||||
|
||||
public void InvokeStrings(string[] args)
|
||||
{
|
||||
Task.Run(() => {
|
||||
PowerShellScript.Execute(File.ReadAllText(FilePath), args);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("mpv.net")]
|
||||
[assembly: AssemblyDescription("mpv/libmpv based player with pure mpv experience")]
|
||||
[assembly: AssemblyDescription("libmpv based player with pure mpv experience")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("mpv.net")]
|
||||
@@ -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("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
[assembly: AssemblyVersion("1.8.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0.0")]
|
||||
|
||||
31
mpv.net/Properties/Resources.Designer.cs
generated
31
mpv.net/Properties/Resources.Designer.cs
generated
@@ -19,7 +19,7 @@ namespace mpvnet.Properties {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
@@ -61,11 +61,38 @@ namespace mpvnet.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to # mpv.net key bindings, mouse bindings and context menu configuration
|
||||
///
|
||||
/// o script-message mpv.net open-files #menu: O ; Open Files...
|
||||
/// _ ignore #menu: _ ; -
|
||||
/// Space cycle pause #menu: Space, Enter ; Play/Pause
|
||||
/// Enter cycle pause
|
||||
/// s stop #menu: S ; Stop
|
||||
/// _ ignore #menu: _ ; -
|
||||
/// f cycle fullscreen #menu: F ; Toggle Fullscreen
|
||||
/// [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string input_conf {
|
||||
get {
|
||||
return ResourceManager.GetString("input_conf", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to input-ar-delay = 500
|
||||
///input-ar-rate = 20
|
||||
///volume = 50
|
||||
///hwdec = yes
|
||||
///vo = direct3d
|
||||
///keep-open = yes
|
||||
///keep-open-pause = no
|
||||
///osd-playing-msg = '${filename}'
|
||||
///screenshot-directory = ~~desktop/.
|
||||
/// </summary>
|
||||
internal static string mpv_conf {
|
||||
get {
|
||||
return ResourceManager.GetString("mpv_conf", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,6 +119,9 @@
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="input_conf" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\input_conf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
<value>..\Resources\input.conf.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</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>
|
||||
</root>
|
||||
@@ -1,33 +0,0 @@
|
||||
using System;
|
||||
|
||||
using IronPython.Hosting;
|
||||
using Microsoft.Scripting.Hosting;
|
||||
|
||||
using static mpvnet.StaticUsing;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class PyScript
|
||||
{
|
||||
ScriptEngine engine;
|
||||
ScriptScope scope;
|
||||
|
||||
public PyScript(string code)
|
||||
{
|
||||
try
|
||||
{
|
||||
engine = Python.CreateEngine();
|
||||
scope = engine.CreateScope();
|
||||
scope.ImportModule("clr");
|
||||
engine.Execute("import clr", scope);
|
||||
engine.Execute("clr.AddReference(\"mpvnet\")", scope);
|
||||
engine.Execute("from mpvnet import *", scope);
|
||||
engine.Execute(code, scope);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MsgError(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
mpv.net/PythonScript.cs
Normal file
56
mpv.net/PythonScript.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using IronPython.Hosting;
|
||||
using Microsoft.Scripting.Hosting;
|
||||
|
||||
using PyRT = IronPython.Runtime;
|
||||
|
||||
namespace mpvnet
|
||||
{
|
||||
public class PythonScript
|
||||
{
|
||||
ScriptEngine engine;
|
||||
ScriptScope scope;
|
||||
|
||||
public PythonScript(string code)
|
||||
{
|
||||
try
|
||||
{
|
||||
engine = Python.CreateEngine();
|
||||
scope = engine.CreateScope();
|
||||
scope.ImportModule("clr");
|
||||
engine.Execute("import clr", scope);
|
||||
engine.Execute("clr.AddReference(\"mpvnet\")", scope);
|
||||
engine.Execute("from mpvnet import *", scope);
|
||||
engine.Execute(code, scope);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.ShowMsgBox(ex.ToString(), MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PythonEventObject
|
||||
{
|
||||
public PyRT.PythonFunction PythonFunction { get; set; }
|
||||
public EventInfo EventInfo { get; set; }
|
||||
public Delegate Delegate { get; set; }
|
||||
|
||||
public void Invoke()
|
||||
{
|
||||
PyRT.Operations.PythonCalls.Call(PythonFunction);
|
||||
}
|
||||
|
||||
public void InvokeEndFileEventMode(EndFileEventMode arg)
|
||||
{
|
||||
PyRT.Operations.PythonCalls.Call(PythonFunction, new[] { arg });
|
||||
}
|
||||
|
||||
public void InvokeStrings(string[] arg)
|
||||
{
|
||||
PyRT.Operations.PythonCalls.Call(PythonFunction, new[] { arg });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,16 +29,16 @@
|
||||
Ctrl++ add video-zoom 0.1 #menu: Ctrl++ ; Pan && Scan > Increase Size
|
||||
Ctrl+- add video-zoom -0.1 #menu: Ctrl+- ; Pan && Scan > Decrease Size
|
||||
_ ignore #menu: _ ; Pan && Scan > -
|
||||
Shift+Left add video-pan-x -0.01 #menu: Shift+Left ; Pan && Scan > Move Left
|
||||
Shift+Right add video-pan-x 0.01 #menu: Shift+Right ; Pan && Scan > Move Right
|
||||
Ctrl+KP4 add video-pan-x -0.01 #menu: Ctrl+Numpad 4 ; Pan && Scan > Move Left
|
||||
Ctrl+KP6 add video-pan-x 0.01 #menu: Ctrl+Numpad 6 ; Pan && Scan > Move Right
|
||||
_ ignore #menu: _ ; Pan && Scan > -
|
||||
Shift+Up add video-pan-y -0.01 #menu: Shift+Up ; Pan && Scan > Move Up
|
||||
Shift+Down add video-pan-y 0.01 #menu: Shift+Down ; Pan && Scan > Move Down
|
||||
Ctrl+KP8 add video-pan-y -0.01 #menu: Ctrl+Numpad 8 ; Pan && Scan > Move Up
|
||||
Ctrl+KP2 add video-pan-y 0.01 #menu: Ctrl+Numpad 2 ; Pan && Scan > Move Down
|
||||
_ ignore #menu: _ ; Pan && Scan > -
|
||||
w add panscan -0.1 #menu: W ; Pan && Scan > Decrease Height
|
||||
W add panscan +0.1 #menu: Shift+W ; Pan && Scan > Increase Height
|
||||
_ ignore #menu: _ ; Pan && Scan > -
|
||||
Shift+BS set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0 #menu: Alt+Backspace ; Pan && Scan > Reset
|
||||
Ctrl+BS set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0 #menu: Ctrl+Backspace ; Pan && Scan > Reset
|
||||
|
||||
Ctrl+1 add contrast -1 #menu: Ctrl+1 ; Video > Decrease Contrast
|
||||
Ctrl+2 add contrast 1 #menu: Ctrl+2 ; Video > Increase Contrast
|
||||
@@ -53,8 +53,6 @@
|
||||
Ctrl+8 add saturation 1 #menu: Ctrl+8 ; Video > Increase Saturation
|
||||
_ ignore #menu: _ ; Video > -
|
||||
Ctrl+S async screenshot #menu: Ctrl+S ; Video > Take Screenshot
|
||||
Ctrl+Shift+S screenshot each-frame #menu: Ctrl+Shift+S ; Video > Take Screenshots All Frames
|
||||
_ ignore #menu: _ ; Video > -
|
||||
d cycle deinterlace #menu: D ; Video > Toggle Deinterlace
|
||||
a cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1" #menu: A ; Video > Cycle Aspect Ratio
|
||||
|
||||
@@ -74,7 +72,6 @@
|
||||
_ ignore #menu: _ ; Subtitle > -
|
||||
_ add sub-scale -0.1 #menu: _ ; Subtitle > Decrease Subtitle Font Size
|
||||
_ add sub-scale +0.1 #menu: _ ; Subtitle > Increase Subtitle Font Size
|
||||
_ ignore #menu: _ ; Subtitle > -
|
||||
|
||||
+ add volume 10 #menu: + ; Volume > Up
|
||||
- add volume -10 #menu: - ; Volume > Down
|
||||
@@ -100,11 +97,12 @@
|
||||
|
||||
_ script-message mpv.net set-setting hwdec yes #menu: _ ; Settings > Hardware Decoding > Enable
|
||||
_ script-message mpv.net set-setting hwdec no #menu: _ ; Settings > Hardware Decoding > Disable
|
||||
p script-message mpv.net show-prefs #menu: P ; Settings > Show Preferences
|
||||
p script-message mpv.net show-prefs #menu: P ; Settings > Show mpv config file
|
||||
e script-message mpv.net show-conf-editor #menu: E ; Settings > Show mpv config editor
|
||||
k script-message mpv.net show-keys #menu: K ; Settings > Show Keys
|
||||
c script-message mpv.net open-config-folder #menu: C ; Settings > Open Config Folder
|
||||
|
||||
i show-progress ; script-message mpv.net show-info #menu: I ; Tools | Info
|
||||
i script-message mpv.net show-info #menu: I ; Tools | Info
|
||||
t script-binding stats/display-stats #menu: T ; Tools > Show Statistics
|
||||
T script-binding stats/display-stats-toggle #menu: Shift+T ; Tools > Toggle Statistics
|
||||
_ ignore #menu: _ ; Tools > -
|
||||
@@ -116,9 +114,10 @@
|
||||
F8 show-text ${playlist} 5000 #menu: F8 ; Tools > Show Playlist
|
||||
F9 show-text ${track-list} 5000 #menu: F9 ; Tools > Show Audio/Video/Subtitle List
|
||||
|
||||
_ script-message mpv.net shell-execute https://mpv.io/manual/stable/ #menu: _ ; Tools > Web > Show mpv manual
|
||||
_ script-message mpv.net shell-execute https://github.com/mpv-player/mpv/blob/master/etc/input.conf #menu: _ ; Tools > Web > Show mpv default keys
|
||||
_ script-message mpv.net shell-execute https://github.com/stax76/mpvnet #menu: _ ; Tools > Web > Show mpv.net web site
|
||||
_ script-message mpv.net shell-execute https://mpv.io/manual/stable/ #menu: _ ; Help > Show mpv manual
|
||||
_ script-message mpv.net shell-execute https://github.com/mpv-player/mpv/blob/master/etc/input.conf #menu: _ ; Help > Show mpv default keys
|
||||
_ script-message mpv.net shell-execute https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/input.conf.txt #menu: _ ; Help > Show mpv.net default keys
|
||||
_ script-message mpv.net shell-execute https://github.com/stax76/mpvnet #menu: _ ; Help > Show mpv.net web site
|
||||
_ ignore #menu: _ ; -
|
||||
Esc quit #menu: Escape ; Exit
|
||||
Q quit-watch-later #menu: Shift+Q ; Exit Watch Later
|
||||
@@ -135,6 +134,4 @@
|
||||
REWIND seek -60
|
||||
VOLUME_UP add volume 2
|
||||
VOLUME_DOWN add volume -2
|
||||
MUTE cycle mute
|
||||
CLOSE_WIN quit
|
||||
CLOSE_WIN {encode} quit 4
|
||||
MUTE cycle mute
|
||||
12
mpv.net/Resources/mpv.conf.txt
Normal file
12
mpv.net/Resources/mpv.conf.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
# mpv manual: https://mpv.io/manual/master/
|
||||
# mpv.net mpv.conf defaults: https://github.com/stax76/mpv.net/blob/master/mpv.net/Resources/mpv.conf.txt
|
||||
|
||||
input-ar-delay = 500
|
||||
input-ar-rate = 20
|
||||
volume = 50
|
||||
hwdec = yes
|
||||
vo = direct3d
|
||||
keep-open = yes
|
||||
keep-open-pause = no
|
||||
osd-playing-msg = ${filename}
|
||||
screenshot-directory = ~~desktop/
|
||||
@@ -1,120 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static string ExtFull(this string filepath)
|
||||
{
|
||||
return Ext(filepath, true);
|
||||
}
|
||||
|
||||
public static string Ext(this string filepath)
|
||||
{
|
||||
return Ext(filepath, false);
|
||||
}
|
||||
|
||||
public static string Ext(this string filepath, bool dot)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filepath))
|
||||
return "";
|
||||
|
||||
var chars = filepath.ToCharArray();
|
||||
|
||||
for (var x = filepath.Length - 1; x >= 0; x += -1)
|
||||
{
|
||||
if (chars[x] == Path.DirectorySeparatorChar)
|
||||
return "";
|
||||
|
||||
if (chars[x] == '.')
|
||||
return filepath.Substring(x + (dot ? 0 : 1)).ToLower();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string Left(this string value, int index)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value) || index < 0)
|
||||
return "";
|
||||
|
||||
if (index > value.Length)
|
||||
return value;
|
||||
|
||||
return value.Substring(0, index);
|
||||
}
|
||||
|
||||
public static string Left(this string value, string start)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(start))
|
||||
return "";
|
||||
|
||||
if (!value.Contains(start))
|
||||
return "";
|
||||
|
||||
return value.Substring(0, value.IndexOf(start));
|
||||
}
|
||||
|
||||
public static string LeftLast(this string value, string start)
|
||||
{
|
||||
if (!value.Contains(start))
|
||||
return "";
|
||||
|
||||
return value.Substring(0, value.LastIndexOf(start));
|
||||
}
|
||||
|
||||
public static string Right(this string value, string start)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(start))
|
||||
return "";
|
||||
|
||||
if (!value.Contains(start))
|
||||
return "";
|
||||
|
||||
return value.Substring(value.IndexOf(start) + start.Length);
|
||||
}
|
||||
|
||||
public static string RightLast(this string value, string start)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(start))
|
||||
return "";
|
||||
|
||||
if (!value.Contains(start))
|
||||
return "";
|
||||
|
||||
return value.Substring(value.LastIndexOf(start) + start.Length);
|
||||
}
|
||||
|
||||
public static string[] SplitNoEmpty(this string value, params string[] delimiters)
|
||||
{
|
||||
return value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public static string[] SplitKeepEmpty(this string value, params string[] delimiters)
|
||||
{
|
||||
return value.Split(delimiters, StringSplitOptions.None);
|
||||
}
|
||||
|
||||
public static string[] SplitNoEmptyAndWhiteSpace(this string value, params string[] delimiters)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return null;
|
||||
|
||||
var a = SplitNoEmpty(value, delimiters);
|
||||
|
||||
for (var i = 0; i <= a.Length - 1; i++)
|
||||
a[i] = a[i].Trim();
|
||||
|
||||
var l = a.ToList();
|
||||
|
||||
while (l.Contains(""))
|
||||
l.Remove("");
|
||||
|
||||
return l.ToArray();
|
||||
}
|
||||
|
||||
public static string[] SplitLinesNoEmpty(this string value)
|
||||
{
|
||||
return SplitNoEmpty(value, Environment.NewLine);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,9 @@
|
||||
</compatibility>
|
||||
<application>
|
||||
<windowsSettings>
|
||||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
<dependency>
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace mpvnet
|
||||
public static extern int mpv_set_option_string(IntPtr mpvHandle, byte[] name, byte[] value);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_get_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref IntPtr data);
|
||||
public static extern int mpv_get_property(IntPtr mpvHandle, byte[] name, mpv_format format, out IntPtr data);
|
||||
|
||||
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int mpv_get_property(IntPtr mpvHandle, byte[] name, mpv_format format, ref double data);
|
||||
|
||||
197
mpv.net/mp.cs
197
mpv.net/mp.cs
@@ -7,12 +7,12 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using static mpvnet.libmpv;
|
||||
using static mpvnet.Native;
|
||||
using static mpvnet.StaticUsing;
|
||||
|
||||
using PyRT = IronPython.Runtime;
|
||||
|
||||
@@ -60,49 +60,45 @@ namespace mpvnet
|
||||
public static string mpvConfFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\";
|
||||
public static string InputConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\input.conf";
|
||||
public static string mpvConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\mpv.conf";
|
||||
public static List<PyScript> PyScripts { get; } = new List<PyScript>();
|
||||
public static List<PythonScript> PythonScripts => new List<PythonScript>();
|
||||
public static AutoResetEvent AutoResetEvent = new AutoResetEvent(false);
|
||||
|
||||
private static Dictionary<string, string> _mpvConv;
|
||||
private static Dictionary<string, string> _mpvConf;
|
||||
|
||||
public static Dictionary<string, string> mpvConv {
|
||||
public static Dictionary<string, string> mpvConf {
|
||||
get {
|
||||
if (_mpvConv == null)
|
||||
if (_mpvConf == null)
|
||||
{
|
||||
_mpvConv = new Dictionary<string, string>();
|
||||
_mpvConf = new Dictionary<string, string>();
|
||||
|
||||
if (File.Exists(mpvConfPath))
|
||||
{
|
||||
foreach (var i in File.ReadAllLines(mpvConfPath))
|
||||
{
|
||||
if (i.Contains("=") && ! i.StartsWith("#"))
|
||||
{
|
||||
_mpvConv[i.Left("=").Trim()] = i.Right("=").Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
_mpvConf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
|
||||
}
|
||||
return _mpvConv;
|
||||
return _mpvConf;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
if (!Directory.Exists(mp.mpvConfFolderPath))
|
||||
Directory.CreateDirectory(mp.mpvConfFolderPath);
|
||||
|
||||
if (!File.Exists(mp.mpvConfPath))
|
||||
File.WriteAllText(mp.mpvConfPath, Properties.Resources.mpv_conf);
|
||||
|
||||
if (!File.Exists(mp.InputConfPath))
|
||||
File.WriteAllText(mp.InputConfPath, Properties.Resources.input_conf);
|
||||
|
||||
LoadLibrary("mpv-1.dll");
|
||||
MpvHandle = mpv_create();
|
||||
SetIntProp("input-ar-delay", 500);
|
||||
SetIntProp("input-ar-rate", 20);
|
||||
SetIntProp("volume", 50);
|
||||
SetStringProp("hwdec", "yes");
|
||||
SetStringProp("vo", "direct3d");
|
||||
SetStringProp("input-default-bindings", "yes");
|
||||
SetStringProp("osd-playing-msg", "'${filename}'");
|
||||
SetStringProp("screenshot-directory", "~~desktop/");
|
||||
SetStringProp("keep-open", "yes");
|
||||
SetStringProp("keep-open-pause", "no");
|
||||
SetStringProp("osc", "yes");
|
||||
SetStringProp("config", "yes");
|
||||
SetStringProp("wid", MainForm.Hwnd.ToString());
|
||||
SetStringProp("force-window", "yes");
|
||||
set_property_string("input-default-bindings", "yes");
|
||||
set_property_string("osc", "yes");
|
||||
set_property_string("config", "yes");
|
||||
set_property_string("wid", MainForm.Hwnd.ToString());
|
||||
set_property_string("force-window", "yes");
|
||||
set_property_string("input-media-keys", "yes");
|
||||
mpv_initialize(MpvHandle);
|
||||
ProcessCommandLine();
|
||||
Task.Run(() => { LoadScripts(); });
|
||||
@@ -117,14 +113,21 @@ namespace mpvnet
|
||||
|
||||
foreach (var scriptPath in startupScripts)
|
||||
if (jsLua.Contains(Path.GetExtension(scriptPath).ToLower()))
|
||||
mp.Command("load-script", $"{scriptPath}");
|
||||
mp.commandv("load-script", $"{scriptPath}");
|
||||
|
||||
foreach (var scriptPath in startupScripts)
|
||||
if (Path.GetExtension(scriptPath) == ".py")
|
||||
PyScripts.Add(new PyScript(File.ReadAllText(scriptPath)));
|
||||
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
|
||||
|
||||
foreach(var scriptPath in Directory.GetFiles(mp.mpvConfFolderPath + "scripts", "*.py"))
|
||||
PyScripts.Add(new PyScript(File.ReadAllText(scriptPath)));
|
||||
foreach (var scriptPath in startupScripts)
|
||||
if (Path.GetExtension(scriptPath) == ".ps1")
|
||||
PowerShellScript.Init(scriptPath);
|
||||
|
||||
foreach (var scriptPath in Directory.GetFiles(mp.mpvConfFolderPath + "Scripts"))
|
||||
if (Path.GetExtension(scriptPath) == ".py")
|
||||
PythonScripts.Add(new PythonScript(File.ReadAllText(scriptPath)));
|
||||
else if (Path.GetExtension(scriptPath) == ".ps1")
|
||||
PowerShellScript.Init(scriptPath);
|
||||
}
|
||||
|
||||
public static void EventLoop()
|
||||
@@ -133,15 +136,17 @@ namespace mpvnet
|
||||
{
|
||||
IntPtr ptr = mpv_wait_event(MpvHandle, -1);
|
||||
mpv_event evt = (mpv_event)Marshal.PtrToStructure(ptr, typeof(mpv_event));
|
||||
//Debug.WriteLine(evt.event_id);
|
||||
|
||||
if (MpvWindowHandle == IntPtr.Zero)
|
||||
MpvWindowHandle = FindWindowEx(MainForm.Hwnd, IntPtr.Zero, "mpv", null);
|
||||
|
||||
//Debug.WriteLine(evt.event_id.ToString());
|
||||
|
||||
switch (evt.event_id)
|
||||
{
|
||||
case mpv_event_id.MPV_EVENT_SHUTDOWN:
|
||||
Shutdown?.Invoke();
|
||||
AutoResetEvent.Set();
|
||||
return;
|
||||
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
|
||||
LogMessage?.Invoke();
|
||||
@@ -202,7 +207,7 @@ namespace mpvnet
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MsgError(ex.GetType().Name + "\r\n\r\n" + ex.ToString());
|
||||
MainForm.Instance.ShowMsgBox(ex.GetType().Name + "\n\n" + ex.ToString(), MessageBoxIcon.Error);
|
||||
}
|
||||
ClientMessage?.Invoke(args);
|
||||
}
|
||||
@@ -229,7 +234,7 @@ namespace mpvnet
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART:
|
||||
PlaybackRestart?.Invoke();
|
||||
Size s = new Size(GetIntProp("dwidth", false), GetIntProp("dheight", false));
|
||||
Size s = new Size(get_property_int("dwidth"), get_property_int("dheight"));
|
||||
|
||||
if (VideoSize != s && s != Size.Empty)
|
||||
{
|
||||
@@ -250,29 +255,7 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
public class EventObject
|
||||
{
|
||||
public PyRT.PythonFunction PythonFunction { get; set; }
|
||||
public EventInfo EventInfo { get; set; }
|
||||
public Delegate Delegate { get; set; }
|
||||
|
||||
public void Invoke()
|
||||
{
|
||||
PyRT.Operations.PythonCalls.Call(PythonFunction);
|
||||
}
|
||||
|
||||
public void InvokeEndFileEventMode(EndFileEventMode arg)
|
||||
{
|
||||
PyRT.Operations.PythonCalls.Call(PythonFunction, new[] { arg });
|
||||
}
|
||||
|
||||
public void InvokeStrings(string[] arg)
|
||||
{
|
||||
PyRT.Operations.PythonCalls.Call(PythonFunction, new[] { arg });
|
||||
}
|
||||
}
|
||||
|
||||
private static List<EventObject> EventObjects = new List<EventObject>();
|
||||
private static List<PythonEventObject> PythonEventObjects = new List<PythonEventObject>();
|
||||
|
||||
public static void register_event(string name, PyRT.PythonFunction pyFunc)
|
||||
{
|
||||
@@ -280,22 +263,22 @@ namespace mpvnet
|
||||
{
|
||||
if (eventInfo.Name.ToLower() == name.Replace("-", ""))
|
||||
{
|
||||
EventObject eventObject = new EventObject();
|
||||
EventObjects.Add(eventObject);
|
||||
PythonEventObject eventObject = new PythonEventObject();
|
||||
PythonEventObjects.Add(eventObject);
|
||||
eventObject.PythonFunction = pyFunc;
|
||||
MethodInfo mi;
|
||||
|
||||
if (eventInfo.EventHandlerType == typeof(Action))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(EventObject.Invoke));
|
||||
mi = eventObject.GetType().GetMethod(nameof(PythonEventObject.Invoke));
|
||||
}
|
||||
else if (eventInfo.EventHandlerType == typeof(Action<EndFileEventMode>))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(EventObject.InvokeEndFileEventMode));
|
||||
mi = eventObject.GetType().GetMethod(nameof(PythonEventObject.InvokeEndFileEventMode));
|
||||
}
|
||||
else if (eventInfo.EventHandlerType == typeof(Action<string[]>))
|
||||
{
|
||||
mi = eventObject.GetType().GetMethod(nameof(EventObject.InvokeStrings));
|
||||
mi = eventObject.GetType().GetMethod(nameof(PythonEventObject.InvokeStrings));
|
||||
}
|
||||
else
|
||||
throw new Exception();
|
||||
@@ -304,29 +287,24 @@ namespace mpvnet
|
||||
Delegate handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, eventObject, mi);
|
||||
eventObject.Delegate = handler;
|
||||
eventInfo.AddEventHandler(eventObject, handler);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void unregister_event(PyRT.PythonFunction pyFunc)
|
||||
{
|
||||
foreach (var eventObjects in EventObjects)
|
||||
foreach (var eventObjects in PythonEventObjects)
|
||||
if (eventObjects.PythonFunction == pyFunc)
|
||||
eventObjects.EventInfo.RemoveEventHandler(eventObjects, eventObjects.Delegate);
|
||||
}
|
||||
|
||||
public static void commandv(params string[] args)
|
||||
{
|
||||
Command(args);
|
||||
}
|
||||
|
||||
public static void Command(params string[] args)
|
||||
{
|
||||
if (MpvHandle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
IntPtr[] byteArrayPointers;
|
||||
var mainPtr = AllocateUtf8IntPtrArrayWithSentinel(args, out byteArrayPointers);
|
||||
IntPtr mainPtr = AllocateUtf8IntPtrArrayWithSentinel(args, out IntPtr[] byteArrayPointers);
|
||||
int err = mpv_command(MpvHandle, mainPtr);
|
||||
|
||||
if (err < 0)
|
||||
@@ -338,7 +316,7 @@ namespace mpvnet
|
||||
Marshal.FreeHGlobal(mainPtr);
|
||||
}
|
||||
|
||||
public static void CommandString(string command, bool throwException = true)
|
||||
public static void command_string(string command, bool throwException = false)
|
||||
{
|
||||
if (MpvHandle == IntPtr.Zero)
|
||||
return;
|
||||
@@ -349,21 +327,20 @@ namespace mpvnet
|
||||
throw new Exception($"{(mpv_error)err}\r\n\r\n" + command);
|
||||
}
|
||||
|
||||
public static void SetStringProp(string name, string value, bool throwException = true)
|
||||
public static void set_property_string(string name, string value, bool throwOnException = false)
|
||||
{
|
||||
var bytes = GetUtf8Bytes(value);
|
||||
byte[] bytes = GetUtf8Bytes(value);
|
||||
int err = mpv_set_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, ref bytes);
|
||||
|
||||
if (err < 0 && throwException)
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
}
|
||||
|
||||
public static string GetStringProp(string name)
|
||||
public static string get_property_string(string name, bool throwOnException = false)
|
||||
{
|
||||
var lpBuffer = IntPtr.Zero;
|
||||
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, ref lpBuffer);
|
||||
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, out IntPtr lpBuffer);
|
||||
|
||||
if (err < 0)
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
|
||||
var ret = StringFromNativeUtf8(lpBuffer);
|
||||
@@ -372,43 +349,47 @@ namespace mpvnet
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int GetIntProp(string name, bool throwException = true)
|
||||
public static int get_property_int(string name, bool throwOnException = false)
|
||||
{
|
||||
var lpBuffer = IntPtr.Zero;
|
||||
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref lpBuffer);
|
||||
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, out IntPtr lpBuffer);
|
||||
|
||||
if (err < 0 && throwException)
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
else
|
||||
return lpBuffer.ToInt32();
|
||||
}
|
||||
|
||||
public static double get_property_number(string name)
|
||||
{
|
||||
return GetDoubleProp(name);
|
||||
}
|
||||
|
||||
public static double GetDoubleProp(string name, bool throwException = true)
|
||||
public static double get_property_number(string name, bool throwOnException = false)
|
||||
{
|
||||
double val = 0;
|
||||
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_DOUBLE, ref val);
|
||||
|
||||
if (err < 0 && throwException)
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
public static void SetIntProp(string name, int value)
|
||||
public static bool get_property_bool(string name, bool throwOnException = false)
|
||||
{
|
||||
int err = mpv_get_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_FLAG, out IntPtr lpBuffer);
|
||||
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
else
|
||||
return lpBuffer.ToInt32() == 1;
|
||||
}
|
||||
|
||||
public static void set_property_int(string name, int value, bool throwOnException = false)
|
||||
{
|
||||
Int64 val = value;
|
||||
int err = mpv_set_property(MpvHandle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val);
|
||||
|
||||
if (err < 0)
|
||||
if (err < 0 && throwOnException)
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
}
|
||||
|
||||
public static void ObserveBoolProp(string name, Action<bool> action)
|
||||
public static void observe_property_bool(string name, Action<bool> action)
|
||||
{
|
||||
int err = mpv_observe_property(MpvHandle, (ulong)action.GetHashCode(), name, mpv_format.MPV_FORMAT_FLAG);
|
||||
|
||||
@@ -418,7 +399,7 @@ namespace mpvnet
|
||||
BoolPropChangeActions.Add(new KeyValuePair<string, Action<bool>>(name, action));
|
||||
}
|
||||
|
||||
public static void UnobserveBoolProp(string name, Action<bool> action)
|
||||
public static void unobserve_property_bool(string name, Action<bool> action)
|
||||
{
|
||||
foreach (var i in BoolPropChangeActions.ToArray())
|
||||
if (i.Value == action)
|
||||
@@ -430,15 +411,15 @@ namespace mpvnet
|
||||
throw new Exception($"{name}: {(mpv_error)err}");
|
||||
}
|
||||
|
||||
public static void ProcessCommandLine()
|
||||
protected static void ProcessCommandLine()
|
||||
{
|
||||
var args = Environment.GetCommandLineArgs().Skip(1);
|
||||
|
||||
foreach (string i in args)
|
||||
if (!i.StartsWith("--") && File.Exists(i))
|
||||
mp.Command("loadfile", i, "append");
|
||||
mp.commandv("loadfile", i, "append");
|
||||
|
||||
mp.SetStringProp("playlist-pos", "0", false);
|
||||
mp.set_property_string("playlist-pos", "0");
|
||||
|
||||
foreach (string i in args)
|
||||
{
|
||||
@@ -448,25 +429,25 @@ namespace mpvnet
|
||||
{
|
||||
string left = i.Substring(2, i.IndexOf("=") - 2);
|
||||
string right = i.Substring(left.Length + 3);
|
||||
mp.SetStringProp(left, right);
|
||||
mp.set_property_string(left, right);
|
||||
}
|
||||
else
|
||||
mp.SetStringProp(i.Substring(2), "yes");
|
||||
mp.set_property_string(i.Substring(2), "yes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadFiles(string[] files)
|
||||
{
|
||||
int count = mp.GetIntProp("playlist-count");
|
||||
int count = mp.get_property_int("playlist-count");
|
||||
|
||||
foreach (string file in files)
|
||||
mp.Command("loadfile", file, "append");
|
||||
mp.commandv("loadfile", file, "append");
|
||||
|
||||
mp.SetIntProp("playlist-pos", count);
|
||||
mp.set_property_int("playlist-pos", count);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
mp.Command("playlist-remove", "0");
|
||||
mp.commandv("playlist-remove", "0");
|
||||
|
||||
mp.LoadFolder();
|
||||
}
|
||||
@@ -478,21 +459,21 @@ namespace mpvnet
|
||||
if (WasFolderLoaded)
|
||||
return;
|
||||
|
||||
if (GetIntProp("playlist-count") == 1)
|
||||
if (get_property_int("playlist-count") == 1)
|
||||
{
|
||||
string[] types = "264 265 3gp aac ac3 avc avi avs bmp divx dts dtshd dtshr dtsma eac3 evo flac flv h264 h265 hevc hvc jpg jpeg m2t m2ts m2v m4a m4v mka mkv mlp mov mp2 mp3 mp4 mpa mpeg mpg mpv mts ogg ogm opus pcm png pva raw rmvb thd thd+ac3 true-hd truehd ts vdr vob vpy w64 wav webm wmv y4m".Split(' ');
|
||||
string path = GetStringProp("path");
|
||||
string path = get_property_string("path");
|
||||
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
|
||||
files = files.Where((file) => types.Contains(file.Ext())).ToList();
|
||||
files = files.Where((file) => types.Contains(Path.GetExtension(file).TrimStart(".".ToCharArray()).ToLower())).ToList();
|
||||
files.Sort(new StringLogicalComparer());
|
||||
int index = files.IndexOf(path);
|
||||
files.Remove(path);
|
||||
|
||||
foreach (string i in files)
|
||||
Command("loadfile", i, "append");
|
||||
commandv("loadfile", i, "append");
|
||||
|
||||
if (index > 0)
|
||||
Command("playlist-move", "0", (index + 1).ToString());
|
||||
commandv("playlist-move", "0", (index + 1).ToString());
|
||||
}
|
||||
|
||||
WasFolderLoaded = true;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -122,6 +123,9 @@
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.1.0\lib\net4\System.Management.Automation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
@@ -132,8 +136,13 @@
|
||||
<Compile Include="Menu.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PyScript.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="PowerShellScript.cs" />
|
||||
<Compile Include="PythonScript.cs" />
|
||||
<Compile Include="libmpv.cs" />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
@@ -155,15 +164,11 @@
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="app.manifest" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
@@ -173,6 +178,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Content Include="Resources\mpv.conf.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
@@ -180,7 +186,7 @@
|
||||
<ItemGroup>
|
||||
<Content Include="mpv.ico" />
|
||||
<Content Include="screenshot.jpg" />
|
||||
<None Include="Resources\input_conf.txt" />
|
||||
<Content Include="Resources\input.conf.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
4
mpv.net/packages.config
Normal file
4
mpv.net/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.PowerShell.5.ReferenceAssemblies" version="1.1.0" targetFramework="net472" />
|
||||
</packages>
|
||||
6
mpvSettingsEditor/App.config
Normal file
6
mpvSettingsEditor/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
30
mpvSettingsEditor/App.xaml
Normal file
30
mpvSettingsEditor/App.xaml
Normal file
@@ -0,0 +1,30 @@
|
||||
<Application x:Class="DynamicGUI.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:DynamicGUI"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
|
||||
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="#FF7EB4EA"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsFocused" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{x:Static SystemParameters.WindowGlassBrush}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
8
mpvSettingsEditor/App.xaml.cs
Normal file
8
mpvSettingsEditor/App.xaml.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace DynamicGUI
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
129
mpvSettingsEditor/Definitions.toml
Normal file
129
mpvSettingsEditor/Definitions.toml
Normal file
@@ -0,0 +1,129 @@
|
||||
[[settings]]
|
||||
name = "hwdec"
|
||||
default = "no"
|
||||
filter = "Video"
|
||||
helpurl = "https://mpv.io/manual/master/#options-hwdec"
|
||||
help = "hwdec=<mode> Specify the hardware video decoding API that should be used if possible. Whether hardware decoding is actually done depends on the video codec. If hardware decoding is not possible, mpv will fall back on software decoding."
|
||||
options = [{ name = "no", text = "no (Default)", help = "always use software decoding (Default)" },
|
||||
{ name = "auto", help = "enable best hw decoder (see below)" },
|
||||
{ name = "yes", help = "exactly the same as auto" },
|
||||
{ name = "auto-copy", help = "enable best hw decoder with copy-back (see below)" },
|
||||
{ name = "dxva2", help = "requires --vo=gpu with --gpu-context=d3d11, --gpu-context=angle or --gpu-context=dxinterop (Windows only)" },
|
||||
{ name = "dxva2-copy", help = "copies video back to system RAM (Windows only)" },
|
||||
{ name = "d3d11va", help = "requires --vo=gpu with --gpu-context=d3d11 or --gpu-context=angle (Windows 8+ only)" },
|
||||
{ name = "d3d11va-copy", help = "copies video back to system RAM (Windows 8+ only)" },
|
||||
{ name = "cuda", help = "requires --vo=gpu (Any platform CUDA is available)" },
|
||||
{ name = "cuda-copy", help = "copies video back to system RAM (Any platform CUDA is available)" },
|
||||
{ name = "nvdec", help = "requires --vo=gpu (Any platform CUDA is available)" },
|
||||
{ name = "nvdec-copy", help = "copies video back to system RAM (Any platform CUDA is available)" },
|
||||
{ name = "crystalhd", help = "copies video back to system RAM (Any platform supported by hardware)" },
|
||||
{ name = "rkmpp", help = "requires --vo=gpu (some RockChip devices only)" }]
|
||||
|
||||
[[settings]]
|
||||
name = "vo"
|
||||
default = "gpu"
|
||||
filter = "Video"
|
||||
helpurl = "https://mpv.io/manual/master/#video-output-drivers-vo"
|
||||
help = "gpu=<mode> Video output drivers to be used. Default = gpu."
|
||||
options = [{ name = "gpu", text = "gpu (Default)", help = "General purpose, customizable, GPU-accelerated video output driver. It supports extended scaling methods, dithering, color management, custom shaders, HDR, and more. (Default)" },
|
||||
{ name = "direct3d", help = "Video output driver that uses the Direct3D interface" }]
|
||||
|
||||
[[settings]]
|
||||
name = "volume"
|
||||
default = ""
|
||||
filter = "Audio"
|
||||
help = "volume=<integer> Set the startup volume. 0 means silence, 100 means no volume reduction or amplification. Negative values can be passed for compatibility, but are treated as 0. Since mpv 0.18.1, this always controls the internal mixer (aka \"softvol\")."
|
||||
|
||||
[[settings]]
|
||||
name = "slang"
|
||||
default = ""
|
||||
filter = "Subtitles"
|
||||
help = "--slang=<languagecode[,languagecode,...]> Specify a priority list of subtitle languages to use. Different container formats employ different language codes. DVDs use ISO 639-1 two letter language codes, Matroska uses ISO 639-2 three letter language codes while OGM uses a free-form identifier. See also --sid."
|
||||
|
||||
[[settings]]
|
||||
name = "screen"
|
||||
default = ""
|
||||
filter = "Screen"
|
||||
help = "screen=<default|0-32> In multi-monitor configurations (i.e. a single desktop that spans across multiple displays), this option tells mpv which screen to display the video on. Default: default."
|
||||
|
||||
[[settings]]
|
||||
name = "osd-playing-msg"
|
||||
default = ""
|
||||
width = 300
|
||||
filter = "Screen"
|
||||
helpurl = "https://mpv.io/manual/master/#property-expansion"
|
||||
help = "osd-playing-msg=<value> Show a message on OSD when playback starts. The string is expanded for properties, e.g. --osd-playing-msg='file: ${filename}' will show the message file: followed by a space and the currently played filename."
|
||||
|
||||
[[settings]]
|
||||
name = "fullscreen"
|
||||
alias = "fs"
|
||||
default = "no"
|
||||
filter = "Screen"
|
||||
help = "fullscreen=<yes|no>, fs=<yes|no> Start the player in fullscreen mode. Default: no."
|
||||
options = [{ name = "yes" }, { name = "no", text = "no (Default)" }]
|
||||
|
||||
[[settings]]
|
||||
name = "keep-open-pause"
|
||||
default = "yes"
|
||||
filter = "Playback"
|
||||
help = "keep-open-pause=<yes|no> If set to no, instead of pausing when --keep-open is active, just stop at end of file and continue playing forward when you seek backwards until end where it stops again. Default: yes."
|
||||
options = [{ name = "yes", text = "yes (Default)" }, { name = "no" }]
|
||||
|
||||
[[settings]]
|
||||
name = "keep-open"
|
||||
default = "no"
|
||||
filter = "Playback"
|
||||
help = "keep-open=<yes|no|always> Do not terminate when playing or seeking beyond the end of the file, and there is not next file to be played (and --loop is not used). Instead, pause the player. When trying to seek beyond end of the file, the player will attempt to seek to the last frame.\n\nNormally, this will act like set pause yes on EOF, unless the --keep-open-pause=no option is set."
|
||||
options = [{ name = "yes", help = "Don't terminate if the current file is the last playlist entry. Equivalent to --keep-open without arguments."},
|
||||
{ name = "no", text = "no (Default)", help = "If the current file ends, go to the next file or terminate. (Default.)" },
|
||||
{ name = "always", help = "Like yes, but also applies to files before the last playlist entry. This means playback will never automatically advance to the next file."}]
|
||||
|
||||
[[settings]]
|
||||
name = "loop-file"
|
||||
alias = "loop"
|
||||
default = ""
|
||||
filter = "Playback"
|
||||
help = "loop-file=<N|inf|no>, loop=<N|inf|no> Loop a single file N times. inf means forever, no means normal playback. For compatibility, --loop-file and --loop-file=yes are also accepted, and are the same as --loop-file=inf.\n\nThe difference to --loop-playlist is that this doesn't loop the playlist, just the file itself. If the playlist contains only a single file, the difference between the two option is that this option performs a seek on loop, instead of reloading the file.\n\n--loop is an alias for this option."
|
||||
|
||||
[[settings]]
|
||||
name = "save-position-on-quit"
|
||||
default = "no"
|
||||
filter = "Playback"
|
||||
help = "Always save the current playback position on quit. When this file is played again later, the player will seek to the old playback position on start. This does not happen if playback of a file is stopped in any other way than quitting. For example, going to the next file in the playlist will not save the position, and start playback at beginning the next time the file is played.\n\nThis behavior is disabled by default, but is always available when quitting the player with Shift+Q."
|
||||
options = [{ name = "yes" }, { name = "no", text = "no (Default)" }]
|
||||
|
||||
[[settings]]
|
||||
name = "screenshot-directory"
|
||||
default = ""
|
||||
width = 500
|
||||
folder = true
|
||||
filter = "Screen"
|
||||
help = "screenshot-directory=<value> Store screenshots in this directory. This path is joined with the filename generated by --screenshot-template. If the template filename is already absolute, the directory is ignored.\n\nIf the directory does not exist, it is created on the first screenshot. If it is not a directory, an error is generated when trying to write a screenshot.\n\nThis option is not set by default, and thus will write screenshots to the directory from which mpv was started. In pseudo-gui mode (see PSEUDO GUI MODE), this is set to the desktop."
|
||||
|
||||
[[settings]]
|
||||
name = "input-ar-delay"
|
||||
default = ""
|
||||
filter = "Input"
|
||||
help = "input-ar-delay=<integer> Delay in milliseconds before we start to autorepeat a key (0 to disable)."
|
||||
|
||||
[[settings]]
|
||||
name = "input-ar-rate"
|
||||
default = ""
|
||||
filter = "Input"
|
||||
help = "input-ar-rate=<integer> Number of key presses to generate per second on autorepeat."
|
||||
|
||||
[[settings]]
|
||||
name = "alang"
|
||||
default = ""
|
||||
filter = "Audio"
|
||||
help = "alang=<languagecode[,languagecode,...]> Specify a priority list of audio languages to use. Different container formats employ different language codes. DVDs use ISO 639-1 two-letter language codes, Matroska, MPEG-TS and NUT use ISO 639-2 three-letter language codes, while OGM uses a free-form identifier. See also --aid.\n\nExamples\n\nmpv dvd://1 --alang=hu,en chooses the Hungarian language track on a DVD and falls back on English if Hungarian is not available.\n\nmpv --alang=jpn example.mkv plays a Matroska file with Japanese audio."
|
||||
|
||||
[[settings]]
|
||||
name = "hr-seek"
|
||||
default = "absolute"
|
||||
filter = "Playback"
|
||||
help = "hr-seek=<no|absolute|yes> Select when to use precise seeks that are not limited to keyframes. Such seeks require decoding video from the previous keyframe up to the target position and so can take some time depending on decoding performance. For some video formats, precise seeks are disabled. This option selects the default choice to use for seeks; it is possible to explicitly override that default in the definition of key bindings and in input commands."
|
||||
options = [{ name = "yes", help = "Use precise seeks whenever possible." },
|
||||
{ name = "no", help = "Never use precise seeks." },
|
||||
{ name = "absolute", text = "absolute (Default)", help = "Use precise seeks if the seek is to an absolute position in the file, such as a chapter seek, but not for relative seeks like the default behavior of arrow keys (default)." },
|
||||
{ name = "always", help = "Same as yes (for compatibility)." }]
|
||||
24
mpvSettingsEditor/DynamicGUI/Controls.cs
Normal file
24
mpvSettingsEditor/DynamicGUI/Controls.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Navigation;
|
||||
|
||||
namespace DynamicGUI
|
||||
{
|
||||
public class HyperlinkEx : Hyperlink
|
||||
{
|
||||
private void HyperLinkEx_RequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(e.Uri.AbsoluteUri);
|
||||
}
|
||||
|
||||
public void SetURL(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return;
|
||||
NavigateUri = new Uri(url);
|
||||
RequestNavigate += HyperLinkEx_RequestNavigate;
|
||||
Inlines.Clear();
|
||||
Inlines.Add(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
108
mpvSettingsEditor/DynamicGUI/DynamicGUI.cs
Normal file
108
mpvSettingsEditor/DynamicGUI/DynamicGUI.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Tommy;
|
||||
|
||||
namespace DynamicGUI
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
public static List<SettingBase> LoadSettings(string filepath)
|
||||
{
|
||||
TomlTable table;
|
||||
using (StreamReader reader = new StreamReader(File.OpenRead(filepath)))
|
||||
table = TOML.Parse(reader);
|
||||
List<SettingBase> settingsList = new List<SettingBase>();
|
||||
|
||||
foreach (TomlTable setting in table["settings"])
|
||||
{
|
||||
SettingBase baseSetting = null;
|
||||
|
||||
if (setting.HasKey("options"))
|
||||
{
|
||||
OptionSetting optionSetting = new OptionSetting();
|
||||
baseSetting = optionSetting;
|
||||
optionSetting.Default = setting["default"];
|
||||
optionSetting.Value = optionSetting.Default;
|
||||
|
||||
foreach (TomlTable option in setting["options"])
|
||||
{
|
||||
var opt = new OptionSettingOption();
|
||||
opt.Name = option["name"];
|
||||
if (option.HasKey("help"))
|
||||
opt.Help = option["help"];
|
||||
if (option.HasKey("text"))
|
||||
opt.Text = option["text"];
|
||||
opt.OptionSetting = optionSetting;
|
||||
optionSetting.Options.Add(opt);
|
||||
}
|
||||
}
|
||||
else if (setting["default"].IsString)
|
||||
{
|
||||
StringSetting stringSetting = new StringSetting();
|
||||
baseSetting = stringSetting;
|
||||
stringSetting.Default = setting["default"];
|
||||
if (setting.HasKey("folder")) stringSetting.IsFolder = true;
|
||||
}
|
||||
|
||||
baseSetting.Name = setting["name"];
|
||||
baseSetting.Filter = setting["filter"];
|
||||
if (setting.HasKey("help")) baseSetting.Help = setting["help"];
|
||||
if (setting.HasKey("helpurl")) baseSetting.HelpURL = setting["helpurl"];
|
||||
if (setting.HasKey("alias")) baseSetting.Alias = setting["alias"];
|
||||
if (setting.HasKey("width")) baseSetting.Width = setting["width"];
|
||||
settingsList.Add(baseSetting);
|
||||
}
|
||||
return settingsList;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class SettingBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Alias { get; set; }
|
||||
public string Help { get; set; }
|
||||
public string HelpURL { get; set; }
|
||||
public string Filter { get; set; }
|
||||
public int Width { get; set; }
|
||||
}
|
||||
|
||||
public class StringSetting : SettingBase
|
||||
{
|
||||
public string Default { get; set; }
|
||||
public string Value { get; set; }
|
||||
public bool IsFolder { get; set; }
|
||||
}
|
||||
|
||||
public class OptionSetting : SettingBase
|
||||
{
|
||||
public string Default { get; set; }
|
||||
public string Value { get; set; }
|
||||
public List<OptionSettingOption> Options = new List<OptionSettingOption>();
|
||||
}
|
||||
|
||||
public class OptionSettingOption
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Help { get; set; }
|
||||
|
||||
public OptionSetting OptionSetting { get; set; }
|
||||
|
||||
private string _Text;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => string.IsNullOrEmpty(_Text) ? Name : _Text;
|
||||
set => _Text = value;
|
||||
}
|
||||
|
||||
public bool IsChecked
|
||||
{
|
||||
get => OptionSetting.Value == Name ;
|
||||
set {
|
||||
if (value)
|
||||
OptionSetting.Value = Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
mpvSettingsEditor/DynamicGUI/Misc.cs
Normal file
8
mpvSettingsEditor/DynamicGUI/Misc.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace DynamicGUI
|
||||
{
|
||||
interface ISettingControl
|
||||
{
|
||||
bool Contains(string searchString);
|
||||
SettingBase SettingBase { get; }
|
||||
}
|
||||
}
|
||||
28
mpvSettingsEditor/DynamicGUI/OptionSettingControl.xaml
Normal file
28
mpvSettingsEditor/DynamicGUI/OptionSettingControl.xaml
Normal file
@@ -0,0 +1,28 @@
|
||||
<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="{x:Static SystemParameters.WindowGlassBrush}"></TextBox>
|
||||
<ItemsControl x:Name="ItemsControl">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<WrapPanel Orientation="Vertical">
|
||||
<RadioButton x:Name="RadioButton" VerticalContentAlignment="Center" IsChecked="{Binding IsChecked}" GroupName="{Binding OptionSetting.Name}" Content="{Binding Text}" FontSize="16" FontWeight="Normal" VerticalAlignment="Top"></RadioButton>
|
||||
<TextBox x:Name="ItemHelpTextBox" TextWrapping="WrapWithOverflow" Text="{Binding Help}" Margin="10,0,0,0" BorderThickness="0" IsReadOnly="True" Padding="7,0,0,0" MinHeight="0"></TextBox>
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<TextBox x:Name="HelpTextBox" TextWrapping="WrapWithOverflow" BorderThickness="0" IsReadOnly="True" Margin="0,10,0,0"></TextBox>
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
41
mpvSettingsEditor/DynamicGUI/OptionSettingControl.xaml.cs
Normal file
41
mpvSettingsEditor/DynamicGUI/OptionSettingControl.xaml.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DynamicGUI
|
||||
{
|
||||
public partial class OptionSettingControl : UserControl, ISettingControl
|
||||
{
|
||||
private OptionSetting OptionSetting;
|
||||
|
||||
public OptionSettingControl(OptionSetting optionSetting)
|
||||
{
|
||||
OptionSetting = optionSetting;
|
||||
InitializeComponent();
|
||||
TitleTextBox.Text = optionSetting.Name;
|
||||
HelpTextBox.Text = optionSetting.Help;
|
||||
ItemsControl.ItemsSource = optionSetting.Options;
|
||||
Link.SetURL(optionSetting.HelpURL);
|
||||
|
||||
if (string.IsNullOrEmpty(optionSetting.HelpURL))
|
||||
LinkTextBlock.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private string _SearchableText;
|
||||
|
||||
public string SearchableText {
|
||||
get {
|
||||
if (_SearchableText is null)
|
||||
{
|
||||
_SearchableText = TitleTextBox.Text + HelpTextBox.Text;
|
||||
foreach (var i in OptionSetting.Options)
|
||||
_SearchableText += i.Text + i.Help + i.Name;
|
||||
_SearchableText = _SearchableText.ToLower();
|
||||
}
|
||||
return _SearchableText;
|
||||
}
|
||||
}
|
||||
|
||||
public SettingBase SettingBase => OptionSetting;
|
||||
public bool Contains(string searchString) => SearchableText.Contains(searchString.ToLower());
|
||||
}
|
||||
}
|
||||
27
mpvSettingsEditor/DynamicGUI/StringSettingControl.xaml
Normal file
27
mpvSettingsEditor/DynamicGUI/StringSettingControl.xaml
Normal file
@@ -0,0 +1,27 @@
|
||||
<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="{x:Static SystemParameters.WindowGlassBrush}"></TextBox>
|
||||
<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" HorizontalAlignment="Left" Height="20"/>
|
||||
<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" Margin="0,0,0,10" BorderThickness="0" IsReadOnly="True"></TextBox>
|
||||
<TextBlock x:Name="LinkTextBlock" Margin="0,10">
|
||||
<local:HyperlinkEx x:Name="Link"></local:HyperlinkEx>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
58
mpvSettingsEditor/DynamicGUI/StringSettingControl.xaml.cs
Normal file
58
mpvSettingsEditor/DynamicGUI/StringSettingControl.xaml.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DynamicGUI
|
||||
{
|
||||
public partial class StringSettingControl : UserControl, ISettingControl
|
||||
{
|
||||
private StringSetting StringSetting;
|
||||
|
||||
public StringSettingControl(StringSetting stringSetting)
|
||||
{
|
||||
StringSetting = stringSetting;
|
||||
InitializeComponent();
|
||||
TitleTextBox.Text = stringSetting.Name;
|
||||
HelpTextBox.Text = stringSetting.Help;
|
||||
ValueTextBox.Text = stringSetting.Value;
|
||||
if (stringSetting.Width > 0)
|
||||
ValueTextBox.Width = stringSetting.Width;
|
||||
if (!StringSetting.IsFolder)
|
||||
Button.Visibility = Visibility.Hidden;
|
||||
Link.SetURL(StringSetting.HelpURL);
|
||||
|
||||
if (string.IsNullOrEmpty(stringSetting.HelpURL))
|
||||
LinkTextBlock.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private string _SearchableText;
|
||||
|
||||
public string SearchableText {
|
||||
get {
|
||||
if (_SearchableText is null)
|
||||
_SearchableText = (TitleTextBox.Text + HelpTextBox.Text +ValueTextBox.Text).ToLower();
|
||||
|
||||
return _SearchableText;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains(string searchString) => SearchableText.Contains(searchString.ToLower());
|
||||
public SettingBase SettingBase => StringSetting;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => StringSetting.Value;
|
||||
set => StringSetting.Value = value;
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
using (var d = new System.Windows.Forms.FolderBrowserDialog())
|
||||
{
|
||||
d.Description = "Choose a folder.";
|
||||
d.SelectedPath = ValueTextBox.Text;
|
||||
if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
ValueTextBox.Text = d.SelectedPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1824
mpvSettingsEditor/DynamicGUI/Tommy.cs
Normal file
1824
mpvSettingsEditor/DynamicGUI/Tommy.cs
Normal file
File diff suppressed because it is too large
Load Diff
39
mpvSettingsEditor/MainWindow.xaml
Normal file
39
mpvSettingsEditor/MainWindow.xaml
Normal file
@@ -0,0 +1,39 @@
|
||||
<Window x:Name="MainWindow1" x:Class="mpvSettingsEditor.MainWindow"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
Height="500" Width="700" Loaded="MainWindow1_Loaded">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="4*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="10*" />
|
||||
<ColumnDefinition Width="60*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid x:Name="SearchGrid" Background="White" Width="300" Margin="0,0,0,10" Grid.ColumnSpan="2">
|
||||
<TextBlock x:Name="SearchTextBlock" Margin="5,2" Text="Find a setting" Foreground="LightSteelBlue" VerticalAlignment="Center" />
|
||||
<TextBox Name="SearchTextBox" Padding="1,2,0,0" BorderThickness="2" Background="Transparent" TextChanged="SearchTextBox_TextChanged" Height="25" />
|
||||
<Button x:Name="SearchClearButton" Background="Transparent" HorizontalAlignment="Right" Margin="2,0,4,0" FontSize="6" Width="16" Height="16" Visibility="Hidden" Click="SearchClearButton_Click">╳</Button>
|
||||
</Grid>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1" Grid.Column="1">
|
||||
<StackPanel x:Name="MainStackPanel"></StackPanel>
|
||||
</ScrollViewer>
|
||||
<StackPanel Margin="20,0,0,0" Grid.Row="1">
|
||||
<ListBox x:Name="FilterListBox" ItemsSource="{Binding FilterStrings}" BorderThickness="0" SelectionChanged="ListBox_SelectionChanged" Foreground="{x:Static SystemParameters.WindowGlassBrush}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding}" FontSize="16" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<TextBlock x:Name="OpenSettingsTextBlock" Margin="0,30,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static SystemParameters.WindowGlassBrush}" MouseUp="OpenSettingsTextBlock_MouseUp">Open settings folder</TextBlock>
|
||||
<TextBlock x:Name="ShowManualTextBlock" Margin="0,15,0,0" Cursor="Hand" TextWrapping="WrapWithOverflow" Foreground="{x:Static SystemParameters.WindowGlassBrush}" MouseUp="ShowManualTextBlock_MouseUp">Show mpv manual</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
218
mpvSettingsEditor/MainWindow.xaml.cs
Normal file
218
mpvSettingsEditor/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,218 @@
|
||||
using DynamicGUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mpvSettingsEditor
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public string mpvConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\mpv.conf";
|
||||
private List<SettingBase> DynamicSettings = Settings.LoadSettings(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Definitions.toml");
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
Title = (Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), true)[0] as AssemblyProductAttribute).Product + " " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
|
||||
foreach (var setting in DynamicSettings)
|
||||
{
|
||||
if (!FilterStrings.Contains(setting.Filter))
|
||||
FilterStrings.Add(setting.Filter);
|
||||
foreach (var pair in mpvConf)
|
||||
{
|
||||
if (setting.Name == pair.Key || setting.Alias == pair.Key)
|
||||
switch (setting)
|
||||
{
|
||||
case StringSetting s:
|
||||
s.Value = pair.Value;
|
||||
continue;
|
||||
case OptionSetting s:
|
||||
s.Value = pair.Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (setting)
|
||||
{
|
||||
case StringSetting s:
|
||||
MainStackPanel.Children.Add(new StringSettingControl(s));
|
||||
break;
|
||||
case OptionSetting s:
|
||||
MainStackPanel.Children.Add(new OptionSettingControl(s));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, string> _mpvConf;
|
||||
|
||||
public Dictionary<string, string> mpvConf {
|
||||
get {
|
||||
if (_mpvConf == null)
|
||||
{
|
||||
_mpvConf = new Dictionary<string, string>();
|
||||
|
||||
if (File.Exists(mpvConfPath))
|
||||
foreach (var i in File.ReadAllLines(mpvConfPath))
|
||||
if (i.Contains("=") && !i.Trim().StartsWith("#"))
|
||||
{
|
||||
int pos = i.IndexOf("=");
|
||||
_mpvConf[i.Substring(0, pos).Trim()] = i.Substring(pos + 1).Trim();
|
||||
}
|
||||
}
|
||||
return _mpvConf;
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<string> FilterStrings { get; } = new ObservableCollection<string>();
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
|
||||
foreach (var mpvSetting in DynamicSettings)
|
||||
{
|
||||
switch (mpvSetting)
|
||||
{
|
||||
case StringSetting s:
|
||||
if ((s.Value ?? "") != s.Default)
|
||||
mpvConf[s.Name] = s.Value;
|
||||
else
|
||||
mpvConf.Remove(s.Name);
|
||||
break;
|
||||
case OptionSetting s:
|
||||
if ((s.Value ?? "") != s.Default)
|
||||
mpvConf[s.Name] = s.Value;
|
||||
else
|
||||
mpvConf.Remove(s.Name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!File.Exists(mpvConfPath))
|
||||
File.WriteAllText(mpvConfPath, "");
|
||||
|
||||
List<string> lines = File.ReadAllLines(mpvConfPath).ToList();
|
||||
|
||||
foreach (var mpvSetting in DynamicSettings)
|
||||
{
|
||||
foreach (var line in lines.ToArray())
|
||||
{
|
||||
string test = line.Replace("#", "").Replace(" ", "");
|
||||
if (test.StartsWith(mpvSetting.Alias + "="))
|
||||
{
|
||||
lines.Remove(line);
|
||||
foreach (var pair in mpvConf.ToArray())
|
||||
if (test.StartsWith(pair.Key + "="))
|
||||
mpvConf.Remove(pair.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var pair in mpvConf)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
for (int i = 0; i < lines.Count; i++)
|
||||
{
|
||||
if (lines[i].Contains("=") &&
|
||||
lines[i].Substring(0, lines[i].IndexOf("=")).Trim("# ".ToCharArray()) == pair.Key)
|
||||
{
|
||||
lines[i] = pair.Key + " = " + pair.Value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!changed)
|
||||
lines.Add(pair.Key + " = " + pair.Value);
|
||||
}
|
||||
|
||||
foreach (var mpvSetting in DynamicSettings)
|
||||
{
|
||||
foreach (var line in lines.ToArray())
|
||||
{
|
||||
string test = line.Replace("#", "").Replace(" ", "");
|
||||
|
||||
if (test.StartsWith(mpvSetting.Name + "=") && !mpvConf.ContainsKey(mpvSetting.Name))
|
||||
lines.Remove(line);
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(mpvConfPath, String.Join(Environment.NewLine, lines));
|
||||
|
||||
foreach (Process process in Process.GetProcesses())
|
||||
if (process.ProcessName == "mpv.net")
|
||||
MessageBox.Show("Restart mpv.net in order to apply changed settings.", Title, MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
else if (process.ProcessName == "mpv")
|
||||
MessageBox.Show("Restart mpv in order to apply changed settings.", Title, MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
SearchTextBlock.Text = SearchTextBox.Text == "" ? "Find a setting" : "";
|
||||
|
||||
if (SearchTextBox.Text == "")
|
||||
SearchClearButton.Visibility = Visibility.Hidden;
|
||||
else
|
||||
SearchClearButton.Visibility = Visibility.Visible;
|
||||
|
||||
string activeFilter = "";
|
||||
|
||||
foreach (var i in FilterStrings)
|
||||
if (SearchTextBox.Text == i + ":")
|
||||
activeFilter = i;
|
||||
|
||||
if (activeFilter == "")
|
||||
{
|
||||
foreach (UIElement i in MainStackPanel.Children)
|
||||
if ((i as ISettingControl).Contains(SearchTextBox.Text))
|
||||
i.Visibility = Visibility.Visible;
|
||||
else
|
||||
i.Visibility = Visibility.Collapsed;
|
||||
|
||||
FilterListBox.SelectedItem = null;
|
||||
}
|
||||
else
|
||||
foreach (UIElement i in MainStackPanel.Children)
|
||||
if ((i as ISettingControl).SettingBase.Filter == activeFilter)
|
||||
i.Visibility = Visibility.Visible;
|
||||
else
|
||||
i.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void MainWindow1_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Keyboard.Focus(SearchTextBox);
|
||||
}
|
||||
|
||||
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.AddedItems.Count > 0)
|
||||
SearchTextBox.Text = e.AddedItems[0].ToString() + ":";
|
||||
}
|
||||
|
||||
private void SearchClearButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SearchTextBox.Text = "";
|
||||
Keyboard.Focus(SearchTextBox);
|
||||
}
|
||||
|
||||
private void OpenSettingsTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Process.Start(Path.GetDirectoryName(mpvConfPath));
|
||||
}
|
||||
|
||||
private void ShowManualTextBlock_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Process.Start("https://mpv.io/manual/master/");
|
||||
}
|
||||
}
|
||||
}
|
||||
55
mpvSettingsEditor/Properties/AssemblyInfo.cs
Normal file
55
mpvSettingsEditor/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// 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("mpv(.net) settings editor")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("mpv(.net) settings editor")]
|
||||
[assembly: AssemblyCopyright("Copyright © 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)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// 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")]
|
||||
63
mpvSettingsEditor/Properties/Resources.Designer.cs
generated
Normal file
63
mpvSettingsEditor/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DynamicGUI.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mpvSettingsEditor.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
mpvSettingsEditor/Properties/Resources.resx
Normal file
117
mpvSettingsEditor/Properties/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
26
mpvSettingsEditor/Properties/Settings.Designer.cs
generated
Normal file
26
mpvSettingsEditor/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DynamicGUI.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
mpvSettingsEditor/Properties/Settings.settings
Normal file
7
mpvSettingsEditor/Properties/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
BIN
mpvSettingsEditor/mpv.ico
Normal file
BIN
mpvSettingsEditor/mpv.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 264 KiB |
135
mpvSettingsEditor/mpvSettingsEditor.csproj
Normal file
135
mpvSettingsEditor/mpvSettingsEditor.csproj
Normal file
@@ -0,0 +1,135 @@
|
||||
<?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>{C4FEAA45-001D-4DC8-8BFA-621527326D09}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>mpvSettingsEditor</RootNamespace>
|
||||
<AssemblyName>mpvSettingsEditor</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NullableReferenceTypes>true</NullableReferenceTypes>
|
||||
<NullableContextOptions>enable</NullableContextOptions>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>mpv.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="DynamicGUI\Controls.cs" />
|
||||
<Compile Include="DynamicGUI\DynamicGUI.cs" />
|
||||
<Compile Include="DynamicGUI\OptionSettingControl.xaml.cs">
|
||||
<DependentUpon>OptionSettingControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DynamicGUI\StringSettingControl.xaml.cs">
|
||||
<DependentUpon>StringSettingControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DynamicGUI\Tommy.cs" />
|
||||
<Page Include="DynamicGUI\OptionSettingControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="DynamicGUI\StringSettingControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DynamicGUI\Misc.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Definitions.toml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="mpv.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
25
mpvSettingsEditor/mpvSettingsEditor.sln
Normal file
25
mpvSettingsEditor/mpvSettingsEditor.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.28714.193
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mpvSettingsEditor", "mpvSettingsEditor.csproj", "{C4FEAA45-001D-4DC8-8BFA-621527326D09}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C4FEAA45-001D-4DC8-8BFA-621527326D09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C4FEAA45-001D-4DC8-8BFA-621527326D09}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C4FEAA45-001D-4DC8-8BFA-621527326D09}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C4FEAA45-001D-4DC8-8BFA-621527326D09}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {959F2890-E1FC-47A2-856C-A42F8C955D15}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -3,10 +3,10 @@ $exePath = $scriptDir + "\mpv.net\bin\Debug\mpvnet.exe"
|
||||
$version = [Diagnostics.FileVersionInfo]::GetVersionInfo($exePath).FileVersion
|
||||
$desktopDir = [Environment]::GetFolderPath("Desktop")
|
||||
$targetDir = $desktopDir + "\mpv.net-" + $version
|
||||
if (Test-Path $targetDir) { rd $targetDir -recurse }
|
||||
Copy-Item $scriptDir\mpv.net\bin\Debug $targetDir -recurse
|
||||
$addonDir = $targetDir + "\Addons"
|
||||
Remove-Item $addonDir -Recurse -Include *mpvnet.exe, *mpvnet.exe.config, *mpvnet.pdb
|
||||
Copy-Item C:\Users\frank\Daten\Projekte\CS\mpv.net\mpvSettingsEditor\bin\mpvSettingsEditor.exe "C:\Users\frank\Daten\Projekte\CS\mpv.net\mpv.net\bin\Debug\mpvSettingsEditor.exe" -Force
|
||||
Copy-Item C:\Users\frank\Daten\Projekte\CS\mpv.net\mpvSettingsEditor\bin\Definitions.toml "C:\Users\frank\Daten\Projekte\CS\mpv.net\mpv.net\bin\Debug\Definitions.toml" -Force
|
||||
Copy-Item $scriptDir\mpv.net\bin\Debug $targetDir -Recurse -Exclude System.Management.Automation.xml -Force
|
||||
Copy-Item $scriptDir\README.md $targetDir\README.md -Force
|
||||
$7zPath = "C:\Program Files\7-Zip\7z.exe"
|
||||
$args = "a -t7z -mx9 $targetDir.7z -r $targetDir\*"
|
||||
Start-Process -FilePath $7zPath -ArgumentList $args
|
||||
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 130 KiB |
Reference in New Issue
Block a user