mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 05:06:36 +02:00
move data to the common project
This commit is contained in:
@@ -572,6 +572,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests-FancyZones", "src\m
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests-FancyZonesEditor", "src\modules\fancyzones\UITests-FancyZonesEditor\UITests-FancyZonesEditor.csproj", "{3A9A791E-94A9-49F8-8401-C11CE288D5FB}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests-FancyZonesEditor", "src\modules\fancyzones\UITests-FancyZonesEditor\UITests-FancyZonesEditor.csproj", "{3A9A791E-94A9-49F8-8401-C11CE288D5FB}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FancyZonesEditorCommon", "src\modules\fancyzones\FancyZonesEditorCommon\FancyZonesEditorCommon.csproj", "{C0974915-8A1D-4BF0-977B-9587D3807AB7}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|ARM64 = Debug|ARM64
|
Debug|ARM64 = Debug|ARM64
|
||||||
@@ -2522,6 +2524,18 @@ Global
|
|||||||
{3A9A791E-94A9-49F8-8401-C11CE288D5FB}.Release|x64.Build.0 = Release|x64
|
{3A9A791E-94A9-49F8-8401-C11CE288D5FB}.Release|x64.Build.0 = Release|x64
|
||||||
{3A9A791E-94A9-49F8-8401-C11CE288D5FB}.Release|x86.ActiveCfg = Release|x64
|
{3A9A791E-94A9-49F8-8401-C11CE288D5FB}.Release|x86.ActiveCfg = Release|x64
|
||||||
{3A9A791E-94A9-49F8-8401-C11CE288D5FB}.Release|x86.Build.0 = Release|x64
|
{3A9A791E-94A9-49F8-8401-C11CE288D5FB}.Release|x86.Build.0 = Release|x64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Debug|x86.ActiveCfg = Debug|x64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Debug|x86.Build.0 = Debug|x64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Release|ARM64.Build.0 = Release|ARM64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Release|x64.Build.0 = Release|x64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Release|x86.ActiveCfg = Release|x64
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7}.Release|x86.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -2733,6 +2747,7 @@ Global
|
|||||||
{9D52FD25-EF90-4F9A-A015-91EFC5DAF54F} = {AB82E5DD-C32D-4F28-9746-2C780846188E}
|
{9D52FD25-EF90-4F9A-A015-91EFC5DAF54F} = {AB82E5DD-C32D-4F28-9746-2C780846188E}
|
||||||
{FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
|
{FE38FC07-1C05-4B57-ADA3-2FE2F53C6A52} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
|
||||||
{3A9A791E-94A9-49F8-8401-C11CE288D5FB} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
|
{3A9A791E-94A9-49F8-8401-C11CE288D5FB} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
|
||||||
|
{C0974915-8A1D-4BF0-977B-9587D3807AB7} = {D1D6BC88-09AE-4FB4-AD24-5DED46A791DD}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
|
||||||
|
namespace FancyZonesEditorCommon.Data
|
||||||
|
{
|
||||||
|
public class AppliedLayouts : EditorData<AppliedLayouts.AppliedLayoutsListWrapper>
|
||||||
|
{
|
||||||
|
public string File
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetDataFolder() + "\\Microsoft\\PowerToys\\FancyZones\\applied-layouts.json";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct AppliedLayoutWrapper
|
||||||
|
{
|
||||||
|
public struct DeviceIdWrapper
|
||||||
|
{
|
||||||
|
public string Monitor { get; set; }
|
||||||
|
|
||||||
|
public string MonitorInstance { get; set; }
|
||||||
|
|
||||||
|
public int MonitorNumber { get; set; }
|
||||||
|
|
||||||
|
public string SerialNumber { get; set; }
|
||||||
|
|
||||||
|
public string VirtualDesktop { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct LayoutWrapper
|
||||||
|
{
|
||||||
|
public string Uuid { get; set; }
|
||||||
|
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
public bool ShowSpacing { get; set; }
|
||||||
|
|
||||||
|
public int Spacing { get; set; }
|
||||||
|
|
||||||
|
public int ZoneCount { get; set; }
|
||||||
|
|
||||||
|
public int SensitivityRadius { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceIdWrapper Device { get; set; }
|
||||||
|
|
||||||
|
public LayoutWrapper AppliedLayout { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct AppliedLayoutsListWrapper
|
||||||
|
{
|
||||||
|
public List<AppliedLayoutWrapper> AppliedLayouts { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using System.Text.Json;
|
||||||
|
using static FancyZonesEditorCommon.Data.CustomLayouts;
|
||||||
|
|
||||||
|
namespace FancyZonesEditorCommon.Data
|
||||||
|
{
|
||||||
|
public class CustomLayouts : EditorData<CustomLayoutListWrapper>
|
||||||
|
{
|
||||||
|
public string File
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetDataFolder() + "\\Microsoft\\PowerToys\\FancyZones\\custom-layouts.json";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class CanvasInfoWrapper
|
||||||
|
{
|
||||||
|
public struct CanvasZoneWrapper
|
||||||
|
{
|
||||||
|
public int X { get; set; }
|
||||||
|
|
||||||
|
public int Y { get; set; }
|
||||||
|
|
||||||
|
public int Width { get; set; }
|
||||||
|
|
||||||
|
public int Height { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int RefWidth { get; set; }
|
||||||
|
|
||||||
|
public int RefHeight { get; set; }
|
||||||
|
|
||||||
|
public List<CanvasZoneWrapper> Zones { get; set; }
|
||||||
|
|
||||||
|
public int SensitivityRadius { get; set; } = LayoutDefaultSettings.DefaultSensitivityRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class GridInfoWrapper
|
||||||
|
{
|
||||||
|
public int Rows { get; set; }
|
||||||
|
|
||||||
|
public int Columns { get; set; }
|
||||||
|
|
||||||
|
public List<int> RowsPercentage { get; set; }
|
||||||
|
|
||||||
|
public List<int> ColumnsPercentage { get; set; }
|
||||||
|
|
||||||
|
public int[][] CellChildMap { get; set; }
|
||||||
|
|
||||||
|
public bool ShowSpacing { get; set; } = LayoutDefaultSettings.DefaultShowSpacing;
|
||||||
|
|
||||||
|
public int Spacing { get; set; } = LayoutDefaultSettings.DefaultSpacing;
|
||||||
|
|
||||||
|
public int SensitivityRadius { get; set; } = LayoutDefaultSettings.DefaultSensitivityRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct CustomLayoutWrapper
|
||||||
|
{
|
||||||
|
public string Uuid { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
public JsonElement Info { get; set; } // CanvasInfoWrapper or GridInfoWrapper
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct CustomLayoutListWrapper
|
||||||
|
{
|
||||||
|
public List<CustomLayoutWrapper> CustomLayouts { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement ToJsonElement(CanvasInfoWrapper info)
|
||||||
|
{
|
||||||
|
string json = JsonSerializer.Serialize(info, this.JsonOptions);
|
||||||
|
return JsonSerializer.Deserialize<JsonElement>(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement ToJsonElement(GridInfoWrapper info)
|
||||||
|
{
|
||||||
|
string json = JsonSerializer.Serialize(info, this.JsonOptions);
|
||||||
|
return JsonSerializer.Deserialize<JsonElement>(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CanvasInfoWrapper CanvasFromJsonElement(string json)
|
||||||
|
{
|
||||||
|
return JsonSerializer.Deserialize<CanvasInfoWrapper>(json, this.JsonOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GridInfoWrapper GridFromJsonElement(string json)
|
||||||
|
{
|
||||||
|
return JsonSerializer.Deserialize<GridInfoWrapper>(json, this.JsonOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using static FancyZonesEditorCommon.Data.DefaultLayouts;
|
||||||
|
|
||||||
|
namespace FancyZonesEditorCommon.Data
|
||||||
|
{
|
||||||
|
public class DefaultLayouts : EditorData<DefaultLayoutsListWrapper>
|
||||||
|
{
|
||||||
|
public string File
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetDataFolder() + "\\Microsoft\\PowerToys\\FancyZones\\default-layouts.json";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct DefaultLayoutWrapper
|
||||||
|
{
|
||||||
|
public struct LayoutWrapper
|
||||||
|
{
|
||||||
|
public string Uuid { get; set; }
|
||||||
|
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
public bool ShowSpacing { get; set; }
|
||||||
|
|
||||||
|
public int Spacing { get; set; }
|
||||||
|
|
||||||
|
public int ZoneCount { get; set; }
|
||||||
|
|
||||||
|
public int SensitivityRadius { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string MonitorConfiguration { get; set; }
|
||||||
|
|
||||||
|
public LayoutWrapper Layout { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct DefaultLayoutsListWrapper
|
||||||
|
{
|
||||||
|
public List<DefaultLayoutWrapper> DefaultLayouts { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,12 +4,16 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using FancyZonesEditorCommon.Utils;
|
||||||
|
|
||||||
namespace FancyZonesEditor.Data
|
namespace FancyZonesEditorCommon.Data
|
||||||
{
|
{
|
||||||
public class EditorData
|
public class EditorData<T>
|
||||||
{
|
{
|
||||||
protected string File { get; set; }
|
public string GetDataFolder()
|
||||||
|
{
|
||||||
|
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||||
|
}
|
||||||
|
|
||||||
protected JsonSerializerOptions JsonOptions
|
protected JsonSerializerOptions JsonOptions
|
||||||
{
|
{
|
||||||
@@ -23,9 +27,16 @@ namespace FancyZonesEditor.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetDataFolder()
|
public T Read(string file)
|
||||||
{
|
{
|
||||||
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
IOUtils ioUtils = new IOUtils();
|
||||||
|
string data = ioUtils.ReadFile(file);
|
||||||
|
return JsonSerializer.Deserialize<T>(data, JsonOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Serialize(T data)
|
||||||
|
{
|
||||||
|
return JsonSerializer.Serialize(data, JsonOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FancyZonesEditorCommon.Data
|
||||||
|
{
|
||||||
|
public class EditorParameters : EditorData<EditorParameters.ParamsWrapper>
|
||||||
|
{
|
||||||
|
public string File
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetDataFolder() + "\\Microsoft\\PowerToys\\FancyZones\\editor-parameters.json";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct NativeMonitorDataWrapper
|
||||||
|
{
|
||||||
|
public string Monitor { get; set; }
|
||||||
|
|
||||||
|
public string MonitorInstanceId { get; set; }
|
||||||
|
|
||||||
|
public string MonitorSerialNumber { get; set; }
|
||||||
|
|
||||||
|
public int MonitorNumber { get; set; }
|
||||||
|
|
||||||
|
public string VirtualDesktop { get; set; }
|
||||||
|
|
||||||
|
public int Dpi { get; set; }
|
||||||
|
|
||||||
|
public int LeftCoordinate { get; set; }
|
||||||
|
|
||||||
|
public int TopCoordinate { get; set; }
|
||||||
|
|
||||||
|
public int WorkAreaWidth { get; set; }
|
||||||
|
|
||||||
|
public int WorkAreaHeight { get; set; }
|
||||||
|
|
||||||
|
public int MonitorWidth { get; set; }
|
||||||
|
|
||||||
|
public int MonitorHeight { get; set; }
|
||||||
|
|
||||||
|
public bool IsSelected { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
// using CultureInfo.InvariantCulture since this is internal data
|
||||||
|
sb.Append("Monitor: ");
|
||||||
|
sb.AppendLine(Monitor);
|
||||||
|
sb.Append("Virtual desktop: ");
|
||||||
|
sb.AppendLine(VirtualDesktop);
|
||||||
|
sb.Append("DPI: ");
|
||||||
|
sb.AppendLine(Dpi.ToString(CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
|
sb.Append("X: ");
|
||||||
|
sb.AppendLine(LeftCoordinate.ToString(CultureInfo.InvariantCulture));
|
||||||
|
sb.Append("Y: ");
|
||||||
|
sb.AppendLine(TopCoordinate.ToString(CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
|
sb.Append("Width: ");
|
||||||
|
sb.AppendLine(MonitorWidth.ToString(CultureInfo.InvariantCulture));
|
||||||
|
sb.Append("Height: ");
|
||||||
|
sb.AppendLine(MonitorHeight.ToString(CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ParamsWrapper
|
||||||
|
{
|
||||||
|
public int ProcessId { get; set; }
|
||||||
|
|
||||||
|
public bool SpanZonesAcrossMonitors { get; set; }
|
||||||
|
|
||||||
|
public List<NativeMonitorDataWrapper> Monitors { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public EditorParameters()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
namespace FancyZonesEditorCommon.Data
|
||||||
|
{
|
||||||
|
public class LayoutDefaultSettings
|
||||||
|
{
|
||||||
|
// TODO: share the constants b/w C# Editor and FancyZoneLib
|
||||||
|
public const bool DefaultShowSpacing = true;
|
||||||
|
|
||||||
|
public const int DefaultSpacing = 16;
|
||||||
|
|
||||||
|
public const int DefaultZoneCount = 3;
|
||||||
|
|
||||||
|
public const int DefaultSensitivityRadius = 20;
|
||||||
|
|
||||||
|
public const int MaxZones = 128;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using static FancyZonesEditorCommon.Data.LayoutHotkeys;
|
||||||
|
|
||||||
|
namespace FancyZonesEditorCommon.Data
|
||||||
|
{
|
||||||
|
public class LayoutHotkeys : EditorData<LayoutHotkeysWrapper>
|
||||||
|
{
|
||||||
|
public string File
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetDataFolder() + "\\Microsoft\\PowerToys\\FancyZones\\layout-hotkeys.json";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct LayoutHotkeyWrapper
|
||||||
|
{
|
||||||
|
public int Key { get; set; }
|
||||||
|
|
||||||
|
public string LayoutId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct LayoutHotkeysWrapper
|
||||||
|
{
|
||||||
|
public List<LayoutHotkeyWrapper> LayoutHotkeys { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using static FancyZonesEditorCommon.Data.LayoutTemplates;
|
||||||
|
|
||||||
|
namespace FancyZonesEditorCommon.Data
|
||||||
|
{
|
||||||
|
public class LayoutTemplates : EditorData<TemplateLayoutsListWrapper>
|
||||||
|
{
|
||||||
|
public string File
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetDataFolder() + "\\Microsoft\\PowerToys\\FancyZones\\layout-templates.json";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct TemplateLayoutWrapper
|
||||||
|
{
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
public bool ShowSpacing { get; set; }
|
||||||
|
|
||||||
|
public int Spacing { get; set; }
|
||||||
|
|
||||||
|
public int ZoneCount { get; set; }
|
||||||
|
|
||||||
|
public int SensitivityRadius { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct TemplateLayoutsListWrapper
|
||||||
|
{
|
||||||
|
public List<TemplateLayoutWrapper> LayoutTemplates { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<Import Project="..\..\..\Version.props" />
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0-windows</TargetFramework>
|
||||||
|
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
||||||
|
<Version>$(Version).0</Version>
|
||||||
|
<Authors>Microsoft Corporation</Authors>
|
||||||
|
<Product>PowerToys</Product>
|
||||||
|
<Description>PowerToys FancyZonesEditorCommon</Description>
|
||||||
|
<AssemblyName>PowerToys.FancyZonesEditorCommon</AssemblyName>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.IO.Abstractions" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\FancyZonesEditorCommon\</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
using FancyZonesEditor.Utils;
|
namespace FancyZonesEditorCommon.Utils
|
||||||
|
|
||||||
namespace FancyZonesEditor
|
|
||||||
{
|
{
|
||||||
public class DashCaseNamingPolicy : JsonNamingPolicy
|
public class DashCaseNamingPolicy : JsonNamingPolicy
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// 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.IO;
|
||||||
|
using System.IO.Abstractions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FancyZonesEditorCommon.Utils
|
||||||
|
{
|
||||||
|
public class IOUtils
|
||||||
|
{
|
||||||
|
private readonly IFileSystem _fileSystem = new FileSystem();
|
||||||
|
|
||||||
|
public IOUtils()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteFile(string fileName, string data)
|
||||||
|
{
|
||||||
|
_fileSystem.File.WriteAllText(fileName, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ReadFile(string fileName)
|
||||||
|
{
|
||||||
|
if (_fileSystem.File.Exists(fileName))
|
||||||
|
{
|
||||||
|
var attempts = 0;
|
||||||
|
while (attempts < 10)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (Stream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
|
||||||
|
using (StreamReader reader = new StreamReader(inputStream))
|
||||||
|
{
|
||||||
|
string data = reader.ReadToEnd();
|
||||||
|
inputStream.Close();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Task.Delay(10).Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
attempts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace FancyZonesEditor.Utils
|
namespace FancyZonesEditorCommon.Utils
|
||||||
{
|
{
|
||||||
public static class StringUtils
|
public static class StringUtils
|
||||||
{
|
{
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
// Copyright (c) Microsoft Corporation
|
|
||||||
// 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.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Windows;
|
|
||||||
using FancyZonesEditor.Models;
|
|
||||||
using FancyZonesEditor.Utils;
|
|
||||||
using Microsoft.FancyZonesEditor.UITests.Utils;
|
|
||||||
|
|
||||||
namespace FancyZonesEditor.Data
|
|
||||||
{
|
|
||||||
public class EditorParameters : EditorData
|
|
||||||
{
|
|
||||||
protected struct NativeMonitorData
|
|
||||||
{
|
|
||||||
public string Monitor { get; set; }
|
|
||||||
|
|
||||||
public string MonitorInstanceId { get; set; }
|
|
||||||
|
|
||||||
public string MonitorSerialNumber { get; set; }
|
|
||||||
|
|
||||||
public int MonitorNumber { get; set; }
|
|
||||||
|
|
||||||
public string VirtualDesktop { get; set; }
|
|
||||||
|
|
||||||
public int Dpi { get; set; }
|
|
||||||
|
|
||||||
public int LeftCoordinate { get; set; }
|
|
||||||
|
|
||||||
public int TopCoordinate { get; set; }
|
|
||||||
|
|
||||||
public int WorkAreaWidth { get; set; }
|
|
||||||
|
|
||||||
public int WorkAreaHeight { get; set; }
|
|
||||||
|
|
||||||
public int MonitorWidth { get; set; }
|
|
||||||
|
|
||||||
public int MonitorHeight { get; set; }
|
|
||||||
|
|
||||||
public bool IsSelected { get; set; }
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
|
|
||||||
// using CultureInfo.InvariantCulture since this is internal data
|
|
||||||
sb.Append("Monitor: ");
|
|
||||||
sb.AppendLine(Monitor);
|
|
||||||
sb.Append("Virtual desktop: ");
|
|
||||||
sb.AppendLine(VirtualDesktop);
|
|
||||||
sb.Append("DPI: ");
|
|
||||||
sb.AppendLine(Dpi.ToString(CultureInfo.InvariantCulture));
|
|
||||||
|
|
||||||
sb.Append("X: ");
|
|
||||||
sb.AppendLine(LeftCoordinate.ToString(CultureInfo.InvariantCulture));
|
|
||||||
sb.Append("Y: ");
|
|
||||||
sb.AppendLine(TopCoordinate.ToString(CultureInfo.InvariantCulture));
|
|
||||||
|
|
||||||
sb.Append("Width: ");
|
|
||||||
sb.AppendLine(MonitorWidth.ToString(CultureInfo.InvariantCulture));
|
|
||||||
sb.Append("Height: ");
|
|
||||||
sb.AppendLine(MonitorHeight.ToString(CultureInfo.InvariantCulture));
|
|
||||||
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected struct EditorParams
|
|
||||||
{
|
|
||||||
public int ProcessId { get; set; }
|
|
||||||
|
|
||||||
public bool SpanZonesAcrossMonitors { get; set; }
|
|
||||||
|
|
||||||
public List<NativeMonitorData> Monitors { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public EditorParameters()
|
|
||||||
: base()
|
|
||||||
{
|
|
||||||
File = GetDataFolder() + "\\Microsoft\\PowerToys\\FancyZones\\editor-parameters.json";
|
|
||||||
}
|
|
||||||
|
|
||||||
public ParsingResult Parse()
|
|
||||||
{
|
|
||||||
IOHelper ioHelper = new IOHelper();
|
|
||||||
string data = ioHelper.ReadFile(File);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
EditorParams editorParams = JsonSerializer.Deserialize<EditorParams>(data, JsonOptions);
|
|
||||||
|
|
||||||
// Process ID
|
|
||||||
App.PowerToysPID = editorParams.ProcessId;
|
|
||||||
|
|
||||||
// Span zones across monitors
|
|
||||||
App.Overlay.SpanZonesAcrossMonitors = editorParams.SpanZonesAcrossMonitors;
|
|
||||||
|
|
||||||
if (!App.Overlay.SpanZonesAcrossMonitors)
|
|
||||||
{
|
|
||||||
string targetMonitorId = string.Empty;
|
|
||||||
string targetMonitorSerialNumber = string.Empty;
|
|
||||||
string targetVirtualDesktop = string.Empty;
|
|
||||||
int targetMonitorNumber = 0;
|
|
||||||
|
|
||||||
foreach (NativeMonitorData nativeData in editorParams.Monitors)
|
|
||||||
{
|
|
||||||
Rect workArea = new Rect(nativeData.LeftCoordinate, nativeData.TopCoordinate, nativeData.WorkAreaWidth, nativeData.WorkAreaHeight);
|
|
||||||
if (nativeData.IsSelected)
|
|
||||||
{
|
|
||||||
targetMonitorId = nativeData.Monitor;
|
|
||||||
targetMonitorSerialNumber = nativeData.MonitorSerialNumber;
|
|
||||||
targetMonitorNumber = nativeData.MonitorNumber;
|
|
||||||
targetVirtualDesktop = nativeData.VirtualDesktop;
|
|
||||||
}
|
|
||||||
|
|
||||||
Size monitorSize = new Size(nativeData.MonitorWidth, nativeData.MonitorHeight);
|
|
||||||
|
|
||||||
var monitor = new Monitor(workArea, monitorSize);
|
|
||||||
monitor.Device.MonitorName = nativeData.Monitor;
|
|
||||||
monitor.Device.MonitorInstanceId = nativeData.MonitorInstanceId;
|
|
||||||
monitor.Device.MonitorSerialNumber = nativeData.MonitorSerialNumber;
|
|
||||||
monitor.Device.MonitorNumber = nativeData.MonitorNumber;
|
|
||||||
monitor.Device.VirtualDesktopId = nativeData.VirtualDesktop;
|
|
||||||
monitor.Device.Dpi = nativeData.Dpi;
|
|
||||||
|
|
||||||
App.Overlay.AddMonitor(monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set active desktop
|
|
||||||
var monitors = App.Overlay.Monitors;
|
|
||||||
for (int i = 0; i < monitors.Count; i++)
|
|
||||||
{
|
|
||||||
var monitor = monitors[i];
|
|
||||||
if (monitor.Device.MonitorName == targetMonitorId &&
|
|
||||||
monitor.Device.MonitorSerialNumber == targetMonitorSerialNumber &&
|
|
||||||
monitor.Device.MonitorNumber == targetMonitorNumber &&
|
|
||||||
monitor.Device.VirtualDesktopId == targetVirtualDesktop)
|
|
||||||
{
|
|
||||||
App.Overlay.CurrentDesktop = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (editorParams.Monitors.Count != 1)
|
|
||||||
{
|
|
||||||
return new ParsingResult(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
var nativeData = editorParams.Monitors[0];
|
|
||||||
Rect workArea = new Rect(nativeData.LeftCoordinate, nativeData.TopCoordinate, nativeData.WorkAreaWidth, nativeData.WorkAreaHeight);
|
|
||||||
Size monitorSize = new Size(nativeData.MonitorWidth, nativeData.MonitorHeight);
|
|
||||||
|
|
||||||
var monitor = new Monitor(workArea, monitorSize);
|
|
||||||
monitor.Device.MonitorName = nativeData.Monitor;
|
|
||||||
monitor.Device.MonitorInstanceId = nativeData.MonitorInstanceId;
|
|
||||||
monitor.Device.MonitorSerialNumber = nativeData.MonitorSerialNumber;
|
|
||||||
monitor.Device.MonitorNumber = nativeData.MonitorNumber;
|
|
||||||
monitor.Device.VirtualDesktopId = nativeData.VirtualDesktop;
|
|
||||||
|
|
||||||
App.Overlay.AddMonitor(monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return new ParsingResult(false, ex.Message, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ParsingResult(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -69,6 +69,7 @@
|
|||||||
<ProjectReference Include="..\..\..\..\common\interop\PowerToys.Interop.vcxproj" />
|
<ProjectReference Include="..\..\..\..\common\interop\PowerToys.Interop.vcxproj" />
|
||||||
<ProjectReference Include="..\..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
<ProjectReference Include="..\..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
|
||||||
<ProjectReference Include="..\..\..\..\common\Common.UI\Common.UI.csproj" />
|
<ProjectReference Include="..\..\..\..\common\Common.UI\Common.UI.csproj" />
|
||||||
|
<ProjectReference Include="..\..\FancyZonesEditorCommon\FancyZonesEditorCommon.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using FancyZonesEditorCommon.Data;
|
||||||
|
|
||||||
namespace FancyZonesEditor.Models
|
namespace FancyZonesEditor.Models
|
||||||
{
|
{
|
||||||
@@ -99,7 +100,7 @@ namespace FancyZonesEditor.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _showSpacing = LayoutSettings.DefaultShowSpacing;
|
private bool _showSpacing = LayoutDefaultSettings.DefaultShowSpacing;
|
||||||
|
|
||||||
// Spacing - free space between cells
|
// Spacing - free space between cells
|
||||||
public int Spacing
|
public int Spacing
|
||||||
@@ -129,7 +130,7 @@ namespace FancyZonesEditor.Models
|
|||||||
get { return 1000; }
|
get { return 1000; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _spacing = LayoutSettings.DefaultSpacing;
|
private int _spacing = LayoutDefaultSettings.DefaultSpacing;
|
||||||
|
|
||||||
public GridLayoutModel()
|
public GridLayoutModel()
|
||||||
: base()
|
: base()
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using FancyZonesEditorCommon.Data;
|
||||||
|
|
||||||
namespace FancyZonesEditor.Models
|
namespace FancyZonesEditor.Models
|
||||||
{
|
{
|
||||||
@@ -195,7 +196,7 @@ namespace FancyZonesEditor.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _sensitivityRadius = LayoutSettings.DefaultSensitivityRadius;
|
private int _sensitivityRadius = LayoutDefaultSettings.DefaultSensitivityRadius;
|
||||||
|
|
||||||
public int SensitivityRadiusMinimum
|
public int SensitivityRadiusMinimum
|
||||||
{
|
{
|
||||||
@@ -304,13 +305,13 @@ namespace FancyZonesEditor.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _zoneCount = LayoutSettings.DefaultZoneCount;
|
private int _zoneCount = LayoutDefaultSettings.DefaultZoneCount;
|
||||||
|
|
||||||
public bool IsZoneAddingAllowed
|
public bool IsZoneAddingAllowed
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return TemplateZoneCount < LayoutSettings.MaxZones;
|
return TemplateZoneCount < LayoutDefaultSettings.MaxZones;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,32 +3,22 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using FancyZonesEditor.Models;
|
using FancyZonesEditor.Models;
|
||||||
|
using FancyZonesEditorCommon.Data;
|
||||||
|
|
||||||
namespace FancyZonesEditor
|
namespace FancyZonesEditor
|
||||||
{
|
{
|
||||||
public class LayoutSettings
|
public class LayoutSettings
|
||||||
{
|
{
|
||||||
// TODO: share the constants b/w C# Editor and FancyZoneLib
|
|
||||||
public const bool DefaultShowSpacing = true;
|
|
||||||
|
|
||||||
public const int DefaultSpacing = 16;
|
|
||||||
|
|
||||||
public const int DefaultZoneCount = 3;
|
|
||||||
|
|
||||||
public const int DefaultSensitivityRadius = 20;
|
|
||||||
|
|
||||||
public const int MaxZones = 128;
|
|
||||||
|
|
||||||
public string ZonesetUuid { get; set; } = string.Empty;
|
public string ZonesetUuid { get; set; } = string.Empty;
|
||||||
|
|
||||||
public LayoutType Type { get; set; } = LayoutType.PriorityGrid;
|
public LayoutType Type { get; set; } = LayoutType.PriorityGrid;
|
||||||
|
|
||||||
public bool ShowSpacing { get; set; } = DefaultShowSpacing;
|
public bool ShowSpacing { get; set; } = LayoutDefaultSettings.DefaultShowSpacing;
|
||||||
|
|
||||||
public int Spacing { get; set; } = DefaultSpacing;
|
public int Spacing { get; set; } = LayoutDefaultSettings.DefaultSpacing;
|
||||||
|
|
||||||
public int ZoneCount { get; set; } = DefaultZoneCount;
|
public int ZoneCount { get; set; } = LayoutDefaultSettings.DefaultZoneCount;
|
||||||
|
|
||||||
public int SensitivityRadius { get; set; } = DefaultSensitivityRadius;
|
public int SensitivityRadius { get; set; } = LayoutDefaultSettings.DefaultSensitivityRadius;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -487,6 +487,15 @@ namespace FancyZonesEditor.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to An error occurred while parsing editor parameters..
|
||||||
|
/// </summary>
|
||||||
|
public static string Error_Parsing_Editor_Parameters_Message {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Error_Parsing_Editor_Parameters_Message", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to An error occurred while parsing layout hotkeys..
|
/// Looks up a localized string similar to An error occurred while parsing layout hotkeys..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -435,4 +435,7 @@
|
|||||||
<data name="Set_Layout_As_Vertical_Default" xml:space="preserve">
|
<data name="Set_Layout_As_Vertical_Default" xml:space="preserve">
|
||||||
<value>Set layout as a default for vertical monitor orientation</value>
|
<value>Set layout as a default for vertical monitor orientation</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Error_Parsing_Editor_Parameters_Message" xml:space="preserve">
|
||||||
|
<value>An error occurred while parsing editor parameters.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -6,13 +6,11 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
|
||||||
using System.IO.Abstractions;
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using FancyZonesEditor.Data;
|
|
||||||
using FancyZonesEditor.Models;
|
using FancyZonesEditor.Models;
|
||||||
|
using FancyZonesEditorCommon.Data;
|
||||||
|
using FancyZonesEditorCommon.Utils;
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
|
|
||||||
namespace FancyZonesEditor.Utils
|
namespace FancyZonesEditor.Utils
|
||||||
@@ -30,233 +28,103 @@ namespace FancyZonesEditor.Utils
|
|||||||
private const string HorizontalJsonTag = "horizontal";
|
private const string HorizontalJsonTag = "horizontal";
|
||||||
private const string VerticalJsonTag = "vertical";
|
private const string VerticalJsonTag = "vertical";
|
||||||
|
|
||||||
// Non-localizable strings: Files
|
|
||||||
private const string AppliedLayoutsFile = "\\Microsoft\\PowerToys\\FancyZones\\applied-layouts.json";
|
|
||||||
private const string LayoutHotkeysFile = "\\Microsoft\\PowerToys\\FancyZones\\layout-hotkeys.json";
|
|
||||||
private const string LayoutTemplatesFile = "\\Microsoft\\PowerToys\\FancyZones\\layout-templates.json";
|
|
||||||
private const string CustomLayoutsFile = "\\Microsoft\\PowerToys\\FancyZones\\custom-layouts.json";
|
|
||||||
private const string DefaultLayoutsFile = "\\Microsoft\\PowerToys\\FancyZones\\default-layouts.json";
|
|
||||||
|
|
||||||
// Non-localizable string: default virtual desktop id
|
// Non-localizable string: default virtual desktop id
|
||||||
private const string DefaultVirtualDesktopGuid = "{00000000-0000-0000-0000-000000000000}";
|
private const string DefaultVirtualDesktopGuid = "{00000000-0000-0000-0000-000000000000}";
|
||||||
|
|
||||||
private readonly IFileSystem _fileSystem = new FileSystem();
|
private List<AppliedLayouts.AppliedLayoutWrapper> _unusedLayouts = new List<AppliedLayouts.AppliedLayoutWrapper>();
|
||||||
|
|
||||||
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
|
|
||||||
{
|
|
||||||
PropertyNamingPolicy = new DashCaseNamingPolicy(),
|
|
||||||
WriteIndented = true,
|
|
||||||
};
|
|
||||||
|
|
||||||
private List<AppliedLayoutWrapper> _unusedLayouts = new List<AppliedLayoutWrapper>();
|
|
||||||
|
|
||||||
public string FancyZonesAppliedLayoutsFile { get; private set; }
|
|
||||||
|
|
||||||
public string FancyZonesLayoutHotkeysFile { get; private set; }
|
|
||||||
|
|
||||||
public string FancyZonesLayoutTemplatesFile { get; private set; }
|
|
||||||
|
|
||||||
public string FancyZonesCustomLayoutsFile { get; private set; }
|
|
||||||
|
|
||||||
public string FancyZonesDefaultLayoutsFile { get; private set; }
|
|
||||||
|
|
||||||
public string FancyZonesEditorParamsFile { get; private set; }
|
|
||||||
|
|
||||||
private enum CmdArgs
|
|
||||||
{
|
|
||||||
PowerToysPID = 0,
|
|
||||||
SpanZones,
|
|
||||||
TargetMonitorId,
|
|
||||||
MonitorsCount,
|
|
||||||
MonitorId,
|
|
||||||
DPI,
|
|
||||||
MonitorLeft,
|
|
||||||
MonitorTop,
|
|
||||||
MonitorWidth,
|
|
||||||
MonitorHeight,
|
|
||||||
}
|
|
||||||
|
|
||||||
// applied-layouts.json
|
|
||||||
private struct AppliedLayoutWrapper
|
|
||||||
{
|
|
||||||
public struct DeviceIdWrapper
|
|
||||||
{
|
|
||||||
public string Monitor { get; set; }
|
|
||||||
|
|
||||||
public string MonitorInstance { get; set; }
|
|
||||||
|
|
||||||
public int MonitorNumber { get; set; }
|
|
||||||
|
|
||||||
public string SerialNumber { get; set; }
|
|
||||||
|
|
||||||
public string VirtualDesktop { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct LayoutWrapper
|
|
||||||
{
|
|
||||||
public string Uuid { get; set; }
|
|
||||||
|
|
||||||
public string Type { get; set; }
|
|
||||||
|
|
||||||
public bool ShowSpacing { get; set; }
|
|
||||||
|
|
||||||
public int Spacing { get; set; }
|
|
||||||
|
|
||||||
public int ZoneCount { get; set; }
|
|
||||||
|
|
||||||
public int SensitivityRadius { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceIdWrapper Device { get; set; }
|
|
||||||
|
|
||||||
public LayoutWrapper AppliedLayout { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// applied-layouts.json
|
|
||||||
private struct AppliedLayoutsListWrapper
|
|
||||||
{
|
|
||||||
public List<AppliedLayoutWrapper> AppliedLayouts { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// custom-layouts.json
|
|
||||||
private sealed class CanvasInfoWrapper
|
|
||||||
{
|
|
||||||
public struct CanvasZoneWrapper
|
|
||||||
{
|
|
||||||
public int X { get; set; }
|
|
||||||
|
|
||||||
public int Y { get; set; }
|
|
||||||
|
|
||||||
public int Width { get; set; }
|
|
||||||
|
|
||||||
public int Height { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public int RefWidth { get; set; }
|
|
||||||
|
|
||||||
public int RefHeight { get; set; }
|
|
||||||
|
|
||||||
public List<CanvasZoneWrapper> Zones { get; set; }
|
|
||||||
|
|
||||||
public int SensitivityRadius { get; set; } = LayoutSettings.DefaultSensitivityRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
// custom-layouts.json
|
|
||||||
private sealed class GridInfoWrapper
|
|
||||||
{
|
|
||||||
public int Rows { get; set; }
|
|
||||||
|
|
||||||
public int Columns { get; set; }
|
|
||||||
|
|
||||||
public List<int> RowsPercentage { get; set; }
|
|
||||||
|
|
||||||
public List<int> ColumnsPercentage { get; set; }
|
|
||||||
|
|
||||||
public int[][] CellChildMap { get; set; }
|
|
||||||
|
|
||||||
public bool ShowSpacing { get; set; } = LayoutSettings.DefaultShowSpacing;
|
|
||||||
|
|
||||||
public int Spacing { get; set; } = LayoutSettings.DefaultSpacing;
|
|
||||||
|
|
||||||
public int SensitivityRadius { get; set; } = LayoutSettings.DefaultSensitivityRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
// custom-layouts.json
|
|
||||||
private struct CustomLayoutWrapper
|
|
||||||
{
|
|
||||||
public string Uuid { get; set; }
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public string Type { get; set; }
|
|
||||||
|
|
||||||
public JsonElement Info { get; set; } // CanvasInfoWrapper or GridInfoWrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
// custom-layouts.json
|
|
||||||
private struct CustomLayoutListWrapper
|
|
||||||
{
|
|
||||||
public List<CustomLayoutWrapper> CustomLayouts { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// layout-templates.json
|
|
||||||
private struct TemplateLayoutWrapper
|
|
||||||
{
|
|
||||||
public string Type { get; set; }
|
|
||||||
|
|
||||||
public bool ShowSpacing { get; set; }
|
|
||||||
|
|
||||||
public int Spacing { get; set; }
|
|
||||||
|
|
||||||
public int ZoneCount { get; set; }
|
|
||||||
|
|
||||||
public int SensitivityRadius { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// layout-templates.json
|
|
||||||
private struct TemplateLayoutsListWrapper
|
|
||||||
{
|
|
||||||
public List<TemplateLayoutWrapper> LayoutTemplates { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// layout-hotkeys.json
|
|
||||||
private struct LayoutHotkeyWrapper
|
|
||||||
{
|
|
||||||
public int Key { get; set; }
|
|
||||||
|
|
||||||
public string LayoutId { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// layout-hotkeys.json
|
|
||||||
private struct LayoutHotkeysWrapper
|
|
||||||
{
|
|
||||||
public List<LayoutHotkeyWrapper> LayoutHotkeys { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// default-layouts.json
|
|
||||||
private struct DefaultLayoutWrapper
|
|
||||||
{
|
|
||||||
public struct LayoutWrapper
|
|
||||||
{
|
|
||||||
public string Uuid { get; set; }
|
|
||||||
|
|
||||||
public string Type { get; set; }
|
|
||||||
|
|
||||||
public bool ShowSpacing { get; set; }
|
|
||||||
|
|
||||||
public int Spacing { get; set; }
|
|
||||||
|
|
||||||
public int ZoneCount { get; set; }
|
|
||||||
|
|
||||||
public int SensitivityRadius { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string MonitorConfiguration { get; set; }
|
|
||||||
|
|
||||||
public LayoutWrapper Layout { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// default-layouts.json
|
|
||||||
private struct DefaultLayoutsListWrapper
|
|
||||||
{
|
|
||||||
public List<DefaultLayoutWrapper> DefaultLayouts { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public FancyZonesEditorIO()
|
public FancyZonesEditorIO()
|
||||||
{
|
{
|
||||||
var localAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
||||||
FancyZonesAppliedLayoutsFile = localAppDataDir + AppliedLayoutsFile;
|
|
||||||
FancyZonesLayoutHotkeysFile = localAppDataDir + LayoutHotkeysFile;
|
|
||||||
FancyZonesLayoutTemplatesFile = localAppDataDir + LayoutTemplatesFile;
|
|
||||||
FancyZonesCustomLayoutsFile = localAppDataDir + CustomLayoutsFile;
|
|
||||||
FancyZonesDefaultLayoutsFile = localAppDataDir + DefaultLayoutsFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParsingResult ParseParams()
|
public ParsingResult ParseParams()
|
||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
EditorParameters parser = new EditorParameters();
|
|
||||||
return parser.Parse();
|
try
|
||||||
|
{
|
||||||
|
EditorParameters parser = new EditorParameters();
|
||||||
|
var editorParams = parser.Read(parser.File);
|
||||||
|
|
||||||
|
// Process ID
|
||||||
|
App.PowerToysPID = editorParams.ProcessId;
|
||||||
|
|
||||||
|
// Span zones across monitors
|
||||||
|
App.Overlay.SpanZonesAcrossMonitors = editorParams.SpanZonesAcrossMonitors;
|
||||||
|
|
||||||
|
if (!App.Overlay.SpanZonesAcrossMonitors)
|
||||||
|
{
|
||||||
|
string targetMonitorId = string.Empty;
|
||||||
|
string targetMonitorSerialNumber = string.Empty;
|
||||||
|
string targetVirtualDesktop = string.Empty;
|
||||||
|
int targetMonitorNumber = 0;
|
||||||
|
|
||||||
|
foreach (EditorParameters.NativeMonitorDataWrapper nativeData in editorParams.Monitors)
|
||||||
|
{
|
||||||
|
Rect workArea = new Rect(nativeData.LeftCoordinate, nativeData.TopCoordinate, nativeData.WorkAreaWidth, nativeData.WorkAreaHeight);
|
||||||
|
if (nativeData.IsSelected)
|
||||||
|
{
|
||||||
|
targetMonitorId = nativeData.Monitor;
|
||||||
|
targetMonitorSerialNumber = nativeData.MonitorSerialNumber;
|
||||||
|
targetMonitorNumber = nativeData.MonitorNumber;
|
||||||
|
targetVirtualDesktop = nativeData.VirtualDesktop;
|
||||||
|
}
|
||||||
|
|
||||||
|
Size monitorSize = new Size(nativeData.MonitorWidth, nativeData.MonitorHeight);
|
||||||
|
|
||||||
|
var monitor = new Monitor(workArea, monitorSize);
|
||||||
|
monitor.Device.MonitorName = nativeData.Monitor;
|
||||||
|
monitor.Device.MonitorInstanceId = nativeData.MonitorInstanceId;
|
||||||
|
monitor.Device.MonitorSerialNumber = nativeData.MonitorSerialNumber;
|
||||||
|
monitor.Device.MonitorNumber = nativeData.MonitorNumber;
|
||||||
|
monitor.Device.VirtualDesktopId = nativeData.VirtualDesktop;
|
||||||
|
monitor.Device.Dpi = nativeData.Dpi;
|
||||||
|
|
||||||
|
App.Overlay.AddMonitor(monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set active desktop
|
||||||
|
var monitors = App.Overlay.Monitors;
|
||||||
|
for (int i = 0; i < monitors.Count; i++)
|
||||||
|
{
|
||||||
|
var monitor = monitors[i];
|
||||||
|
if (monitor.Device.MonitorName == targetMonitorId &&
|
||||||
|
monitor.Device.MonitorSerialNumber == targetMonitorSerialNumber &&
|
||||||
|
monitor.Device.MonitorNumber == targetMonitorNumber &&
|
||||||
|
monitor.Device.VirtualDesktopId == targetVirtualDesktop)
|
||||||
|
{
|
||||||
|
App.Overlay.CurrentDesktop = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (editorParams.Monitors.Count != 1)
|
||||||
|
{
|
||||||
|
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Editor_Parameters_Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
var nativeData = editorParams.Monitors[0];
|
||||||
|
Rect workArea = new Rect(nativeData.LeftCoordinate, nativeData.TopCoordinate, nativeData.WorkAreaWidth, nativeData.WorkAreaHeight);
|
||||||
|
Size monitorSize = new Size(nativeData.MonitorWidth, nativeData.MonitorHeight);
|
||||||
|
|
||||||
|
var monitor = new Monitor(workArea, monitorSize);
|
||||||
|
monitor.Device.MonitorName = nativeData.Monitor;
|
||||||
|
monitor.Device.MonitorInstanceId = nativeData.MonitorInstanceId;
|
||||||
|
monitor.Device.MonitorSerialNumber = nativeData.MonitorSerialNumber;
|
||||||
|
monitor.Device.MonitorNumber = nativeData.MonitorNumber;
|
||||||
|
monitor.Device.VirtualDesktopId = nativeData.VirtualDesktop;
|
||||||
|
|
||||||
|
App.Overlay.AddMonitor(monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ParsingResult(true);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return new ParsingResult(false, e.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParsingResult ParseAppliedLayouts()
|
public ParsingResult ParseAppliedLayouts()
|
||||||
@@ -265,36 +133,22 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
_unusedLayouts.Clear();
|
_unusedLayouts.Clear();
|
||||||
|
|
||||||
if (_fileSystem.File.Exists(FancyZonesAppliedLayoutsFile))
|
try
|
||||||
{
|
{
|
||||||
AppliedLayoutsListWrapper appliedLayouts;
|
AppliedLayouts parser = new AppliedLayouts();
|
||||||
string settingsString = string.Empty;
|
var appliedLayouts = parser.Read(parser.File);
|
||||||
|
|
||||||
try
|
bool parsingResult = SetAppliedLayouts(appliedLayouts.AppliedLayouts);
|
||||||
|
if (!parsingResult)
|
||||||
{
|
{
|
||||||
settingsString = ReadFile(FancyZonesAppliedLayoutsFile);
|
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Applied_Layouts_Message);
|
||||||
appliedLayouts = JsonSerializer.Deserialize<AppliedLayoutsListWrapper>(settingsString, _options);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Applied layouts parsing error", ex);
|
|
||||||
return new ParsingResult(false, ex.Message, settingsString);
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
bool parsingResult = SetAppliedLayouts(appliedLayouts.AppliedLayouts);
|
|
||||||
if (!parsingResult)
|
|
||||||
{
|
|
||||||
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Applied_Layouts_Message, settingsString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Applied layouts parsing error", ex);
|
|
||||||
return new ParsingResult(false, ex.Message, settingsString);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError("Applied layouts parsing error", ex);
|
||||||
|
return new ParsingResult(false, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
return new ParsingResult(true);
|
return new ParsingResult(true);
|
||||||
}
|
}
|
||||||
@@ -303,167 +157,105 @@ namespace FancyZonesEditor.Utils
|
|||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
if (_fileSystem.File.Exists(FancyZonesLayoutHotkeysFile))
|
try
|
||||||
{
|
{
|
||||||
LayoutHotkeysWrapper layoutHotkeys;
|
LayoutHotkeys parser = new LayoutHotkeys();
|
||||||
string dataString = string.Empty;
|
var layoutHotkeys = parser.Read(parser.File);
|
||||||
|
|
||||||
try
|
bool layoutHotkeysParsingResult = SetLayoutHotkeys(layoutHotkeys);
|
||||||
|
|
||||||
|
if (!layoutHotkeysParsingResult)
|
||||||
{
|
{
|
||||||
dataString = ReadFile(FancyZonesLayoutHotkeysFile);
|
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Layout_Hotkeys_Message);
|
||||||
layoutHotkeys = JsonSerializer.Deserialize<LayoutHotkeysWrapper>(dataString, _options);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Layout hotkeys parsing error", ex);
|
|
||||||
return new ParsingResult(false, ex.Message, dataString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
return new ParsingResult(true);
|
||||||
{
|
}
|
||||||
bool layoutHotkeysParsingResult = SetLayoutHotkeys(layoutHotkeys);
|
catch (Exception ex)
|
||||||
|
{
|
||||||
if (!layoutHotkeysParsingResult)
|
Logger.LogError("Layout hotkeys parsing error", ex);
|
||||||
{
|
return new ParsingResult(false, ex.Message);
|
||||||
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Layout_Hotkeys_Message, dataString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Layout hotkeys parsing error", ex);
|
|
||||||
return new ParsingResult(false, ex.Message, dataString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ParsingResult(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParsingResult ParseLayoutTemplates()
|
public ParsingResult ParseLayoutTemplates()
|
||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
if (_fileSystem.File.Exists(FancyZonesLayoutTemplatesFile))
|
try
|
||||||
{
|
{
|
||||||
TemplateLayoutsListWrapper templates;
|
LayoutTemplates parser = new LayoutTemplates();
|
||||||
string dataString = string.Empty;
|
var templates = parser.Read(parser.File);
|
||||||
|
|
||||||
try
|
bool parsingResult = SetTemplateLayouts(templates.LayoutTemplates);
|
||||||
|
if (parsingResult)
|
||||||
{
|
{
|
||||||
dataString = ReadFile(FancyZonesLayoutTemplatesFile);
|
return new ParsingResult(true);
|
||||||
templates = JsonSerializer.Deserialize<TemplateLayoutsListWrapper>(dataString, _options);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Layout templates parsing error", ex);
|
|
||||||
return new ParsingResult(false, ex.Message, dataString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Layout_Templates_Message);
|
||||||
{
|
}
|
||||||
bool parsingResult = SetTemplateLayouts(templates.LayoutTemplates);
|
catch (Exception ex)
|
||||||
if (parsingResult)
|
{
|
||||||
{
|
Logger.LogError("Layout templates parsing error", ex);
|
||||||
return new ParsingResult(true);
|
return new ParsingResult(false, ex.Message);
|
||||||
}
|
|
||||||
|
|
||||||
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Layout_Templates_Message, dataString);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Layout templates parsing error", ex);
|
|
||||||
return new ParsingResult(false, ex.Message, dataString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ParsingResult(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParsingResult ParseCustomLayouts()
|
public ParsingResult ParseCustomLayouts()
|
||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
if (_fileSystem.File.Exists(FancyZonesCustomLayoutsFile))
|
try
|
||||||
{
|
{
|
||||||
CustomLayoutListWrapper wrapper;
|
CustomLayouts parser = new CustomLayouts();
|
||||||
string dataString = string.Empty;
|
var wrapper = parser.Read(parser.File);
|
||||||
|
|
||||||
try
|
bool parsingResult = SetCustomLayouts(wrapper.CustomLayouts);
|
||||||
|
if (parsingResult)
|
||||||
{
|
{
|
||||||
dataString = ReadFile(FancyZonesCustomLayoutsFile);
|
return new ParsingResult(true);
|
||||||
wrapper = JsonSerializer.Deserialize<CustomLayoutListWrapper>(dataString, _options);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Custom layouts parsing error", ex);
|
|
||||||
return new ParsingResult(false, ex.Message, dataString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Custom_Layouts_Message);
|
||||||
{
|
}
|
||||||
bool parsingResult = SetCustomLayouts(wrapper.CustomLayouts);
|
catch (Exception ex)
|
||||||
if (parsingResult)
|
{
|
||||||
{
|
Logger.LogError("Custom layouts parsing error", ex);
|
||||||
return new ParsingResult(true);
|
return new ParsingResult(false, ex.Message);
|
||||||
}
|
|
||||||
|
|
||||||
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Custom_Layouts_Message, dataString);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Custom layouts parsing error", ex);
|
|
||||||
return new ParsingResult(false, ex.Message, dataString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ParsingResult(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParsingResult ParseDefaultLayouts()
|
public ParsingResult ParseDefaultLayouts()
|
||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
if (_fileSystem.File.Exists(FancyZonesDefaultLayoutsFile))
|
try
|
||||||
{
|
{
|
||||||
DefaultLayoutsListWrapper wrapper;
|
DefaultLayouts parser = new DefaultLayouts();
|
||||||
string dataString = string.Empty;
|
var wrapper = parser.Read(parser.File);
|
||||||
|
|
||||||
try
|
bool parsingResult = SetDefaultLayouts(wrapper.DefaultLayouts);
|
||||||
|
if (parsingResult)
|
||||||
{
|
{
|
||||||
dataString = ReadFile(FancyZonesDefaultLayoutsFile);
|
return new ParsingResult(true);
|
||||||
wrapper = JsonSerializer.Deserialize<DefaultLayoutsListWrapper>(dataString, _options);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Default layouts parsing error", ex);
|
|
||||||
return new ParsingResult(false, ex.Message, dataString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Default_Layouts_Message);
|
||||||
{
|
}
|
||||||
bool parsingResult = SetDefaultLayouts(wrapper.DefaultLayouts);
|
catch (Exception ex)
|
||||||
if (parsingResult)
|
{
|
||||||
{
|
Logger.LogError("Default layouts parsing error", ex);
|
||||||
return new ParsingResult(true);
|
return new ParsingResult(false, ex.Message);
|
||||||
}
|
|
||||||
|
|
||||||
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Default_Layouts_Message, dataString);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Default layouts parsing error", ex);
|
|
||||||
return new ParsingResult(false, ex.Message, dataString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ParsingResult(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SerializeAppliedLayouts()
|
public void SerializeAppliedLayouts()
|
||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
AppliedLayoutsListWrapper layouts = new AppliedLayoutsListWrapper { };
|
AppliedLayouts.AppliedLayoutsListWrapper layouts = new AppliedLayouts.AppliedLayoutsListWrapper { };
|
||||||
layouts.AppliedLayouts = new List<AppliedLayoutWrapper>();
|
layouts.AppliedLayouts = new List<AppliedLayouts.AppliedLayoutWrapper>();
|
||||||
|
|
||||||
// Serialize used layouts
|
// Serialize used layouts
|
||||||
foreach (var monitor in App.Overlay.Monitors)
|
foreach (var monitor in App.Overlay.Monitors)
|
||||||
@@ -474,9 +266,9 @@ namespace FancyZonesEditor.Utils
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
layouts.AppliedLayouts.Add(new AppliedLayoutWrapper
|
layouts.AppliedLayouts.Add(new AppliedLayouts.AppliedLayoutWrapper
|
||||||
{
|
{
|
||||||
Device = new AppliedLayoutWrapper.DeviceIdWrapper
|
Device = new AppliedLayouts.AppliedLayoutWrapper.DeviceIdWrapper
|
||||||
{
|
{
|
||||||
Monitor = monitor.Device.MonitorName,
|
Monitor = monitor.Device.MonitorName,
|
||||||
MonitorInstance = monitor.Device.MonitorInstanceId,
|
MonitorInstance = monitor.Device.MonitorInstanceId,
|
||||||
@@ -485,7 +277,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
VirtualDesktop = monitor.Device.VirtualDesktopId,
|
VirtualDesktop = monitor.Device.VirtualDesktopId,
|
||||||
},
|
},
|
||||||
|
|
||||||
AppliedLayout = new AppliedLayoutWrapper.LayoutWrapper
|
AppliedLayout = new AppliedLayouts.AppliedLayoutWrapper.LayoutWrapper
|
||||||
{
|
{
|
||||||
Uuid = zoneset.ZonesetUuid,
|
Uuid = zoneset.ZonesetUuid,
|
||||||
Type = LayoutTypeToJsonTag(zoneset.Type),
|
Type = LayoutTypeToJsonTag(zoneset.Type),
|
||||||
@@ -505,8 +297,9 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string jsonString = JsonSerializer.Serialize(layouts, _options);
|
AppliedLayouts serializer = new AppliedLayouts();
|
||||||
_fileSystem.File.WriteAllText(FancyZonesAppliedLayoutsFile, jsonString);
|
IOUtils iOUtils = new IOUtils();
|
||||||
|
iOUtils.WriteFile(serializer.File, serializer.Serialize(layouts));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -517,8 +310,8 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
public void SerializeLayoutHotkeys()
|
public void SerializeLayoutHotkeys()
|
||||||
{
|
{
|
||||||
LayoutHotkeysWrapper hotkeys = new LayoutHotkeysWrapper { };
|
LayoutHotkeys.LayoutHotkeysWrapper hotkeys = new LayoutHotkeys.LayoutHotkeysWrapper { };
|
||||||
hotkeys.LayoutHotkeys = new List<LayoutHotkeyWrapper>();
|
hotkeys.LayoutHotkeys = new List<LayoutHotkeys.LayoutHotkeyWrapper>();
|
||||||
|
|
||||||
foreach (var pair in MainWindowSettingsModel.LayoutHotkeys.SelectedKeys)
|
foreach (var pair in MainWindowSettingsModel.LayoutHotkeys.SelectedKeys)
|
||||||
{
|
{
|
||||||
@@ -526,7 +319,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LayoutHotkeyWrapper wrapper = new LayoutHotkeyWrapper
|
LayoutHotkeys.LayoutHotkeyWrapper wrapper = new LayoutHotkeys.LayoutHotkeyWrapper
|
||||||
{
|
{
|
||||||
Key = int.Parse(pair.Key, CultureInfo.CurrentCulture),
|
Key = int.Parse(pair.Key, CultureInfo.CurrentCulture),
|
||||||
LayoutId = pair.Value,
|
LayoutId = pair.Value,
|
||||||
@@ -543,8 +336,9 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string jsonString = JsonSerializer.Serialize(hotkeys, _options);
|
LayoutHotkeys serializer = new LayoutHotkeys();
|
||||||
_fileSystem.File.WriteAllText(FancyZonesLayoutHotkeysFile, jsonString);
|
IOUtils iOUtils = new IOUtils();
|
||||||
|
iOUtils.WriteFile(serializer.File, serializer.Serialize(hotkeys));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -555,12 +349,12 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
public void SerializeLayoutTemplates()
|
public void SerializeLayoutTemplates()
|
||||||
{
|
{
|
||||||
TemplateLayoutsListWrapper templates = new TemplateLayoutsListWrapper { };
|
LayoutTemplates.TemplateLayoutsListWrapper templates = new LayoutTemplates.TemplateLayoutsListWrapper { };
|
||||||
templates.LayoutTemplates = new List<TemplateLayoutWrapper>();
|
templates.LayoutTemplates = new List<LayoutTemplates.TemplateLayoutWrapper>();
|
||||||
|
|
||||||
foreach (LayoutModel layout in MainWindowSettingsModel.TemplateModels)
|
foreach (LayoutModel layout in MainWindowSettingsModel.TemplateModels)
|
||||||
{
|
{
|
||||||
TemplateLayoutWrapper wrapper = new TemplateLayoutWrapper
|
LayoutTemplates.TemplateLayoutWrapper wrapper = new LayoutTemplates.TemplateLayoutWrapper
|
||||||
{
|
{
|
||||||
Type = LayoutTypeToJsonTag(layout.Type),
|
Type = LayoutTypeToJsonTag(layout.Type),
|
||||||
SensitivityRadius = layout.SensitivityRadius,
|
SensitivityRadius = layout.SensitivityRadius,
|
||||||
@@ -578,8 +372,9 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string jsonString = JsonSerializer.Serialize(templates, _options);
|
LayoutTemplates serializer = new LayoutTemplates();
|
||||||
_fileSystem.File.WriteAllText(FancyZonesLayoutTemplatesFile, jsonString);
|
IOUtils iOUtils = new IOUtils();
|
||||||
|
iOUtils.WriteFile(serializer.File, serializer.Serialize(templates));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -590,8 +385,9 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
public void SerializeCustomLayouts()
|
public void SerializeCustomLayouts()
|
||||||
{
|
{
|
||||||
CustomLayoutListWrapper layouts = new CustomLayoutListWrapper { };
|
CustomLayouts serializer = new CustomLayouts();
|
||||||
layouts.CustomLayouts = new List<CustomLayoutWrapper>();
|
CustomLayouts.CustomLayoutListWrapper layouts = new CustomLayouts.CustomLayoutListWrapper { };
|
||||||
|
layouts.CustomLayouts = new List<CustomLayouts.CustomLayoutWrapper>();
|
||||||
|
|
||||||
foreach (LayoutModel layout in MainWindowSettingsModel.CustomModels)
|
foreach (LayoutModel layout in MainWindowSettingsModel.CustomModels)
|
||||||
{
|
{
|
||||||
@@ -609,17 +405,17 @@ namespace FancyZonesEditor.Utils
|
|||||||
canvasRect = App.Overlay.WorkArea;
|
canvasRect = App.Overlay.WorkArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
var wrapper = new CanvasInfoWrapper
|
var wrapper = new CustomLayouts.CanvasInfoWrapper
|
||||||
{
|
{
|
||||||
RefWidth = (int)canvasRect.Width,
|
RefWidth = (int)canvasRect.Width,
|
||||||
RefHeight = (int)canvasRect.Height,
|
RefHeight = (int)canvasRect.Height,
|
||||||
Zones = new List<CanvasInfoWrapper.CanvasZoneWrapper>(),
|
Zones = new List<CustomLayouts.CanvasInfoWrapper.CanvasZoneWrapper>(),
|
||||||
SensitivityRadius = canvasLayout.SensitivityRadius,
|
SensitivityRadius = canvasLayout.SensitivityRadius,
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var zone in canvasLayout.Zones)
|
foreach (var zone in canvasLayout.Zones)
|
||||||
{
|
{
|
||||||
wrapper.Zones.Add(new CanvasInfoWrapper.CanvasZoneWrapper
|
wrapper.Zones.Add(new CustomLayouts.CanvasInfoWrapper.CanvasZoneWrapper
|
||||||
{
|
{
|
||||||
X = zone.X,
|
X = zone.X,
|
||||||
Y = zone.Y,
|
Y = zone.Y,
|
||||||
@@ -628,8 +424,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
string json = JsonSerializer.Serialize(wrapper, _options);
|
info = serializer.ToJsonElement(wrapper);
|
||||||
info = JsonSerializer.Deserialize<JsonElement>(json);
|
|
||||||
}
|
}
|
||||||
else if (layout is GridLayoutModel)
|
else if (layout is GridLayoutModel)
|
||||||
{
|
{
|
||||||
@@ -646,7 +441,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var wrapper = new GridInfoWrapper
|
var wrapper = new CustomLayouts.GridInfoWrapper
|
||||||
{
|
{
|
||||||
Rows = gridLayout.Rows,
|
Rows = gridLayout.Rows,
|
||||||
Columns = gridLayout.Columns,
|
Columns = gridLayout.Columns,
|
||||||
@@ -658,8 +453,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
SensitivityRadius = gridLayout.SensitivityRadius,
|
SensitivityRadius = gridLayout.SensitivityRadius,
|
||||||
};
|
};
|
||||||
|
|
||||||
string json = JsonSerializer.Serialize(wrapper, _options);
|
info = serializer.ToJsonElement(wrapper);
|
||||||
info = JsonSerializer.Deserialize<JsonElement>(json);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -667,7 +461,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomLayoutWrapper customLayout = new CustomLayoutWrapper
|
CustomLayouts.CustomLayoutWrapper customLayout = new CustomLayouts.CustomLayoutWrapper
|
||||||
{
|
{
|
||||||
Uuid = layout.Uuid,
|
Uuid = layout.Uuid,
|
||||||
Name = layout.Name,
|
Name = layout.Name,
|
||||||
@@ -680,8 +474,8 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string jsonString = JsonSerializer.Serialize(layouts, _options);
|
IOUtils iOUtils = new IOUtils();
|
||||||
_fileSystem.File.WriteAllText(FancyZonesCustomLayoutsFile, jsonString);
|
iOUtils.WriteFile(serializer.File, serializer.Serialize(layouts));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -692,14 +486,14 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
public void SerializeDefaultLayouts()
|
public void SerializeDefaultLayouts()
|
||||||
{
|
{
|
||||||
DefaultLayoutsListWrapper layouts = new DefaultLayoutsListWrapper { };
|
DefaultLayouts.DefaultLayoutsListWrapper layouts = new DefaultLayouts.DefaultLayoutsListWrapper { };
|
||||||
layouts.DefaultLayouts = new List<DefaultLayoutWrapper>();
|
layouts.DefaultLayouts = new List<DefaultLayouts.DefaultLayoutWrapper>();
|
||||||
|
|
||||||
foreach (LayoutModel layout in MainWindowSettingsModel.TemplateModels)
|
foreach (LayoutModel layout in MainWindowSettingsModel.TemplateModels)
|
||||||
{
|
{
|
||||||
if (layout.IsHorizontalDefault || layout.IsVerticalDefault)
|
if (layout.IsHorizontalDefault || layout.IsVerticalDefault)
|
||||||
{
|
{
|
||||||
DefaultLayoutWrapper.LayoutWrapper layoutWrapper = new DefaultLayoutWrapper.LayoutWrapper
|
DefaultLayouts.DefaultLayoutWrapper.LayoutWrapper layoutWrapper = new DefaultLayouts.DefaultLayoutWrapper.LayoutWrapper
|
||||||
{
|
{
|
||||||
Uuid = string.Empty,
|
Uuid = string.Empty,
|
||||||
Type = LayoutTypeToJsonTag(layout.Type),
|
Type = LayoutTypeToJsonTag(layout.Type),
|
||||||
@@ -716,7 +510,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
// can be both horizontal and vertical, so check separately
|
// can be both horizontal and vertical, so check separately
|
||||||
if (layout.IsHorizontalDefault)
|
if (layout.IsHorizontalDefault)
|
||||||
{
|
{
|
||||||
DefaultLayoutWrapper wrapper = new DefaultLayoutWrapper
|
DefaultLayouts.DefaultLayoutWrapper wrapper = new DefaultLayouts.DefaultLayoutWrapper
|
||||||
{
|
{
|
||||||
MonitorConfiguration = MonitorConfigurationTypeToJsonTag(MonitorConfigurationType.Horizontal),
|
MonitorConfiguration = MonitorConfigurationTypeToJsonTag(MonitorConfigurationType.Horizontal),
|
||||||
Layout = layoutWrapper,
|
Layout = layoutWrapper,
|
||||||
@@ -727,7 +521,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
if (layout.IsVerticalDefault)
|
if (layout.IsVerticalDefault)
|
||||||
{
|
{
|
||||||
DefaultLayoutWrapper wrapper = new DefaultLayoutWrapper
|
DefaultLayouts.DefaultLayoutWrapper wrapper = new DefaultLayouts.DefaultLayoutWrapper
|
||||||
{
|
{
|
||||||
MonitorConfiguration = MonitorConfigurationTypeToJsonTag(MonitorConfigurationType.Vertical),
|
MonitorConfiguration = MonitorConfigurationTypeToJsonTag(MonitorConfigurationType.Vertical),
|
||||||
Layout = layoutWrapper,
|
Layout = layoutWrapper,
|
||||||
@@ -742,7 +536,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
{
|
{
|
||||||
if (layout.IsHorizontalDefault || layout.IsVerticalDefault)
|
if (layout.IsHorizontalDefault || layout.IsVerticalDefault)
|
||||||
{
|
{
|
||||||
DefaultLayoutWrapper.LayoutWrapper layoutWrapper = new DefaultLayoutWrapper.LayoutWrapper
|
DefaultLayouts.DefaultLayoutWrapper.LayoutWrapper layoutWrapper = new DefaultLayouts.DefaultLayoutWrapper.LayoutWrapper
|
||||||
{
|
{
|
||||||
Uuid = layout.Uuid,
|
Uuid = layout.Uuid,
|
||||||
Type = LayoutTypeToJsonTag(LayoutType.Custom),
|
Type = LayoutTypeToJsonTag(LayoutType.Custom),
|
||||||
@@ -757,7 +551,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
// can be both horizontal and vertical, so check separately
|
// can be both horizontal and vertical, so check separately
|
||||||
if (layout.IsHorizontalDefault)
|
if (layout.IsHorizontalDefault)
|
||||||
{
|
{
|
||||||
DefaultLayoutWrapper wrapper = new DefaultLayoutWrapper
|
DefaultLayouts.DefaultLayoutWrapper wrapper = new DefaultLayouts.DefaultLayoutWrapper
|
||||||
{
|
{
|
||||||
MonitorConfiguration = MonitorConfigurationTypeToJsonTag(MonitorConfigurationType.Horizontal),
|
MonitorConfiguration = MonitorConfigurationTypeToJsonTag(MonitorConfigurationType.Horizontal),
|
||||||
Layout = layoutWrapper,
|
Layout = layoutWrapper,
|
||||||
@@ -768,7 +562,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
if (layout.IsVerticalDefault)
|
if (layout.IsVerticalDefault)
|
||||||
{
|
{
|
||||||
DefaultLayoutWrapper wrapper = new DefaultLayoutWrapper
|
DefaultLayouts.DefaultLayoutWrapper wrapper = new DefaultLayouts.DefaultLayoutWrapper
|
||||||
{
|
{
|
||||||
MonitorConfiguration = MonitorConfigurationTypeToJsonTag(MonitorConfigurationType.Vertical),
|
MonitorConfiguration = MonitorConfigurationTypeToJsonTag(MonitorConfigurationType.Vertical),
|
||||||
Layout = layoutWrapper,
|
Layout = layoutWrapper,
|
||||||
@@ -781,8 +575,9 @@ namespace FancyZonesEditor.Utils
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string jsonString = JsonSerializer.Serialize(layouts, _options);
|
DefaultLayouts serializer = new DefaultLayouts();
|
||||||
_fileSystem.File.WriteAllText(FancyZonesDefaultLayoutsFile, jsonString);
|
IOUtils iOUtils = new IOUtils();
|
||||||
|
iOUtils.WriteFile(serializer.File, serializer.Serialize(layouts));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -791,36 +586,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ReadFile(string fileName)
|
private bool SetAppliedLayouts(List<AppliedLayouts.AppliedLayoutWrapper> layouts)
|
||||||
{
|
|
||||||
Logger.LogTrace();
|
|
||||||
|
|
||||||
var attempts = 0;
|
|
||||||
while (attempts < 10)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using (Stream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
|
|
||||||
using (StreamReader reader = new StreamReader(inputStream))
|
|
||||||
{
|
|
||||||
string data = reader.ReadToEnd();
|
|
||||||
inputStream.Close();
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
Logger.LogError("File reading error, retry");
|
|
||||||
Task.Delay(10).Wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
attempts++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool SetAppliedLayouts(List<AppliedLayoutWrapper> layouts)
|
|
||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
@@ -907,7 +673,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SetCustomLayouts(List<CustomLayoutWrapper> customLayouts)
|
private bool SetCustomLayouts(List<CustomLayouts.CustomLayoutWrapper> customLayouts)
|
||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
@@ -960,7 +726,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SetTemplateLayouts(List<TemplateLayoutWrapper> templateLayouts)
|
private bool SetTemplateLayouts(List<LayoutTemplates.TemplateLayoutWrapper> templateLayouts)
|
||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
@@ -989,7 +755,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SetLayoutHotkeys(LayoutHotkeysWrapper layoutHotkeys)
|
private bool SetLayoutHotkeys(LayoutHotkeys.LayoutHotkeysWrapper layoutHotkeys)
|
||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
@@ -1002,7 +768,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SetDefaultLayouts(List<DefaultLayoutWrapper> layouts)
|
private bool SetDefaultLayouts(List<DefaultLayouts.DefaultLayoutWrapper> layouts)
|
||||||
{
|
{
|
||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
@@ -1059,9 +825,10 @@ namespace FancyZonesEditor.Utils
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CanvasLayoutModel ParseCanvasInfo(CustomLayoutWrapper wrapper)
|
private CanvasLayoutModel ParseCanvasInfo(CustomLayouts.CustomLayoutWrapper wrapper)
|
||||||
{
|
{
|
||||||
var info = JsonSerializer.Deserialize<CanvasInfoWrapper>(wrapper.Info.GetRawText(), _options);
|
CustomLayouts deserializer = new CustomLayouts();
|
||||||
|
var info = deserializer.CanvasFromJsonElement(wrapper.Info.GetRawText());
|
||||||
|
|
||||||
var zones = new List<Int32Rect>();
|
var zones = new List<Int32Rect>();
|
||||||
foreach (var zone in info.Zones)
|
foreach (var zone in info.Zones)
|
||||||
@@ -1081,9 +848,10 @@ namespace FancyZonesEditor.Utils
|
|||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GridLayoutModel ParseGridInfo(CustomLayoutWrapper wrapper)
|
private GridLayoutModel ParseGridInfo(CustomLayouts.CustomLayoutWrapper wrapper)
|
||||||
{
|
{
|
||||||
var info = JsonSerializer.Deserialize<GridInfoWrapper>(wrapper.Info.GetRawText(), _options);
|
CustomLayouts deserializer = new CustomLayouts();
|
||||||
|
var info = deserializer.GridFromJsonElement(wrapper.Info.GetRawText());
|
||||||
|
|
||||||
// Check if rows and columns are valid
|
// Check if rows and columns are valid
|
||||||
if (info.Rows <= 0 || info.Columns <= 0)
|
if (info.Rows <= 0 || info.Columns <= 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user