This commit is contained in:
Frank Skare
2019-08-01 04:45:11 +02:00
parent a572bd8553
commit d90025e8fe
14 changed files with 184 additions and 125 deletions

View File

@@ -13,9 +13,30 @@
- 'Tools > Manage File Associations' was replaced by 'Tools > OS Setup', - 'Tools > Manage File Associations' was replaced by 'Tools > OS Setup',
it has now a feature to add and remove mpv.net to and from the Path it has now a feature to add and remove mpv.net to and from the Path
environment variable and the OS default apps settings can be opened (Win 10 only) environment variable and the OS default apps settings can be opened (Win 10 only)
- startup folder and config folder beeing identical is no longer a supported scenaria - startup folder and config folder beeing identical was causing a critical issue
as mpv.net was loading extensions twice and scripts four times, now identical
folders are no longer permitted
- error messages are shown when unknown scripts and extensions are found in the startup folder - error messages are shown when unknown scripts and extensions are found in the startup folder
because user scripts and extensions are supposed to be located in the config folder instead because user scripts and extensions are supposed to be located in the config folder instead
- changing from maximized to fullscreen did not work
- the search field in the config editor was not always remembered
- new setting remember-volume added, saves volume and mute on exit
and restores it on start.
- it's now enforced that mpv properties on the command line and in
the mpv.conf config file are lowercase, if not a error is shown
- gpu-api vulkan was not working if media files were opened via
command line (that included Explorer), Vulkan unlike d3d11 and opengl
requires a window being visible, this is now satisfied with a
workaround, it's only possible showing a window with default size
first as defines by autofit. Vulkan has few issues, usually the auto option
which uses d3d11 is better! Using Vulkan the mpv.net setting
- new setting minimum-aspect-ratio added, minimum aspect ratio for the window,
this was previously hard coded to 1.3
- new setting auto-load-folder added, for single files automatically load
the entire directory into the playlist, previously this was forced,
now it can be disabled
- new setting themed-menu added, follow theme color in context menu,
default: no, UI related settings have now a separate UI tab in the config editor
### 5.0 ### 5.0
@@ -98,10 +119,6 @@
the task bar because this is the WinForms default behavier. This the task bar because this is the WinForms default behavier. This
was fixed by calling Spy++ to the rescue and adding WS_MINIMIZEBOX was fixed by calling Spy++ to the rescue and adding WS_MINIMIZEBOX
in CreateParams in CreateParams
- changing from maximized to fullscreen did not work
- the search field in the config editor was not always remembered
- new setting remember-volume added, saves volume and mute on exit
and restores it on start.
### 4.6 ### 4.6

View File

