From 6c85ea9625bea7b261737903081b64d1e94553fb Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Sat, 27 Apr 2019 06:16:46 +0200 Subject: [PATCH] - --- README.md | 4 ++++ mpv.net/Command.cs | 2 +- mpv.net/Misc.cs | 21 +++++++++++++---- mpv.net/Windows/CommandPaletteWindow.xaml.cs | 12 +++++++++- mpv.net/Windows/ConfWindow.xaml.cs | 24 ++++++-------------- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index db781d9..6d506bf 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,10 @@ mpv.net bugs and requests: ### Changelog +### 3.3 (2019-??-??) + +- dark mode support added to the command palette + ### 3.2 (2019-04-27) - mpvInputEdit and mpvConfEdit were discontinued and merged into diff --git a/mpv.net/Command.cs b/mpv.net/Command.cs index 0b7f46a..a7b558a 100644 --- a/mpv.net/Command.cs +++ b/mpv.net/Command.cs @@ -49,7 +49,7 @@ namespace mpvnet using (var d = new OpenFileDialog()) { d.Multiselect = true; - d.Filter = Misc.GetFilter(Misc.FileTypes); + d.Filter = Sys.GetFilter(); if (d.ShowDialog() == DialogResult.OK) mp.LoadFiles(d.FileNames); diff --git a/mpv.net/Misc.cs b/mpv.net/Misc.cs index 8208e2f..2484cec 100644 --- a/mpv.net/Misc.cs +++ b/mpv.net/Misc.cs @@ -15,12 +15,17 @@ using Microsoft.Win32; namespace mpvnet { - public class Misc + public class App { - public static readonly string[] FileTypes = "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(' '); - - public static string GetFilter(IEnumerable values) => "*." + - String.Join(";*.", values) + "|*." + String.Join(";*.", values) + "|All Files|*.*"; + public static bool IsDarkMode { + get { + string darkMode = MainForm.Instance.MpvNetDarkMode; + object value = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 1); + if (value is null) value = 1; + bool isDarkTheme = (int)value == 0; + return (darkMode == "system" && isDarkTheme) || darkMode == "always"; + } + } } public class Sys @@ -46,6 +51,12 @@ namespace mpvnet { } return false; } + + public static string GetFilter() + { + string[] fileTypes = "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(' '); + return "*." + String.Join(";*.", fileTypes) + "|*." + String.Join(";*.", fileTypes) + "|All Files|*.*"; + } } public class StringLogicalComparer : IComparer, IComparer diff --git a/mpv.net/Windows/CommandPaletteWindow.xaml.cs b/mpv.net/Windows/CommandPaletteWindow.xaml.cs index 3a1bcc2..aa0f686 100644 --- a/mpv.net/Windows/CommandPaletteWindow.xaml.cs +++ b/mpv.net/Windows/CommandPaletteWindow.xaml.cs @@ -1,9 +1,11 @@ -using System; +using Microsoft.Win32; +using System; using System.ComponentModel; using System.Windows; using System.Windows.Data; using System.Windows.Input; using System.Windows.Interop; +using System.Windows.Media; namespace mpvnet { @@ -19,6 +21,14 @@ namespace mpvnet var yourCostumFilter = new Predicate(item => Filter((CommandItem)item)); CollectionView.Filter = yourCostumFilter; ListView.ItemsSource = CollectionView; + + if (App.IsDarkMode) + { + ListView.Foreground = Brushes.White; + ListView.Background = Brushes.Black; + FilterTextBox.Foreground = Brushes.White; + FilterTextBox.Background = Brushes.Black; + } } bool Filter(CommandItem item) diff --git a/mpv.net/Windows/ConfWindow.xaml.cs b/mpv.net/Windows/ConfWindow.xaml.cs index 89223b9..37315ab 100644 --- a/mpv.net/Windows/ConfWindow.xaml.cs +++ b/mpv.net/Windows/ConfWindow.xaml.cs @@ -30,7 +30,13 @@ namespace mpvnet LoadSettings(MpvSettingsDefinitions, MpvConf); LoadSettings(MpvNetSettingsDefinitions, MpvNetConf); SearchControl.Text = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\mpv.net", "conf editor search", ""); - SetDarkTheme(); + + if (App.IsDarkMode) + { + Foreground = Brushes.White; + Foreground2 = Brushes.Silver; + Background = Brushes.Black; + } } public Brush Foreground2 { @@ -41,22 +47,6 @@ namespace mpvnet public static readonly DependencyProperty Foreground2Property = DependencyProperty.Register("Foreground2", typeof(Brush), typeof(ConfWindow), new PropertyMetadata(Brushes.DarkSlateGray)); - void SetDarkTheme() - { - string darkMode = MpvNetSettingsDefinitions.Where(item => item.Name == "dark-mode").First().Value; - - object value = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 1); - if (value is null) value = 1; - bool isDarkTheme = (int)value == 0; - - if (!((darkMode == "system" && isDarkTheme) || darkMode == "always")) - return; - - Foreground = Brushes.White; - Foreground2 = Brushes.Silver; - Background = Brushes.Black; - } - private void LoadSettings(List settingsDefinitions, Dictionary confSettings) {