From f16f3a8a3df33f46c4ec6c864447cced97c0f034 Mon Sep 17 00:00:00 2001 From: AShifter Date: Sun, 26 Mar 2017 11:28:05 -0600 Subject: Finished WindowManager.cs I HOPE YOU LIKE IT HONEYFRY --- TimeHACK.Engine/Properties/Resources.Designer.cs | 10 ++++ TimeHACK.Engine/Properties/Resources.resx | 3 + .../Resources/WinClassic/Window/nullIcon.png | Bin 0 -> 157 bytes TimeHACK.Engine/Resources/WinClassic/desktop.ini | 3 - TimeHACK.Engine/Template/WinClassic.Designer.cs | 27 +++++++-- TimeHACK.Engine/Template/WinClassic.cs | 66 ++++++++++++++++++--- TimeHACK.Engine/TimeHACK.Engine.csproj | 5 +- TimeHACK.Engine/WindowManager.cs | 42 ++++++++++--- TimeHACK.Engine/bin/Debug/TimeHACK.Engine.dll | Bin 19456 -> 21504 bytes TimeHACK.Engine/bin/Debug/TimeHACK.Engine.pdb | Bin 24064 -> 26112 bytes .../DesignTimeResolveAssemblyReferencesInput.cache | Bin 8376 -> 8212 bytes .../TimeHACK.Engine.Properties.Resources.resources | Bin 4715 -> 5051 bytes .../TimeHACK.Engine.csproj.GenerateResource.Cache | Bin 1742 -> 1838 bytes ...ACK.Engine.csprojResolveAssemblyReference.cache | Bin 2230 -> 2230 bytes TimeHACK.Engine/obj/Debug/TimeHACK.Engine.dll | Bin 19456 -> 21504 bytes TimeHACK.Engine/obj/Debug/TimeHACK.Engine.pdb | Bin 24064 -> 26112 bytes 16 files changed, 130 insertions(+), 26 deletions(-) create mode 100644 TimeHACK.Engine/Resources/WinClassic/Window/nullIcon.png delete mode 100644 TimeHACK.Engine/Resources/WinClassic/desktop.ini (limited to 'TimeHACK.Engine') diff --git a/TimeHACK.Engine/Properties/Resources.Designer.cs b/TimeHACK.Engine/Properties/Resources.Designer.cs index de94a30..a5a90ba 100644 --- a/TimeHACK.Engine/Properties/Resources.Designer.cs +++ b/TimeHACK.Engine/Properties/Resources.Designer.cs @@ -100,6 +100,16 @@ namespace TimeHACK.Engine.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap nullIcon { + get { + object obj = ResourceManager.GetObject("nullIcon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/TimeHACK.Engine/Properties/Resources.resx b/TimeHACK.Engine/Properties/Resources.resx index f63b0e2..ff58fbd 100644 --- a/TimeHACK.Engine/Properties/Resources.resx +++ b/TimeHACK.Engine/Properties/Resources.resx @@ -130,6 +130,9 @@ ..\resources\winclassic\window\leftside.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\resources\winclassic\window\nullicon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\resources\winclassic\window\rightside.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/TimeHACK.Engine/Resources/WinClassic/Window/nullIcon.png b/TimeHACK.Engine/Resources/WinClassic/Window/nullIcon.png new file mode 100644 index 0000000..a8bbc1d Binary files /dev/null and b/TimeHACK.Engine/Resources/WinClassic/Window/nullIcon.png differ diff --git a/TimeHACK.Engine/Resources/WinClassic/desktop.ini b/TimeHACK.Engine/Resources/WinClassic/desktop.ini deleted file mode 100644 index 00ae697..0000000 --- a/TimeHACK.Engine/Resources/WinClassic/desktop.ini +++ /dev/null @@ -1,3 +0,0 @@ -[LocalizedFileNames] -settings pic start.png=@settings pic start.png,0 -windows 95 sidemenustart.bmp=@windows 95 sidemenustart.bmp,0 diff --git a/TimeHACK.Engine/Template/WinClassic.Designer.cs b/TimeHACK.Engine/Template/WinClassic.Designer.cs index 7df96b7..6fc4a78 100644 --- a/TimeHACK.Engine/Template/WinClassic.Designer.cs +++ b/TimeHACK.Engine/Template/WinClassic.Designer.cs @@ -44,11 +44,13 @@ this.bottom = new System.Windows.Forms.Panel(); this.right = new System.Windows.Forms.Panel(); this.top = new System.Windows.Forms.Panel(); + this.programIcon = new System.Windows.Forms.PictureBox(); this.program.SuspendLayout(); this.programtopbar.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.maximizebutton)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.minimizebutton)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.closebutton)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.programIcon)).BeginInit(); this.SuspendLayout(); // // program @@ -81,6 +83,7 @@ // programtopbar // this.programtopbar.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(170))))); + this.programtopbar.Controls.Add(this.programIcon); this.programtopbar.Controls.Add(this.maximizebutton); this.programtopbar.Controls.Add(this.minimizebutton); this.programtopbar.Controls.Add(this.Title); @@ -90,6 +93,7 @@ this.programtopbar.Name = "programtopbar"; this.programtopbar.Size = new System.Drawing.Size(292, 18); this.programtopbar.TabIndex = 0; + this.programtopbar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.programtopbar_drag); // // maximizebutton // @@ -100,6 +104,7 @@ this.maximizebutton.Size = new System.Drawing.Size(16, 14); this.maximizebutton.TabIndex = 6; this.maximizebutton.TabStop = false; + this.maximizebutton.Click += new System.EventHandler(this.maximizebutton_Click); // // minimizebutton // @@ -116,7 +121,7 @@ this.Title.AutoSize = true; this.Title.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Title.ForeColor = System.Drawing.Color.White; - this.Title.Location = new System.Drawing.Point(3, 2); + this.Title.Location = new System.Drawing.Point(23, 3); this.Title.Name = "Title"; this.Title.Size = new System.Drawing.Size(99, 13); this.Title.TabIndex = 3; @@ -131,6 +136,7 @@ this.closebutton.Size = new System.Drawing.Size(16, 14); this.closebutton.TabIndex = 4; this.closebutton.TabStop = false; + this.closebutton.Click += new System.EventHandler(this.closebutton_Click); // // toprightcorner // @@ -208,6 +214,17 @@ this.top.Size = new System.Drawing.Size(300, 4); this.top.TabIndex = 8; // + // programIcon + // + this.programIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.programIcon.ErrorImage = null; + this.programIcon.InitialImage = null; + this.programIcon.Location = new System.Drawing.Point(2, 1); + this.programIcon.Name = "programIcon"; + this.programIcon.Size = new System.Drawing.Size(16, 16); + this.programIcon.TabIndex = 0; + this.programIcon.TabStop = false; + // // WinClassic // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -223,6 +240,7 @@ ((System.ComponentModel.ISupportInitialize)(this.maximizebutton)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.minimizebutton)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.closebutton)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.programIcon)).EndInit(); this.ResumeLayout(false); } @@ -230,10 +248,7 @@ #endregion internal System.Windows.Forms.Panel program; - private System.Windows.Forms.Panel programContent; internal System.Windows.Forms.Panel programtopbar; - internal System.Windows.Forms.PictureBox maximizebutton; - internal System.Windows.Forms.PictureBox minimizebutton; internal System.Windows.Forms.Label Title; internal System.Windows.Forms.PictureBox closebutton; internal System.Windows.Forms.Panel toprightcorner; @@ -244,5 +259,9 @@ internal System.Windows.Forms.Panel bottom; internal System.Windows.Forms.Panel right; internal System.Windows.Forms.Panel top; + public System.Windows.Forms.Panel programContent; + public System.Windows.Forms.PictureBox maximizebutton; + public System.Windows.Forms.PictureBox minimizebutton; + public System.Windows.Forms.PictureBox programIcon; } } \ No newline at end of file diff --git a/TimeHACK.Engine/Template/WinClassic.cs b/TimeHACK.Engine/Template/WinClassic.cs index aa72263..1bd11e3 100644 --- a/TimeHACK.Engine/Template/WinClassic.cs +++ b/TimeHACK.Engine/Template/WinClassic.cs @@ -1,11 +1,5 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Runtime.InteropServices; using System.Windows.Forms; namespace TimeHACK.Engine.Template @@ -16,5 +10,63 @@ namespace TimeHACK.Engine.Template { InitializeComponent(); } + + public const int WM_NCLBUTTONDOWN = 0xA1; + public const int HT_CAPTION = 0x2; + + [DllImportAttribute("user32.dll")] + public static extern int SendMessage(IntPtr hWnd, + int Msg, int wParam, int lParam); + [DllImportAttribute("user32.dll")] + public static extern bool ReleaseCapture(); + + private void programtopbar_drag(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + ReleaseCapture(); + SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); + } + } + + private void closebutton_Click(object sender, EventArgs e) + { + this.Close(); + } + + public Boolean max = false; + + private void maximizebutton_Click(object sender, EventArgs e) + { + if (max == false) + { + this.right.Hide(); + this.left.Hide(); + this.bottom.Hide(); + this.top.Hide(); + this.bottomleftcorner.Hide(); + this.bottomrightcorner.Hide(); + this.topleftcorner.Hide(); + this.toprightcorner.Hide(); + this.Dock = DockStyle.Fill; + max = true; + maximizebutton.Image = Properties.Resources.WinClassicRestore; + } + else + { + this.right.Show(); + this.left.Show(); + this.bottom.Show(); + this.top.Show(); + this.bottomleftcorner.Show(); + this.bottomrightcorner.Show(); + this.topleftcorner.Show(); + this.toprightcorner.Show(); + this.Dock = DockStyle.None; + max = false; + maximizebutton.Image = Properties.Resources.WinClassicMax; + } + + } } } diff --git a/TimeHACK.Engine/TimeHACK.Engine.csproj b/TimeHACK.Engine/TimeHACK.Engine.csproj index c691b41..840be1f 100644 --- a/TimeHACK.Engine/TimeHACK.Engine.csproj +++ b/TimeHACK.Engine/TimeHACK.Engine.csproj @@ -71,6 +71,7 @@ + @@ -80,8 +81,6 @@ - - - + \ No newline at end of file diff --git a/TimeHACK.Engine/WindowManager.cs b/TimeHACK.Engine/WindowManager.cs index 540dddd..fc9bd94 100644 --- a/TimeHACK.Engine/WindowManager.cs +++ b/TimeHACK.Engine/WindowManager.cs @@ -1,20 +1,44 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using TimeHACK.Engine.Template; +using System.Windows.Forms; namespace TimeHACK.Engine { - class WindowManager + public class WindowManager { - private void startWinClassic(String title, int width, int height) + public void startWinClassic(UserControl content, String title, PictureBox icon, Boolean MaxButton, Boolean MinButton) { + // Setup Window WinClassic app = new WinClassic(); app.Title.Text = title; - app.Width = width + 8; - app.Height = height + 26; + app.Width = content.Width + 8; + app.Height = content.Height + 26; + content.Parent = app.programContent; + content.BringToFront(); + content.Dock = DockStyle.Fill; + if (icon == null) + { + icon = app.programIcon; + icon.Image = Properties.Resources.nullIcon; + } + app.programIcon.Image = icon.Image; + + // Check if Max button is enabled + if (MaxButton == false) + { + app.maximizebutton.Visible = false; + } + + // Check if Min button is enabled + if (MinButton == false) + { + app.minimizebutton.Visible = false; + } + + // Show the app + app.Show(); + + } } -} +} \ No newline at end of file diff --git a/TimeHACK.Engine/bin/Debug/TimeHACK.Engine.dll b/TimeHACK.Engine/bin/Debug/TimeHACK.Engine.dll index 9c859e2..9e8c504 100644 Binary files a/TimeHACK.Engine/bin/Debug/TimeHACK.Engine.dll and b/TimeHACK.Engine/bin/Debug/TimeHACK.Engine.dll differ diff --git a/TimeHACK.Engine/bin/Debug/TimeHACK.Engine.pdb b/TimeHACK.Engine/bin/Debug/TimeHACK.Engine.pdb index a92c614..b0d17dc 100644 Binary files a/TimeHACK.Engine/bin/Debug/TimeHACK.Engine.pdb and b/TimeHACK.Engine/bin/Debug/TimeHACK.Engine.pdb differ diff --git a/TimeHACK.Engine/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/TimeHACK.Engine/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 2bcd07c..6e8cfad 100644 Binary files a/TimeHACK.Engine/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/TimeHACK.Engine/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.Properties.Resources.resources b/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.Properties.Resources.resources index f78bd37..9629cd7 100644 Binary files a/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.Properties.Resources.resources and b/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.Properties.Resources.resources differ diff --git a/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.csproj.GenerateResource.Cache b/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.csproj.GenerateResource.Cache index 13bac28..360f1c8 100644 Binary files a/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.csproj.GenerateResource.Cache and b/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.csproj.GenerateResource.Cache differ diff --git a/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.csprojResolveAssemblyReference.cache b/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.csprojResolveAssemblyReference.cache index d835909..1de83d9 100644 Binary files a/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.csprojResolveAssemblyReference.cache and b/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.csprojResolveAssemblyReference.cache differ diff --git a/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.dll b/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.dll index 9c859e2..9e8c504 100644 Binary files a/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.dll and b/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.dll differ diff --git a/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.pdb b/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.pdb index a92c614..b0d17dc 100644 Binary files a/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.pdb and b/TimeHACK.Engine/obj/Debug/TimeHACK.Engine.pdb differ -- cgit v1.2.3