mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-20 20:33:06 +12:00
Added basic resizing with mouse wheel (bugged still).
This commit is contained in:
parent
964c2a000f
commit
07b4db4666
|
@ -70,6 +70,24 @@ namespace OnTopReplica {
|
|||
ClientSize = new Size(newWidth, newHeight);
|
||||
}
|
||||
|
||||
public void AdjustSize(double delta) {
|
||||
int newWidth = Math.Max((int)(ClientSize.Width + delta), MinimumSize.Width);
|
||||
int newHeight = (int)((newWidth - ExtraPadding.Horizontal) / AspectRatio + ExtraPadding.Vertical);
|
||||
|
||||
//Readjust if we go lower than minimal height
|
||||
if (newHeight < MinimumSize.Height) {
|
||||
newHeight = MinimumSize.Height;
|
||||
newWidth = (int)((newHeight - ExtraPadding.Vertical) * AspectRatio + ExtraPadding.Horizontal);
|
||||
}
|
||||
|
||||
//Compute movement to re-center
|
||||
int deltaX = newWidth - ClientSize.Width;
|
||||
int deltaY = newHeight - ClientSize.Height;
|
||||
|
||||
ClientSize = new Size(newWidth, newHeight);
|
||||
Location = new Point(Location.X - (deltaX / 2), Location.Y - (deltaY / 2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the aspect ratio of the form and forces a refresh.
|
||||
/// </summary>
|
||||
|
@ -146,14 +164,6 @@ namespace OnTopReplica {
|
|||
return new Size(size.Width - clientSizeConversionWidth, size.Height - clientSizeConversionHeight);
|
||||
}
|
||||
|
||||
/*private void ClientSizeInit() {
|
||||
if (clientSizeConversionSet)
|
||||
return;
|
||||
|
||||
clientSizeConversionWidth = this.Size.Width - this.ClientSize.Width;
|
||||
clientSizeConversionHeight = this.ClientSize.Width - this.ClientSize.Height;
|
||||
}*/
|
||||
|
||||
protected override void OnShown(EventArgs e) {
|
||||
base.OnShown(e);
|
||||
|
||||
|
|
|
@ -229,6 +229,12 @@ namespace OnTopReplica {
|
|||
new Margins(-1);
|
||||
}
|
||||
|
||||
protected override void OnMouseWheel(MouseEventArgs e) {
|
||||
base.OnMouseWheel(e);
|
||||
|
||||
AdjustSize(e.Delta);
|
||||
}
|
||||
|
||||
protected override void OnShown(EventArgs e) {
|
||||
base.OnShown(e);
|
||||
|
||||
|
|
Loading…
Reference in a new issue