}
protected void CenterToScreen() {
- Size DisplaySize;
- int w;
- int h;
+ int w;
+ int h;
// MS creates the handle here.
if (TopLevel) {
h = DefaultSize.Height;
}
- XplatUI.GetDisplaySize(out DisplaySize);
- this.Location = new Point(DisplaySize.Width / 2 - w / 2, DisplaySize.Height / 2 - h / 2);
+ Rectangle workingArea;
+ if (Owner == null) {
+ workingArea = Screen.FromPoint (MousePosition).WorkingArea;
+ } else {
+ workingArea = Screen.FromControl (Owner).WorkingArea;
+ }
+ this.Location = new Point (workingArea.Left + workingArea.Width / 2 - w / 2,
+ workingArea.Top + workingArea.Height / 2 - h / 2);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]