Aspect ratio keeping improved.

Weird bug on "region box" removed.
This commit is contained in:
Lorenz Cuno Klopfenstein 2010-02-09 00:35:28 +01:00
parent 5c47783de1
commit a649deb174
11 changed files with 24 additions and 109 deletions

View file

@ -60,7 +60,6 @@ namespace OnTopReplica {
/// Forces the form to update its height based on the current aspect ratio setting.
/// </summary>
public void RefreshAspectRatio() {
Console.WriteLine("Refreshing, size " + ClientSize.ToString() + " padding " + ExtraPadding.ToString());
ClientSize = new Size(ClientSize.Width,
(int)((ClientSize.Width - ExtraPadding.Horizontal) / AspectRatio) + ExtraPadding.Vertical);
}
@ -74,8 +73,20 @@ namespace OnTopReplica {
RefreshAspectRatio();
}
protected override void OnResizeEnd(EventArgs e) {
base.OnResizeEnd(e);
//Ensure that the ClientSize of the form is always respected (not ensured by the WM_SIZING message alone)
if (KeepAspectRatio) {
//Since WM_SIZING already fixes up the size almost correctly,
//simply set the height to the correct value
var newHeight = (int)((ClientSize.Width - ExtraPadding.Horizontal) / AspectRatio + ExtraPadding.Vertical);
ClientSize = new Size(ClientSize.Width, newHeight);
}
}
/// <summary>
/// Override WM_SIZING message.
/// Override WM_SIZING message to restrict resizing.
/// Taken from: http://www.vcskicks.com/maintain-aspect-ratio.php
/// </summary>
protected override void WndProc(ref Message m) {

View file

@ -1,51 +0,0 @@
<html>
<head>
<style type="text/css">
body {
font-family: Segoe UI, Arial, sans-serif;
font-size: 0.8em;
margin: 0;
padding: 0.75em;
}
h1 {
font-size: 1.4em;
font-weight: bold;
margin: 0 0 1em 0;
padding: 0;
}
p {
margin: 0.5em 0 0.5em 1em;
padding: 0;
}
a {
font-weight: bold;
color: blue;
}
a:hover {
color: red;
}
</style>
</head>
<body>
<h1>License</h1>
<p><b>OnTopReplica</b> is licensed under the <a href="http://opensource.org/licenses/ms-rl.html">Microsoft Reciprocal License (Ms-RL)</a>.</p>
<p>The original source code can be found on the <a href="http://www.codeplex.com/ontopreplica">project's homepage on CodePlex</a>.</p>
<h1>Credits</h1>
<p>OnTopReplica was inspired by <a href="http://insentient.net">Switcher</a> and other DWM based applications.</p>
<p>All Vista controls are part of the <a href="http://www.codeplex.com/windowsformsaero">WindowsFormsAero library</a> for .NET.</p>
<p>Some example code taken from <a href="http://www.ookii.org">Ookii</a> on Channel9.</p>
<p>NativeToolstripRenderer class taken from <a href="http://wp.asztal.net/2007/12/vista-style-menus-in-dotnet/">asztal.net</a>.</p>
<p>Some icons from <a href="http://www.vistaico.com">VistaICO.com</a> and the Xiao icon set.</p>
</body>
</html>

View file

@ -466,7 +466,7 @@
this.ControlBox = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(200, 205);
this.MinimumSize = new System.Drawing.Size(200, 210);
this.Name = "MainForm";
this.ShowInTaskbar = false;
this.TopMost = true;

View file

@ -92,6 +92,7 @@ namespace OnTopReplica
void RegionBox_RequestRegionReset(object sender, EventArgs e) {
_thumbnailPanel.ResetShownRegion();
SetAspectRatio(_thumbnailPanel.ThumbnailOriginalSize);
}
void Thumbnail_RegionDrawn(object sender, Rectangle region) {
@ -151,6 +152,7 @@ namespace OnTopReplica
X = (value) ? (ClientSize.Width - _regionBox.Width) : ClientSize.Width,
Y = 0
};
_regionBox.Size = new Size(_regionBox.Width, ClientSize.Height);
//Check form boundaries and move form if necessary
if (value) {

View file

@ -49,8 +49,8 @@
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>2.9.1.%2a</ApplicationVersion>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>2.9.2.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
@ -254,7 +254,6 @@
<None Include="Assets\arrow_down.png" />
<None Include="Assets\arrow_up.png" />
<None Include="Assets\component.png" />
<None Include="Assets\about.html" />
<None Include="Assets\flag_usa.png" />
<None Include="Assets\flag_ita.png" />
<Content Include="Assets\icon.ico" />

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.1.0")]
[assembly: AssemblyFileVersion("2.9.1.0")]
[assembly: AssemblyVersion("2.9.2.0")]
[assembly: AssemblyFileVersion("2.9.2.0")]

View file

@ -60,49 +60,6 @@ namespace OnTopReplica.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to &lt;html&gt;
/// &lt;head&gt;
/// &lt;style type=&quot;text/css&quot;&gt;
///body {
/// font-family: Segoe UI, Arial, sans-serif;
/// font-size: 0.8em;
/// margin: 0;
/// padding: 0.75em;
///}
///h1 {
/// font-size: 1.4em;
/// font-weight: bold;
///
/// margin: 0 0 1em 0;
/// padding: 0;
///}
///p {
/// margin: 0.5em 0 0.5em 1em;
/// padding: 0;
///}
///a {
/// font-weight: bold;
/// color: blue;
///}
///a:hover {
/// color: red;
///}
/// &lt;/style&gt;
/// &lt;/head&gt;
///
/// &lt;body&gt;
///
/// &lt;h1&gt;License&lt;/h1&gt;
///
/// &lt;p&gt;&lt;b&gt;OnTopReplica&lt;/b&gt; is licensed under the &lt;a href=&quot;http://opensource.org/licenses/m [rest of string was truncated]&quot;;.
/// </summary>
internal static string about {
get {
return ResourceManager.GetString("about", resourceCulture);
}
}
internal static System.Drawing.Bitmap back {
get {
object obj = ResourceManager.GetObject("back", resourceCulture);

View file

@ -169,9 +169,6 @@
<data name="pos_topright" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Assets\pos_topright.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="about" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Assets\about.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="window_border16" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Assets\window_border16.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

View file

@ -110,7 +110,7 @@ namespace OnTopReplica {
/// font-size: 1.4em;
/// font-weight: bold;
///
/// margin: 0 0 1em 0;
/// margin: 1em 0 0.4em 0;
/// padding: 0;
///}
///p {
@ -131,7 +131,7 @@ namespace OnTopReplica {
///
/// &lt;h1&gt;License&lt;/h1&gt;
///
/// &lt;p&gt;&lt;b&gt;OnTopReplica&lt;/b&gt; is licensed under the &lt;a href=&quot;http://opensource.org/licenses/ms- [rest of string was truncated]&quot;;.
/// &lt;p&gt;&lt;b&gt;OnTopReplica&lt;/b&gt; is licensed under the &lt;a href=&quot;http://opensource.org/licenses [rest of string was truncated]&quot;;.
/// </summary>
internal static string AboutDetails {
get {

View file

@ -489,7 +489,7 @@ h1 {
font-size: 1.4em;
font-weight: bold;
margin: 0 0 1em 0;
margin: 1em 0 0.4em 0;
padding: 0;
}
p {

View file

@ -489,7 +489,7 @@ h1 {
font-size: 1.4em;
font-weight: bold;
margin: 0 0 1em 0;
margin: 1em 0 0.4em 0;
padding: 0;
}
p {