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

@@ -28,6 +28,7 @@ namespace mpvnet
case "cycle-subtitles": CycleSubtitles(); break;
case "load-audio": LoadAudio(); break;
case "load-sub": LoadSubtitle(); break;
case "move-window": MoveWindow(args[0]); break;
case "open-clipboard": OpenFromClipboard(); break;
case "open-conf-folder": ProcessHelp.ShellExecute(Core.ConfigFolder); break;
case "open-files": OpenFiles(args); break;
@@ -759,5 +760,7 @@ namespace mpvnet
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<Size> VideoSizeChanged;
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<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 RaiseMoveWindow(string value) => MoveWindow(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+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
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

View File

@@ -46,6 +46,7 @@ namespace mpvnet
Instance = this;
Core.FileLoaded += Core_FileLoaded;
Core.MoveWindow += Core_MoveWindow;
Core.Pause += Core_Pause;
Core.PlaylistPosChanged += Core_PlaylistPosChanged;
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)
SetTitle();