summaryrefslogtreecommitdiff
path: root/grapher/Form1.cs
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-01-21 22:54:30 -0500
committera1xd <[email protected]>2021-01-21 22:54:30 -0500
commitd5316b36a285287a3e02a1c568c4b66f02c23c7b (patch)
tree5a5177845b4f7bf3073474ec98ecaed88d54411c /grapher/Form1.cs
parentupdate signed (diff)
downloadrawaccel-d5316b36a285287a3e02a1c568c4b66f02c23c7b.tar.xz
rawaccel-d5316b36a285287a3e02a1c568c4b66f02c23c7b.zip
center gui on initial resize
position is no longer based on the Form.Location property, should fix issues with multi-monitor setups
Diffstat (limited to 'grapher/Form1.cs')
-rw-r--r--grapher/Form1.cs17
1 files changed, 13 insertions, 4 deletions
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
index 71a5e01..6927211 100644
--- a/grapher/Form1.cs
+++ b/grapher/Form1.cs
@@ -160,6 +160,8 @@ namespace grapher
DirectionalityRangeLabel,
RangeActiveValueX,
RangeActiveValueY);
+
+ ResizeAndCenter();
}
#endregion Constructor
@@ -191,18 +193,25 @@ namespace grapher
chartsPanel.AutoScrollPosition = Constants.Origin;
}
- public void DoResize()
+ public void ResizeAndCenter()
{
ResetAutoScroll();
- var workingArea = Screen.PrimaryScreen.WorkingArea;
+ var workingArea = Screen.FromControl(this).WorkingArea;
var chartsPreferredSize = chartsPanel.GetPreferredSize(Constants.MaxSize);
Size = new Size
{
- Width = Math.Min(workingArea.Width - Location.X, optionsPanel.Size.Width + chartsPreferredSize.Width),
- Height = Math.Min(workingArea.Height - Location.Y, chartsPreferredSize.Height + 48)
+ Width = Math.Min(workingArea.Width, optionsPanel.Size.Width + chartsPreferredSize.Width),
+ Height = Math.Min(workingArea.Height, chartsPreferredSize.Height + 48)
};
+
+ Location = new Point
+ {
+ X = workingArea.X + (workingArea.Width - Size.Width) / 2,
+ Y = workingArea.Y + (workingArea.Height - Size.Height) / 2
+ };
+
}
#endregion Method