@@ -8,6 +8,12 @@ namespace mpvnet
{ {
public class App public class App
{ {
public static string[] VideoTypes { get; } = "264 265 asf avc avi avs flv h264 h265 hevc m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm webm wmv y4m".Split(' ');
public static string[] AudioTypes { get; } = "mp3 mp2 ac3 ogg opus flac wav w64 m4a dts dtsma dtshr dtshd eac3 thd thd+ac3 mka aac mpa".Split(' ');
public static string[] ImageTypes { get; } = {"jpg", "bmp", "gif", "png"};
public static string[] SubtitleTypes { get; } = { "srt", "ass", "idx", "sup", "ttxt", "ssa", "smi" };
public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" };
public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName; public static string RegPath { get; } = @"HKCU\Software\" + Application.ProductName;
public static string ConfPath { get; } = mp.ConfigFolder + "\\mpvnet.conf"; public static string ConfPath { get; } = mp.ConfigFolder + "\\mpvnet.conf";
public static string DarkMode { get; set; } = "always"; public static string DarkMode { get; set; } = "always";
@@ -15,20 +21,18 @@ namespace mpvnet
public static string DarkColor { get; set; } public static string DarkColor { get; set; }
public static string LightColor { get; set; } public static string LightColor { get; set; }
public static string[] VideoTypes { get; } = "264 265 asf avc avi avs flv h264 h265 hevc m2ts m2v m4v mkv mov mp4 mpeg mpg mpv mts ts vob vpy webm webm wmv y4m".Split(' ');
public static string[] AudioTypes { get; } = "mp3 mp2 ac3 ogg opus flac wav w64 m4a dts dtsma dtshr dtshd eac3 thd thd+ac3 mka aac mpa".Split(' ');
public static string[] ImageTypes { get; } = "jpg bmp gif png".Split(' ');
public static string[] SubtitleTypes { get; } = "srt ass idx sup ttxt ssa smi".Split(' ');
public static string[] UrlWhitelist { get; set; } = { "tube", "vimeo", "ard", "zdf" };
public static bool RememberHeight { get; set; } = true; public static bool RememberHeight { get; set; } = true;
public static bool RememberPosition { get; set; } public static bool RememberPosition { get; set; }
public static bool DebugMode { get; set; } public static bool DebugMode { get; set; }
public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes"; public static bool IsStartedFromTerminal { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
public static bool RememberVolume { get; set; } public static bool RememberVolume { get; set; }
public static bool AutoLoadFolder { get; set; } = true;
public static bool ThemedMenu { get; set; }
public static int StartThreshold { get; set; } = 1500; public static int StartThreshold { get; set; } = 1500;
public static float MinimumAspectRatio { get; set; } = 1.3f;
public static bool IsDarkMode { public static bool IsDarkMode {
get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always"; get => (DarkMode == "system" && Sys.IsDarkTheme) || DarkMode == "always";
} }
@@ -103,7 +107,7 @@ namespace mpvnet
public static bool ProcessProperty(string name, string value) public static bool ProcessProperty(string name, string value)
{ {
switch (name) // return true instead of break! switch (name)
{ {
case "remember-position": RememberPosition = value == "yes"; return true; case "remember-position": RememberPosition = value == "yes"; return true;
case "start-size": RememberHeight = value == "previous"; return true; case "start-size": RememberHeight = value == "previous"; return true;
@@ -114,10 +118,10 @@ namespace mpvnet
case "light-color": LightColor = value.Trim('\'', '"'); return true; case "light-color": LightColor = value.Trim('\'', '"'); return true;
case "url-whitelist": UrlWhitelist = value.Split(' ', ',', ';'); return true; case "url-whitelist": UrlWhitelist = value.Split(' ', ',', ';'); return true;
case "remember-volume": RememberVolume = value == "yes"; return true; case "remember-volume": RememberVolume = value == "yes"; return true;
case "start-threshold": case "start-threshold": StartThreshold = value.Int(); return true;
int.TryParse(value, out int result); case "minimum-aspect-ratio": MinimumAspectRatio = value.Float(); return true;
StartThreshold = result; case "auto-load-folder": AutoLoadFolder = value == "yes"; return true;
return true; case "themed-menu": ThemedMenu = value == "yes"; return true;
} }
return false; return false;
} }

View File

@@ -93,7 +93,7 @@ namespace mpvnet
{ {
fileSize = new FileInfo(path).Length; fileSize = new FileInfo(path).Length;
if (App.AudioTypes.Contains(PathHelp.GetShortExtension(path))) if (App.AudioTypes.Contains(path.ShortExt()))
{ {
using (MediaInfo mediaInfo = new MediaInfo(path)) using (MediaInfo mediaInfo = new MediaInfo(path))
{ {
@@ -111,13 +111,13 @@ namespace mpvnet
if (date != "") text += "Year: " + date + "\n"; if (date != "") text += "Year: " + date + "\n";
if (duration != "") text += "Length: " + duration + "\n"; if (duration != "") text += "Length: " + duration + "\n";
text += "Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n"; text += "Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n";
text += "Type: " + PathHelp.GetShortExtension(path).ToUpper(); text += "Type: " + path.ShortExt().ToUpper();
mp.commandv("show-text", text, "5000"); mp.commandv("show-text", text, "5000");
return; return;
} }
} }
else if (App.ImageTypes.Contains(PathHelp.GetShortExtension(path))) else if (App.ImageTypes.Contains(path.ShortExt()))
{ {
using (MediaInfo mediaInfo = new MediaInfo(path)) using (MediaInfo mediaInfo = new MediaInfo(path))
{ {
@@ -125,7 +125,7 @@ namespace mpvnet
"Width: " + mediaInfo.GetInfo(MediaInfoStreamKind.Image, "Width") + "\n" + "Width: " + mediaInfo.GetInfo(MediaInfoStreamKind.Image, "Width") + "\n" +
"Height: " + mediaInfo.GetInfo(MediaInfoStreamKind.Image, "Height") + "\n" + "Height: " + mediaInfo.GetInfo(MediaInfoStreamKind.Image, "Height") + "\n" +
"Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n" + "Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n" +
"Type: " + PathHelp.GetShortExtension(path).ToUpper(); "Type: " + path.ShortExt().ToUpper();
mp.commandv("show-text", text, "5000"); mp.commandv("show-text", text, "5000");
return; return;
@@ -138,7 +138,7 @@ namespace mpvnet
string videoFormat = mp.get_property_string("video-format").ToUpper(); string videoFormat = mp.get_property_string("video-format").ToUpper();
string audioCodec = mp.get_property_string("audio-codec-name").ToUpper(); string audioCodec = mp.get_property_string("audio-codec-name").ToUpper();
text = PathHelp.GetFileName(path) + "\n" + text = path.FileName() + "\n" +
FormatTime(position.TotalMinutes) + ":" + FormatTime(position.TotalMinutes) + ":" +
FormatTime(position.Seconds) + " / " + FormatTime(position.Seconds) + " / " +
FormatTime(duration2.TotalMinutes) + ":" + FormatTime(duration2.TotalMinutes) + ":" +

View File

@@ -0,0 +1,32 @@
using System.Globalization;
using System.IO;
public static class Extensions
{
public static string FileName(this string path)
{
if (string.IsNullOrEmpty(path)) return "";
int index = path.LastIndexOf('\\');
if (index > -1) return path.Substring(index + 1);
index = path.LastIndexOf('/');
if (index > -1) return path.Substring(index + 1);
return path;
}
public static string ShortExt(this string path)
{
return Path.GetExtension(path).ToLower().TrimStart('.');
}
public static int Int(this string value)
{
int.TryParse(value, out int result);
return result;
}
public static float Float(this string value)
{
float.TryParse(value.Replace(",", "."), NumberStyles.Float, CultureInfo.InvariantCulture, out float result);
return result;
}
}

View File

@@ -294,20 +294,5 @@ namespace mpvnet
public class PathHelp public class PathHelp
{ {
public static string StartupPath { get; } = Application.StartupPath + "\\"; public static string StartupPath { get; } = Application.StartupPath + "\\";
public static string GetFileName(string path)
{
if (string.IsNullOrEmpty(path)) return "";
int index = path.LastIndexOf('\\');
if (index > -1) return path.Substring(index + 1);
index = path.LastIndexOf('/');
if (index > -1) return path.Substring(index + 1);
return path;
}
public static string GetShortExtension(string path)
{
return Path.GetExtension(path).ToLower().TrimStart('.');
}
} }
} }

View File

@@ -244,17 +244,17 @@ help = "Specify the OSD font size. See sub-font-size for details. Default: 55"
[[settings]] [[settings]]
name = "autofit" name = "autofit"
filter = "Screen" filter = "Screen"
help = "<int> Initial window height in percent. Default: 50%" help = "<int> Initial window height in percent. Default: 50"
[[settings]] [[settings]]
name = "autofit-smaller" name = "autofit-smaller"
filter = "Screen" filter = "Screen"
help = "<int> Minimum window height in percent. Default: 40%" help = "<int> Minimum window height in percent. Default: 40"
[[settings]] [[settings]]
name = "autofit-larger" name = "autofit-larger"
filter = "Screen" filter = "Screen"
help = "<int> Maximum window height in percent. Default: 75%" help = "<int> Maximum window height in percent. Default: 75"
[[settings]] [[settings]]
name = "screenshot-directory" name = "screenshot-directory"

View File

@@ -1,29 +1,9 @@
[[settings]] [[settings]]
name = "dark-mode"
default = "always"
filter = "General"
help = "Enables a dark theme. (mpv.net specific setting)"
options = [{ name = "always" },
{ name = "system" , help = "Available on Windows 10 or higher" },
{ name = "never" }]
[[settings]]
name = "dark-color"
type = "color"
filter = "General"
help = "Theme color used in dark-mode. Leave empty to use OS theme. (mpv.net specific setting)"
[[settings]]
name = "light-color"
type = "color"
filter = "General"
help = "Theme color used when dark-mode is disabled. Leave empty to use OS theme. (mpv.net specific setting)"
[[settings]]
name = "url-whitelist" name = "url-whitelist"
filter = "General" filter = "General"
type = "string" type = "string"
help = "Whitelist setting to monitor the clipboard for URLs to play. (mpv.net specific setting)\n\nDefault: tube vimeo ard zdf" help = "Whitelist setting to monitor the clipboard for URLs to play. (mpv.net specific setting)\n\nDefault: tube vimeo ard zdf\n\nHow to start mpv.net directly from Google Chrome is described in the manual:"
url = "https://github.com/stax76/mpv.net/blob/master/Manual.md#chrome-extension"
[[settings]] [[settings]]
name = "process-instance" name = "process-instance"
@@ -55,6 +35,11 @@ name = "start-threshold"
filter = "Screen" filter = "Screen"
help = "Threshold in milliseconds to wait for libmpv returning the video resolution before the window is shown, otherwise default dimensions are used as defined by autofit and start-size. (mpv.net specific setting) Default: 1500" help = "Threshold in milliseconds to wait for libmpv returning the video resolution before the window is shown, otherwise default dimensions are used as defined by autofit and start-size. (mpv.net specific setting) Default: 1500"
[[settings]]
name = "minimum-aspect-ratio"
filter = "Screen"
help = "<float> Minimum aspect ratio for the window. Default: 1.3"
[[settings]] [[settings]]
name = "remember-position" name = "remember-position"
default = "no" default = "no"
@@ -70,3 +55,40 @@ filter = "Audio"
help = "Save volume and mute on exit and restore it on start. (mpv.net specific setting)" help = "Save volume and mute on exit and restore it on start. (mpv.net specific setting)"
options = [{ name = "yes" }, options = [{ name = "yes" },
{ name = "no" }] { name = "no" }]
[[settings]]
name = "auto-load-folder"
default = "yes"
filter = "Playback"
help = "For single files automatically load the entire directory into the playlist. (mpv.net specific setting)"
options = [{ name = "yes" },
{ name = "no" }]
[[settings]]
name = "dark-mode"
default = "always"
filter = "UI"
help = "Enables a dark theme. (mpv.net specific setting)"
options = [{ name = "always" },
{ name = "system" , help = "Available on Windows 10 or higher" },
{ name = "never" }]
[[settings]]
name = "dark-color"
type = "color"
filter = "UI"
help = "Theme color used in dark-mode. Leave empty to use OS theme. (mpv.net specific setting)"
[[settings]]
name = "light-color"
type = "color"
filter = "UI"
help = "Theme color used when dark-mode is disabled. Leave empty to use OS theme. (mpv.net specific setting)"
[[settings]]
name = "themed-menu"
default = "no"
filter = "UI"
help = "Follow theme color in context menu. (mpv.net specific setting)"
options = [{ name = "yes" },
{ name = "no" }]

View File

@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:WPF="clr-namespace:WPF" xmlns:WPF="clr-namespace:WPF"
mc:Ignorable="d" mc:Ignorable="d"
Height="500" Width="700" Loaded="ConfWindow1_Loaded" ShowInTaskbar="False" Height="530" Width="700" Loaded="ConfWindow1_Loaded" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" Title="Config Editor"> WindowStartupLocation="CenterScreen" Title="Config Editor">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -21,7 +21,7 @@
<StackPanel x:Name="MainStackPanel"></StackPanel> <StackPanel x:Name="MainStackPanel"></StackPanel>
</ScrollViewer> </ScrollViewer>
<StackPanel Margin="20,0,0,0" Grid.Row="1"> <StackPanel Margin="20,0,0,0" Grid.Row="1">
<ListBox x:Name="FilterListBox" ItemsSource="{Binding FilterStrings}" BorderThickness="0" SelectionChanged="ListBox_SelectionChanged" Foreground="{x:Static WPF:WPF.ThemeBrush}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"> <ListBox x:Name="FilterListBox" ItemsSource="{Binding FilterStrings}" BorderThickness="0" SelectionChanged="FilterListBox_SelectionChanged" Foreground="{x:Static WPF:WPF.ThemeBrush}" Background="{Binding Path=Background, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding}" FontSize="16" /> <TextBlock Text="{Binding}" FontSize="16" />

View File

@@ -197,7 +197,7 @@ namespace mpvnet
i.Update(); i.Update();
} }
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) private void FilterListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (e.AddedItems.Count > 0) if (e.AddedItems.Count > 0)
SearchControl.Text = e.AddedItems[0].ToString() + ":"; SearchControl.Text = e.AddedItems[0].ToString() + ":";

View File

@@ -136,10 +136,11 @@ namespace mpvnet
Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH); Everything_SetRequestFlags(EVERYTHING_REQUEST_FILE_NAME | EVERYTHING_REQUEST_PATH);
Everything_SetSort(EVERYTHING_SORT_SIZE_DESCENDING); Everything_SetSort(EVERYTHING_SORT_SIZE_DESCENDING);
Everything_Query(true); Everything_Query(true);
for (i = 0; i < Everything_GetNumResults(); i++) for (i = 0; i < Everything_GetNumResults(); i++)
{ {
Everything_GetResultFullPathName(i, buf, bufsize); Everything_GetResultFullPathName(i, buf, bufsize);
string ext = PathHelp.GetShortExtension(buf.ToString()); string ext = buf.ToString().ShortExt();
if (App.AudioTypes.Contains(ext) || App.VideoTypes.Contains(ext) || if (App.AudioTypes.Contains(ext) || App.VideoTypes.Contains(ext) ||
App.ImageTypes.Contains(ext)) App.ImageTypes.Contains(ext))
@@ -148,6 +149,7 @@ namespace mpvnet
if (items.Count > 100) break; if (items.Count > 100) break;
} }
Application.Current.Dispatcher.Invoke(() => { Application.Current.Dispatcher.Invoke(() => {
ListView.ItemsSource = items; ListView.ItemsSource = items;
SelectFirst(); SelectFirst();

View File

@@ -2,7 +2,6 @@
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
@@ -82,7 +81,7 @@ namespace mpvnet
mp.observe_property_string("vid", PropChangeVid); mp.observe_property_string("vid", PropChangeVid);
mp.observe_property_int("edition", PropChangeEdition); mp.observe_property_int("edition", PropChangeEdition);
mp.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold); if (mp.GPUAPI != "vulkan") mp.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold);
if (Height < FontHeight * 4) SetFormPosAndSize(); if (Height < FontHeight * 4) SetFormPosAndSize();
} }
catch (Exception ex) catch (Exception ex)
@@ -239,7 +238,7 @@ namespace mpvnet
int autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * mp.Autofit); int autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * mp.Autofit);
if (mp.VideoSize.Height == 0 || mp.VideoSize.Width == 0 || if (mp.VideoSize.Height == 0 || mp.VideoSize.Width == 0 ||
mp.VideoSize.Width / (float)mp.VideoSize.Height < 1.3) mp.VideoSize.Width / (float)mp.VideoSize.Height < App.MinimumAspectRatio)
mp.VideoSize = new Size((int)(autoFitHeight * (16 / 9.0)), autoFitHeight); mp.VideoSize = new Size((int)(autoFitHeight * (16 / 9.0)), autoFitHeight);
@@ -367,7 +366,7 @@ namespace mpvnet
string path = mp.get_property_string("path"); string path = mp.get_property_string("path");
BeginInvoke(new Action(() => { BeginInvoke(new Action(() => {
if (File.Exists(path) || path.Contains("://")) if (File.Exists(path) || path.Contains("://"))
Text = PathHelp.GetFileName(path) + " - mpv.net " + Application.ProductVersion; Text = path.FileName() + " - mpv.net " + Application.ProductVersion;
else else
Text = "mpv.net " + Application.ProductVersion; Text = "mpv.net " + Application.ProductVersion;
})); }));
@@ -508,9 +507,10 @@ namespace mpvnet
protected override void OnShown(EventArgs e) protected override void OnShown(EventArgs e)
{ {
base.OnShown(e); base.OnShown(e);
if (mp.GPUAPI == "vulkan") mp.ProcessCommandLine();
var wpfColor = WPF.WPF.ThemeColor; var wpfColor = WPF.WPF.ThemeColor;
Color color = Color.FromArgb(wpfColor.A, wpfColor.R, wpfColor.G, wpfColor.B); Color color = Color.FromArgb(wpfColor.A, wpfColor.R, wpfColor.G, wpfColor.B);
ToolStripRendererEx.InitColors(color, App.IsDarkMode); ToolStripRendererEx.InitColors(color, App.IsDarkMode, App.ThemedMenu);
BuildMenu(); BuildMenu();
ContextMenuStrip = ContextMenu; ContextMenuStrip = ContextMenu;
WPF.WPF.Init(); WPF.WPF.Init();

View File

@@ -131,8 +131,6 @@ public class MenuItem : ToolStripMenuItem
public class ToolStripRendererEx : ToolStripSystemRenderer public class ToolStripRendererEx : ToolStripSystemRenderer
{ {
public static bool IsDarkMode { get; set; }
public static Color ColorForeground { get; set; } = Color.Black; public static Color ColorForeground { get; set; } = Color.Black;
public static Color ColorTheme { get; set; } public static Color ColorTheme { get; set; }
public static Color ColorChecked { get; set; } public static Color ColorChecked { get; set; }
@@ -141,34 +139,33 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
public static Color ColorSelection { get; set; } public static Color ColorSelection { get; set; }
public static Color ColorBackground { get; set; } public static Color ColorBackground { get; set; }
public static Color ColorToolStrip1 { get; set; }
public static Color ColorToolStrip2 { get; set; }
public static Color ColorToolStrip3 { get; set; }
public static Color ColorToolStrip4 { get; set; }
int TextOffset; int TextOffset;
public static void InitColors(Color c, bool darkMode) public static void InitColors(Color themeColor, bool darkMode, bool themed)
{ {
ColorBorder = HSLColor.Convert(c).ToColorSetLuminosity(100);
ColorChecked = HSLColor.Convert(c).ToColorSetLuminosity(160);
ColorSelection = HSLColor.Convert(c).ToColorSetLuminosity(180);
ColorBackground = HSLColor.Convert(c).ToColorSetLuminosity(210);
ColorTop = HSLColor.Convert(c).ToColorSetLuminosity(240);
if (darkMode) if (darkMode)
{ {
ColorBorder = Color.White; ColorBorder = Color.White;
ColorBackground = Color.FromArgb(50, 50, 50); ColorBackground = Color.FromArgb(50, 50, 50);
ColorSelection = Color.FromArgb(80, 80, 80); ColorSelection = Color.FromArgb(80, 80, 80);
if (themed)
ColorForeground = themeColor;
else
ColorForeground = Color.White; ColorForeground = Color.White;
ColorChecked = Color.FromArgb(90, 90, 90); ColorChecked = Color.FromArgb(90, 90, 90);
} }
else
{
if (!themed) themeColor = Color.FromArgb(238, 238, 238);
ColorToolStrip1 = ControlPaint.LightLight(ControlPaint.LightLight(ControlPaint.Light(ColorBorder, 1))); ColorBorder = HSLColor.Convert(themeColor).ToColorSetLuminosity(100);
ColorToolStrip2 = ControlPaint.LightLight(ControlPaint.LightLight(ControlPaint.Light(ColorBorder, 0.7f))); ColorChecked = HSLColor.Convert(themeColor).ToColorSetLuminosity(160);
ColorToolStrip3 = ControlPaint.LightLight(ControlPaint.LightLight(ControlPaint.Light(ColorBorder, 0.1f))); ColorSelection = HSLColor.Convert(themeColor).ToColorSetLuminosity(180);
ColorToolStrip4 = ControlPaint.LightLight(ControlPaint.LightLight(ControlPaint.Light(ColorBorder, 0.4f))); ColorBackground = HSLColor.Convert(themeColor).ToColorSetLuminosity(210);
ColorTop = HSLColor.Convert(themeColor).ToColorSetLuminosity(240);
}
} }
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
@@ -200,17 +197,6 @@ public class ToolStripRendererEx : ToolStripSystemRenderer
base.OnRenderItemText(e); base.OnRenderItemText(e);
} }
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
{
if (!(e.ToolStrip is ToolStripDropDownMenu) && !(e.ToolStrip.LayoutStyle == ToolStripLayoutStyle.VerticalStackWithOverflow))
{
Rectangle r = new Rectangle(-1, -1, e.AffectedBounds.Width, e.AffectedBounds.Height);
using (SolidBrush b = new SolidBrush(ColorToolStrip2))
e.Graphics.FillRectangle(b, r);
}
}
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
{ {
Rectangle rect = new Rectangle(Point.Empty, e.Item.Size); Rectangle rect = new Rectangle(Point.Empty, e.Item.Size);

View File

@@ -151,6 +151,7 @@
<DependentUpon>StringSettingControl.xaml</DependentUpon> <DependentUpon>StringSettingControl.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="DynamicGUI\Tommy.cs" /> <Compile Include="DynamicGUI\Tommy.cs" />
<Compile Include="Misc\ExtensionMethods.cs" />
<Compile Include="Native\MediaInfo.cs" /> <Compile Include="Native\MediaInfo.cs" />
<Compile Include="WinForms\Menu.cs"> <Compile Include="WinForms\Menu.cs">
<SubType>Component</SubType> <SubType>Component</SubType>

View File

@@ -56,27 +56,29 @@ namespace mpvnet
public static event Action Initialized; public static event Action Initialized;
public static IntPtr Handle { get; set; }
public static IntPtr WindowHandle { get; set; }
public static Extension Extension { get; set; }
public static bool IsLogoVisible { set; get; }
public static bool IsQuitNeeded { set; get; } = true;
public static List<KeyValuePair<string, Action<bool>>> BoolPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<bool>>>(); public static List<KeyValuePair<string, Action<bool>>> BoolPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<bool>>>();
public static List<KeyValuePair<string, Action<int>>> IntPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<int>>>(); public static List<KeyValuePair<string, Action<int>>> IntPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<int>>>();
public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>(); public static List<KeyValuePair<string, Action<string>>> StringPropChangeActions { get; set; } = new List<KeyValuePair<string, Action<string>>>();
public static Size VideoSize { get; set; }
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
public static AutoResetEvent ShutdownAutoResetEvent { get; set; } = new AutoResetEvent(false);
public static AutoResetEvent VideoSizeAutoResetEvent { get; set; } = new AutoResetEvent(false);
public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>(); public static List<MediaTrack> MediaTracks { get; set; } = new List<MediaTrack>();
public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>(); public static List<KeyValuePair<string, double>> Chapters { get; set; } = new List<KeyValuePair<string, double>>();
public static IntPtr Handle { get; set; }
public static IntPtr WindowHandle { get; set; }
public static Extension Extension { get; set; }
public static List<PythonScript> PythonScripts { get; set; } = new List<PythonScript>();
public static Size VideoSize { get; set; }
public static AutoResetEvent ShutdownAutoResetEvent { get; set; } = new AutoResetEvent(false);
public static AutoResetEvent VideoSizeAutoResetEvent { get; set; } = new AutoResetEvent(false);
public static string InputConfPath { get; } = ConfigFolder + "\\input.conf"; public static string InputConfPath { get; } = ConfigFolder + "\\input.conf";
public static string ConfPath { get; } = ConfigFolder + "\\mpv.conf"; public static string ConfPath { get; } = ConfigFolder + "\\mpv.conf";
public static string Sid { get; set; } = ""; public static string Sid { get; set; } = "";
public static string Aid { get; set; } = ""; public static string Aid { get; set; } = "";
public static string Vid { get; set; } = ""; public static string Vid { get; set; } = "";
public static string GPUAPI { get; set; } = "auto";
public static bool IsLogoVisible { set; get; }
public static bool IsQuitNeeded { set; get; } = true;
public static bool Fullscreen { get; set; } public static bool Fullscreen { get; set; }
public static bool Border { get; set; } = true; public static bool Border { get; set; } = true;
@@ -100,20 +102,23 @@ namespace mpvnet
} }
set_property_string("wid", MainForm.Hwnd.ToString()); set_property_string("wid", MainForm.Hwnd.ToString());
set_property_string("config-dir", ConfigFolder);
set_property_string("osc", "yes"); set_property_string("osc", "yes");
set_property_string("config", "yes");
set_property_string("force-window", "yes"); set_property_string("force-window", "yes");
set_property_string("input-media-keys", "yes"); set_property_string("input-media-keys", "yes");
set_property_string("config-dir", ConfigFolder);
set_property_string("config", "yes");
mpv_initialize(Handle); mpv_initialize(Handle);
Initialized?.Invoke(); Initialized?.Invoke();
ShowLogo(); ShowLogo();
LoadMpvScripts(); LoadMpvScripts();
ProcessCommandLine(); if (GPUAPI != "vulkan") ProcessCommandLine();
} }
public static void ProcessProperty(string name, string value) public static void ProcessProperty(string name, string value)
{ {
if (name.Any(char.IsUpper)) Msg.ShowError("Uppercase char detected: " + name, "mpv properties using the command line and the mpv.conf config file are required to be lowercase.");
switch (name) switch (name)
{ {
case "autofit": case "autofit":
@@ -132,6 +137,7 @@ namespace mpvnet
case "fullscreen": Fullscreen = value == "yes"; break; case "fullscreen": Fullscreen = value == "yes"; break;
case "border": Border = value == "yes"; break; case "border": Border = value == "yes"; break;
case "screen": Screen = Convert.ToInt32(value); break; case "screen": Screen = Convert.ToInt32(value); break;
case "gpu-api": GPUAPI = value; break;
} }
} }
@@ -212,10 +218,10 @@ namespace mpvnet
if (File.Exists(ConfPath)) if (File.Exists(ConfPath))
foreach (var i in File.ReadAllLines(ConfPath)) foreach (var i in File.ReadAllLines(ConfPath))
if (i.Contains("=") && ! i.StartsWith("#")) if (i.Contains("=") && !i.TrimStart().StartsWith("#"))
_Conf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim(); _Conf[i.Substring(0, i.IndexOf("=")).Trim()] = i.Substring(i.IndexOf("=") + 1).Trim();
foreach (var i in Conf) foreach (var i in _Conf)
ProcessProperty(i.Key, i.Value); ProcessProperty(i.Key, i.Value);
} }
return _Conf; return _Conf;
@@ -223,6 +229,8 @@ namespace mpvnet
} }
public static void LoadMpvScripts() public static void LoadMpvScripts()
{
if (Directory.Exists(PathHelp.StartupPath + "Scripts"))
{ {
string[] startupScripts = Directory.GetFiles(PathHelp.StartupPath + "Scripts"); string[] startupScripts = Directory.GetFiles(PathHelp.StartupPath + "Scripts");
@@ -233,6 +241,7 @@ namespace mpvnet
else else
App.UnknownModule(path); App.UnknownModule(path);
} }
}
public static string[] KnownScripts { get; } = { "osc-visibility.js", "show-playlist.js", "seek-show-position.py" }; public static string[] KnownScripts { get; } = { "osc-visibility.js", "show-playlist.js", "seek-show-position.py" };
@@ -624,7 +633,7 @@ namespace mpvnet
LastLoad = DateTime.Now; LastLoad = DateTime.Now;
for (int i = 0; i < files.Length; i++) for (int i = 0; i < files.Length; i++)
if (App.SubtitleTypes.Contains(PathHelp.GetShortExtension(files[i]))) if (App.SubtitleTypes.Contains(files[i].ShortExt()))
commandv("sub-add", files[i]); commandv("sub-add", files[i]);
else else
if (i == 0 && !append) if (i == 0 && !append)
@@ -640,14 +649,15 @@ namespace mpvnet
public static void LoadFolder() public static void LoadFolder()
{ {
if (!App.AutoLoadFolder) return;
Thread.Sleep(200); // user reported race condition Thread.Sleep(200); // user reported race condition
string path = get_property_string("path"); string path = get_property_string("path");
if (!File.Exists(path) || get_property_int("playlist-count") != 1) return; if (!File.Exists(path) || get_property_int("playlist-count") != 1) return;
List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList(); List<string> files = Directory.GetFiles(Path.GetDirectoryName(path)).ToList();
files = files.Where((file) => files = files.Where((file) =>
App.VideoTypes.Contains(PathHelp.GetShortExtension(file)) || App.VideoTypes.Contains(file.ShortExt()) ||
App.AudioTypes.Contains(PathHelp.GetShortExtension(file)) || App.AudioTypes.Contains(file.ShortExt()) ||
App.ImageTypes.Contains(PathHelp.GetShortExtension(file))).ToList(); App.ImageTypes.Contains(file.ShortExt())).ToList();
files.Sort(new StringLogicalComparer()); files.Sort(new StringLogicalComparer());
int index = files.IndexOf(path); int index = files.IndexOf(path);
files.Remove(path); files.Remove(path);