mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-25 05:11:56 +00:00
mainwindow now saves position/size/state. also changed path seperater in configuration.
This commit is contained in:
parent
eac7ca5652
commit
705ee05c54
5 changed files with 124 additions and 11 deletions
|
@ -0,0 +1,10 @@
|
|||
|
||||
mainwindow
|
||||
{
|
||||
positionx = 27;
|
||||
windowstate = 2;
|
||||
sizeheight = 586;
|
||||
sizewidth = 750;
|
||||
positiony = 15;
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Create main window
|
||||
mainwindow = new MainForm();
|
||||
|
||||
|
||||
// Show main window
|
||||
mainwindow.Show();
|
||||
mainwindow.Update();
|
||||
|
@ -147,5 +147,22 @@ namespace CodeImp.DoomBuilder
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Terminate
|
||||
|
||||
// This terminates the program
|
||||
public static void Terminate()
|
||||
{
|
||||
// Clean up
|
||||
mainwindow.Dispose();
|
||||
|
||||
// Save settings configuration
|
||||
settings.SaveConfiguration(Path.Combine(apppath, SETTINGS_CONFIG_FILE));
|
||||
|
||||
// Application ends here and now
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
#region ================== Constants
|
||||
|
||||
// Path seperator
|
||||
public const string DEFAULT_SEPERATOR = "/";
|
||||
public const string DEFAULT_SEPERATOR = ".";
|
||||
|
||||
// Parse mode constants
|
||||
private const int PM_NOTHING = 0;
|
||||
|
@ -1208,6 +1208,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
string data = OutputConfiguration(newline, whitespace);
|
||||
byte[] baData= Encoding.ASCII.GetBytes(data);
|
||||
fstream.Write(baData, 0, baData.Length);
|
||||
fstream.Flush();
|
||||
fstream.Close();
|
||||
|
||||
// Return true when done, false when errors occurred
|
||||
|
|
23
Source/Interface/MainForm.Designer.cs
generated
23
Source/Interface/MainForm.Designer.cs
generated
|
@ -55,7 +55,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.menufile});
|
||||
this.menumain.Location = new System.Drawing.Point(0, 0);
|
||||
this.menumain.Name = "menumain";
|
||||
this.menumain.Size = new System.Drawing.Size(619, 24);
|
||||
this.menumain.Size = new System.Drawing.Size(731, 24);
|
||||
this.menumain.TabIndex = 0;
|
||||
this.menumain.Text = "menuStrip1";
|
||||
//
|
||||
|
@ -125,7 +125,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.toolbar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
this.toolbar.Location = new System.Drawing.Point(0, 24);
|
||||
this.toolbar.Name = "toolbar";
|
||||
this.toolbar.Size = new System.Drawing.Size(619, 25);
|
||||
this.toolbar.Size = new System.Drawing.Size(731, 25);
|
||||
this.toolbar.TabIndex = 1;
|
||||
this.toolbar.Text = "toolStrip1";
|
||||
//
|
||||
|
@ -134,16 +134,16 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.statusbar.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.statusbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.statuslabel});
|
||||
this.statusbar.Location = new System.Drawing.Point(0, 471);
|
||||
this.statusbar.Location = new System.Drawing.Point(0, 523);
|
||||
this.statusbar.Name = "statusbar";
|
||||
this.statusbar.Size = new System.Drawing.Size(619, 22);
|
||||
this.statusbar.Size = new System.Drawing.Size(731, 22);
|
||||
this.statusbar.TabIndex = 2;
|
||||
//
|
||||
// statuslabel
|
||||
//
|
||||
this.statuslabel.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
|
||||
this.statuslabel.Name = "statuslabel";
|
||||
this.statuslabel.Size = new System.Drawing.Size(573, 17);
|
||||
this.statuslabel.Size = new System.Drawing.Size(716, 17);
|
||||
this.statuslabel.Spring = true;
|
||||
this.statuslabel.Text = "Initializing user interface...";
|
||||
this.statuslabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
|
@ -151,9 +151,9 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
// panelinfo
|
||||
//
|
||||
this.panelinfo.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panelinfo.Location = new System.Drawing.Point(0, 370);
|
||||
this.panelinfo.Location = new System.Drawing.Point(0, 422);
|
||||
this.panelinfo.Name = "panelinfo";
|
||||
this.panelinfo.Size = new System.Drawing.Size(619, 101);
|
||||
this.panelinfo.Size = new System.Drawing.Size(731, 101);
|
||||
this.panelinfo.TabIndex = 4;
|
||||
//
|
||||
// display
|
||||
|
@ -167,14 +167,14 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.display.InitialImage = null;
|
||||
this.display.Location = new System.Drawing.Point(0, 49);
|
||||
this.display.Name = "display";
|
||||
this.display.Size = new System.Drawing.Size(619, 321);
|
||||
this.display.Size = new System.Drawing.Size(731, 373);
|
||||
this.display.TabIndex = 5;
|
||||
this.display.TabStop = false;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(619, 493);
|
||||
this.ClientSize = new System.Drawing.Size(731, 545);
|
||||
this.Controls.Add(this.display);
|
||||
this.Controls.Add(this.panelinfo);
|
||||
this.Controls.Add(this.statusbar);
|
||||
|
@ -186,7 +186,12 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.KeyPreview = true;
|
||||
this.MainMenuStrip = this.menumain;
|
||||
this.Name = "MainForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "Doom Builder";
|
||||
this.Move += new System.EventHandler(this.MainForm_Move);
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||
this.ResizeEnd += new System.EventHandler(this.MainForm_ResizeEnd);
|
||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||
this.menumain.ResumeLayout(false);
|
||||
this.menumain.PerformLayout();
|
||||
this.statusbar.ResumeLayout(false);
|
||||
|
|
|
@ -15,6 +15,14 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
// Position/size
|
||||
private Point lastposition;
|
||||
private Size lastsize;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
|
@ -22,6 +30,78 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
{
|
||||
// Setup controls
|
||||
InitializeComponent();
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue