2017-03-17 19:31:41 -04:00
|
|
|
|
using System;
|
2017-03-26 13:28:05 -04:00
|
|
|
|
using System.Windows.Forms;
|
2017-03-26 19:56:21 -04:00
|
|
|
|
using System.Drawing;
|
2017-08-23 13:38:40 -04:00
|
|
|
|
using Histacom2.Engine.Template;
|
2017-04-28 13:48:46 -04:00
|
|
|
|
using System.Media;
|
2017-03-17 19:31:41 -04:00
|
|
|
|
|
2017-08-23 13:38:40 -04:00
|
|
|
|
namespace Histacom2.Engine
|
2017-03-17 19:31:41 -04:00
|
|
|
|
{
|
2017-03-26 13:28:05 -04:00
|
|
|
|
public class WindowManager
|
2017-03-17 19:31:41 -04:00
|
|
|
|
{
|
2017-03-28 21:53:18 -04:00
|
|
|
|
public static System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
|
|
|
|
|
|
2017-10-24 19:21:45 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates and returns a WinClassic window.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="content">The UserControl to put inside the window.</param>
|
|
|
|
|
/// <param name="title">The name of the window.</param>
|
|
|
|
|
/// <param name="icon">The window's icon. If set to null, then the title moves over to compensate.</param>
|
|
|
|
|
/// <param name="MaxButton">Whether or not the maximize button is shown.</param>
|
|
|
|
|
/// <param name="MinButton">Whether or not the minimize button is shown.</param>
|
|
|
|
|
/// <param name="ShowApplicationAsDialog">Whether or not to interrupt all other processes while this window is open.</param>
|
|
|
|
|
/// <param name="resize">Whether or not this window is resizable.</param>
|
|
|
|
|
/// <returns></returns>
|
2017-08-29 22:33:11 -04:00
|
|
|
|
public WinClassic Init(UserControl content, string title, Image icon, bool MaxButton, bool MinButton, bool ShowApplicationAsDialog = false, bool resize = true)
|
2017-03-17 19:31:41 -04:00
|
|
|
|
{
|
2017-10-24 19:21:45 -04:00
|
|
|
|
WinClassic app = new WinClassic();
|
|
|
|
|
|
2017-03-27 15:32:59 -04:00
|
|
|
|
app.Text = title;
|
2017-03-18 17:26:56 -04:00
|
|
|
|
app.Title.Text = title;
|
2017-03-26 13:28:05 -04:00
|
|
|
|
app.Width = content.Width + 8;
|
|
|
|
|
app.Height = content.Height + 26;
|
2017-03-28 21:53:18 -04:00
|
|
|
|
// Initialize Font
|
2017-06-14 20:22:37 -04:00
|
|
|
|
pfc.AddFontFile(SaveSystem.GameDirectory + "\\Data\\LeviWindows.ttf");
|
2017-04-09 12:31:17 -04:00
|
|
|
|
Font fnt = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0)));
|
2017-03-27 10:53:12 -04:00
|
|
|
|
app.fnt = fnt;
|
2017-04-01 18:44:31 -04:00
|
|
|
|
app.Title.Font = new Font(pfc.Families[0], 16F, FontStyle.Bold, GraphicsUnit.Point, ((0)));
|
2017-03-28 21:53:18 -04:00
|
|
|
|
// Setup UC
|
2017-03-26 13:28:05 -04:00
|
|
|
|
content.Parent = app.programContent;
|
|
|
|
|
content.BringToFront();
|
|
|
|
|
content.Dock = DockStyle.Fill;
|
2017-09-05 21:13:06 -04:00
|
|
|
|
app.progContent = content;
|
2017-03-28 21:53:18 -04:00
|
|
|
|
|
|
|
|
|
// Check if icon is null
|
2017-04-09 19:38:33 -04:00
|
|
|
|
if (icon == null)
|
|
|
|
|
{
|
|
|
|
|
app.programIcon.Hide();
|
|
|
|
|
app.programIcon.Image = Engine.Properties.Resources.nullIcon;
|
|
|
|
|
app.Title.Location = new Point(2, 1);
|
|
|
|
|
}
|
2017-04-09 14:05:04 -04:00
|
|
|
|
else app.programIcon.Image = icon;
|
2017-03-26 13:28:05 -04:00
|
|
|
|
|
2017-03-26 19:56:21 -04:00
|
|
|
|
// Check if Max button is enabled and set proper X for Min button
|
2017-11-04 05:43:02 -04:00
|
|
|
|
if (!MaxButton)
|
2017-03-26 13:28:05 -04:00
|
|
|
|
{
|
|
|
|
|
app.maximizebutton.Visible = false;
|
2017-03-27 15:32:59 -04:00
|
|
|
|
app.minimizebutton.Location = new Point(app.closebutton.Location.X - 14, app.minimizebutton.Location.Y);
|
2017-03-26 13:28:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if Min button is enabled
|
2017-11-04 05:43:02 -04:00
|
|
|
|
if (!MinButton)
|
2017-03-26 13:28:05 -04:00
|
|
|
|
{
|
|
|
|
|
app.minimizebutton.Visible = false;
|
2017-03-26 19:56:21 -04:00
|
|
|
|
app.minimizebutton.Location = new Point(app.minimizebutton.Location.X, app.minimizebutton.Location.Y);
|
2017-03-26 13:28:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-31 23:14:24 -04:00
|
|
|
|
//Resize
|
|
|
|
|
app.resizable = resize;
|
|
|
|
|
|
2017-07-31 15:40:59 -04:00
|
|
|
|
// Time for the colors
|
|
|
|
|
app.programtopbar.BackColor = SaveSystem.currentTheme.activeTitleBarColor;
|
2017-07-31 15:46:27 -04:00
|
|
|
|
app.Title.ForeColor = SaveSystem.currentTheme.activeTitleTextColor;
|
2017-04-30 10:46:36 -04:00
|
|
|
|
|
2017-05-01 04:54:13 -04:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
2017-04-30 10:46:36 -04:00
|
|
|
|
|
2017-05-01 04:54:13 -04:00
|
|
|
|
// Set some values (for the taskbar)
|
2017-04-30 10:46:36 -04:00
|
|
|
|
app.Tag = TaskBarController.AvalibleApplicationID;
|
2017-05-19 16:01:07 -04:00
|
|
|
|
app.Text = title;
|
2017-04-30 10:46:36 -04:00
|
|
|
|
|
2017-03-26 13:28:05 -04:00
|
|
|
|
// Show the app
|
2017-03-27 19:23:12 -04:00
|
|
|
|
app.TopMost = true;
|
2017-11-04 05:43:02 -04:00
|
|
|
|
if (!ShowApplicationAsDialog) { app.Show(); } else { app.ShowDialog(); }
|
2017-03-27 17:42:35 -04:00
|
|
|
|
return app;
|
2017-03-17 19:31:41 -04:00
|
|
|
|
}
|
2017-08-29 22:33:11 -04:00
|
|
|
|
|
2017-10-23 12:01:44 -04:00
|
|
|
|
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;
|
|
|
|
|
// Setup UC
|
2017-10-23 16:49:06 -04:00
|
|
|
|
content.Parent = app.flowLayoutPanel1;
|
2017-10-23 12:01:44 -04:00
|
|
|
|
content.BringToFront();
|
|
|
|
|
content.Dock = DockStyle.Fill;
|
|
|
|
|
app.progContent = content;
|
|
|
|
|
|
|
|
|
|
// Check if icon is null
|
|
|
|
|
if (icon == null)
|
|
|
|
|
{
|
|
|
|
|
app.programIcon.Hide();
|
2017-10-24 19:21:45 -04:00
|
|
|
|
app.programIcon.Image = Properties.Resources.nullIcon;
|
2017-10-26 00:03:57 -04:00
|
|
|
|
app.programname.Location = new Point(3, 6);
|
2017-10-23 12:01:44 -04:00
|
|
|
|
}
|
|
|
|
|
else app.programIcon.Image = icon;
|
|
|
|
|
|
|
|
|
|
// Check if Max button is enabled and set proper X for Min button
|
2017-11-04 05:43:02 -04:00
|
|
|
|
if (!MaxButton)
|
2017-10-23 12:01:44 -04:00
|
|
|
|
{
|
|
|
|
|
app.maximizebutton.Visible = false;
|
|
|
|
|
app.minimizebutton.Location = new Point(app.closebutton.Location.X - 14, app.minimizebutton.Location.Y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if Min button is enabled
|
2017-11-04 05:43:02 -04:00
|
|
|
|
if (!MinButton)
|
2017-10-23 12:01:44 -04:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
2017-08-29 22:33:11 -04:00
|
|
|
|
|
2017-10-23 12:01:44 -04:00
|
|
|
|
// Set some values (for the taskbar)
|
|
|
|
|
app.Tag = TaskBarController.AvalibleApplicationID;
|
|
|
|
|
app.Text = title;
|
|
|
|
|
|
|
|
|
|
// Show the app
|
|
|
|
|
app.TopMost = true;
|
2017-11-04 05:43:02 -04:00
|
|
|
|
if (!ShowApplicationAsDialog) { app.Show(); } else { app.ShowDialog(); }
|
2017-10-23 12:01:44 -04:00
|
|
|
|
return app;
|
|
|
|
|
}
|
2017-03-31 16:17:32 -04:00
|
|
|
|
|
2017-07-30 00:10:22 -04:00
|
|
|
|
public WinClassic StartInfobox95(string title, string text, InfoboxType type, InfoboxButtons btns)
|
2017-03-31 16:17:32 -04:00
|
|
|
|
{
|
2017-07-30 00:10:22 -04:00
|
|
|
|
pfc.AddFontFile(SaveSystem.GameDirectory + "\\Data\\LeviWindows.ttf");
|
|
|
|
|
Infobox95 app = new Infobox95(type, btns);
|
2017-03-31 16:17:32 -04:00
|
|
|
|
app.infoText.Text = text;
|
2017-07-30 00:10:22 -04:00
|
|
|
|
app.infoText.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0)));
|
2017-07-02 16:44:11 -04:00
|
|
|
|
|
2017-08-29 22:33:11 -04:00
|
|
|
|
return Init(app, title, null, false, false, resize: false);
|
2017-03-31 16:17:32 -04:00
|
|
|
|
}
|
2017-04-09 19:38:33 -04:00
|
|
|
|
|
2017-07-13 10:46:24 -04:00
|
|
|
|
public WinClassic StartAboutBox95(string shortname, string longname, Image appicon)
|
2017-04-09 19:38:33 -04:00
|
|
|
|
{
|
|
|
|
|
AboutBox95 uc = new AboutBox95();
|
|
|
|
|
uc.pictureBox1.Image = appicon;
|
2017-04-10 11:51:00 -04:00
|
|
|
|
uc.textBox1.Text = longname + "\r\nWindows 95\r\nCopyright © 1981-1995 Microsoft Corp.";
|
2017-11-15 15:49:35 -05:00
|
|
|
|
uc.textBox1.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0)));
|
|
|
|
|
uc.textBox2.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0)));
|
|
|
|
|
|
|
|
|
|
return Init(uc, "About " + shortname, null, false, false, resize: false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public WinClassic StartAboutBox98(string shortname, string longname, Image appicon)
|
|
|
|
|
{
|
|
|
|
|
AboutBox98 uc = new AboutBox98();
|
|
|
|
|
uc.pictureBox1.Image = appicon;
|
|
|
|
|
uc.textBox1.Text = longname + "\r\nWindows 98\r\nCopyright © 1981-1997 Microsoft Corp.";
|
|
|
|
|
uc.textBox1.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0)));
|
|
|
|
|
uc.textBox2.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0)));
|
2017-04-09 19:38:33 -04:00
|
|
|
|
|
2017-08-29 22:33:11 -04:00
|
|
|
|
return Init(uc, "About " + shortname, null, false, false, resize: false);
|
2017-04-09 19:38:33 -04:00
|
|
|
|
}
|
2017-03-17 19:31:41 -04:00
|
|
|
|
}
|
2017-03-31 16:17:32 -04:00
|
|
|
|
}
|