Skip to content

Commit

Permalink
Cleanup Editor cmd args (#4022)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansjfw committed Jun 4, 2020
1 parent f5dc197 commit 2b62244
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
1 change: 0 additions & 1 deletion src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Windows;
using FancyZonesEditor.Models;

Expand Down
18 changes: 2 additions & 16 deletions src/modules/fancyzones/editor/FancyZonesEditor/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ public class Settings : INotifyPropertyChanged
{
private enum CmdArgs
{
MonitorHandle = 1,
X_Y_Width_Height,
ResolutionKey,
X_Y_Width_Height = 1,
ActiveZoneSetTmpFile,
AppliedZoneSetTmpFile,
CustomZoneSetsTmpFile,
Expand Down Expand Up @@ -217,8 +215,6 @@ public bool IsCtrlKeyPressed

public static Rect WorkArea { get; private set; }

public static uint Monitor { get; private set; }

public static string UniqueKey { get; private set; }

public static string ActiveZoneSetUUid { get; private set; }
Expand Down Expand Up @@ -246,8 +242,6 @@ public static string CustomZoneSetsTmpFile

private static string _customZoneSetsTmpFile;

public static string WorkAreaKey { get; private set; }

// UpdateLayoutModels
// Update the five default layouts based on the new ZoneCount
private void UpdateLayoutModels()
Expand Down Expand Up @@ -414,16 +408,10 @@ private void ParseDeviceInfoData()
private void ParseCommandLineArgs()
{
WorkArea = SystemParameters.WorkArea;
Monitor = 0;

string[] args = Environment.GetCommandLineArgs();
if (args.Length == 7)
if (args.Length == 5)
{
if (uint.TryParse(args[(int)CmdArgs.MonitorHandle], out uint monitor))
{
Monitor = monitor;
}

var parsedLocation = args[(int)CmdArgs.X_Y_Width_Height].Split('_');
var x = int.Parse(parsedLocation[0]);
var y = int.Parse(parsedLocation[1]);
Expand All @@ -432,8 +420,6 @@ private void ParseCommandLineArgs()

WorkArea = new Rect(x, y, width, height);

WorkAreaKey = args[(int)CmdArgs.ResolutionKey];

_activeZoneSetTmpFile = args[(int)CmdArgs.ActiveZoneSetTmpFile];
_appliedZoneSetTmpFile = args[(int)CmdArgs.AppliedZoneSetTmpFile];
_customZoneSetsTmpFile = args[(int)CmdArgs.CustomZoneSetsTmpFile];
Expand Down
16 changes: 7 additions & 9 deletions src/modules/fancyzones/lib/FancyZones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,6 @@ void FancyZones::ToggleEditor() noexcept
} })
.wait();

const auto& fancyZonesData = JSONHelpers::FancyZonesDataInstance();
fancyZonesData.CustomZoneSetsToJsonFile(ZoneWindowUtils::GetCustomZoneSetsTmpPath());

const auto taskbar_x_offset = mi.rcWork.left - mi.rcMonitor.left;
const auto taskbar_y_offset = mi.rcWork.top - mi.rcMonitor.top;
const auto x = mi.rcMonitor.left + taskbar_x_offset;
Expand All @@ -460,6 +457,9 @@ void FancyZones::ToggleEditor() noexcept
std::to_wstring(width) + L"_" +
std::to_wstring(height);

const auto& fancyZonesData = JSONHelpers::FancyZonesDataInstance();
fancyZonesData.CustomZoneSetsToJsonFile(ZoneWindowUtils::GetCustomZoneSetsTmpPath());

const auto deviceInfo = fancyZonesData.FindDeviceInfo(zoneWindow->UniqueId());
if (!deviceInfo.has_value())
{
Expand All @@ -470,12 +470,10 @@ void FancyZones::ToggleEditor() noexcept
fancyZonesData.SerializeDeviceInfoToTmpFile(deviceInfoJson, ZoneWindowUtils::GetActiveZoneSetTmpPath());

const std::wstring params =
/*1*/ std::to_wstring(reinterpret_cast<UINT_PTR>(monitor)) + L" " +
/*2*/ editorLocation + L" " +
/*3*/ zoneWindow->WorkAreaKey() + L" " +
/*4*/ L"\"" + ZoneWindowUtils::GetActiveZoneSetTmpPath() + L"\" " +
/*5*/ L"\"" + ZoneWindowUtils::GetAppliedZoneSetTmpPath() + L"\" " +
/*6*/ L"\"" + ZoneWindowUtils::GetCustomZoneSetsTmpPath() + L"\"";
/*1*/ editorLocation + L" " +
/*2*/ L"\"" + ZoneWindowUtils::GetActiveZoneSetTmpPath() + L"\" " +
/*3*/ L"\"" + ZoneWindowUtils::GetAppliedZoneSetTmpPath() + L"\" " +
/*4*/ L"\"" + ZoneWindowUtils::GetCustomZoneSetsTmpPath() + L"\"";

SHELLEXECUTEINFO sei{ sizeof(sei) };
sei.fMask = { SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI };
Expand Down

0 comments on commit 2b62244

Please sign in to comment.