From 0f11f8e2d536e06b1b1175388752ede4db716117 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 15 May 2005 01:04:53 +0000 Subject: Initial working editor and character selection --- GfxEditor.cs | 252 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 137 insertions(+), 115 deletions(-) (limited to 'GfxEditor.cs') diff --git a/GfxEditor.cs b/GfxEditor.cs index d67b19e..d72b2fb 100644 --- a/GfxEditor.cs +++ b/GfxEditor.cs @@ -33,20 +33,21 @@ namespace BitmapFontEd [ToolboxItem(true)] public class GfxEditor : System.Windows.Forms.UserControl { - private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button m_undoButton; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label m_fgPreview; - private System.Windows.Forms.NumericUpDown m_sizeX; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.Label m_bgPreview; private System.Windows.Forms.PictureBox m_edit; - private System.Windows.Forms.NumericUpDown m_sizeY; private System.Windows.Forms.ComboBox m_modeList; + private System.Windows.Forms.Label m_fgPreview; 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.NumericUpDown m_sizeX; + private System.Windows.Forms.Label m_pos; + private System.Windows.Forms.Button m_undoButton; private const uint SIZE=256; private Color TRANS=Color.Empty; @@ -146,93 +147,76 @@ namespace BitmapFontEd /// not be able to load this method if it was changed manually. /// private void InitializeComponent() { - this.m_preview = new System.Windows.Forms.PictureBox(); - this.m_modeList = new System.Windows.Forms.ComboBox(); - this.m_sizeY = new System.Windows.Forms.NumericUpDown(); - this.m_edit = new System.Windows.Forms.PictureBox(); + 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.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); - this.m_sizeX = new System.Windows.Forms.NumericUpDown(); + this.m_sizeY = new System.Windows.Forms.NumericUpDown(); + this.m_preview = new System.Windows.Forms.PictureBox(); this.m_fgPreview = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.m_undoButton = new System.Windows.Forms.Button(); + 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.label3 = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).BeginInit(); + this.label4 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.m_sizeX)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).BeginInit(); this.SuspendLayout(); // - // m_preview + // m_undoButton // - this.m_preview.BackColor = System.Drawing.SystemColors.Control; - this.m_preview.Location = new System.Drawing.Point(288, 208); - this.m_preview.Name = "m_preview"; - this.m_preview.Size = new System.Drawing.Size(34, 34); - this.m_preview.TabIndex = 1; - this.m_preview.TabStop = false; + this.m_undoButton.Location = new System.Drawing.Point(8, 272); + this.m_undoButton.Name = "m_undoButton"; + this.m_undoButton.Size = new System.Drawing.Size(72, 24); + this.m_undoButton.TabIndex = 16; + this.m_undoButton.Text = "Undo"; + this.m_undoButton.Click += new System.EventHandler(this.OnUndo); // - // m_modeList + // m_pos // - this.m_modeList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.m_modeList.Items.AddRange(new object[] { - "Plot", - "Line", - "Rectangle", - "Filled Rect", - "Circle", - "Filled Circle", - "Ellipse", - "Filled Ellipse", - "Flood Fill", - "Copy/Paste"}); - this.m_modeList.Location = new System.Drawing.Point(280, 64); - this.m_modeList.MaxDropDownItems = 16; - this.m_modeList.Name = "m_modeList"; - this.m_modeList.Size = new System.Drawing.Size(104, 21); - this.m_modeList.TabIndex = 15; - this.m_modeList.SelectedIndexChanged += new System.EventHandler(this.OnModeSelect); + this.m_pos.Location = new System.Drawing.Point(160, 272); + this.m_pos.Name = "m_pos"; + this.m_pos.Size = new System.Drawing.Size(104, 24); + this.m_pos.TabIndex = 23; + this.m_pos.TextAlign = System.Drawing.ContentAlignment.TopRight; // - // m_sizeY + // m_sizeX // - this.m_sizeY.CausesValidation = false; - this.m_sizeY.Location = new System.Drawing.Point(336, 24); - this.m_sizeY.Maximum = new System.Decimal(new int[] { + this.m_sizeX.CausesValidation = false; + this.m_sizeX.Location = new System.Drawing.Point(280, 24); + this.m_sizeX.Maximum = new System.Decimal(new int[] { 32, 0, 0, 0}); - this.m_sizeY.Minimum = new System.Decimal(new int[] { + this.m_sizeX.Minimum = new System.Decimal(new int[] { 1, 0, 0, 0}); - this.m_sizeY.Name = "m_sizeY"; - this.m_sizeY.ReadOnly = true; - this.m_sizeY.Size = new System.Drawing.Size(48, 21); - this.m_sizeY.TabIndex = 20; - this.m_sizeY.Value = new System.Decimal(new int[] { + this.m_sizeX.Name = "m_sizeX"; + this.m_sizeX.ReadOnly = true; + this.m_sizeX.Size = new System.Drawing.Size(48, 20); + this.m_sizeX.TabIndex = 19; + this.m_sizeX.Value = new System.Decimal(new int[] { 1, 0, 0, 0}); - this.m_sizeY.ValueChanged += new System.EventHandler(this.OnSize); - this.m_sizeY.Leave += new System.EventHandler(this.OnSize); + this.m_sizeX.ValueChanged += new System.EventHandler(this.OnSize); + this.m_sizeX.Leave += new System.EventHandler(this.OnSize); // - // m_edit + // label3 // - this.m_edit.BackColor = System.Drawing.SystemColors.Control; - this.m_edit.Location = new System.Drawing.Point(8, 8); - this.m_edit.Name = "m_edit"; - this.m_edit.Size = new System.Drawing.Size(256, 256); - this.m_edit.TabIndex = 0; - this.m_edit.TabStop = false; - this.m_edit.MouseEnter += new System.EventHandler(this.OnEnterEditor); - this.m_edit.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove); - this.m_edit.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove); - this.m_edit.MouseLeave += new System.EventHandler(this.OnLeaveEditor); - this.m_edit.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove); + 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; // // m_bgPreview // @@ -244,6 +228,15 @@ namespace BitmapFontEd this.m_bgPreview.TabIndex = 18; this.m_bgPreview.Click += new System.EventHandler(this.OnBackground); // + // label5 + // + this.label5.Location = new System.Drawing.Point(336, 96); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(40, 16); + this.label5.TabIndex = 12; + this.label5.Text = "Right"; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // // label6 // this.label6.Location = new System.Drawing.Point(336, 8); @@ -253,31 +246,40 @@ namespace BitmapFontEd this.label6.Text = "Height"; this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // m_sizeX + // m_sizeY // - this.m_sizeX.CausesValidation = false; - this.m_sizeX.Location = new System.Drawing.Point(280, 24); - this.m_sizeX.Maximum = new System.Decimal(new int[] { + this.m_sizeY.CausesValidation = false; + this.m_sizeY.Location = new System.Drawing.Point(336, 24); + this.m_sizeY.Maximum = new System.Decimal(new int[] { 32, 0, 0, 0}); - this.m_sizeX.Minimum = new System.Decimal(new int[] { + this.m_sizeY.Minimum = new System.Decimal(new int[] { 1, 0, 0, 0}); - this.m_sizeX.Name = "m_sizeX"; - this.m_sizeX.ReadOnly = true; - this.m_sizeX.Size = new System.Drawing.Size(48, 21); - this.m_sizeX.TabIndex = 19; - this.m_sizeX.Value = new System.Decimal(new int[] { + this.m_sizeY.Name = "m_sizeY"; + this.m_sizeY.ReadOnly = true; + this.m_sizeY.Size = new System.Drawing.Size(48, 20); + this.m_sizeY.TabIndex = 20; + this.m_sizeY.Value = new System.Decimal(new int[] { 1, 0, 0, 0}); - this.m_sizeX.ValueChanged += new System.EventHandler(this.OnSize); - this.m_sizeX.Leave += new System.EventHandler(this.OnSize); + this.m_sizeY.ValueChanged += new System.EventHandler(this.OnSize); + this.m_sizeY.Leave += new System.EventHandler(this.OnSize); + // + // m_preview + // + this.m_preview.BackColor = System.Drawing.SystemColors.Control; + this.m_preview.Location = new System.Drawing.Point(288, 208); + this.m_preview.Name = "m_preview"; + this.m_preview.Size = new System.Drawing.Size(34, 34); + this.m_preview.TabIndex = 1; + this.m_preview.TabStop = false; // // m_fgPreview // @@ -289,32 +291,40 @@ namespace BitmapFontEd this.m_fgPreview.TabIndex = 17; this.m_fgPreview.Click += new System.EventHandler(this.OnForeground); // - // label4 - // - 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 + // m_modeList // - this.label5.Location = new System.Drawing.Point(336, 96); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(40, 16); - this.label5.TabIndex = 12; - this.label5.Text = "Right"; - this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.m_modeList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.m_modeList.Items.AddRange(new object[] { + "Plot", + "Line", + "Rectangle", + "Filled Rect", + "Circle", + "Filled Circle", + "Ellipse", + "Filled Ellipse", + "Flood Fill", + "Copy/Paste"}); + this.m_modeList.Location = new System.Drawing.Point(280, 64); + this.m_modeList.MaxDropDownItems = 16; + this.m_modeList.Name = "m_modeList"; + this.m_modeList.Size = new System.Drawing.Size(104, 21); + this.m_modeList.TabIndex = 15; + this.m_modeList.SelectedIndexChanged += new System.EventHandler(this.OnModeSelect); // - // m_undoButton + // m_edit // - this.m_undoButton.Location = new System.Drawing.Point(8, 272); - this.m_undoButton.Name = "m_undoButton"; - this.m_undoButton.Size = new System.Drawing.Size(72, 24); - this.m_undoButton.TabIndex = 16; - this.m_undoButton.Text = "Undo"; - this.m_undoButton.Click += new System.EventHandler(this.OnUndo); + this.m_edit.BackColor = System.Drawing.SystemColors.Control; + this.m_edit.Location = new System.Drawing.Point(8, 8); + this.m_edit.Name = "m_edit"; + this.m_edit.Size = new System.Drawing.Size(256, 256); + this.m_edit.TabIndex = 0; + this.m_edit.TabStop = false; + this.m_edit.MouseEnter += new System.EventHandler(this.OnEnterEditor); + this.m_edit.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove); + this.m_edit.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove); + this.m_edit.MouseLeave += new System.EventHandler(this.OnLeaveEditor); + this.m_edit.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove); // // label1 // @@ -334,17 +344,18 @@ namespace BitmapFontEd this.label2.Text = "Preview"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // label3 + // label4 // - 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.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; // // GfxEditor // + this.Controls.Add(this.m_pos); this.Controls.Add(this.label6); this.Controls.Add(this.label2); this.Controls.Add(this.m_sizeY); @@ -361,8 +372,8 @@ namespace BitmapFontEd this.Controls.Add(this.m_edit); this.Name = "GfxEditor"; this.Size = new System.Drawing.Size(392, 304); - ((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.m_sizeX)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.m_sizeY)).EndInit(); this.ResumeLayout(false); } #endregion @@ -377,9 +388,14 @@ namespace BitmapFontEd set {m_gridCol=value;} } - public Size CharSize + public uint CharWidth { - get {return new Size((int)m_width,(int)m_height);} + get {return m_width;} + } + + public uint CharHeight + { + get {return m_height;} } public BitmapChar BitmapChar @@ -390,8 +406,8 @@ namespace BitmapFontEd m_char=value; m_ignoreSize=true; m_sizeX.Value=Convert.ToDecimal(m_char.Width); - m_sizeY.Value=Convert.ToDecimal(m_char.Height); m_ignoreSize=false; + m_sizeY.Value=Convert.ToDecimal(m_char.Height); InitialiseOverlay(); DrawChar(); } @@ -840,6 +856,8 @@ namespace BitmapFontEd void OnLeaveEditor(object sender, System.EventArgs e) { //m_inEditor=false; + + m_pos.Text=""; if (m_drawing && m_mode==Mode.ePlot) { @@ -881,6 +899,8 @@ namespace BitmapFontEd x=(uint)e.X/m_grid; y=(uint)e.Y/m_grid; + m_pos.Text=x+","+y; + if (x>=m_char.Width || y>=m_char.Height) { return; @@ -1052,6 +1072,7 @@ namespace BitmapFontEd ColorDialog d=new ColorDialog(); d.Color=m_fgPreview.BackColor; + d.FullOpen=true; if (d.ShowDialog()==DialogResult.OK) { @@ -1064,6 +1085,7 @@ namespace BitmapFontEd ColorDialog d=new ColorDialog(); d.Color=m_bgPreview.BackColor; + d.FullOpen=true; if (d.ShowDialog()==DialogResult.OK) { -- cgit v1.2.3