diff --git a/mpv.net/Command.cs b/mpv.net/Command.cs index 87c33a6..8678f2e 100644 --- a/mpv.net/Command.cs +++ b/mpv.net/Command.cs @@ -58,19 +58,14 @@ namespace mpvnet Process.Start(mp.mpvConfFolderPath); } - public static void show_keys(string[] args) + public static void show_input_editor(string[] args) { - Process.Start(NativeHelp.GetAssociatedApplication(".txt"), mp.InputConfPath); - } - - public static void show_prefs(string[] args) - { - Process.Start(NativeHelp.GetAssociatedApplication(".txt"), mp.mpvConfPath); + Process.Start(Application.StartupPath + "\\mpvInputEdit.exe"); } public static void show_conf_editor(string[] args) { - Process.Start(Application.StartupPath + "\\mpvSettingsEditor.exe"); + Process.Start(Application.StartupPath + "\\mpvConfEdit.exe"); } public static void history(string[] args) diff --git a/mpv.net/MainForm.cs b/mpv.net/MainForm.cs index c518de6..b74aed0 100644 --- a/mpv.net/MainForm.cs +++ b/mpv.net/MainForm.cs @@ -4,7 +4,6 @@ using System.IO; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; -using System.Diagnostics; using System.Linq; namespace mpvnet @@ -143,11 +142,11 @@ namespace mpvnet 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; + var key = left.Substring(0, left.IndexOf(" ")); + if (key == "_") key = ""; + if (menu.Contains(";")) key = menu.Substring(0, menu.IndexOf(";")).Trim(); + var path = menu.Substring(menu.IndexOf(";") + 1).Trim().Replace("&", "&&"); + if (path == "" || cmd == "") continue; var menuItem = CMS.Add(path, () => { try @@ -397,5 +396,11 @@ namespace mpvnet mp.commandv("quit"); mp.AutoResetEvent.WaitOne(3000); } + + protected override void OnLostFocus(EventArgs e) + { + base.OnLostFocus(e); + CursorHelp.Show(); + } } } \ No newline at end of file diff --git a/mpv.net/Native.cs b/mpv.net/Native.cs index 4ab9eca..aa8e058 100644 --- a/mpv.net/Native.cs +++ b/mpv.net/Native.cs @@ -32,9 +32,6 @@ 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 { diff --git a/mpv.net/NativeHelp.cs b/mpv.net/NativeHelp.cs index 8e8b54a..caea177 100644 --- a/mpv.net/NativeHelp.cs +++ b/mpv.net/NativeHelp.cs @@ -1,6 +1,4 @@ using System; -using System.IO; -using System.Text; namespace mpvnet { @@ -36,25 +34,5 @@ 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 ""; - } } } \ No newline at end of file diff --git a/mpv.net/Properties/AssemblyInfo.cs b/mpv.net/Properties/AssemblyInfo.cs index 9e874ad..72e0fe2 100644 --- a/mpv.net/Properties/AssemblyInfo.cs +++ b/mpv.net/Properties/AssemblyInfo.cs @@ -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("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0.0.0")] +[assembly: AssemblyVersion("2.1.0.0")] +[assembly: AssemblyFileVersion("2.1.0.0")] diff --git a/mpv.net/Resources/input.conf.txt b/mpv.net/Resources/input.conf.txt index b9248fa..ec66b16 100644 --- a/mpv.net/Resources/input.conf.txt +++ b/mpv.net/Resources/input.conf.txt @@ -1,139 +1,124 @@ - # mpv.net key bindings, mouse bindings and context menu configuration + o script-message mpv.net open-files #menu: Open > Open Files... + u script-message mpv.net open-url #menu: Open > Open URL... + _ ignore #menu: - + Space cycle pause #menu: Play/Pause + s stop #menu: Stop + _ ignore #menu: - + f cycle fullscreen #menu: Toggle Fullscreen - o script-message mpv.net open-files #menu: O ; Open > Open Files... - u script-message mpv.net open-url #menu: U ; Open > Open URL... - _ 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 + F11 playlist-prev #menu: Navigate > Previous + F12 playlist-next #menu: Navigate > Next + _ ignore #menu: Navigate > - + PGUP add chapter 1 #menu: Navigate > Next Chapter + PGDWN add chapter -1 #menu: Navigate > Previous Chapter - F11 playlist-prev #menu: F11 ; Navigate > Previous - F12 playlist-next #menu: F12 ; Navigate > Next - _ ignore #menu: _ ; Navigate > - - PGUP add chapter 1 #menu: Page Up ; Navigate > Next Chapter - PGDWN add chapter -1 #menu: Page Down ; Navigate > Previous Chapter - - . frame-step #menu: . ; Seek > Next Frame - , frame-back-step #menu: , ; Seek > Previous Frame - _ ignore #menu: _ ; Seek > - - Right no-osd seek 7 #menu: Right ; Seek > 7 sec forward - Left no-osd seek -7 #menu: Left ; Seek > 7 sec backward - _ ignore #menu: _ ; Seek > - - Up no-osd seek 40 #menu: Up ; Seek > 40 sec forward - Down no-osd seek -40 #menu: Down ; Seek > 40 sec backward - _ ignore #menu: _ ; Seek > - - Ctrl+Right no-osd seek 300 #menu: Ctrl+Right ; Seek > 5 min forward - Ctrl+Left no-osd seek -300 #menu: Ctrl+Left ; Seek > 5 min backward - - 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 > - - 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 > - - 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 > - - 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 - _ ignore #menu: _ ; Video > - - Ctrl+3 add brightness -1 #menu: Ctrl+3 ; Video > Decrease Brightness - Ctrl+4 add brightness 1 #menu: Ctrl+4 ; Video > Increase Brightness - _ ignore #menu: _ ; Video > - - Ctrl+5 add gamma -1 #menu: Ctrl+5 ; Video > Decrease Gamma - Ctrl+6 add gamma 1 #menu: Ctrl+6 ; Video > Increase Gamma - _ ignore #menu: _ ; Video > - - Ctrl+7 add saturation -1 #menu: Ctrl+7 ; Video > Decrease Saturation - Ctrl+8 add saturation 1 #menu: Ctrl+8 ; Video > Increase Saturation - _ ignore #menu: _ ; Video > - - Ctrl+S async screenshot #menu: Ctrl+S ; Video > Take Screenshot - 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 - - KP7 cycle audio #menu: Keypad 7 ; Audio > Cycle/Next - _ ignore #menu: _ ; Audio > - - KP6 add audio-delay 0.100 #menu: Keypad 6 ; Audio > Delay +0.1 - KP9 add audio-delay -0.100 #menu: Keypad 9 ; Audio > Delay -0.1 - - KP8 cycle sub #menu: Keypad 8 ; Subtitle > Cycle/Next - v cycle sub-visibility #menu: V ; Subtitle > Toggle Visibility - _ ignore #menu: _ ; Subtitle > - - z add sub-delay -0.1 #menu: Z ; Subtitle > Delay -0.1 - Z add sub-delay +0.1 #menu: Shift+Z ; Subtitle > Delay +0.1 - _ ignore #menu: _ ; Subtitle > - - r add sub-pos -1 #menu: R ; Subtitle > Move Up - R add sub-pos +1 #menu: Shift+R ; Subtitle > Move Down - _ 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 - - + add volume 10 #menu: + ; Volume > Up - - add volume -10 #menu: - ; Volume > Down - WHEEL_UP add volume 10 - WHEEL_DOWN add volume -10 - _ ignore #menu: _ ; Volume > - - m cycle mute #menu: M ; Volume > Mute - - [ multiply speed 0.9 #menu: [ ; Speed > -10% - ] multiply speed 1.1 #menu: ] ; Speed > +10% - _ ignore #menu: _ ; Speed > - - { multiply speed 0.5 #menu: { ; Speed > Half - } multiply speed 2.0 #menu: } ; Speed > Double - _ ignore #menu: _ ; Speed > - - BS set speed 1 #menu: Backspace ; Speed > Reset - - KP0 script-message rate-file 0 #menu: Keypad 0 ; Addons > Rating > 0stars - KP1 script-message rate-file 1 #menu: Keypad 1 ; Addons > Rating > 1stars - KP2 script-message rate-file 2 #menu: Keypad 2 ; Addons > Rating > 2stars - KP3 script-message rate-file 3 #menu: Keypad 3 ; Addons > Rating > 3stars - KP4 script-message rate-file 4 #menu: Keypad 4 ; Addons > Rating > 4stars - KP5 script-message rate-file 5 #menu: Keypad 5 ; Addons > Rating > 5stars - - _ 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 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 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 > - - h script-message mpv.net history #menu: H ; Tools > Show History - l ab-loop #menu: L ; Tools > Set/clear A-B loop points - L cycle-values loop-file "inf" "no" #menu: Shift+L ; Tools > Toggle Infinite Looping - DEL script-binding osc/visibility #menu: Delete ; Tools > Toggle OSC Visibility - Ctrl+H cycle-values hwdec "auto" "no" #menu: Ctrl+H ; Tools > Cycle Hardware Decoding - 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 execute-mpv-command #menu: _ ; Tools > Enter a mpv command for execution... - - _ 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 - + . frame-step #menu: Seek > Next Frame + , frame-back-step #menu: Seek > Previous Frame + _ ignore #menu: Seek > - + Right no-osd seek 7 #menu: Seek > 7 sec forward + Left no-osd seek -7 #menu: Seek > 7 sec backward + _ ignore #menu: Seek > - + Up no-osd seek 40 #menu: Seek > 40 sec forward + Down no-osd seek -40 #menu: Seek > 40 sec backward + _ ignore #menu: Seek > - + Ctrl+Right no-osd seek 300 #menu: Seek > 5 min forward + Ctrl+Left no-osd seek -300 #menu: Seek > 5 min backward + Ctrl++ add video-zoom 0.1 #menu: Pan & Scan > Increase Size + Ctrl+- add video-zoom -0.1 #menu: Pan & Scan > Decrease Size + _ ignore #menu: Pan & Scan > - + Ctrl+KP4 add video-pan-x -0.01 #menu: Pan & Scan > Move Left + Ctrl+KP6 add video-pan-x 0.01 #menu: Pan & Scan > Move Right + _ ignore #menu: Pan & Scan > - + Ctrl+KP8 add video-pan-y -0.01 #menu: Pan & Scan > Move Up + Ctrl+KP2 add video-pan-y 0.01 #menu: Pan & Scan > Move Down + _ ignore #menu: Pan & Scan > - + w add panscan -0.1 #menu: Pan & Scan > Decrease Height + W add panscan +0.1 #menu: Pan & Scan > Increase Height + _ ignore #menu: Pan & Scan > - + Ctrl+BS set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0 #menu: Pan & Scan > Reset + Ctrl+1 add contrast -1 #menu: Video > Decrease Contrast + Ctrl+2 add contrast 1 #menu: Video > Increase Contrast + _ ignore #menu: Video > - + Ctrl+3 add brightness -1 #menu: Video > Decrease Brightness + Ctrl+4 add brightness 1 #menu: Video > Increase Brightness + _ ignore #menu: Video > - + Ctrl+5 add gamma -1 #menu: Video > Decrease Gamma + Ctrl+6 add gamma 1 #menu: Video > Increase Gamma + _ ignore #menu: Video > - + Ctrl+7 add saturation -1 #menu: Video > Decrease Saturation + Ctrl+8 add saturation 1 #menu: Video > Increase Saturation + _ ignore #menu: Video > - + Ctrl+s async screenshot #menu: Video > Take Screenshot + d cycle deinterlace #menu: Video > Toggle Deinterlace + a cycle-values video-aspect "16:9" "4:3" "2.35:1" "-1" #menu: Video > Cycle Aspect Ratio + KP7 cycle audio #menu: Audio > Cycle/Next + _ ignore #menu: Audio > - + KP6 add audio-delay 0.100 #menu: Audio > Delay +0.1 + KP9 add audio-delay -0.100 #menu: Audio > Delay -0.1 + KP8 cycle sub #menu: Subtitle > Cycle/Next + v cycle sub-visibility #menu: Subtitle > Toggle Visibility + _ ignore #menu: Subtitle > - + z add sub-delay -0.1 #menu: Subtitle > Delay -0.1 + Z add sub-delay +0.1 #menu: Subtitle > Delay +0.1 + _ ignore #menu: Subtitle > - + r add sub-pos -1 #menu: Subtitle > Move Up + R add sub-pos +1 #menu: Subtitle > Move Down + _ 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 + + add volume 10 #menu: Volume > Up + - add volume -10 #menu: Volume > Down + _ ignore #menu: Volume > - + m cycle mute #menu: Volume > Mute + [ multiply speed 0.9 #menu: Speed > -10% + ] multiply speed 1.1 #menu: Speed > +10% + _ ignore #menu: Speed > - + { multiply speed 0.5 #menu: Speed > Half + } multiply speed 2.0 #menu: Speed > Double + _ ignore #menu: Speed > - + BS set speed 1 #menu: Speed > Reset + KP0 script-message rate-file 0 #menu: Addons > Rating > 0stars + KP1 script-message rate-file 1 #menu: Addons > Rating > 1stars + KP2 script-message rate-file 2 #menu: Addons > Rating > 2stars + KP3 script-message rate-file 3 #menu: Addons > Rating > 3stars + KP4 script-message rate-file 4 #menu: Addons > Rating > 4stars + KP5 script-message rate-file 5 #menu: Addons > Rating > 5stars + _ 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 + e script-message mpv.net show-conf-editor #menu: Settings > Show config editor + Ctrl+i script-message mpv.net show-input-editor #menu: Settings > Show input editor + c script-message mpv.net open-config-folder #menu: Settings > Open Config Folder + i script-message mpv.net show-info #menu: Tools > Info + t script-binding stats/display-stats #menu: Tools > Show Statistics + T script-binding stats/display-stats-toggle #menu: Tools > Toggle Statistics + _ ignore #menu: Tools > - + h script-message mpv.net history #menu: Tools > Show History + l ab-loop #menu: Tools > Set/clear A-B loop points + L cycle-values loop-file "inf" "no" #menu: Tools > Toggle Infinite Looping + Del script-binding osc/visibility #menu: Tools > Toggle OSC Visibility + Ctrl+h cycle-values hwdec "auto" "no" #menu: Tools > Cycle Hardware Decoding + F8 show-text ${playlist} 5000 #menu: Tools > Show Playlist + F9 show-text ${track-list} 5000 #menu: Tools > Show Audio/Video/Subtitle List + _ script-message mpv.net execute-mpv-command #menu: Tools > Execute mpv command... + _ 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: Exit + Q quit-watch-later #menu: Exit Watch Later > playlist-next < playlist-prev - - POWER quit - PLAY cycle pause - PAUSE cycle pause - PLAYPAUSE cycle pause - STOP quit - FORWARD seek 60 - REWIND seek -60 - VOLUME_UP add volume 2 - VOLUME_DOWN add volume -2 - MUTE cycle mute \ No newline at end of file + Enter cycle pause + Power quit + Play cycle pause + Pause cycle pause + PlayPause cycle pause + Stop quit + Forward seek 60 + Rewind seek -60 + Mute cycle mute + Volume_Up add volume 10 + Volume_Down add volume -10 + Wheel_Up add volume 10 + Wheel_Down add volume -10 \ No newline at end of file diff --git a/mpv.net/Resources/mpv.conf.txt b/mpv.net/Resources/mpv.conf.txt index 092210d..2fbbaa6 100644 --- a/mpv.net/Resources/mpv.conf.txt +++ b/mpv.net/Resources/mpv.conf.txt @@ -9,4 +9,5 @@ vo = direct3d keep-open = yes keep-open-pause = no osd-playing-msg = ${filename} -screenshot-directory = ~~desktop/ \ No newline at end of file +screenshot-directory = ~~desktop/ +input-default-bindings = no \ No newline at end of file diff --git a/mpv.net/mpv.net.csproj b/mpv.net/mpv.net.csproj index 781131f..22843cb 100644 --- a/mpv.net/mpv.net.csproj +++ b/mpv.net/mpv.net.csproj @@ -157,6 +157,7 @@ + MainForm.cs diff --git a/mpv.net/trash.cs b/mpv.net/trash.cs new file mode 100644 index 0000000..9e37ca3 --- /dev/null +++ b/mpv.net/trash.cs @@ -0,0 +1,22 @@ +//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 ""; +//} + +//[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); \ No newline at end of file diff --git a/mpvSettingsEditor/App.config b/mpvConfEdit/App.config similarity index 100% rename from mpvSettingsEditor/App.config rename to mpvConfEdit/App.config diff --git a/mpvSettingsEditor/App.xaml b/mpvConfEdit/App.xaml similarity index 100% rename from mpvSettingsEditor/App.xaml rename to mpvConfEdit/App.xaml diff --git a/mpvSettingsEditor/App.xaml.cs b/mpvConfEdit/App.xaml.cs similarity index 100% rename from mpvSettingsEditor/App.xaml.cs rename to mpvConfEdit/App.xaml.cs diff --git a/mpvSettingsEditor/DynamicGUI/DynamicGUI.cs b/mpvConfEdit/DynamicGUI/DynamicGUI.cs similarity index 83% rename from mpvSettingsEditor/DynamicGUI/DynamicGUI.cs rename to mpvConfEdit/DynamicGUI/DynamicGUI.cs index 5660b1d..ec1054a 100644 --- a/mpvSettingsEditor/DynamicGUI/DynamicGUI.cs +++ b/mpvConfEdit/DynamicGUI/DynamicGUI.cs @@ -1,6 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Windows.Documents; +using System.Windows.Navigation; using Tommy; namespace DynamicGUI @@ -107,4 +110,27 @@ namespace DynamicGUI } } } + + interface ISettingControl + { + bool Contains(string searchString); + SettingBase SettingBase { get; } + } + + 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); + } + } } \ No newline at end of file diff --git a/mpvSettingsEditor/DynamicGUI/OptionSettingControl.xaml b/mpvConfEdit/DynamicGUI/OptionSettingControl.xaml similarity index 100% rename from mpvSettingsEditor/DynamicGUI/OptionSettingControl.xaml rename to mpvConfEdit/DynamicGUI/OptionSettingControl.xaml diff --git a/mpvSettingsEditor/DynamicGUI/OptionSettingControl.xaml.cs b/mpvConfEdit/DynamicGUI/OptionSettingControl.xaml.cs similarity index 100% rename from mpvSettingsEditor/DynamicGUI/OptionSettingControl.xaml.cs rename to mpvConfEdit/DynamicGUI/OptionSettingControl.xaml.cs diff --git a/mpvSettingsEditor/DynamicGUI/StringSettingControl.xaml b/mpvConfEdit/DynamicGUI/StringSettingControl.xaml similarity index 100% rename from mpvSettingsEditor/DynamicGUI/StringSettingControl.xaml rename to mpvConfEdit/DynamicGUI/StringSettingControl.xaml diff --git a/mpvSettingsEditor/DynamicGUI/StringSettingControl.xaml.cs b/mpvConfEdit/DynamicGUI/StringSettingControl.xaml.cs similarity index 100% rename from mpvSettingsEditor/DynamicGUI/StringSettingControl.xaml.cs rename to mpvConfEdit/DynamicGUI/StringSettingControl.xaml.cs diff --git a/mpvSettingsEditor/DynamicGUI/Tommy.cs b/mpvConfEdit/DynamicGUI/Tommy.cs similarity index 100% rename from mpvSettingsEditor/DynamicGUI/Tommy.cs rename to mpvConfEdit/DynamicGUI/Tommy.cs diff --git a/mpvSettingsEditor/MainWindow.xaml b/mpvConfEdit/MainWindow.xaml similarity index 76% rename from mpvSettingsEditor/MainWindow.xaml rename to mpvConfEdit/MainWindow.xaml index 10343aa..e451bff 100644 --- a/mpvSettingsEditor/MainWindow.xaml +++ b/mpvConfEdit/MainWindow.xaml @@ -1,4 +1,4 @@ - - - - - - + diff --git a/mpvSettingsEditor/MainWindow.xaml.cs b/mpvConfEdit/MainWindow.xaml.cs similarity index 90% rename from mpvSettingsEditor/MainWindow.xaml.cs rename to mpvConfEdit/MainWindow.xaml.cs index 1b5128f..99af4d2 100644 --- a/mpvSettingsEditor/MainWindow.xaml.cs +++ b/mpvConfEdit/MainWindow.xaml.cs @@ -1,5 +1,4 @@ -using DynamicGUI; -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; @@ -10,18 +9,21 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; -namespace mpvSettingsEditor +using DynamicGUI; + +namespace mpvConfEdit { public partial class MainWindow : Window { public string mpvConfPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\mpv.conf"; - private List DynamicSettings = Settings.LoadSettings(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\mpvSettingsEditor.toml"); + private List DynamicSettings = Settings.LoadSettings(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\mpvConfEdit.toml"); public MainWindow() { InitializeComponent(); DataContext = this; Title = (Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), true)[0] as AssemblyProductAttribute).Product + " " + Assembly.GetExecutingAssembly().GetName().Version.ToString(); + SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged; foreach (var setting in DynamicSettings) { @@ -157,23 +159,16 @@ namespace mpvSettingsEditor 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 + ":") + if (SearchControl.Text == i + ":") activeFilter = i; if (activeFilter == "") { foreach (UIElement i in MainStackPanel.Children) - if ((i as ISettingControl).Contains(SearchTextBox.Text)) + if ((i as ISettingControl).Contains(SearchControl.Text)) i.Visibility = Visibility.Visible; else i.Visibility = Visibility.Collapsed; @@ -192,19 +187,13 @@ namespace mpvSettingsEditor private void MainWindow1_Loaded(object sender, RoutedEventArgs e) { - Keyboard.Focus(SearchTextBox); + Keyboard.Focus(SearchControl.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); + SearchControl.Text = e.AddedItems[0].ToString() + ":"; } private void OpenSettingsTextBlock_MouseUp(object sender, MouseButtonEventArgs e) diff --git a/mpvSettingsEditor/Properties/AssemblyInfo.cs b/mpvConfEdit/Properties/AssemblyInfo.cs similarity index 95% rename from mpvSettingsEditor/Properties/AssemblyInfo.cs rename to mpvConfEdit/Properties/AssemblyInfo.cs index 8423c64..8259b3f 100644 --- a/mpvSettingsEditor/Properties/AssemblyInfo.cs +++ b/mpvConfEdit/Properties/AssemblyInfo.cs @@ -7,11 +7,11 @@ 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: AssemblyTitle("mpv(.net) conf edit")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("mpv(.net) settings editor")] +[assembly: AssemblyProduct("mpv(.net) conf edit")] [assembly: AssemblyCopyright("Copyright © stax76")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/mpvSettingsEditor/Properties/Resources.Designer.cs b/mpvConfEdit/Properties/Resources.Designer.cs similarity index 94% rename from mpvSettingsEditor/Properties/Resources.Designer.cs rename to mpvConfEdit/Properties/Resources.Designer.cs index 7be58d6..015c669 100644 --- a/mpvSettingsEditor/Properties/Resources.Designer.cs +++ b/mpvConfEdit/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace mpvSettingsEditor.Properties { +namespace mpvConfEdit.Properties { using System; @@ -39,7 +39,7 @@ namespace mpvSettingsEditor.Properties { 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); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mpvConfEdit.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/mpvSettingsEditor/Properties/Resources.resx b/mpvConfEdit/Properties/Resources.resx similarity index 100% rename from mpvSettingsEditor/Properties/Resources.resx rename to mpvConfEdit/Properties/Resources.resx diff --git a/mpvSettingsEditor/Properties/Settings.Designer.cs b/mpvConfEdit/Properties/Settings.Designer.cs similarity index 96% rename from mpvSettingsEditor/Properties/Settings.Designer.cs rename to mpvConfEdit/Properties/Settings.Designer.cs index fda0227..af9cb96 100644 --- a/mpvSettingsEditor/Properties/Settings.Designer.cs +++ b/mpvConfEdit/Properties/Settings.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace mpvSettingsEditor.Properties { +namespace mpvConfEdit.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] diff --git a/mpvSettingsEditor/Properties/Settings.settings b/mpvConfEdit/Properties/Settings.settings similarity index 100% rename from mpvSettingsEditor/Properties/Settings.settings rename to mpvConfEdit/Properties/Settings.settings diff --git a/mpvConfEdit/SearchTextBoxUserControl.xaml b/mpvConfEdit/SearchTextBoxUserControl.xaml new file mode 100644 index 0000000..48a4a32 --- /dev/null +++ b/mpvConfEdit/SearchTextBoxUserControl.xaml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/mpvConfEdit/SearchTextBoxUserControl.xaml.cs b/mpvConfEdit/SearchTextBoxUserControl.xaml.cs new file mode 100644 index 0000000..8235d12 --- /dev/null +++ b/mpvConfEdit/SearchTextBoxUserControl.xaml.cs @@ -0,0 +1,32 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; + +namespace Controls +{ + public partial class SearchTextBoxUserControl : UserControl + { + public SearchTextBoxUserControl() + { + InitializeComponent(); + } + + public string Text { get => SearchTextBox.Text; set => SearchTextBox.Text = value; } + + private void SearchClearButton_Click(object sender, RoutedEventArgs e) + { + SearchTextBox.Text = ""; + Keyboard.Focus(SearchTextBox); + } + + 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; + } + } +} \ No newline at end of file diff --git a/mpvSettingsEditor/mpv.ico b/mpvConfEdit/mpv.ico similarity index 100% rename from mpvSettingsEditor/mpv.ico rename to mpvConfEdit/mpv.ico diff --git a/mpvSettingsEditor/mpvSettingsEditor.csproj b/mpvConfEdit/mpvConfEdit.csproj similarity index 92% rename from mpvSettingsEditor/mpvSettingsEditor.csproj rename to mpvConfEdit/mpvConfEdit.csproj index 7b44662..16a563e 100644 --- a/mpvSettingsEditor/mpvSettingsEditor.csproj +++ b/mpvConfEdit/mpvConfEdit.csproj @@ -6,8 +6,8 @@ AnyCPU {C4FEAA45-001D-4DC8-8BFA-621527326D09} WinExe - mpvSettingsEditor - mpvSettingsEditor + mpvConfEdit + mpvConfEdit v4.7.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} @@ -66,7 +66,6 @@ MSBuild:Compile Designer - OptionSettingControl.xaml @@ -75,6 +74,9 @@ StringSettingControl.xaml + + SearchTextBoxUserControl.xaml + Designer MSBuild:Compile @@ -95,9 +97,12 @@ MainWindow.xaml Code + + Designer + MSBuild:Compile + - Code @@ -124,7 +129,7 @@ - + Always diff --git a/mpvSettingsEditor/mpvSettingsEditor.sln b/mpvConfEdit/mpvConfEdit.sln similarity index 87% rename from mpvSettingsEditor/mpvSettingsEditor.sln rename to mpvConfEdit/mpvConfEdit.sln index ec1caaa..9f519b1 100644 --- a/mpvSettingsEditor/mpvSettingsEditor.sln +++ b/mpvConfEdit/mpvConfEdit.sln @@ -3,7 +3,7 @@ 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}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mpvConfEdit", "mpvConfEdit.csproj", "{C4FEAA45-001D-4DC8-8BFA-621527326D09}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/mpvSettingsEditor/mpvSettingsEditor.toml b/mpvConfEdit/mpvConfEdit.toml similarity index 100% rename from mpvSettingsEditor/mpvSettingsEditor.toml rename to mpvConfEdit/mpvConfEdit.toml diff --git a/mpvInputEdit/App.config b/mpvInputEdit/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/mpvInputEdit/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/mpvInputEdit/App.xaml b/mpvInputEdit/App.xaml new file mode 100644 index 0000000..1adb6d1 --- /dev/null +++ b/mpvInputEdit/App.xaml @@ -0,0 +1,42 @@ + + + + + + diff --git a/mpvInputEdit/App.xaml.cs b/mpvInputEdit/App.xaml.cs new file mode 100644 index 0000000..3fec150 --- /dev/null +++ b/mpvInputEdit/App.xaml.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.ObjectModel; +using System.IO; +using System.Windows; + +namespace mpvInputEdit +{ + public partial class App : Application + { + public static string InputConfPath { get; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\input.conf"; + + private static ObservableCollection _InputItems; + + public static ObservableCollection InputItems + { + get + { + if (_InputItems is null) + { + _InputItems = new ObservableCollection(); + + if (File.Exists(InputConfPath)) + { + foreach (string line in File.ReadAllLines(InputConfPath)) + { + string l = line.Trim(); + if (l.StartsWith("#")) continue; + if (!l.Contains(" ")) continue; + InputItem item = new InputItem(); + item.Key = l.Substring(0, l.IndexOf(" ")); + if (item.Key == "") continue; + l = l.Substring(l.IndexOf(" ") + 1); + + if (l.Contains("#menu:")) + { + item.Menu = l.Substring(l.IndexOf("#menu:") + 6).Trim(); + l = l.Substring(0, l.IndexOf("#menu:")); + + if (item.Menu.Contains(";")) + item.Menu = item.Menu.Substring(item.Menu.IndexOf(";") + 1).Trim(); + } + + item.Command = l.Trim(); + if (item.Command == "") + continue; + if (item.Command.ToLower() == "ignore") + item.Command = ""; + _InputItems.Add(item); + } + } + } + return _InputItems; + } + } + } +} \ No newline at end of file diff --git a/mpvInputEdit/InputWindow.xaml b/mpvInputEdit/InputWindow.xaml new file mode 100644 index 0000000..7b70887 --- /dev/null +++ b/mpvInputEdit/InputWindow.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mpvInputEdit/InputWindow.xaml.cs b/mpvInputEdit/InputWindow.xaml.cs new file mode 100644 index 0000000..b6a556e --- /dev/null +++ b/mpvInputEdit/InputWindow.xaml.cs @@ -0,0 +1,296 @@ +using System; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Input; +using System.Windows.Interop; +using WF = System.Windows.Forms; + +namespace mpvInputEdit +{ + public partial class InputWindow : Window + { + string InputString = ""; + public InputItem InputItem { get; set; } + public string NewKey { get; set; } = ""; + + public InputWindow() + { + InitializeComponent(); + } + + private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) + { + WF.Message m = new WF.Message(); + m.HWnd = hwnd; + m.Msg = msg; + m.WParam = wParam; + m.LParam = lParam; + ProcessKeyEventArgs(ref m); + return m.Result; + } + + void OnKeyUp(WF.KeyEventArgs e) + { + if (e.KeyCode == WF.Keys.None) return; + char c = Convert.ToChar(e.KeyCode); + string text = InputString; + + if (e.KeyCode == WF.Keys.ControlKey || e.KeyCode == WF.Keys.ShiftKey || + e.KeyCode == WF.Keys.Menu) + { + return; + } + + if (text == "") + { + text = e.KeyCode.ToString(); + if (text.Length == 1) + text = text.ToLowerInvariant(); + } + + for (int i = 0; i < 13; i++) + if ("D" + i.ToString() == text) + text = text.Substring(1); + + //Debug.WriteLine((int)c); + //Debug.WriteLine(e.KeyCode.ToString()); + + switch (e.KeyCode) + { + case WF.Keys.NumPad0: + case WF.Keys.NumPad1: + case WF.Keys.NumPad2: + case WF.Keys.NumPad3: + case WF.Keys.NumPad4: + case WF.Keys.NumPad5: + case WF.Keys.NumPad6: + case WF.Keys.NumPad7: + case WF.Keys.NumPad8: + case WF.Keys.NumPad9: + text = "KP" + e.KeyCode.ToString()[6].ToString(); break; + case WF.Keys.Space: + text = "Space"; break; + case WF.Keys.Enter: + text = "Enter"; break; + case WF.Keys.Tab: + text = "Tab"; break; + case WF.Keys.Back: + text = "BS"; break; + case WF.Keys.Delete: + text = "Del"; break; + case WF.Keys.Insert: + text = "Ins"; break; + case WF.Keys.Home: + text = "Home"; break; + case WF.Keys.End: + text = "End"; break; + case WF.Keys.PageUp: + text = "PGUP"; break; + case WF.Keys.PageDown: + text = "PGDWN"; break; + case WF.Keys.Escape: + text = "Esc"; break; + case WF.Keys.PrintScreen: + text = "Print"; break; + case WF.Keys.Right: + text = "Right"; break; + case WF.Keys.Left: + text = "Left"; break; + case WF.Keys.Up: + text = "Up"; break; + case WF.Keys.Down: + text = "Down"; break; + case WF.Keys.Play: + text = "Play"; break; + case WF.Keys.Pause: + text = "Pause"; break; + case WF.Keys.MediaPlayPause: + text = "PlayPause"; break; + case WF.Keys.MediaStop: + text = "Stop"; break; + case WF.Keys.MediaNextTrack: + text = "Next"; break; + case WF.Keys.MediaPreviousTrack: + text = "Prev"; break; + case WF.Keys.VolumeUp: + text = "Volume_Up"; break; + case WF.Keys.VolumeDown: + text = "Volume_Down"; break; + case WF.Keys.VolumeMute: + text = "Mute"; break; + case WF.Keys.BrowserHome: + text = "Homepage"; break; + case WF.Keys.LaunchMail: + text = "Mail"; break; + case WF.Keys.BrowserFavorites: + text = "Favorites"; break; + case WF.Keys.BrowserSearch: + text = "Search"; break; + case WF.Keys.Sleep: + text = "Sleep"; break; + case WF.Keys.Cancel: + text = "Cancel"; break; + } + + if (text == "#") + text = "Sharp"; + + bool isAlt = GetKeyState(18) < (short)0; + bool isShift = GetKeyState(16) < (short)0; + bool isCtrl = GetKeyState(17) < (short)0; + + if (!(isAlt && isCtrl && !isShift) && !(isShift && !isAlt && !isCtrl && !int.TryParse(text.Replace("F", ""), out int value))) + { + if (isAlt) text = "Alt+" + text; + if (isShift) text = "Shift+" + text; + if (isCtrl) text = "Ctrl+" + text; + } + + if (!string.IsNullOrEmpty(text)) + SetKey(text); + } + + void SetKey(string key) + { + NewKey = key; + MenuLabel.Content = InputItem.Menu; + KeyLabel.Content = key; + } + + void OnKeyPress(WF.KeyPressEventArgs e) + { + if (char.IsControl(e.KeyChar)) + InputString = ""; + else + InputString = e.KeyChar.ToString(); + } + + public static WF.Keys ModifierKeys { + get { + WF.Keys keys = WF.Keys.None; + if (GetKeyState(17) < (short)0) + keys |= WF.Keys.Control; + if (GetKeyState(16) < (short)0) + keys |= WF.Keys.Shift; + if (GetKeyState(18) < (short)0) + keys |= WF.Keys.Alt; + return keys; + } + } + + void ProcessKeyEventArgs(ref WF.Message m) + { + int WM_CHAR = 258, WM_SYSCHAR = 262, /*WM_KEYDOWN = 256, WM_SYSKEYDOWN = 260,*/ + WM_KEYUP = 0x0101, WM_SYSKEYUP = 0x0105, WM_APPCOMMAND = 0x0319; + + IntPtr newWParam = IntPtr.Zero; + WF.KeyEventArgs ke = null; + WF.KeyPressEventArgs kpe = null; + + if (m.Msg == WM_CHAR || m.Msg == WM_SYSCHAR) + { + kpe = new WF.KeyPressEventArgs(unchecked((char)(long)m.WParam)); + OnKeyPress(kpe); + newWParam = (IntPtr)kpe.KeyChar; + } + else + { + ke = new WF.KeyEventArgs((WF.Keys)(unchecked((int)(long)m.WParam)) | ModifierKeys); + + //if (m.Msg == WM_KEYDOWN || m.Msg == WM_SYSKEYDOWN) + // OnKeyDown(ke); + + if (m.Msg == WM_KEYUP || m.Msg == WM_SYSKEYUP) + OnKeyUp(ke); + + if (m.Msg == WM_APPCOMMAND) + { + switch ((AppCommand)m.LParam.ToInt32()) + { + case AppCommand.MEDIA_CHANNEL_DOWN: + SetKey("CHANNEL_DOWN"); + break; + case AppCommand.MEDIA_CHANNEL_UP: + SetKey("CHANNEL_UP"); + break; + case AppCommand.MEDIA_FAST_FORWARD: + SetKey("FORWARD"); + break; + case AppCommand.MEDIA_NEXTTRACK: + SetKey("NEXT"); + break; + case AppCommand.MEDIA_PAUSE: + SetKey("PAUSE"); + break; + case AppCommand.MEDIA_PLAY: + SetKey("PLAY"); + break; + case AppCommand.MEDIA_PLAY_PAUSE: + SetKey("PLAYPAUSE"); + break; + case AppCommand.MEDIA_PREVIOUSTRACK: + SetKey("PREV"); + break; + case AppCommand.MEDIA_RECORD: + SetKey("RECORD"); + break; + case AppCommand.MEDIA_REWIND: + SetKey("REWIND"); + break; + case AppCommand.MEDIA_STOP: + SetKey("STOP"); + break; + } + } + } + + if (kpe != null) + m.WParam = newWParam; + } + + internal enum AppCommand + { + MEDIA_CHANNEL_DOWN = 52, + MEDIA_CHANNEL_UP = 51, + MEDIA_FAST_FORWARD = 49, + MEDIA_NEXTTRACK = 11, + MEDIA_PAUSE = 47, + MEDIA_PLAY = 46, + MEDIA_PLAY_PAUSE = 14, + MEDIA_PREVIOUSTRACK = 12, + MEDIA_RECORD = 48, + MEDIA_REWIND = 50, + MEDIA_STOP = 13 + } + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern short GetKeyState(int keyCode); + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); + source.AddHook(new HwndSourceHook(WndProc)); + SetKey(InputItem.Key); + } + + private void ConfirmButton_Click(object sender, RoutedEventArgs e) + { + InputItem.Key = NewKey; + Close(); + } + + private void ClearButton_Click(object sender, RoutedEventArgs e) + { + InputItem.Key = "_"; + Close(); + } + + private void Window_MouseWheel(object sender, MouseWheelEventArgs e) + { + if (e.Delta > 0) + SetKey("WHEEL_UP"); + else + SetKey("WHEEL_DOWN"); + } + } +} \ No newline at end of file diff --git a/mpvInputEdit/MainWindow.xaml b/mpvInputEdit/MainWindow.xaml new file mode 100644 index 0000000..92442cb --- /dev/null +++ b/mpvInputEdit/MainWindow.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mpvInputEdit/MainWindow.xaml.cs b/mpvInputEdit/MainWindow.xaml.cs new file mode 100644 index 0000000..b8b8981 --- /dev/null +++ b/mpvInputEdit/MainWindow.xaml.cs @@ -0,0 +1,119 @@ +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Input; + +namespace mpvInputEdit +{ + public partial class MainWindow : Window + { + ICollectionView CollectionView; + + public MainWindow() + { + InitializeComponent(); + Title = (Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), true)[0] as AssemblyProductAttribute).Product + " " + Assembly.GetExecutingAssembly().GetName().Version.ToString(); + SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged; + DataGrid.SelectionMode = DataGridSelectionMode.Single; + CollectionViewSource collectionViewSource = new CollectionViewSource() { Source = App.InputItems }; + CollectionView = collectionViewSource.View; + var yourCostumFilter = new Predicate(item => Filter((InputItem)item)); + CollectionView.Filter = yourCostumFilter; + DataGrid.ItemsSource = CollectionView; + } + + private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e) + { + CollectionView.Refresh(); + } + + bool Filter(InputItem item) + { + string searchText = SearchControl.SearchTextBox.Text.ToLowerInvariant(); + + if (searchText == "") + return true; + + if (item.Command.ToLower().Contains(searchText) || + item.Menu.ToLower().Contains(searchText) || + item.Key.ToLower().Contains(searchText)) + { + return true; + } + + return false; + } + + private void ButtonClick(object sender, RoutedEventArgs e) + { + InputItem item = ((Button)e.Source).DataContext as InputItem; + if (item is null) return; + InputWindow w = new InputWindow(); + w.Owner = this; + w.InputItem = item; + w.ShowDialog(); + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + Keyboard.Focus(SearchControl.SearchTextBox); + } + + private void Grid_PreviewCanExecute(object sender, CanExecuteRoutedEventArgs e) + { + DataGrid grid = (DataGrid)sender; + + if (e.Command == DataGrid.DeleteCommand) + { + if (MessageBox.Show($"Would you like to delete the selected item?\n\n{(grid.SelectedItem as InputItem).Menu}", + "Confirm Delete", MessageBoxButton.OKCancel) != MessageBoxResult.OK) + { + e.Handled = true; + } + } + } + + private void Window_Closed(object sender, EventArgs e) + { + if (MessageBox.Show("Would you like to save changes?", "Confirm Save", MessageBoxButton.OKCancel) != MessageBoxResult.OK) + return; + + var backupDir = Path.GetDirectoryName(App.InputConfPath) + "\\backup\\"; + + if (!Directory.Exists(backupDir)) + Directory.CreateDirectory(backupDir); + + File.Copy(App.InputConfPath, backupDir + "input conf " + DateTime.Now.ToString("yyyy-MM-dd HH-mm") + ".conf"); + + string text = ""; + + foreach (InputItem item in App.InputItems) + { + string line = " " + item.Key.PadRight(14); + + if (item.Command.Trim() == "") + line += " ignore"; + else + line += " " + item.Command.Trim(); + + if (item.Menu.Trim() != "") + line = line.PadRight(40) + " #menu: " + item.Menu; + + text += line + "\r\n"; + } + + File.WriteAllText(App.InputConfPath, text); + + foreach (Process process in Process.GetProcesses()) + if (process.ProcessName == "mpvnet") + MessageBox.Show("Restart mpv.net in order to apply changed input bindings.", Title, MessageBoxButton.OK, MessageBoxImage.Information); + else if (process.ProcessName == "mpv") + MessageBox.Show("Restart mpv in order to apply changed input bindings.", Title, MessageBoxButton.OK, MessageBoxImage.Information); + } + } +} \ No newline at end of file diff --git a/mpvInputEdit/Properties/AssemblyInfo.cs b/mpvInputEdit/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..62a3340 --- /dev/null +++ b/mpvInputEdit/Properties/AssemblyInfo.cs @@ -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) input edit")] +[assembly: AssemblyDescription("mpv(.net) key bindings editor")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("mpv input edit")] +[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 +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the 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")] diff --git a/mpvInputEdit/Properties/Resources.Designer.cs b/mpvInputEdit/Properties/Resources.Designer.cs new file mode 100644 index 0000000..4f907a1 --- /dev/null +++ b/mpvInputEdit/Properties/Resources.Designer.cs @@ -0,0 +1,66 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace mpvInputEdit.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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", "4.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() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mpvInputEdit.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/mpvInputEdit/Properties/Resources.resx b/mpvInputEdit/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/mpvInputEdit/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/mpvInputEdit/Properties/Settings.Designer.cs b/mpvInputEdit/Properties/Settings.Designer.cs new file mode 100644 index 0000000..79837a8 --- /dev/null +++ b/mpvInputEdit/Properties/Settings.Designer.cs @@ -0,0 +1,28 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace mpvInputEdit.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.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; + } + } + } +} diff --git a/mpvInputEdit/Properties/Settings.settings b/mpvInputEdit/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/mpvInputEdit/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/mpvInputEdit/SearchTextBoxUserControl.xaml b/mpvInputEdit/SearchTextBoxUserControl.xaml new file mode 100644 index 0000000..0a614da --- /dev/null +++ b/mpvInputEdit/SearchTextBoxUserControl.xaml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/mpvInputEdit/SearchTextBoxUserControl.xaml.cs b/mpvInputEdit/SearchTextBoxUserControl.xaml.cs new file mode 100644 index 0000000..d09dd10 --- /dev/null +++ b/mpvInputEdit/SearchTextBoxUserControl.xaml.cs @@ -0,0 +1,32 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; + +namespace Controls +{ + public partial class SearchTextBoxUserControl : UserControl + { + public SearchTextBoxUserControl() + { + InitializeComponent(); + } + + public string Text { get => SearchTextBox.Text; set => SearchTextBox.Text = value; } + + private void SearchClearButton_Click(object sender, RoutedEventArgs e) + { + SearchTextBox.Text = ""; + Keyboard.Focus(SearchTextBox); + } + + private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e) + { + SearchTextBlock.Text = SearchTextBox.Text == "" ? "Search" : ""; + + if (SearchTextBox.Text == "") + SearchClearButton.Visibility = Visibility.Hidden; + else + SearchClearButton.Visibility = Visibility.Visible; + } + } +} \ No newline at end of file diff --git a/mpvInputEdit/misc.cs b/mpvInputEdit/misc.cs new file mode 100644 index 0000000..affc2ef --- /dev/null +++ b/mpvInputEdit/misc.cs @@ -0,0 +1,30 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace mpvInputEdit +{ + public class InputItem : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + public string Menu { get; set; } = ""; + public string Command { get; set; } = ""; + + private void NotifyPropertyChanged([CallerMemberName] string propertyName = "") + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + private string _Key = ""; + + public string Key { + get { + return _Key; + } + set { + _Key = value; + NotifyPropertyChanged(); + } + } + } +} \ No newline at end of file diff --git a/mpvInputEdit/mpv.ico b/mpvInputEdit/mpv.ico new file mode 100644 index 0000000..5467e4e Binary files /dev/null and b/mpvInputEdit/mpv.ico differ diff --git a/mpvInputEdit/mpvInputEdit.csproj b/mpvInputEdit/mpvInputEdit.csproj new file mode 100644 index 0000000..f3a77b0 --- /dev/null +++ b/mpvInputEdit/mpvInputEdit.csproj @@ -0,0 +1,121 @@ + + + + + Debug + AnyCPU + {635F8308-9F79-4BCC-B839-75FCEF8588AE} + WinExe + mpvInputEdit + mpvInputEdit + v4.7.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + ..\mpv.net\bin\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + ..\mpv.net\bin\ + TRACE + prompt + 4 + + + mpv.ico + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + SearchTextBoxUserControl.xaml + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + InputWindow.xaml + + + MainWindow.xaml + Code + + + MSBuild:Compile + Designer + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + \ No newline at end of file diff --git a/mpvInputEdit/mpvInputEdit.sln b/mpvInputEdit/mpvInputEdit.sln new file mode 100644 index 0000000..224a34c --- /dev/null +++ b/mpvInputEdit/mpvInputEdit.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28721.148 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mpvInputEdit", "mpvInputEdit.csproj", "{635F8308-9F79-4BCC-B839-75FCEF8588AE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {635F8308-9F79-4BCC-B839-75FCEF8588AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {635F8308-9F79-4BCC-B839-75FCEF8588AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {635F8308-9F79-4BCC-B839-75FCEF8588AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {635F8308-9F79-4BCC-B839-75FCEF8588AE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {492E8273-D465-496D-BA18-DC8CEC9EAD70} + EndGlobalSection +EndGlobal diff --git a/mpvSettingsEditor/DynamicGUI/Controls.cs b/mpvSettingsEditor/DynamicGUI/Controls.cs deleted file mode 100644 index d45bb4b..0000000 --- a/mpvSettingsEditor/DynamicGUI/Controls.cs +++ /dev/null @@ -1,24 +0,0 @@ -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); - } - } -} \ No newline at end of file diff --git a/mpvSettingsEditor/DynamicGUI/Misc.cs b/mpvSettingsEditor/DynamicGUI/Misc.cs deleted file mode 100644 index c96e9cd..0000000 --- a/mpvSettingsEditor/DynamicGUI/Misc.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace DynamicGUI -{ - interface ISettingControl - { - bool Contains(string searchString); - SettingBase SettingBase { get; } - } -} \ No newline at end of file