mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
[FancyZones] Feature to create zone layouts spanning multiple monitors (#5289)
* Added the setting * Added a property to Editor Settings This will be used later * Fixed a bug in the previous commit * Simplified a method * Added snapping points to the editor * Simplified a method in ZoneSet * Updated ZoneSet testcases * Add a method to FancyZones / ZoneWindowHost * Almost works * The editor now launches, but FZ does not understand the results * Refactored some code * Snapping to a zone by dragging seems to work * Hotkeys seem to work * Refresh the work area handler after changing settings * Fixed zones not snapping to monitor edges when moved * Remove unused method in FancyZones.h * Fixed an issue with DPI awareness * Renamed setting to spanZonesAcrossMonitors * Renamed a function * Fixed a bug with the magnetic effect * Fix restoring window positions on layout changes
This commit is contained in:
@@ -259,6 +259,8 @@ namespace FancyZonesEditor
|
||||
|
||||
public static Rect WorkArea { get; private set; }
|
||||
|
||||
public static List<Rect> UsedWorkAreas { get; private set; }
|
||||
|
||||
public static string UniqueKey { get; private set; }
|
||||
|
||||
public static string ActiveZoneSetUUid { get; private set; }
|
||||
@@ -453,6 +455,7 @@ namespace FancyZonesEditor
|
||||
private void ParseCommandLineArgs()
|
||||
{
|
||||
WorkArea = SystemParameters.WorkArea;
|
||||
UsedWorkAreas = new List<Rect> { WorkArea };
|
||||
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
|
||||
@@ -470,20 +473,34 @@ namespace FancyZonesEditor
|
||||
}
|
||||
else if (args.Length == 3)
|
||||
{
|
||||
var parsedLocation = args[(int)CmdArgs.WorkAreaSize].Split('_');
|
||||
if (parsedLocation.Length != 4)
|
||||
UsedWorkAreas.Clear();
|
||||
foreach (var singleMonitorString in args[(int)CmdArgs.WorkAreaSize].Split('/'))
|
||||
{
|
||||
MessageBox.Show(ErrorInvalidArgs, ErrorMessageBoxTitle);
|
||||
((App)Application.Current).Shutdown();
|
||||
var parsedLocation = singleMonitorString.Split('_');
|
||||
if (parsedLocation.Length != 4)
|
||||
{
|
||||
MessageBox.Show(ErrorInvalidArgs, ErrorMessageBoxTitle);
|
||||
((App)Application.Current).Shutdown();
|
||||
}
|
||||
|
||||
var x = int.Parse(parsedLocation[(int)WorkAreaCmdArgElements.X]);
|
||||
var y = int.Parse(parsedLocation[(int)WorkAreaCmdArgElements.Y]);
|
||||
var width = int.Parse(parsedLocation[(int)WorkAreaCmdArgElements.Width]);
|
||||
var height = int.Parse(parsedLocation[(int)WorkAreaCmdArgElements.Height]);
|
||||
|
||||
Rect thisMonitor = new Rect(x, y, width, height);
|
||||
if (UsedWorkAreas.Count == 0)
|
||||
{
|
||||
WorkArea = thisMonitor;
|
||||
}
|
||||
else
|
||||
{
|
||||
WorkArea = Rect.Union(WorkArea, thisMonitor);
|
||||
}
|
||||
|
||||
UsedWorkAreas.Add(thisMonitor);
|
||||
}
|
||||
|
||||
var x = int.Parse(parsedLocation[(int)WorkAreaCmdArgElements.X]);
|
||||
var y = int.Parse(parsedLocation[(int)WorkAreaCmdArgElements.Y]);
|
||||
var width = int.Parse(parsedLocation[(int)WorkAreaCmdArgElements.Width]);
|
||||
var height = int.Parse(parsedLocation[(int)WorkAreaCmdArgElements.Height]);
|
||||
|
||||
WorkArea = new Rect(x, y, width, height);
|
||||
|
||||
int.TryParse(args[(int)CmdArgs.PowerToysPID], out _powerToysPID);
|
||||
ParseDeviceInfoData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user