From 779300236a4bc3cda33fbdf91411b7a40c17b16d Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 15 May 2005 20:46:43 +0000 Subject: Implemented load/save and tidied some editor control bugs --- GfxEditor.cs | 129 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 67 insertions(+), 62 deletions(-) (limited to 'GfxEditor.cs') diff --git a/GfxEditor.cs b/GfxEditor.cs index d72b2fb..048317e 100644 --- a/GfxEditor.cs +++ b/GfxEditor.cs @@ -33,18 +33,18 @@ namespace BitmapFontEd [ToolboxItem(true)] public class GfxEditor : System.Windows.Forms.UserControl { - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label m_bgPreview; private System.Windows.Forms.Label label1; private System.Windows.Forms.PictureBox m_edit; private System.Windows.Forms.ComboBox m_modeList; private System.Windows.Forms.Label m_fgPreview; + private System.Windows.Forms.Label label2; private System.Windows.Forms.PictureBox m_preview; private System.Windows.Forms.NumericUpDown m_sizeY; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label m_bgPreview; - private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; private System.Windows.Forms.NumericUpDown m_sizeX; private System.Windows.Forms.Label m_pos; private System.Windows.Forms.Button m_undoButton; @@ -75,8 +75,6 @@ namespace BitmapFontEd private uint m_width; private uint m_height; - private bool m_ignoreSize; - private Rectangle m_editRect; private Bitmap m_editBmp; private Rectangle m_prevRect; @@ -117,8 +115,6 @@ namespace BitmapFontEd m_my=SIZE; m_gridCol=Color.LightGreen; - m_ignoreSize=false; - m_editRect=m_edit.ClientRectangle; m_editBmp=new Bitmap(m_editRect.Width,m_editRect.Height); m_edit.Image=m_editBmp; @@ -150,18 +146,18 @@ namespace BitmapFontEd this.m_undoButton = new System.Windows.Forms.Button(); this.m_pos = new System.Windows.Forms.Label(); this.m_sizeX = new System.Windows.Forms.NumericUpDown(); - this.label3 = new System.Windows.Forms.Label(); - this.m_bgPreview = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.m_sizeY = new System.Windows.Forms.NumericUpDown(); this.m_preview = new System.Windows.Forms.PictureBox(); + this.label2 = new System.Windows.Forms.Label(); this.m_fgPreview = new System.Windows.Forms.Label(); this.m_modeList = new System.Windows.Forms.ComboBox(); this.m_edit = new System.Windows.Forms.PictureBox(); this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); + this.m_bgPreview = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.m_sizeX)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).BeginInit(); this.SuspendLayout(); @@ -206,27 +202,17 @@ namespace BitmapFontEd 0, 0, 0}); - this.m_sizeX.ValueChanged += new System.EventHandler(this.OnSize); - this.m_sizeX.Leave += new System.EventHandler(this.OnSize); - // - // label3 - // - this.label3.Location = new System.Drawing.Point(280, 8); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(48, 16); - this.label3.TabIndex = 8; - this.label3.Text = "Width"; - this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.m_sizeX.ValueChanged += new System.EventHandler(this.OnSizeWidth); + this.m_sizeX.Leave += new System.EventHandler(this.OnSizeWidth); // - // m_bgPreview + // label4 // - this.m_bgPreview.BackColor = System.Drawing.Color.Black; - this.m_bgPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.m_bgPreview.Location = new System.Drawing.Point(336, 120); - this.m_bgPreview.Name = "m_bgPreview"; - this.m_bgPreview.Size = new System.Drawing.Size(40, 40); - this.m_bgPreview.TabIndex = 18; - this.m_bgPreview.Click += new System.EventHandler(this.OnBackground); + this.label4.Location = new System.Drawing.Point(280, 96); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(32, 16); + this.label4.TabIndex = 10; + this.label4.Text = "Left"; + this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // label5 // @@ -269,8 +255,8 @@ namespace BitmapFontEd 0, 0, 0}); - this.m_sizeY.ValueChanged += new System.EventHandler(this.OnSize); - this.m_sizeY.Leave += new System.EventHandler(this.OnSize); + this.m_sizeY.ValueChanged += new System.EventHandler(this.OnSizeHeight); + this.m_sizeY.Leave += new System.EventHandler(this.OnSizeHeight); // // m_preview // @@ -281,6 +267,15 @@ namespace BitmapFontEd this.m_preview.TabIndex = 1; this.m_preview.TabStop = false; // + // label2 + // + this.label2.Location = new System.Drawing.Point(280, 176); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(56, 16); + this.label2.TabIndex = 21; + this.label2.Text = "Preview"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // // m_fgPreview // this.m_fgPreview.BackColor = System.Drawing.Color.White; @@ -335,23 +330,24 @@ namespace BitmapFontEd this.label1.Text = "Draw Mode"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // label2 + // m_bgPreview // - this.label2.Location = new System.Drawing.Point(280, 176); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(56, 16); - this.label2.TabIndex = 21; - this.label2.Text = "Preview"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.m_bgPreview.BackColor = System.Drawing.Color.Black; + this.m_bgPreview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.m_bgPreview.Location = new System.Drawing.Point(336, 120); + this.m_bgPreview.Name = "m_bgPreview"; + this.m_bgPreview.Size = new System.Drawing.Size(40, 40); + this.m_bgPreview.TabIndex = 18; + this.m_bgPreview.Click += new System.EventHandler(this.OnBackground); // - // label4 + // label3 // - this.label4.Location = new System.Drawing.Point(280, 96); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(32, 16); - this.label4.TabIndex = 10; - this.label4.Text = "Left"; - this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.label3.Location = new System.Drawing.Point(280, 8); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(48, 16); + this.label3.TabIndex = 8; + this.label3.Text = "Width"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // GfxEditor // @@ -404,11 +400,12 @@ namespace BitmapFontEd set { m_char=value; - m_ignoreSize=true; + m_width=m_char.Width; + m_height=m_char.Height; m_sizeX.Value=Convert.ToDecimal(m_char.Width); - m_ignoreSize=false; m_sizeY.Value=Convert.ToDecimal(m_char.Height); InitialiseOverlay(); + DrawGrid(); DrawChar(); } } @@ -429,19 +426,16 @@ namespace BitmapFontEd private void DrawGrid() { - Graphics g=Graphics.FromImage(m_editBmp); + Graphics g=Graphics.FromImage(m_prevBmp); Pen p=new Pen(m_gridCol); - - g.Clear(Color.Black); - Flush(ref g); - - g=Graphics.FromImage(m_prevBmp); g.Clear(Color.Black); Flush(ref g); g=Graphics.FromImage(m_editBmp); + g.Clear(Color.Black); + for(int x=0;x