summaryrefslogtreecommitdiff
path: root/GfxEditor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'GfxEditor.cs')
-rw-r--r--GfxEditor.cs129
1 files changed, 67 insertions, 62 deletions
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<m_width+1;x++)
{
g.DrawLine(p,x*m_grid,0,x*m_grid,m_my);
@@ -822,14 +816,27 @@ namespace BitmapFontEd
m_mode=(Mode)m_modeList.SelectedIndex;
}
- void OnSize(object sender, System.EventArgs e)
+ void OnSizeWidth(object sender, System.EventArgs e)
{
- if (m_ignoreSize)
+ m_width=Convert.ToUInt32(m_sizeX.Value);
+
+ if (m_char!=null)
{
- return;
+ m_undo=new BitmapChar(m_char);
+ m_char.Resize(m_width,m_height);
+ InitialiseOverlay();
}
- m_width=Convert.ToUInt32(m_sizeX.Value);
+ m_grid=Math.Min(SIZE/m_width,SIZE/m_height);
+
+ m_mx=m_width*m_grid;
+
+ DrawGrid();
+ DrawChar();
+ }
+
+ void OnSizeHeight(object sender, System.EventArgs e)
+ {
m_height=Convert.ToUInt32(m_sizeY.Value);
if (m_char!=null)
@@ -841,13 +848,12 @@ namespace BitmapFontEd
m_grid=Math.Min(SIZE/m_width,SIZE/m_height);
- m_mx=m_width*m_grid;
m_my=m_height*m_grid;
DrawGrid();
DrawChar();
}
-
+
void OnEnterEditor(object sender, System.EventArgs e)
{
//m_inEditor=true;
@@ -1094,6 +1100,5 @@ namespace BitmapFontEd
}
#endregion
-
}
}