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-03-31 18:31:16 -04:00
|
|
|
|
using TimeHACK.Engine.Template;
|
2017-04-28 13:48:46 -04:00
|
|
|
|
using System.Media;
|
2017-03-17 19:31:41 -04:00
|
|
|
|
|
2017-03-31 18:31:16 -04:00
|
|
|
|
namespace TimeHACK.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-07-02 16:44:11 -04:00
|
|
|
|
public WinClassic StartWin95(UserControl content, String title, Image icon, Boolean MaxButton, Boolean MinButton, Boolean ShowApplicationAsDialog = false)
|
2017-03-17 19:31:41 -04:00
|
|
|
|
{
|
2017-03-26 13:28:05 -04:00
|
|
|
|
// Setup Window
|
2017-03-18 17:26:56 -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-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-03-26 13:28:05 -04:00
|
|
|
|
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);
|
2017-03-26 13:28:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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-03-26 13:28:05 -04:00
|
|
|
|
}
|
|
|
|
|
|
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-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-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;
|
2017-03-17 19:31:41 -04:00
|
|
|
|
}
|
2017-03-31 16:17:32 -04:00
|
|
|
|
|
2017-07-02 16:44:11 -04:00
|
|
|
|
public WinClassic StartInfobox95(String title, String text, Image erroricon)
|
2017-03-31 16:17:32 -04:00
|
|
|
|
{
|
|
|
|
|
Infobox95 app = new Infobox95();
|
|
|
|
|
app.infoText.Text = text;
|
2017-07-02 16:44:11 -04:00
|
|
|
|
|
2017-04-28 13:48:46 -04:00
|
|
|
|
SoundPlayer sp = new SoundPlayer(Properties.Resources.CHORD);
|
|
|
|
|
sp.Play();
|
2017-07-02 16:44:11 -04:00
|
|
|
|
return StartWin95(app, title, null, false, false);
|
2017-03-31 16:17:32 -04:00
|
|
|
|
}
|
2017-04-09 19:38:33 -04:00
|
|
|
|
|
2017-07-02 16:44:11 -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-07-02 16:44:11 -04:00
|
|
|
|
return StartWin95(uc, "About " + shortname, null, false, 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
|
|
|
|
}
|