mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-21 04:43:55 +12:00
Issue #58: when resizing (WM_SIZING) and on wheel scroll the aspect ratio of the source window is refreshed.
AspectRatioForm now stores initial aspect ratio on window handle creation (until new aspect ratio is set).
This commit is contained in:
parent
56e47fb7e5
commit
1c253bdcb1
|
@ -71,6 +71,13 @@ namespace OnTopReplica {
|
|||
}
|
||||
}
|
||||
|
||||
protected override void OnHandleCreated(EventArgs e) {
|
||||
base.OnHandleCreated(e);
|
||||
|
||||
//When created, use first size of the window as aspect ratio
|
||||
SetAspectRatio(ClientSize, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Forces the form to update its height based on the current aspect ratio setting.
|
||||
/// </summary>
|
||||
|
@ -155,13 +162,20 @@ namespace OnTopReplica {
|
|||
}
|
||||
}
|
||||
|
||||
protected virtual void OnResizing(EventArgs e) {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override WM_SIZING message to restrict resizing.
|
||||
/// Taken from: http://www.vcskicks.com/maintain-aspect-ratio.php
|
||||
/// Improved with code from: http://stoyanoff.info/blog/2010/06/27/resizing-forms-while-keeping-aspect-ratio/
|
||||
/// </summary>
|
||||
protected override void WndProc(ref Message m) {
|
||||
if (KeepAspectRatio && m.Msg == WM.SIZING) {
|
||||
if (m.Msg == WM.SIZING) {
|
||||
this.OnResizing(EventArgs.Empty);
|
||||
|
||||
if (KeepAspectRatio) {
|
||||
var clientSizeConversion = ClientWindowDifference;
|
||||
|
||||
var rc = (Native.NRectangle)Marshal.PtrToStructure(m.LParam, typeof(Native.NRectangle));
|
||||
|
@ -197,6 +211,7 @@ namespace OnTopReplica {
|
|||
|
||||
Marshal.StructureToPtr(rc, m.LParam, false);
|
||||
}
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
|
|
@ -101,6 +101,13 @@ namespace OnTopReplica {
|
|||
RefreshScreenLock();
|
||||
}
|
||||
|
||||
protected override void OnResizing(EventArgs e) {
|
||||
//Update aspect ratio from thumbnail while resizing (but do not refresh, resizing does that anyway)
|
||||
if (_thumbnailPanel.IsShowingThumbnail) {
|
||||
SetAspectRatio(_thumbnailPanel.ThumbnailPixelSize, false);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e) {
|
||||
base.OnActivated(e);
|
||||
|
||||
|
@ -127,8 +134,13 @@ namespace OnTopReplica {
|
|||
base.OnMouseWheel(e);
|
||||
|
||||
if (!FullscreenManager.IsFullscreen) {
|
||||
if (_thumbnailPanel.IsShowingThumbnail) {
|
||||
SetAspectRatio(_thumbnailPanel.ThumbnailPixelSize, false);
|
||||
}
|
||||
|
||||
int change = (int)(e.Delta / 6.0); //assumes a mouse wheel "tick" is in the 80-120 range
|
||||
AdjustSize(change);
|
||||
|
||||
RefreshScreenLock();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue