feat: Resizing properly working without taking delta magnitude into account
This commit is contained in:
parent
ce692af862
commit
65af35e8d5
4 changed files with 49 additions and 28 deletions
|
@ -295,24 +295,45 @@ namespace SatorImaging.AppWindowUtility
|
|||
WinApi.RECT rect;
|
||||
WinApi.GetWindowRect(hWnd, out rect);
|
||||
|
||||
float resizeFactor = Mathf.Abs(resizeDirection.x) > Mathf.Abs(resizeDirection.y)
|
||||
? deltaX
|
||||
: deltaY;
|
||||
|
||||
int x = rect.left;
|
||||
int y = rect.top;
|
||||
int width = (int)(rect.right - rect.left + resizeFactor);
|
||||
//int height = (int)(rect.bottom - rect.top + deltaY);
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
if (resizeDirection.x < 0) {
|
||||
x += (int)resizeFactor;
|
||||
width = rect.right - x;
|
||||
}
|
||||
int height = (int)(width / aspectRatio);
|
||||
if (resizeDirection.y < 0) {
|
||||
y += (int)resizeFactor;
|
||||
height = rect.bottom - y;
|
||||
width = (int)(height * aspectRatio);
|
||||
if (resizeDirection.x > 0) {
|
||||
if (resizeDirection.y > 0) {
|
||||
width = (int)(rect.right - rect.left + deltaX);
|
||||
height = (int)(width / aspectRatio);
|
||||
}else if (resizeDirection.y < 0) {
|
||||
width = (int)(rect.right - rect.left + deltaX);
|
||||
height = (int)(width / aspectRatio);
|
||||
}else {
|
||||
width = (int)(rect.right - rect.left + deltaX);
|
||||
height = (int)(width / aspectRatio);
|
||||
}
|
||||
}else if (resizeDirection.x < 0) {
|
||||
if (resizeDirection.y > 0) {
|
||||
x += (int)deltaX;
|
||||
width = rect.right - x;
|
||||
height = (int)(width / aspectRatio);
|
||||
}else if (resizeDirection.y < 0) {
|
||||
x += (int)deltaX;
|
||||
width = rect.right - x;
|
||||
height = (int)(width / aspectRatio);
|
||||
}else {
|
||||
x += (int)deltaX;
|
||||
width = rect.right - x;
|
||||
height = (int)(width / aspectRatio);
|
||||
}
|
||||
} else {
|
||||
if (resizeDirection.y > 0) {
|
||||
y += (int)deltaY;
|
||||
height = rect.bottom - y;
|
||||
width = (int)(height * aspectRatio);
|
||||
}else if (resizeDirection.y < 0) {
|
||||
height = (int)(rect.bottom - rect.top + deltaY);
|
||||
width = (int)(height * aspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
WinApi.SetWindowPos(hWnd, IntPtr.Zero, x, y, width, height, WinApi.SetWindowPosFlags.NoFlag);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue