}
- Rect GetRegion()
+ Rect GetClientSize()
{
Rect retval = API.GetWindowBounds(window.Handle, WindowRegionCode.ContentRegion);
-
return retval;
}
- void SetLocation(short x, short y)
+ void SetClientSize(short width, short height)
{
- if (windowState == WindowState.Fullscreen)
+ if (WindowState == WindowState.Fullscreen)
return;
-
- API.MoveWindow(window.Handle, x, y, false);
+
+ Rect new_bounds = new Rect(Bounds.X, Bounds.Y, width, height);
+ API.SetWindowBounds(window.Handle, WindowRegionCode.ContentRegion, ref new_bounds);
+ LoadSize();
}
- void SetSize(short width, short height)
+ void SetLocation(short x, short y)
{
- if (WindowState == WindowState.Fullscreen)
+ if (windowState == WindowState.Fullscreen)
return;
-
- // The bounds of the window should be the size specified, but
- // API.SizeWindow sets the content region size. So
- // we reduce the size to get the correct bounds.
- width -= (short)(bounds.Width - clientRectangle.Width);
- height -= (short)(bounds.Height - clientRectangle.Height);
-
- API.SizeWindow(window.Handle, width, height, true);
+
+ Rect new_bounds = new Rect(x, y, Bounds.Width, Bounds.Height);
+ API.SetWindowBounds(window.Handle, WindowRegionCode.StructureRegion, ref new_bounds);
+ LoadSize();
}
- void SetClientSize(short width, short height)
+ void SetSize(short width, short height)
{
if (WindowState == WindowState.Fullscreen)
return;
-
- API.SizeWindow(window.Handle, width, height, true);
+
+ Rect new_bounds = new Rect(Bounds.X, Bounds.Y, width, height);
+ API.SetWindowBounds(window.Handle, WindowRegionCode.StructureRegion, ref new_bounds);
+ LoadSize();
}
private void LoadSize()
{
if (WindowState == WindowState.Fullscreen)
return;
-
+
Rect r = API.GetWindowBounds(window.Handle, WindowRegionCode.StructureRegion);
bounds = new Rectangle(r.X, r.Y, r.Width, r.Height);
-
- r = API.GetWindowBounds(window.Handle, WindowRegionCode.GlobalPortRegion);
+
+ r = API.GetWindowBounds(window.Handle, WindowRegionCode.ContentRegion);
clientRectangle = new Rectangle(0, 0, r.Width, r.Height);
}
public int X
{
- get { return ClientRectangle.X; }
+ get { return Bounds.X; }
set { Location = new Point(value, Y); }
}
public int Y
{
- get { return ClientRectangle.Y; }
+ get { return Bounds.Y; }
set { Location = new Point(X, value); }
}