mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-24 04:00:02 +01:00
Make canvas layout scaling sensitive
This commit is contained in:
@@ -21,7 +21,10 @@ namespace FancyZonesEditor
|
||||
|
||||
private void OnAddZone(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_model.AddZone(new Int32Rect(_offset, _offset, (int)(_model.ReferenceWidth * 0.6), (int)(_model.ReferenceHeight * 0.6)));
|
||||
/* string message = "Simple MessageBox width: " + _model.ReferenceWidth + " height" + _model.ReferenceHeight;
|
||||
MessageBox.Show(message);
|
||||
*/
|
||||
_model.AddZone(new Int32Rect(_offset, _offset, (int)(Settings.WorkArea.Width * 0.6), (int)(Settings.WorkArea.Height * 0.6)));
|
||||
_offset += 100;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ namespace FancyZonesEditor
|
||||
Canvas.SetZIndex(this, zIndex++);
|
||||
}
|
||||
|
||||
private readonly Settings _settings = ((App)Application.Current).ZoneSettings;
|
||||
|
||||
private CanvasLayoutModel model;
|
||||
|
||||
private int zoneIndex;
|
||||
@@ -289,8 +287,8 @@ namespace FancyZonesEditor
|
||||
// Corner dragging
|
||||
private void Caption_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
||||
{
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.BothEdges, (int)_settings.WorkArea.Width);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.BothEdges, (int)_settings.WorkArea.Height);
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.BothEdges, (int)Settings.WorkArea.Width);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.BothEdges, (int)Settings.WorkArea.Height);
|
||||
}
|
||||
|
||||
public CanvasLayoutModel Model { get => model; set => model = value; }
|
||||
@@ -299,50 +297,50 @@ namespace FancyZonesEditor
|
||||
|
||||
private void NWResize_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
||||
{
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.BottomEdge, (int)_settings.WorkArea.Width);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.BottomEdge, (int)_settings.WorkArea.Height);
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.BottomEdge, (int)Settings.WorkArea.Width);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.BottomEdge, (int)Settings.WorkArea.Height);
|
||||
}
|
||||
|
||||
private void NEResize_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
||||
{
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.TopEdge, (int)_settings.WorkArea.Width);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.BottomEdge, (int)_settings.WorkArea.Height);
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.TopEdge, (int)Settings.WorkArea.Width);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.BottomEdge, (int)Settings.WorkArea.Height);
|
||||
}
|
||||
|
||||
private void SWResize_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
||||
{
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.BottomEdge, (int)_settings.WorkArea.Width);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.TopEdge, (int)_settings.WorkArea.Height);
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.BottomEdge, (int)Settings.WorkArea.Width);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.TopEdge, (int)Settings.WorkArea.Height);
|
||||
}
|
||||
|
||||
private void SEResize_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
||||
{
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.TopEdge, (int)_settings.WorkArea.Width);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.TopEdge, (int)_settings.WorkArea.Height);
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.TopEdge, (int)Settings.WorkArea.Width);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.TopEdge, (int)Settings.WorkArea.Height);
|
||||
}
|
||||
|
||||
// Edge dragging
|
||||
private void NResize_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
||||
{
|
||||
snappyX = null;
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.BottomEdge, (int)_settings.WorkArea.Height);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.BottomEdge, (int)Settings.WorkArea.Height);
|
||||
}
|
||||
|
||||
private void SResize_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
||||
{
|
||||
snappyX = null;
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.TopEdge, (int)_settings.WorkArea.Height);
|
||||
snappyY = NewDefaultSnappyHelper(false, ResizeMode.TopEdge, (int)Settings.WorkArea.Height);
|
||||
}
|
||||
|
||||
private void WResize_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
||||
{
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.BottomEdge, (int)_settings.WorkArea.Width);
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.BottomEdge, (int)Settings.WorkArea.Width);
|
||||
snappyY = null;
|
||||
}
|
||||
|
||||
private void EResize_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
||||
{
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.TopEdge, (int)_settings.WorkArea.Width);
|
||||
snappyX = NewDefaultSnappyHelper(true, ResizeMode.TopEdge, (int)Settings.WorkArea.Width);
|
||||
snappyY = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ namespace FancyZonesEditor
|
||||
InitializeComponent();
|
||||
Current = this;
|
||||
|
||||
Left = _settings.WorkArea.Left;
|
||||
Top = _settings.WorkArea.Top;
|
||||
Width = _settings.WorkArea.Width;
|
||||
Height = _settings.WorkArea.Height;
|
||||
Left = Settings.WorkArea.Left;
|
||||
Top = Settings.WorkArea.Top;
|
||||
Width = Settings.WorkArea.Width;
|
||||
Height = Settings.WorkArea.Height;
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -16,6 +16,11 @@ namespace FancyZonesEditor
|
||||
EditorOverlay mainEditor = EditorOverlay.Current;
|
||||
if (mainEditor.DataContext is LayoutModel model)
|
||||
{
|
||||
if (model.Type == LayoutType.Blank)
|
||||
{
|
||||
model.Type = LayoutType.Custom;
|
||||
}
|
||||
|
||||
model.Persist();
|
||||
}
|
||||
|
||||
|
||||
@@ -106,8 +106,8 @@ namespace FancyZonesEditor
|
||||
|
||||
int spacing = settings.ShowSpacing ? settings.Spacing : 0;
|
||||
|
||||
int width = (int)settings.WorkArea.Width;
|
||||
int height = (int)settings.WorkArea.Height;
|
||||
int width = (int)Settings.WorkArea.Width;
|
||||
int height = (int)Settings.WorkArea.Height;
|
||||
|
||||
double totalWidth = width - (spacing * (cols + 1));
|
||||
double totalHeight = height - (spacing * (rows + 1));
|
||||
@@ -265,8 +265,8 @@ namespace FancyZonesEditor
|
||||
Body.Children.Add(viewbox);
|
||||
Canvas frame = new Canvas
|
||||
{
|
||||
Width = canvas.ReferenceWidth,
|
||||
Height = canvas.ReferenceHeight,
|
||||
Width = Settings.WorkArea.Width,
|
||||
Height = Settings.WorkArea.Height,
|
||||
};
|
||||
viewbox.Child = frame;
|
||||
foreach (Int32Rect zone in canvas.Zones)
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace FancyZonesEditor
|
||||
|
||||
KeyUp += MainWindow_KeyUp;
|
||||
|
||||
if (_settings.WorkArea.Height < 900)
|
||||
if (Settings.WorkArea.Height < 900)
|
||||
{
|
||||
SizeToContent = SizeToContent.WidthAndHeight;
|
||||
WrapPanelItemSize = 180;
|
||||
|
||||
@@ -14,69 +14,30 @@ namespace FancyZonesEditor.Models
|
||||
// Free form Layout Model, which specifies independent zone rects
|
||||
public class CanvasLayoutModel : LayoutModel
|
||||
{
|
||||
public CanvasLayoutModel(string uuid, string name, LayoutType type, int referenceWidth, int referenceHeight, IList<Int32Rect> zones)
|
||||
public CanvasLayoutModel(string uuid, string name, LayoutType type, IList<Int32Rect> zones, int workAreaWidth, int workAreaHeight/*, int workAreaDPI*/)
|
||||
: base(uuid, name, type)
|
||||
{
|
||||
_referenceWidth = referenceWidth;
|
||||
_referenceHeight = referenceHeight;
|
||||
Zones = zones;
|
||||
lastWorkAreaWidth = workAreaWidth;
|
||||
lastWorkAreaHeight = workAreaHeight;
|
||||
//lastWorkAreaDPI = workAreaDPI;
|
||||
|
||||
ScaleLayout(zones);
|
||||
//Zones = zones;
|
||||
}
|
||||
|
||||
public CanvasLayoutModel(string name, LayoutType type, int referenceWidth, int referenceHeight)
|
||||
public CanvasLayoutModel(string name, LayoutType type)
|
||||
: base(name, type)
|
||||
{
|
||||
// Initialize Reference Size
|
||||
_referenceWidth = referenceWidth;
|
||||
_referenceHeight = referenceHeight;
|
||||
}
|
||||
|
||||
public CanvasLayoutModel(string name)
|
||||
: base(name)
|
||||
{
|
||||
}
|
||||
|
||||
// ReferenceWidth - the reference width for the layout rect that all Zones are relative to
|
||||
public int ReferenceWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return _referenceWidth;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_referenceWidth != value)
|
||||
{
|
||||
_referenceWidth = value;
|
||||
FirePropertyChanged("ReferenceWidth");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _referenceWidth;
|
||||
|
||||
// ReferenceHeight - the reference height for the layout rect that all Zones are relative to
|
||||
public int ReferenceHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return _referenceHeight;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_referenceHeight != value)
|
||||
{
|
||||
_referenceHeight = value;
|
||||
FirePropertyChanged("ReferenceHeight");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _referenceHeight;
|
||||
|
||||
// Zones - the list of all zones in this layout, described as independent rectangles
|
||||
public IList<Int32Rect> Zones { get; } = new List<Int32Rect>();
|
||||
public IList<Int32Rect> Zones { get; private set; } = new List<Int32Rect>();
|
||||
|
||||
private int lastWorkAreaWidth = (int)Settings.WorkArea.Width;
|
||||
|
||||
private int lastWorkAreaHeight = (int)Settings.WorkArea.Height;
|
||||
|
||||
//private int lastWorkAreaDPI = (int)Settings.WorkAreaDPI;
|
||||
|
||||
// RemoveZoneAt
|
||||
// Removes the specified index from the Zones list, and fires a property changed notification for the Zones property
|
||||
@@ -99,11 +60,7 @@ namespace FancyZonesEditor.Models
|
||||
// Clones the data from this CanvasLayoutModel to a new CanvasLayoutModel
|
||||
public override LayoutModel Clone()
|
||||
{
|
||||
CanvasLayoutModel layout = new CanvasLayoutModel(Name)
|
||||
{
|
||||
ReferenceHeight = ReferenceHeight,
|
||||
ReferenceWidth = ReferenceWidth,
|
||||
};
|
||||
CanvasLayoutModel layout = new CanvasLayoutModel(Name, Type);
|
||||
|
||||
foreach (Int32Rect zone in Zones)
|
||||
{
|
||||
@@ -122,6 +79,32 @@ namespace FancyZonesEditor.Models
|
||||
}
|
||||
}
|
||||
|
||||
private void ScaleLayout(IList<Int32Rect> zones)
|
||||
{
|
||||
if (lastWorkAreaWidth != -1 || /*lastWorkAreaDPI != Settings.WorkAreaDPI ||*/ lastWorkAreaHeight != Settings.WorkArea.Height || lastWorkAreaWidth != Settings.WorkArea.Width)
|
||||
{
|
||||
foreach (Int32Rect zone in zones)
|
||||
{
|
||||
double widthFactor = (double)Settings.WorkArea.Width / lastWorkAreaWidth;
|
||||
double heightFactor = (double)Settings.WorkArea.Height / lastWorkAreaHeight;
|
||||
int scaledX = (int)(zone.X * widthFactor);
|
||||
int scaledY = (int)(zone.Y * heightFactor);
|
||||
int scaledWidth = (int)(zone.Width * widthFactor);
|
||||
int scaledHeight = (int)(zone.Height * heightFactor);
|
||||
Zones.Add(new Int32Rect(scaledX, scaledY, scaledWidth, scaledHeight));
|
||||
}
|
||||
|
||||
//lastWorkAreaDPI = Settings.WorkAreaDPI;
|
||||
lastWorkAreaHeight = (int)Settings.WorkArea.Height;
|
||||
lastWorkAreaWidth = (int)Settings.WorkArea.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no scaling needed
|
||||
Zones = zones;
|
||||
}
|
||||
}
|
||||
|
||||
private struct Zone
|
||||
{
|
||||
public int X { get; set; }
|
||||
@@ -159,8 +142,9 @@ namespace FancyZonesEditor.Models
|
||||
{
|
||||
CanvasLayoutInfo layoutInfo = new CanvasLayoutInfo
|
||||
{
|
||||
RefWidth = _referenceWidth,
|
||||
RefHeight = _referenceHeight,
|
||||
RefWidth = lastWorkAreaWidth,
|
||||
RefHeight = lastWorkAreaHeight,
|
||||
//LastWorkAreaDpi = lastWorkAreaDPI,
|
||||
Zones = new Zone[Zones.Count],
|
||||
};
|
||||
for (int i = 0; i < Zones.Count; ++i)
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace FancyZonesEditor.Models
|
||||
protected LayoutModel(string name)
|
||||
: this()
|
||||
{
|
||||
_guid = Guid.NewGuid();
|
||||
Name = name;
|
||||
}
|
||||
|
||||
@@ -220,8 +219,10 @@ namespace FancyZonesEditor.Models
|
||||
}
|
||||
else if (type.Equals("canvas"))
|
||||
{
|
||||
int referenceWidth = info.GetProperty("ref-width").GetInt32();
|
||||
int referenceHeight = info.GetProperty("ref-height").GetInt32();
|
||||
int lastWorkAreaWidth = info.GetProperty("last-workarea-width").GetInt32();
|
||||
int lastWorkAreaHeight = info.GetProperty("last-workarea-height").GetInt32();
|
||||
//int lastWorkAreaDPI = info.GetProperty("last-workarea-dpi").GetInt32();
|
||||
|
||||
JsonElement.ArrayEnumerator zonesEnumerator = info.GetProperty("zones").EnumerateArray();
|
||||
IList<Int32Rect> zones = new List<Int32Rect>();
|
||||
while (zonesEnumerator.MoveNext())
|
||||
@@ -233,7 +234,7 @@ namespace FancyZonesEditor.Models
|
||||
zones.Add(new Int32Rect(x, y, width, height));
|
||||
}
|
||||
|
||||
_customModels.Add(new CanvasLayoutModel(uuid, name, LayoutType.Custom, referenceWidth, referenceHeight, zones));
|
||||
_customModels.Add(new CanvasLayoutModel(uuid, name, LayoutType.Custom, zones, lastWorkAreaWidth, lastWorkAreaHeight/*, lastWorkAreaDPI*/));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace FancyZonesEditor
|
||||
public const ushort _blankCustomModelId = 0xFFFA;
|
||||
public const ushort _lastPrefinedId = _blankCustomModelId;
|
||||
|
||||
private const int _defaultDPI = 96;
|
||||
|
||||
// hard coded data for all the "Priority Grid" configurations that are unique to "Grid"
|
||||
private static readonly byte[][] _priorityData = new byte[][]
|
||||
{
|
||||
@@ -84,7 +86,7 @@ namespace FancyZonesEditor
|
||||
|
||||
// Initialize the five default layout models: Focus, Columns, Rows, Grid, and PriorityGrid
|
||||
DefaultModels = new List<LayoutModel>(5);
|
||||
_focusModel = new CanvasLayoutModel("Focus", LayoutType.Focus, (int)_workArea.Width, (int)_workArea.Height);
|
||||
_focusModel = new CanvasLayoutModel("Focus", LayoutType.Focus);
|
||||
DefaultModels.Add(_focusModel);
|
||||
|
||||
_columnsModel = new GridLayoutModel("Columns", LayoutType.Columns)
|
||||
@@ -107,7 +109,7 @@ namespace FancyZonesEditor
|
||||
_priorityGridModel = new GridLayoutModel("Priority Grid", LayoutType.PriorityGrid);
|
||||
DefaultModels.Add(_priorityGridModel);
|
||||
|
||||
_blankCustomModel = new CanvasLayoutModel("Create new custom", LayoutType.Blank, (int)_workArea.Width, (int)_workArea.Height);
|
||||
_blankCustomModel = new CanvasLayoutModel("Create new custom", LayoutType.Blank);
|
||||
|
||||
UpdateLayoutModels();
|
||||
}
|
||||
@@ -213,12 +215,9 @@ namespace FancyZonesEditor
|
||||
|
||||
private bool _isCtrlKeyPressed;
|
||||
|
||||
public Rect WorkArea
|
||||
{
|
||||
get { return _workArea; }
|
||||
}
|
||||
public static Rect WorkArea { get; private set; }
|
||||
|
||||
private Rect _workArea;
|
||||
//public static int WorkAreaDPI { get; private set; }
|
||||
|
||||
public static uint Monitor { get; private set; }
|
||||
|
||||
@@ -252,7 +251,7 @@ namespace FancyZonesEditor
|
||||
public static string WorkAreaKey { get; private set; }
|
||||
|
||||
// UpdateLayoutModels
|
||||
// Update the five default layouts based on the new ZoneCount
|
||||
// Update the five default layouts based on the new ZoneCount
|
||||
private void UpdateLayoutModels()
|
||||
{
|
||||
// Update the "Focus" Default Layout
|
||||
@@ -264,9 +263,9 @@ namespace FancyZonesEditor
|
||||
ZoneCount = 3;
|
||||
}
|
||||
|
||||
Int32Rect focusZoneRect = new Int32Rect((int)(_focusModel.ReferenceWidth * 0.1), (int)(_focusModel.ReferenceHeight * 0.1), (int)(_focusModel.ReferenceWidth * 0.6), (int)(_focusModel.ReferenceHeight * 0.6));
|
||||
int focusRectXIncrement = (ZoneCount <= 1) ? 0 : (int)(_focusModel.ReferenceWidth * 0.2) / (ZoneCount - 1);
|
||||
int focusRectYIncrement = (ZoneCount <= 1) ? 0 : (int)(_focusModel.ReferenceHeight * 0.2) / (ZoneCount - 1);
|
||||
Int32Rect focusZoneRect = new Int32Rect((int)(WorkArea.Width * 0.1), (int)(WorkArea.Height * 0.1), (int)(WorkArea.Width * 0.6), (int)(WorkArea.Height * 0.6));
|
||||
int focusRectXIncrement = (ZoneCount <= 1) ? 0 : (int)(WorkArea.Width * 0.2) / (ZoneCount - 1);
|
||||
int focusRectYIncrement = (ZoneCount <= 1) ? 0 : (int)(WorkArea.Height * 0.2) / (ZoneCount - 1);
|
||||
|
||||
for (int i = 0; i < ZoneCount; i++)
|
||||
{
|
||||
@@ -416,7 +415,8 @@ namespace FancyZonesEditor
|
||||
|
||||
private void ParseCommandLineArgs()
|
||||
{
|
||||
_workArea = SystemParameters.WorkArea;
|
||||
WorkArea = SystemParameters.WorkArea;
|
||||
//WorkAreaDPI = _defaultDPI;
|
||||
Monitor = 0;
|
||||
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
@@ -432,8 +432,9 @@ namespace FancyZonesEditor
|
||||
var y = int.Parse(parsedLocation[1]);
|
||||
var width = int.Parse(parsedLocation[2]);
|
||||
var height = int.Parse(parsedLocation[3]);
|
||||
//WorkAreaDPI = int.Parse(parsedLocation[4]);
|
||||
|
||||
_workArea = new Rect(x, y, width, height);
|
||||
WorkArea = new Rect(x, y, width, height);
|
||||
|
||||
WorkAreaKey = args[(int)CmdArgs.ResolutionKey];
|
||||
|
||||
|
||||
@@ -481,7 +481,13 @@ void FancyZones::ToggleEditor() noexcept
|
||||
const auto& fancyZonesData = JSONHelpers::FancyZonesDataInstance();
|
||||
fancyZonesData.CustomZoneSetsToJsonFile(ZoneWindowUtils::GetCustomZoneSetsTmpPath());
|
||||
|
||||
// Do not scale window params by the dpi, that will be done in the editor - see LayoutModel.Apply
|
||||
//TODO: stefan
|
||||
//UINT dpi_x = 0, dpi_y = 0;
|
||||
//if (GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y) != S_OK)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
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;
|
||||
@@ -494,6 +500,10 @@ void FancyZones::ToggleEditor() noexcept
|
||||
std::to_wstring(width) + L"_" +
|
||||
std::to_wstring(height);
|
||||
|
||||
// TODO: stefan
|
||||
/*+L"_" +
|
||||
std::to_wstring(dpi_x);*/
|
||||
|
||||
const auto deviceInfo = fancyZonesData.FindDeviceInfo(zoneWindow->UniqueId());
|
||||
if (!deviceInfo.has_value())
|
||||
{
|
||||
|
||||
@@ -745,11 +745,12 @@ namespace JSONHelpers
|
||||
}
|
||||
case CustomLayoutType::Canvas: {
|
||||
CanvasLayoutInfo info;
|
||||
//info.lastWorkAreaWidth = info.lastWorkAreaHeight = /*info.lastWorkAreaDPI =*/ -1;
|
||||
|
||||
int j = 5;
|
||||
info.referenceWidth = data[j] * 256 + data[j + 1];
|
||||
info.lastWorkAreaWidth = data[j] * 256 + data[j + 1];
|
||||
j += 2;
|
||||
info.referenceHeight = data[j] * 256 + data[j + 1];
|
||||
info.lastWorkAreaHeight = data[j] * 256 + data[j + 1];
|
||||
j += 2;
|
||||
|
||||
int count = data[j++];
|
||||
@@ -898,8 +899,9 @@ namespace JSONHelpers
|
||||
json::JsonObject CanvasLayoutInfo::ToJson(const CanvasLayoutInfo& canvasInfo)
|
||||
{
|
||||
json::JsonObject infoJson{};
|
||||
infoJson.SetNamedValue(L"ref-width", json::value(canvasInfo.referenceWidth));
|
||||
infoJson.SetNamedValue(L"ref-height", json::value(canvasInfo.referenceHeight));
|
||||
infoJson.SetNamedValue(L"ref-width", json::value(canvasInfo.lastWorkAreaWidth));
|
||||
infoJson.SetNamedValue(L"ref-height", json::value(canvasInfo.lastWorkAreaHeight));
|
||||
|
||||
json::JsonArray zonesJson;
|
||||
|
||||
for (const auto& [x, y, width, height] : canvasInfo.zones)
|
||||
@@ -920,8 +922,9 @@ namespace JSONHelpers
|
||||
try
|
||||
{
|
||||
CanvasLayoutInfo info;
|
||||
info.referenceWidth = static_cast<int>(infoJson.GetNamedNumber(L"ref-width"));
|
||||
info.referenceHeight = static_cast<int>(infoJson.GetNamedNumber(L"ref-height"));
|
||||
info.lastWorkAreaWidth = static_cast<int>(infoJson.GetNamedNumber(L"ref-width"));
|
||||
info.lastWorkAreaHeight = static_cast<int>(infoJson.GetNamedNumber(L"ref-height"));
|
||||
|
||||
json::JsonArray zonesJson = infoJson.GetNamedArray(L"zones");
|
||||
uint32_t size = zonesJson.Size();
|
||||
info.zones.reserve(size);
|
||||
|
||||
@@ -45,8 +45,9 @@ namespace JSONHelpers
|
||||
|
||||
struct CanvasLayoutInfo
|
||||
{
|
||||
int referenceWidth;
|
||||
int referenceHeight;
|
||||
int lastWorkAreaWidth;
|
||||
int lastWorkAreaHeight;
|
||||
//int lastWorkAreaDPI;
|
||||
struct Rect
|
||||
{
|
||||
int x;
|
||||
|
||||
@@ -597,7 +597,7 @@ bool ZoneSet::CalculateCustomLayout(Rect workArea, int spacing) noexcept
|
||||
wil::unique_cotaskmem_string guuidStr;
|
||||
if (SUCCEEDED_LOG(StringFromCLSID(m_config.Id, &guuidStr)))
|
||||
{
|
||||
const std::wstring guuid = guuidStr.get();
|
||||
const std::wstring guuid = guuidStr.get();
|
||||
|
||||
const auto zoneSetSearchResult = JSONHelpers::FancyZonesDataInstance().FindCustomZoneSet(guuid);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <dwmapi.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <shellapi.h>
|
||||
#include <ShellScalingApi.h>
|
||||
#include <strsafe.h>
|
||||
#include <TraceLoggingActivity.h>
|
||||
#include <wil\resource.h>
|
||||
|
||||
Reference in New Issue
Block a user