aboutsummaryrefslogtreecommitdiff
path: root/Histacom2.Engine/Template/WinClassic.cs
diff options
context:
space:
mode:
authorlempamo <[email protected]>2017-08-29 14:32:19 -0400
committerGitHub <[email protected]>2017-08-29 14:32:19 -0400
commitd4d94f85a6424e4d21cecccec21b0e78860431d6 (patch)
tree3644ac63218378082e0afa90d4c42d73d6d3980c /Histacom2.Engine/Template/WinClassic.cs
parent7e54d42ed67bf8417a4a479dedce65217adc8309 (diff)
parent213861a59ee7cb42816172c38994d93484d129e8 (diff)
downloadhistacom2-d4d94f85a6424e4d21cecccec21b0e78860431d6.tar.gz
histacom2-d4d94f85a6424e4d21cecccec21b0e78860431d6.tar.bz2
histacom2-d4d94f85a6424e4d21cecccec21b0e78860431d6.zip
Merge pull request #154 from Alex-TIMEHACK/master
New resizing system + Save troubleshooter fix
Diffstat (limited to 'Histacom2.Engine/Template/WinClassic.cs')
-rw-r--r--Histacom2.Engine/Template/WinClassic.cs115
1 files changed, 82 insertions, 33 deletions
diff --git a/Histacom2.Engine/Template/WinClassic.cs b/Histacom2.Engine/Template/WinClassic.cs
index 4c495bc..23ea562 100644
--- a/Histacom2.Engine/Template/WinClassic.cs
+++ b/Histacom2.Engine/Template/WinClassic.cs
@@ -14,11 +14,13 @@ namespace Histacom2.Engine.Template
}
public Font fnt;
+ public ResizeOverlay resizer = new ResizeOverlay();
public bool resizable = true;
public bool closeDisabled = false;
public bool isActive = true;
-
+ public bool Resizing = false;
+ public Bitmap ResizingBmp = null;
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int WM_SYSCOMMAND = 0x0112;
public const int HT_CAPTION = 0x2;
@@ -72,7 +74,9 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Size = new Size(MousePosition.X - this.Location.X, this.Size.Height);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = MousePosition.X - this.Location.X;
+ resizer.ToDraw = toDraw;
}
}
@@ -80,8 +84,10 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
- if (resizable)this.Location = new Point(Cursor.Position.X, this.Location.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
+ if (resizable) toDraw.X = Cursor.Position.X;
+ resizer.ToDraw = toDraw;
}
}
@@ -89,7 +95,10 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Size = new Size(this.Size.Width, MousePosition.Y - this.Location.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Y = this.Location.Y;
+ if (resizable) toDraw.Height = MousePosition.Y - this.Location.Y;
+ resizer.ToDraw = toDraw;
}
}
@@ -97,7 +106,10 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Size = new Size(MousePosition.X - this.Location.X, MousePosition.Y - this.Location.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = MousePosition.X - this.Location.X;
+ if (resizable) toDraw.Height = MousePosition.Y - this.Location.Y;
+ resizer.ToDraw = toDraw;
}
}
@@ -105,9 +117,11 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
- if (resizable) this.Height = (Cursor.Position.Y - this.Location.Y);
- if (resizable) this.Location = new Point(Cursor.Position.X, this.Location.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = ((toDraw.Width + toDraw.Location.X) - Cursor.Position.X);
+ if (resizable) toDraw.Height = Cursor.Position.Y - this.Location.Y;
+ if (resizable) toDraw.X = Cursor.Position.X;
+ resizer.ToDraw = toDraw;
}
}
@@ -115,10 +129,12 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
- if (resizable) this.Location = new Point(Cursor.Position.X, this.Location.Y);
- if (resizable) this.Height = ((this.Height + this.Location.Y) - Cursor.Position.Y);
- if (resizable) this.Location = new Point(this.Location.X, Cursor.Position.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
+ if (resizable) toDraw.X = Cursor.Position.X;
+ if (resizable) toDraw.Height = ((this.Height + this.Location.Y) - Cursor.Position.Y);
+ if (resizable) toDraw.Y = Cursor.Position.Y;
+ resizer.ToDraw = toDraw;
}
}
@@ -126,8 +142,10 @@ namespace Histacom2.Engine.Template
{
if(e.Button == MouseButtons.Left)
{
- if(resizable) this.Height = ((this.Height + this.Location.Y) - Cursor.Position.Y);
- if(resizable) this.Location = new Point(this.Location.X, Cursor.Position.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y);
+ if (resizable) toDraw.Y = Cursor.Position.Y;
+ resizer.ToDraw = toDraw;
}
}
@@ -135,12 +153,58 @@ namespace Histacom2.Engine.Template
{
if (e.Button == MouseButtons.Left)
{
- if (resizable) this.Width = (Cursor.Position.X - this.Location.X);
- if (resizable) this.Height = ((this.Location.Y - Cursor.Position.Y) + this.Height);
- if (resizable) this.Location = new Point(this.Location.X, Cursor.Position.Y);
+ var toDraw = resizer.ToDraw;
+ if (resizable) toDraw.Width = MousePosition.X - this.Location.X;
+ if (resizable) toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y);
+ if (resizable) toDraw.Y = Cursor.Position.Y;
+ resizer.ToDraw = toDraw;
+ }
+ }
+
+ private void WinClassic_Paint(object sender, PaintEventArgs e)
+ {
+ if (Resizing)
+ {
+ MessageBox.Show("HIT IT");
+ e.Graphics.DrawImage(ResizingBmp, 0, 0, this.Width, this.Height);
}
}
+ private void border_MouseUp(object sender, MouseEventArgs e)
+ {
+ this.Bounds = resizer.ToDraw;
+ resizer.tmrMove.Stop();
+ resizer.Close();
+
+ resizer = new ResizeOverlay();
+ }
+
+ private void border_MouseDown(object sender, MouseEventArgs e)
+ {
+ var cursor = this.PointToClient(Cursor.Position);
+
+ if (topleftcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF004, 0);
+ else if (toprightcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF005, 0);
+ else if (bottomleftcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF007, 0);
+ else if (bottomrightcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF008, 0);
+
+ else if (top.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF003, 0);
+ else if (left.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF001, 0);
+ else if (right.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF002, 0);
+ else if (bottom.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF006, 0);
+
+ // Now we need to fix this weird artificating!
+
+ resizer.tmrMove.Start();
+ resizer.Show();
+
+ resizer.ToDraw = this.Bounds;
+
+ // However this defocuses the window which we don't want
+
+ WinClassic_Activated(null, null);
+ }
+
public bool max = false;
private void maximizebutton_Click(object sender, EventArgs e)
@@ -216,20 +280,5 @@ namespace Histacom2.Engine.Template
var c = (Button)sender;
c.UseVisualStyleBackColor = true;
}
-
- private void border_MouseDown(object sender, EventArgs e)
- {
- var cursor = this.PointToClient(Cursor.Position);
-
- if (topleftcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF004, 0);
- else if (toprightcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF005, 0);
- else if (bottomleftcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF007, 0);
- else if (bottomrightcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF008, 0);
-
- else if (top.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF003, 0);
- else if (left.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF001, 0);
- else if (right.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF002, 0);
- else if (bottom.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF006, 0);
- }
}
}