New command to move the Window to the screen edge

This commit is contained in:
stax76
2022-08-18 09:31:23 +02:00
parent 00bfa20fac
commit 1f6025a10f
6 changed files with 58 additions and 1 deletions

View File

@@ -4,7 +4,20 @@
- Support multiple folders input (regression fix). - Support multiple folders input (regression fix).
- Relative file input paths are converted to absolute paths. - Relative file input paths are converted to absolute paths.
- New history-filter option added to define paths to be excluded from the history log feature. - New history-filter option added to define paths to be excluded from the history log feature.
- New command to move the Window to the screen edge (Alt+Arrow) or center (Alt+BS).
- libmpv shinchiro 2022-08-11
input.conf changes:
New:
```
Alt+Left script-message-to mpvnet move-window left #menu: View > Move > Left
Alt+Right script-message-to mpvnet move-window right #menu: View > Move > Right
Alt+Up script-message-to mpvnet move-window top #menu: View > Move > Top
Alt+Down script-message-to mpvnet move-window bottom #menu: View > Move > Bottom
Alt+BS script-message-to mpvnet move-window center #menu: View > Move > Center
```
# 6.0.3.1 (2022-07-30) # 6.0.3.1 (2022-07-30)

View File

@@ -241,6 +241,9 @@ Shows a file browser dialog to open external audio files.
### load-sub ### load-sub
Shows a file browser dialog to open external subtitle files. Shows a file browser dialog to open external subtitle files.
### move-window [left|top|right|bottom|center]
Moves the Window to the screen edge (Alt+Arrow) or center (Alt+BS).
### open-conf-folder ### open-conf-folder
Opens the config folder with Windows File Explorer. Opens the config folder with Windows File Explorer.

View File

@@ -28,6 +28,7 @@ namespace mpvnet
case "cycle-subtitles": CycleSubtitles(); break; case "cycle-subtitles": CycleSubtitles(); break;
case "load-audio": LoadAudio(); break; case "load-audio": LoadAudio(); break;
case "load-sub": LoadSubtitle(); break; case "load-sub": LoadSubtitle(); break;
case "move-window": MoveWindow(args[0]); break;
case "open-clipboard": OpenFromClipboard(); break; case "open-clipboard": OpenFromClipboard(); break;
case "open-conf-folder": ProcessHelp.ShellExecute(Core.ConfigFolder); break; case "open-conf-folder": ProcessHelp.ShellExecute(Core.ConfigFolder); break;
case "open-files": OpenFiles(args); break; case "open-files": OpenFiles(args); break;
@@ -759,5 +760,7 @@ namespace mpvnet
App.QuickBookmark = 0; App.QuickBookmark = 0;
} }
} }
public static void MoveWindow(string direction) => Core.RaiseMoveWindow(direction);
} }
} }

View File

@@ -63,6 +63,7 @@ namespace mpvnet
public event Action<int> PlaylistPosChangedAsync; public event Action<int> PlaylistPosChangedAsync;
public event Action<Size> VideoSizeChanged; public event Action<Size> VideoSizeChanged;
public event Action<Size> VideoSizeChangedAsync; public event Action<Size> VideoSizeChangedAsync;
public event Action<string> MoveWindow;
public Dictionary<string, List<Action>> PropChangeActions { get; set; } = new Dictionary<string, List<Action>>(); public Dictionary<string, List<Action>> PropChangeActions { get; set; } = new Dictionary<string, List<Action>>();
public Dictionary<string, List<Action<int>>> IntPropChangeActions { get; set; } = new Dictionary<string, List<Action<int>>>(); public Dictionary<string, List<Action<int>>> IntPropChangeActions { get; set; } = new Dictionary<string, List<Action<int>>>();
@@ -1465,6 +1466,8 @@ namespace mpvnet
} }
public void RaiseScaleWindow(float value) => ScaleWindow(value); public void RaiseScaleWindow(float value) => ScaleWindow(value);
public void RaiseMoveWindow(string value) => MoveWindow(value);
public void RaiseWindowScaleNET(float value) => WindowScaleNET(value); public void RaiseWindowScaleNET(float value) => WindowScaleNET(value);

View File

@@ -117,6 +117,12 @@ Alt+1 script-message-to mpvnet window-scale 1.0 #menu: View > Zoom > 100 %
Alt+2 script-message-to mpvnet window-scale 2.0 #menu: View > Zoom > 200 % Alt+2 script-message-to mpvnet window-scale 2.0 #menu: View > Zoom > 200 %
Alt+3 script-message-to mpvnet window-scale 3.0 #menu: View > Zoom > 300 % Alt+3 script-message-to mpvnet window-scale 3.0 #menu: View > Zoom > 300 %
Alt+Left script-message-to mpvnet move-window left #menu: View > Move > Left
Alt+Right script-message-to mpvnet move-window right #menu: View > Move > Right
Alt+Up script-message-to mpvnet move-window top #menu: View > Move > Top
Alt+Down script-message-to mpvnet move-window bottom #menu: View > Move > Bottom
Alt+BS script-message-to mpvnet move-window center #menu: View > Move > Center
F8 script-message-to mpvnet show-playlist #menu: View > Show Playlist F8 script-message-to mpvnet show-playlist #menu: View > Show Playlist
Ctrl+p script-message-to mpvnet select-profile #menu: View > Show Profile Selection Ctrl+p script-message-to mpvnet select-profile #menu: View > Show Profile Selection
Ctrl+P script-message-to mpvnet show-profiles #menu: View > Show Profiles Ctrl+P script-message-to mpvnet show-profiles #menu: View > Show Profiles

View File

@@ -46,6 +46,7 @@ namespace mpvnet
Instance = this; Instance = this;
Core.FileLoaded += Core_FileLoaded; Core.FileLoaded += Core_FileLoaded;
Core.MoveWindow += Core_MoveWindow;
Core.Pause += Core_Pause; Core.Pause += Core_Pause;
Core.PlaylistPosChanged += Core_PlaylistPosChanged; Core.PlaylistPosChanged += Core_PlaylistPosChanged;
Core.ScaleWindow += Core_ScaleWindow; Core.ScaleWindow += Core_ScaleWindow;
@@ -117,7 +118,35 @@ namespace mpvnet
} }
} }
private void Core_PlaylistPosChanged(int pos) void Core_MoveWindow(string direction)
{
BeginInvoke(new Action(() => {
Screen screen = Screen.FromControl(this);
Rectangle workingArea = GetWorkingArea(Handle, screen.WorkingArea);
switch (direction)
{
case "left":
Left = workingArea.Left;
break;
case "top":
Top = 0;
break;
case "right":
Left = workingArea.Width - Width + workingArea.Left;
break;
case "bottom":
Top = workingArea.Height - Height;
break;
case "center":
Left = (screen.Bounds.Width - Width) / 2;
Top = (screen.Bounds.Height - Height) / 2;
break;
}
}));
}
void Core_PlaylistPosChanged(int pos)
{ {
if (pos == -1) if (pos == -1)
SetTitle(); SetTitle();