[FancyZones editor] Fix CanvasRect not being initialized (#10163)

* Fix CanvasRect not being initialized

* No need to use workArea height if it's set in CanvasLayoutModel
This commit is contained in:
Ivan Stošić 2021-03-11 10:50:53 +01:00 committed by GitHub
parent 72da703f0e
commit 488ee19f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -261,7 +261,7 @@ namespace FancyZonesEditor
private void RenderCanvasPreview(CanvasLayoutModel canvas)
{
var workArea = canvas.CanvasRect;
if (workArea.Width == 0 || workArea.Height == 0 || App.Overlay.SpanZonesAcrossMonitors)
if (workArea.Width == 0 || workArea.Height == 0)
{
workArea = App.Overlay.WorkArea;
}

View File

@ -304,7 +304,8 @@ namespace FancyZonesEditor
}
else
{
CanvasLayoutModel canvasModel = new CanvasLayoutModel(LayoutNameText.Text, LayoutType.Custom);
var area = App.Overlay.WorkArea;
CanvasLayoutModel canvasModel = new CanvasLayoutModel(LayoutNameText.Text, LayoutType.Custom, (int)area.Width, (int)area.Height);
canvasModel.AddZone();
selectedLayoutModel = canvasModel;
}

View File

@ -36,6 +36,12 @@ namespace FancyZonesEditor.Models
CanvasRect = new Rect(new Size(width, height));
}
public CanvasLayoutModel(string name, LayoutType type, int width, int height)
: base(name, type)
{
CanvasRect = new Rect(new Size(width, height));
}
public CanvasLayoutModel(string name, LayoutType type)
: base(name, type)
{
@ -148,6 +154,7 @@ namespace FancyZonesEditor.Models
}
layout.SensitivityRadius = SensitivityRadius;
layout.CanvasRect = CanvasRect;
return layout;
}
@ -161,6 +168,7 @@ namespace FancyZonesEditor.Models
other._topLeft = _topLeft;
other.SensitivityRadius = SensitivityRadius;
other.CanvasRect = CanvasRect;
other.UpdateLayout();
}