Histacom2/TimeHACK.Engine/WindowManager.cs

97 lines
3.6 KiB
C#
Raw Normal View History

using System;
using System.Windows.Forms;
2017-03-26 19:56:21 -04:00
using System.Drawing;
2017-03-31 18:31:16 -04:00
using TimeHACK.Engine.Template;
2017-04-28 13:48:46 -04:00
using System.Media;
2017-03-31 18:31:16 -04:00
namespace TimeHACK.Engine
{
public class WindowManager
{
2017-03-28 21:53:18 -04:00
public static System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
2017-04-09 14:05:04 -04:00
public WinClassic startWin95(UserControl content, String title, Image icon, Boolean MaxButton, Boolean MinButton)
{
// Setup Window
WinClassic app = new WinClassic();
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
pfc.AddFontFile(AppDomain.CurrentDomain.BaseDirectory + "\\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-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-04-30 10:46:36 -04:00
// Time for the taskbar
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-01 04:54:13 -04:00
app.Text = title;
2017-04-30 10:46:36 -04:00
// Show the app
app.Show();
app.BringToFront();
app.TopMost = true;
2017-03-27 17:42:35 -04:00
return app;
}
public WinClassic startInfobox95(String title, String text, Image erroricon)
{
Infobox95 app = new Infobox95();
app.infoText.Text = text;
2017-04-28 13:48:46 -04:00
SoundPlayer sp = new SoundPlayer(Properties.Resources.CHORD);
sp.Play();
return startWin95(app, title, null, false, false);
}
2017-04-09 19:38:33 -04:00
2017-04-10 11:51:00 -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)));
2017-04-10 11:51:00 -04:00
return startWin95(uc, "About " + shortname, null, false, false);
2017-04-09 19:38:33 -04:00
}
}
}