2007-06-14 23:31:57 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
2007-06-13 19:39:38 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
2007-06-14 23:31:57 +00:00
|
|
|
#endregion
|
|
|
|
|
2007-06-13 19:39:38 +00:00
|
|
|
namespace CodeImp.DoomBuilder.Interface
|
|
|
|
{
|
|
|
|
public partial class MainForm : Form
|
|
|
|
{
|
2007-06-14 14:44:18 +00:00
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
private const string STATUS_READY_TEXT = "Ready.";
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2007-06-14 15:35:37 +00:00
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// Position/size
|
|
|
|
private Point lastposition;
|
|
|
|
private Size lastsize;
|
|
|
|
|
|
|
|
#endregion
|
2007-06-15 10:18:03 +00:00
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public PictureBox Display { get { return display; } }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2007-06-14 14:44:18 +00:00
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
2007-06-13 19:39:38 +00:00
|
|
|
// Constructor
|
|
|
|
public MainForm()
|
|
|
|
{
|
|
|
|
// Setup controls
|
|
|
|
InitializeComponent();
|
2007-06-14 15:35:37 +00:00
|
|
|
|
|
|
|
// Keep last position and size
|
|
|
|
lastposition = this.Location;
|
|
|
|
lastsize = this.Size;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Window
|
|
|
|
|
|
|
|
// Window is loaded
|
|
|
|
private void MainForm_Load(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
// Position window from configuration settings
|
|
|
|
this.SuspendLayout();
|
|
|
|
this.Location = new Point(General.Settings.ReadSetting("mainwindow.positionx", this.Location.X),
|
|
|
|
General.Settings.ReadSetting("mainwindow.positiony", this.Location.Y));
|
|
|
|
this.Size = new Size(General.Settings.ReadSetting("mainwindow.sizewidth", this.Size.Width),
|
|
|
|
General.Settings.ReadSetting("mainwindow.sizeheight", this.Size.Height));
|
|
|
|
this.WindowState = (FormWindowState)General.Settings.ReadSetting("mainwindow.windowstate", (int)FormWindowState.Maximized);
|
|
|
|
this.ResumeLayout(true);
|
|
|
|
|
|
|
|
// Normal windowstate?
|
|
|
|
if(this.WindowState == FormWindowState.Normal)
|
|
|
|
{
|
|
|
|
// Keep last position and size
|
|
|
|
lastposition = this.Location;
|
|
|
|
lastsize = this.Size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Window is moved
|
|
|
|
private void MainForm_Move(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
// Normal windowstate?
|
|
|
|
if(this.WindowState == FormWindowState.Normal)
|
|
|
|
{
|
|
|
|
// Keep last position and size
|
|
|
|
lastposition = this.Location;
|
|
|
|
lastsize = this.Size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Window was resized
|
|
|
|
private void MainForm_ResizeEnd(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
// Normal windowstate?
|
|
|
|
if(this.WindowState == FormWindowState.Normal)
|
|
|
|
{
|
|
|
|
// Keep last position and size
|
|
|
|
lastposition = this.Location;
|
|
|
|
lastsize = this.Size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Window is being closed
|
|
|
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
{
|
|
|
|
int windowstate;
|
|
|
|
|
|
|
|
// Determine window state to save
|
|
|
|
if(this.WindowState != FormWindowState.Minimized) windowstate = (int)this.WindowState; else windowstate = (int)FormWindowState.Normal;
|
|
|
|
|
|
|
|
// Save settings to configuration
|
|
|
|
General.Settings.WriteSetting("mainwindow.positionx", lastposition.X);
|
|
|
|
General.Settings.WriteSetting("mainwindow.positiony", lastposition.Y);
|
|
|
|
General.Settings.WriteSetting("mainwindow.sizewidth", lastsize.Width);
|
|
|
|
General.Settings.WriteSetting("mainwindow.sizeheight", lastsize.Height);
|
|
|
|
General.Settings.WriteSetting("mainwindow.windowstate", windowstate);
|
|
|
|
|
|
|
|
// Terminate the program
|
|
|
|
General.Terminate();
|
2007-06-13 19:39:38 +00:00
|
|
|
}
|
2007-06-14 14:44:18 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Statusbar
|
|
|
|
|
|
|
|
// This changes status text
|
|
|
|
public void DisplayStatus(string status)
|
|
|
|
{
|
|
|
|
// Update status description
|
|
|
|
if(statuslabel.Text != status)
|
|
|
|
statuslabel.Text = status;
|
|
|
|
|
|
|
|
// Refresh if needed
|
|
|
|
statusbar.Invalidate();
|
|
|
|
this.Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This changes status text to Ready
|
|
|
|
public void DisplayReady()
|
|
|
|
{
|
|
|
|
// Display ready status description
|
|
|
|
DisplayStatus(STATUS_READY_TEXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2007-06-14 23:31:57 +00:00
|
|
|
|
2007-06-15 10:18:03 +00:00
|
|
|
#region ================== Display
|
|
|
|
|
|
|
|
// This shows the splash screen on display
|
|
|
|
public void ShowSplashDisplay()
|
|
|
|
{
|
|
|
|
// Change display to show splash logo
|
|
|
|
display.BackColor = System.Drawing.SystemColors.AppWorkspace;
|
|
|
|
display.BackgroundImage = global::CodeImp.DoomBuilder.Properties.Resources.Splash2;
|
|
|
|
display.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This clears the display
|
|
|
|
public void ClearDisplay()
|
|
|
|
{
|
|
|
|
// Clear the display
|
|
|
|
display.BackColor = Color.Black;
|
|
|
|
display.BackgroundImage = null;
|
|
|
|
display.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Menus
|
|
|
|
|
|
|
|
// This updates all menus for the current status
|
|
|
|
public void UpdateMenus()
|
|
|
|
{
|
|
|
|
// Update them all
|
|
|
|
UpdateFileMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2007-06-14 23:31:57 +00:00
|
|
|
#region ================== File Menu
|
|
|
|
|
|
|
|
// New map clicked
|
|
|
|
private void itemnewmap_Click(object sender, EventArgs e) { General.NewMap(); }
|
|
|
|
|
2007-06-15 10:18:03 +00:00
|
|
|
// Close map clicked
|
|
|
|
private void itemclosemap_Click(object sender, EventArgs e) { General.CloseMap(); }
|
|
|
|
|
|
|
|
// Exit clicked
|
|
|
|
private void itemexit_Click(object sender, EventArgs e) { this.Close(); }
|
|
|
|
|
|
|
|
// This sets up the file menu
|
|
|
|
private void UpdateFileMenu()
|
|
|
|
{
|
|
|
|
// Enable/disable items
|
|
|
|
itemclosemap.Enabled = (General.Map != null);
|
|
|
|
itemsavemap.Enabled = (General.Map != null);
|
|
|
|
itemsavemapas.Enabled = (General.Map != null);
|
|
|
|
itemsavemapinto.Enabled = (General.Map != null);
|
|
|
|
}
|
|
|
|
|
2007-06-14 23:31:57 +00:00
|
|
|
#endregion
|
2007-06-13 19:39:38 +00:00
|
|
|
}
|
|
|
|
}
|