Fixed many resizing details.

AspectRatioForm refreshes size correctly.
ThumbnailPanel now takes all available space and trims on bottom if needed.
This commit is contained in:
Lorenz Cuno Klopfenstein 2010-02-05 02:07:19 +01:00
parent d43dda7aba
commit 95d4a9bd1d
7 changed files with 32 additions and 29 deletions

View file

@ -1,3 +1,4 @@
glob:OnTopReplica.suo
glob:bin/*
glob:obj/*
glob:publish/*

View file

@ -47,7 +47,7 @@ namespace OnTopReplica {
/// Forces the form to update its height based on the current aspect ratio setting.
/// </summary>
public void RefreshAspectRatio() {
this.Height = (int)(this.Width / AspectRatio);
ClientSize = new Size(ClientSize.Width, (int)(ClientSize.Width / AspectRatio));
}
/// <summary>
@ -55,7 +55,7 @@ namespace OnTopReplica {
/// </summary>
public void SetAspectRatio(Size aspectRatioSource) {
_keepAspectRatio = true; //set without updating
AspectRatio = (aspectRatioSource.Width / (double)aspectRatioSource.Height);
AspectRatio = ((double)aspectRatioSource.Width / (double)aspectRatioSource.Height);
RefreshAspectRatio();
}
@ -70,7 +70,7 @@ namespace OnTopReplica {
if (res == NativeMethods.WMSZ_LEFT || res == NativeMethods.WMSZ_RIGHT) {
//Left or right resize -> adjust height (bottom)
int targetHeight = (int)(this.Width / AspectRatio);
int targetHeight = (int)Math.Ceiling(this.Width / AspectRatio);
int originalHeight = rc.Bottom - rc.Top;
int diffHeight = originalHeight - targetHeight;
@ -79,7 +79,7 @@ namespace OnTopReplica {
}
else if (res == NativeMethods.WMSZ_TOP || res == NativeMethods.WMSZ_BOTTOM) {
//Up or down resize -> adjust width (right)
int targetWidth = (int)(this.Height * AspectRatio);
int targetWidth = (int)Math.Ceiling(this.Height * AspectRatio);
int originalWidth = rc.Right - rc.Left;
int diffWidth = originalWidth - targetWidth;
@ -88,19 +88,19 @@ namespace OnTopReplica {
}
else if (res == NativeMethods.WMSZ_RIGHT + NativeMethods.WMSZ_BOTTOM) {
//Lower-right corner resize -> adjust height (could have been width)
rc.Bottom = rc.Top + (int)(this.Width / AspectRatio);
rc.Bottom = rc.Top + (int)Math.Ceiling(this.Width / AspectRatio);
}
else if (res == NativeMethods.WMSZ_LEFT + NativeMethods.WMSZ_BOTTOM) {
//Lower-left corner resize -> adjust height (could have been width)
rc.Bottom = rc.Top + (int)(this.Width / AspectRatio);
rc.Bottom = rc.Top + (int)Math.Ceiling(this.Width / AspectRatio);
}
else if (res == NativeMethods.WMSZ_LEFT + NativeMethods.WMSZ_TOP) {
//Upper-left corner -> adjust width (could have been height)
rc.Left = rc.Right - (int)(this.Height * AspectRatio);
rc.Left = rc.Right - (int)Math.Ceiling(this.Height * AspectRatio);
}
else if (res == NativeMethods.WMSZ_RIGHT + NativeMethods.WMSZ_TOP) {
//Upper-right corner -> adjust width (could have been height)
rc.Right = rc.Left + (int)(this.Height * AspectRatio);
rc.Right = rc.Left + (int)Math.Ceiling(this.Height * AspectRatio);
}
Marshal.StructureToPtr(rc, m.LParam, true);

View file

@ -95,7 +95,7 @@
this.aboutToolStripMenuItem,
this.menuContextClose});
this.menuContext.Name = "menuContext";
this.menuContext.Size = new System.Drawing.Size(169, 296);
this.menuContext.Size = new System.Drawing.Size(169, 274);
this.menuContext.Opening += new System.ComponentModel.CancelEventHandler(this.Menu_opening);
//
// menuContextWindows
@ -170,7 +170,7 @@
this.menuOpacity.OwnerItem = this.menuContextOpacity;
this.menuOpacity.ShowCheckMargin = true;
this.menuOpacity.ShowImageMargin = false;
this.menuOpacity.Size = new System.Drawing.Size(154, 142);
this.menuOpacity.Size = new System.Drawing.Size(154, 120);
this.menuOpacity.Opening += new System.ComponentModel.CancelEventHandler(this.Menu_Opacity_opening);
//
// toolStripMenuItem1
@ -244,6 +244,7 @@
this.toolStripSeparator3,
this.fullscreenToolStripMenuItem1});
this.menuResize.Name = "menuResize";
this.menuResize.OwnerItem = this.resizeToolStripMenuItem;
this.menuResize.Size = new System.Drawing.Size(165, 120);
this.menuResize.Opening += new System.ComponentModel.CancelEventHandler(this.Menu_Resize_opening);
//
@ -351,8 +352,8 @@
//
this.chromeToolStripMenuItem.Name = "chromeToolStripMenuItem";
this.chromeToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.chromeToolStripMenuItem.Text = Strings.MenuChrome;
this.chromeToolStripMenuItem.ToolTipText = Strings.MenuChromeTT;
this.chromeToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuChrome;
this.chromeToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuChromeTT;
this.chromeToolStripMenuItem.Click += new System.EventHandler(this.Menu_Chrome_click);
//
// reduceToIconToolStripMenuItem
@ -524,7 +525,7 @@
private System.Windows.Forms.ContextMenuStrip menuLanguages;
private System.Windows.Forms.ToolStripMenuItem englishToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem italianoToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem chromeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem chromeToolStripMenuItem;
}
}

View file

@ -105,10 +105,6 @@ namespace OnTopReplica
RegionBoxShowing = false;
}
void Thumbnail_IdealSizeChange(object sender, Size e) {
ClientSize = e;
}
#endregion
#region Side "Region box" events
@ -225,7 +221,6 @@ namespace OnTopReplica
//Do some checks in order to verify the presence of desktop composition
if (!VistaControls.OsSupport.IsVistaOrBetter) {
MessageBox.Show(Strings.ErrorNoDwm, Strings.ErrorNoDwmTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
return;
@ -325,6 +320,10 @@ namespace OnTopReplica
#region Menu Event Handling
private void Close_click(object sender, EventArgs e) {
this.Close();
}
private void Menu_opening(object sender, CancelEventArgs e) {
//Cancel if currently "fullscreen" mode
if (_isFullscreen) {

View file

@ -49,8 +49,8 @@
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>2.9.0.%2a</ApplicationVersion>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>2.9.1.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>

View file

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.9.0.0")]
[assembly: AssemblyFileVersion("2.9.0.0")]
[assembly: AssemblyVersion("2.9.1.0")]
[assembly: AssemblyFileVersion("2.9.1.0")]

View file

@ -71,7 +71,7 @@ namespace OnTopReplica {
_glassMode = value;
//Set correct backcolor: black if glass is on
BackColor = (value || _fullscreenMode) ? Color.Black : SystemColors.Control;
BackColor = (value || _fullscreenMode) ? Color.Black : SystemColors.Control;
UpdateRightClickLabels();
}
@ -136,7 +136,7 @@ namespace OnTopReplica {
private byte ThumbnailOpacity {
get {
return (_drawMouseRegions) ? (byte)130 : (byte)255;
return (_drawMouseRegions) ? (byte)130 : (byte)255;
}
}
@ -204,15 +204,17 @@ namespace OnTopReplica {
if (_thumbnail != null && !_thumbnail.IsInvalid){
try {
Size sourceSize = (_regionEnabled) ? _regionCurrent.Size : _thumbnail.SourceSize;
thumbnailSize = new Size(Size.Width, Size.Height * 2); //ComputeIdealSize(sourceSize, Size);
thumbnailSize = ComputeIdealSize(sourceSize, Size);
padWidth = (Size.Width - thumbnailSize.Width) / 2;
/*padWidth = (Size.Width - thumbnailSize.Width) / 2;
padHeight = (Size.Height - thumbnailSize.Height) / 2;
Rectangle target = new Rectangle(padWidth, padHeight, thumbnailSize.Width, thumbnailSize.Height);
Rectangle target = new Rectangle(padWidth, padHeight, thumbnailSize.Width, thumbnailSize.Height);*/
var target = new Rectangle(0, 0, thumbnailSize.Width, thumbnailSize.Height);
Rectangle source = (_regionEnabled) ? _regionCurrent : new Rectangle(Point.Empty, _thumbnail.SourceSize);
//Console.WriteLine("Source " + sourceSize.ToString() + ", Target " + Size.ToString() + ", Fit " + thumbnailSize.ToString() + ", Padding " + padWidth + "," + padHeight);
_thumbnail.Update(target, source, ThumbnailOpacity, true, true);
}
catch {
@ -225,7 +227,7 @@ namespace OnTopReplica {
UpdateRightClickLabels();
}
/// <summary>Computes ideal size given an original size and a target to fit.</summary>
/// <summary>Computes ideal thumbnail size given an original size and a target to fit.</summary>
/// <param name="sourceSize">Size of the original thumbnail.</param>
/// <param name="clientSize">Size of the client area to fit.</param>
private Size ComputeIdealSize(Size sourceSize, Size clientSize) {