diff --git a/Changelog.md b/Changelog.md
index adfb147..3afdac2 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -5,7 +5,8 @@
pdn and png source is located [here](https://github.com/stax76/mpv.net/tree/master/img)
- everytime only one file is opened the complete folder is loaded in the playlist
- the info command (i key) shows the audio format
-- new options osd-font-size, sub-font, sub-font-size, sub-color, sub-border-color, sub-back-color
+- new options osd-font-size, sub-font, sub-font-size
+- new color options with dedicated GUI support: sub-color, sub-border-color, sub-back-color
- the config editor no longer shows the command line switches
- the github start page was greatly improved
- the setup.ps1 PowerShell script was greatly improved in regard of error handling and readability
diff --git a/README.md b/README.md
index 0406213..838d592 100644
--- a/README.md
+++ b/README.md
@@ -165,6 +165,11 @@ Third party components:
- [CS-Script, scripting with C#](http://www.csscript.net/)
- [Everything, a blazing fast file search service](https://www.voidtools.com)
+Due to mpv.net being my first WPF app and mpv.net never ment
+to be a large application best practices and design pattern
+are often ignored, also the coding style might not be the
+best because I don't believe C has good syntax.
+
### Support
[Support thread in Doom9 forum](https://forum.doom9.org/showthread.php?t=174841)
diff --git a/mpv.net/DynamicGUI/DynamicGUI.cs b/mpv.net/DynamicGUI/DynamicGUI.cs
index bce67e1..2c48b08 100644
--- a/mpv.net/DynamicGUI/DynamicGUI.cs
+++ b/mpv.net/DynamicGUI/DynamicGUI.cs
@@ -49,14 +49,16 @@ namespace DynamicGUI
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("width")) baseSetting.Width = setting["width"];
+ if (setting.HasKey("type")) baseSetting.Type = setting["type"];
+
settingsList.Add(baseSetting);
}
return settingsList;
@@ -72,12 +74,12 @@ namespace DynamicGUI
public string Default { get; set; }
public string HelpURL { get; set; }
public string Filter { get; set; }
+ public string Type { get; set; }
public int Width { get; set; }
}
public class StringSetting : SettingBase
{
- public bool IsFolder { get; set; }
}
public class OptionSetting : SettingBase
diff --git a/mpv.net/DynamicGUI/StringSettingControl.xaml b/mpv.net/DynamicGUI/StringSettingControl.xaml
index e6d6c9a..5036141 100644
--- a/mpv.net/DynamicGUI/StringSettingControl.xaml
+++ b/mpv.net/DynamicGUI/StringSettingControl.xaml
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:DynamicGUI"
mc:Ignorable="d"
d:DesignHeight="450"
- d:DesignWidth="800" >
+ d:DesignWidth="800">
@@ -15,7 +15,7 @@
-
+
diff --git a/mpv.net/DynamicGUI/StringSettingControl.xaml.cs b/mpv.net/DynamicGUI/StringSettingControl.xaml.cs
index 24db9cc..bfdec93 100644
--- a/mpv.net/DynamicGUI/StringSettingControl.xaml.cs
+++ b/mpv.net/DynamicGUI/StringSettingControl.xaml.cs
@@ -1,5 +1,9 @@
-using System.Windows;
+using System;
+using System.Globalization;
+using System.Windows;
using System.Windows.Controls;
+using System.Windows.Media;
+using WinForms = System.Windows.Forms;
namespace DynamicGUI
{
@@ -13,10 +17,10 @@ namespace DynamicGUI
InitializeComponent();
TitleTextBox.Text = stringSetting.Name;
HelpTextBox.Text = stringSetting.Help;
- ValueTextBox.Text = stringSetting.Value;
- if (stringSetting.Width > 0)
- ValueTextBox.Width = stringSetting.Width;
- if (!StringSetting.IsFolder)
+ ValueTextBox.Text = StringSetting.Value;
+ if (StringSetting.Width > 0)
+ ValueTextBox.Width = StringSetting.Width;
+ if (StringSetting.Type != "folder" && StringSetting.Type != "color")
Button.Visibility = Visibility.Hidden;
Link.SetURL(StringSetting.HelpURL);
if (string.IsNullOrEmpty(stringSetting.HelpURL))
@@ -29,7 +33,6 @@ namespace DynamicGUI
get {
if (_SearchableText is null)
_SearchableText = (TitleTextBox.Text + HelpTextBox.Text +ValueTextBox.Text).ToLower();
-
return _SearchableText;
}
}
@@ -45,13 +48,56 @@ namespace DynamicGUI
private void Button_Click(object sender, RoutedEventArgs e)
{
- using (var d = new System.Windows.Forms.FolderBrowserDialog())
+ switch (StringSetting.Type)
{
- d.Description = "Choose a folder.";
- d.SelectedPath = ValueTextBox.Text;
- if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- ValueTextBox.Text = d.SelectedPath;
+ case "folder":
+ using (var d = new WinForms.FolderBrowserDialog())
+ {
+ d.Description = "Choose a folder.";
+ d.SelectedPath = ValueTextBox.Text;
+ if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ ValueTextBox.Text = d.SelectedPath;
+ }
+ break;
+ case "color":
+ using (var d = new WinForms.ColorDialog())
+ {
+ d.FullOpen = true;
+ try {
+ d.Color = System.Drawing.ColorTranslator.FromHtml(ValueTextBox.Text);
+ } catch { }
+ if (d.ShowDialog() == WinForms.DialogResult.OK)
+ ValueTextBox.Text = System.Drawing.ColorTranslator.ToHtml(d.Color);
+ }
+ break;
}
}
+
+ private void ValueTextBox_TextChanged(object sender, TextChangedEventArgs e) => Update();
+
+ public void Update()
+ {
+ if (StringSetting.Type == "color")
+ {
+ Color c = Colors.Transparent;
+ if (ValueTextBox.Text != "")
+ {
+ try {
+ if (ValueTextBox.Text.Contains("/"))
+ {
+ string[] a = ValueTextBox.Text.Split('/');
+ if (a.Length == 3)
+ c = Color.FromRgb(ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
+ else if (a.Length == 4)
+ c = Color.FromArgb(ToByte(a[3]), ToByte(a[0]), ToByte(a[1]), ToByte(a[2]));
+ }
+ else
+ c = (Color)ColorConverter.ConvertFromString(ValueTextBox.Text);
+ } catch {}
+ }
+ ValueTextBox.Background = new SolidColorBrush(c);
+ }
+ Byte ToByte(string val) => Convert.ToByte(Convert.ToSingle(val, CultureInfo.InvariantCulture) * 255);
+ }
}
}
\ No newline at end of file
diff --git a/mpv.net/Resources/mpvConfToml.txt b/mpv.net/Resources/mpvConfToml.txt
index 85c8cf9..2671cc3 100644
--- a/mpv.net/Resources/mpvConfToml.txt
+++ b/mpv.net/Resources/mpvConfToml.txt
@@ -193,18 +193,21 @@ help = "Specify the sub font size. The unit is the size in scaled pixels at a wi
[[settings]]
name = "sub-color"
default = ""
+type = "color"
filter = "Subtitle"
help = "Specify the color used for unstyled text subtitles.\n\nThe color is specified in the form r/g/b, where each color component is specified as number in the range 0.0 to 1.0. It's also possible to specify the transparency by using r/g/b/a, where the alpha value 0 means fully transparent, and 1.0 means opaque. If the alpha component is not given, the color is 100% opaque.\n\nPassing a single number to the option sets the sub to gray, and the form gray/a lets you specify alpha additionally.\n\nExamples\n\n1.0/0.0/0.0 set sub to opaque red\n1.0/0.0/0.0/0.75 set sub to opaque red with 75% alpha\n0.5/0.75 set sub to 50% gray with 75% alpha\n\nAlternatively, the color can be specified as a RGB hex triplet in the form #RRGGBB, where each 2-digit group expresses a color value in the range 0 (00) to 255 (FF). For example, #FF0000 is red. This is similar to web colors. Alpha is given with #AARRGGBB.\n\nExamples\n\n#FF0000 set sub to opaque red\n#C0808080 set sub to 50% gray with 75% alpha"
[[settings]]
name = "sub-border-color"
default = ""
+type = "color"
filter = "Subtitle"
help = "See --sub-color. Color used for the sub font border. Ignored when sub-back-color is specified (or more exactly: when that option is not set to completely transparent)."
[[settings]]
name = "sub-back-color"
default = ""
+type = "color"
filter = "Subtitle"
help = "See sub-color. Color used for sub text background. You can use sub-shadow-offset to change its size relative to the text."
@@ -240,7 +243,7 @@ options = [{ name = "yes" },
name = "screenshot-directory"
default = ""
width = 500
-folder = true
+type = "folder"
filter = "Screen"
help = "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."
diff --git a/mpv.net/WPF/ConfWindow.xaml.cs b/mpv.net/WPF/ConfWindow.xaml.cs
index 03ea5b2..37b1e50 100644
--- a/mpv.net/WPF/ConfWindow.xaml.cs
+++ b/mpv.net/WPF/ConfWindow.xaml.cs
@@ -7,6 +7,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
+using System.Linq;
using DynamicGUI;
@@ -28,7 +29,7 @@ namespace mpvnet
LoadSettings(MpvSettingsDefinitions, MpvConf);
LoadSettings(MpvNetSettingsDefinitions, MpvNetConf);
SearchControl.Text = RegistryHelp.GetString(@"HKCU\Software\mpv.net", "config editor search");
-
+
if (App.IsDarkMode)
{
Foreground = Brushes.White;
@@ -215,6 +216,8 @@ namespace mpvnet
{
SearchControl.SearchTextBox.SelectAll();
Keyboard.Focus(SearchControl.SearchTextBox);
+ foreach (var i in MainStackPanel.Children.OfType())
+ i.Update();
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)