Ejemplo n.º 1
0
        public WinClassic StartWin95(UserControl content, String title, Image icon, Boolean MaxButton, Boolean MinButton, Boolean ShowApplicationAsDialog = false)
        {
            // Setup Window
            WinClassic app = new WinClassic();

            app.Text       = title;
            app.Title.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;

            // Check if icon is null
            if (icon == null)
            {
                app.programIcon.Hide();
                app.programIcon.Image = Engine.Properties.Resources.nullIcon;
                app.Title.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);
            }

            // Time for the taskbar

            // 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;
            }

            // 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);
        }