Histacom2/Histacom2.Engine/WindowManager.cs

139 lines
5.1 KiB
C#
Raw Normal View History

using System;
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-08-23 13:38:40 -04:00
namespace Histacom2.Engine
{
public class WindowManager
{
2017-03-28 21:53:18 -04:00
public static System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
public WinClassic Init(UserControl content, string title, Image icon, bool MaxButton, bool MinButton, bool ShowApplicationAsDialog = false, bool resize = true)
{
WinClassic app = null;
// Setup Window
switch (SaveSystem.CurrentSave.CurrentOS)
{
case "95":
{
app = new WinClassic();
break;
}
case "98":
{
app = new WinClassic();
break;
}
case "ME":
{
app = new WinClassic();
break;
}
case "2000":
{
app = new WinClassic();
break;
}
case "XP":
{
// app = new WinXP();
break;
}
default:
{
app = new WinClassic();
break;
}
}
2017-03-27 15:32:59 -04:00
app.Text = title;
app.Title.Text = title;
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
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 19:56:21 -04:00
// Check if Max button is enabled and set proper X for Min button
if (MaxButton == false)
{
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);
}
// Check if Min button is enabled
if (MinButton == false)
{
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-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
// Show the app
app.TopMost = true;
2017-05-19 16:01:07 -04:00
if (ShowApplicationAsDialog == false) { app.Show(); } else { app.ShowDialog(); }
2017-03-27 17:42:35 -04:00
return app;
}
// A THING TM
// A THING TM
2017-07-30 00:10:22 -04:00
public WinClassic StartInfobox95(string title, string text, InfoboxType type, InfoboxButtons btns)
{
2017-07-30 00:10:22 -04:00
pfc.AddFontFile(SaveSystem.GameDirectory + "\\Data\\LeviWindows.ttf");
Infobox95 app = new Infobox95(type, btns);
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)));
return Init(app, title, null, false, false, resize: false);
}
2017-04-09 19:38:33 -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-04-09 19:38:33 -04:00
uc.Font = new Font(pfc.Families[0], 16F, FontStyle.Regular, GraphicsUnit.Point, ((0)));
return Init(uc, "About " + shortname, null, false, false, resize: false);
2017-04-09 19:38:33 -04:00
}
}
}