From 5e91513731ab83f356fd3cb4d2a13c93e933419a Mon Sep 17 00:00:00 2001 From: lempamo Date: Mon, 23 Oct 2017 12:01:44 -0400 Subject: winxp template needs fixing --- Histacom2.Engine/WindowManager.cs | 69 +++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 7 deletions(-) (limited to 'Histacom2.Engine/WindowManager.cs') diff --git a/Histacom2.Engine/WindowManager.cs b/Histacom2.Engine/WindowManager.cs index 4f4951c..ca0c782 100644 --- a/Histacom2.Engine/WindowManager.cs +++ b/Histacom2.Engine/WindowManager.cs @@ -36,11 +36,6 @@ namespace Histacom2.Engine app = new WinClassic(); break; } - case "XP": - { - // app = new WinXP(); - break; - } default: { app = new WinClassic(); @@ -111,9 +106,69 @@ namespace Histacom2.Engine return app; } - // A THING TM + public WinXP InitXP(UserControl content, string title, Image icon, bool MaxButton, bool MinButton, bool ShowApplicationAsDialog = false, bool resize = true) + { + WinXP app = new WinXP(); + + app.Text = title; + app.programname.Text = title; + app.Width = content.Width + 8; + app.Height = content.Height + 26; + // Initialize Font + pfc.AddFontFile(SaveSystem.GameDirectory + "\\Data\\LeviWindows.ttf"); + Font fnt = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0))); + app.fnt = fnt; + app.Title.Font = new Font(pfc.Families[0], 16F, FontStyle.Bold, GraphicsUnit.Point, ((0))); + // Setup UC + content.Parent = app.programContent; + content.BringToFront(); + content.Dock = DockStyle.Fill; + app.progContent = content; + + // Check if icon is null + if (icon == null) + { + app.programIcon.Hide(); + app.programIcon.Image = Engine.Properties.Resources.nullIcon; + app.programname.Location = new Point(2, 1); + } + else app.programIcon.Image = icon; + + // Check if Max button is enabled and set proper X for Min button + if (MaxButton == false) + { + app.maximizebutton.Visible = false; + app.minimizebutton.Location = new Point(app.closebutton.Location.X - 14, app.minimizebutton.Location.Y); + } + + // Check if Min button is enabled + if (MinButton == false) + { + app.minimizebutton.Visible = false; + app.minimizebutton.Location = new Point(app.minimizebutton.Location.X, app.minimizebutton.Location.Y); + } + + //Resize + app.resizable = resize; + + // Convert an image to an icon (for the taskbar) + if (icon != null) + { + Bitmap theBitmap = new Bitmap(icon, new Size(icon.Width, icon.Height)); + IntPtr Hicon = theBitmap.GetHicon(); // Get an Hicon for myBitmap. + Icon newIcon = Icon.FromHandle(Hicon); // Create a new icon from the handle. + app.Icon = newIcon; + } - // A THING TM + // Set some values (for the taskbar) + app.Tag = TaskBarController.AvalibleApplicationID; + app.Text = title; + + // Show the app + app.TopMost = true; + if (ShowApplicationAsDialog == false) { app.Show(); } else { app.ShowDialog(); } + return app; + } public WinClassic StartInfobox95(string title, string text, InfoboxType type, InfoboxButtons btns) { -- cgit v1.2.3 From fcab724a3d12bbd20dd123b96ac2596526057eec Mon Sep 17 00:00:00 2001 From: lempamo Date: Mon, 23 Oct 2017 16:49:06 -0400 Subject: fix a few winxp template things --- Histacom2.Engine/Template/WinXP.Designer.cs | 51 +++++++++++++++-------------- Histacom2.Engine/Template/WinXP.cs | 45 +++++++++++++++++++++++++ Histacom2.Engine/WindowManager.cs | 3 +- 3 files changed, 73 insertions(+), 26 deletions(-) (limited to 'Histacom2.Engine/WindowManager.cs') diff --git a/Histacom2.Engine/Template/WinXP.Designer.cs b/Histacom2.Engine/Template/WinXP.Designer.cs index 66cb521..0d1e060 100644 --- a/Histacom2.Engine/Template/WinXP.Designer.cs +++ b/Histacom2.Engine/Template/WinXP.Designer.cs @@ -30,26 +30,26 @@ { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WinXP)); this.program = new System.Windows.Forms.Panel(); + this.flowLayoutPanel1 = new System.Windows.Forms.Panel(); this.bottomleftcorner = new System.Windows.Forms.Panel(); this.toprightcorner = new System.Windows.Forms.Panel(); this.bottomrightcorner = new System.Windows.Forms.Panel(); this.topleftcorner = new System.Windows.Forms.Panel(); this.bottom = new System.Windows.Forms.Panel(); this.top = new System.Windows.Forms.Panel(); + this.programIcon = new System.Windows.Forms.PictureBox(); this.maximizebutton = new System.Windows.Forms.PictureBox(); this.minimizebutton = new System.Windows.Forms.PictureBox(); this.programname = new System.Windows.Forms.Label(); this.closebutton = new System.Windows.Forms.PictureBox(); this.right = new System.Windows.Forms.Panel(); this.left = new System.Windows.Forms.Panel(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.programIcon = new System.Windows.Forms.PictureBox(); this.program.SuspendLayout(); this.top.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.programIcon)).BeginInit(); ((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 @@ -70,6 +70,14 @@ this.program.Size = new System.Drawing.Size(300, 300); this.program.TabIndex = 10; // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel1.Location = new System.Drawing.Point(4, 30); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(292, 266); + this.flowLayoutPanel1.TabIndex = 11; + // // bottomleftcorner // this.bottomleftcorner.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -133,6 +141,18 @@ this.top.Name = "top"; this.top.Size = new System.Drawing.Size(292, 30); this.top.TabIndex = 0; + this.top.MouseDown += new System.Windows.Forms.MouseEventHandler(this.top_MouseDown); + // + // programIcon + // + this.programIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.programIcon.ErrorImage = null; + this.programIcon.InitialImage = null; + this.programIcon.Location = new System.Drawing.Point(6, 7); + this.programIcon.Name = "programIcon"; + this.programIcon.Size = new System.Drawing.Size(16, 16); + this.programIcon.TabIndex = 7; + this.programIcon.TabStop = false; // // maximizebutton // @@ -165,6 +185,7 @@ this.programname.Size = new System.Drawing.Size(99, 13); this.programname.TabIndex = 3; this.programname.Text = "Application Title"; + this.programname.MouseDown += new System.Windows.Forms.MouseEventHandler(this.top_MouseDown); // // closebutton // @@ -175,6 +196,7 @@ this.closebutton.Size = new System.Drawing.Size(21, 21); this.closebutton.TabIndex = 4; this.closebutton.TabStop = false; + this.closebutton.Click += new System.EventHandler(this.closebutton_Click); // // right // @@ -195,25 +217,6 @@ this.left.Size = new System.Drawing.Size(4, 300); this.left.TabIndex = 1; // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.flowLayoutPanel1.Location = new System.Drawing.Point(4, 30); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(292, 266); - this.flowLayoutPanel1.TabIndex = 11; - // - // programIcon - // - this.programIcon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.programIcon.ErrorImage = null; - this.programIcon.InitialImage = null; - this.programIcon.Location = new System.Drawing.Point(6, 7); - this.programIcon.Name = "programIcon"; - this.programIcon.Size = new System.Drawing.Size(16, 16); - this.programIcon.TabIndex = 7; - this.programIcon.TabStop = false; - // // WinXP // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -227,10 +230,10 @@ this.program.ResumeLayout(false); this.top.ResumeLayout(false); this.top.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.programIcon)).EndInit(); ((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); } @@ -250,7 +253,7 @@ internal System.Windows.Forms.PictureBox closebutton; internal System.Windows.Forms.Panel right; internal System.Windows.Forms.Panel left; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; public System.Windows.Forms.PictureBox programIcon; + public System.Windows.Forms.Panel flowLayoutPanel1; } } \ No newline at end of file diff --git a/Histacom2.Engine/Template/WinXP.cs b/Histacom2.Engine/Template/WinXP.cs index cf6640b..fa26611 100644 --- a/Histacom2.Engine/Template/WinXP.cs +++ b/Histacom2.Engine/Template/WinXP.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -19,6 +20,50 @@ namespace Histacom2.Engine.Template DoubleBuffered = true; } + public Font fnt; + public ResizeOverlay resizer = new ResizeOverlay(); + public UserControl progContent; + + public bool resizable = true; + public bool max = false; + 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; + + private const int + HTLEFT = 10, + HTRIGHT = 11, + HTTOP = 12, + HTTOPLEFT = 13, + HTTOPRIGHT = 14, + HTBOTTOM = 15, + HTBOTTOMLEFT = 16, + HTBOTTOMRIGHT = 17; + + private void closebutton_Click(object sender, EventArgs e) + { + if (!closeDisabled) this.Close(); + } + + private void top_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left && max == false) + { + ReleaseCapture(); + SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); + } + } + + [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 WinXP_Load(object sender, EventArgs e) { diff --git a/Histacom2.Engine/WindowManager.cs b/Histacom2.Engine/WindowManager.cs index ca0c782..12f7954 100644 --- a/Histacom2.Engine/WindowManager.cs +++ b/Histacom2.Engine/WindowManager.cs @@ -118,9 +118,8 @@ namespace Histacom2.Engine pfc.AddFontFile(SaveSystem.GameDirectory + "\\Data\\LeviWindows.ttf"); Font fnt = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0))); app.fnt = fnt; - app.Title.Font = new Font(pfc.Families[0], 16F, FontStyle.Bold, GraphicsUnit.Point, ((0))); // Setup UC - content.Parent = app.programContent; + content.Parent = app.flowLayoutPanel1; content.BringToFront(); content.Dock = DockStyle.Fill; app.progContent = content; -- cgit v1.2.3