From 81ed3c21ad7624a383a721c9509f671bd6f5ac23 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 16 May 2005 00:31:10 +0000 Subject: Added adjustements and drop shadow --- BitmapChar.cs | 34 ++ BitmapFontEd.DropShadowForm.resources | Bin 0 -> 8589 bytes BitmapFontEd.MainForm.resources | Bin 12270 -> 17457 bytes BitmapFontEd.prjx | 2 + DropShadowForm.cs | 320 ++++++++++++++++ GfxEditor.cs | 12 + MainForm.cs | 666 +++++++++++++++++++++++++--------- Util.cs | 11 +- 8 files changed, 869 insertions(+), 176 deletions(-) create mode 100644 BitmapFontEd.DropShadowForm.resources create mode 100644 DropShadowForm.cs diff --git a/BitmapChar.cs b/BitmapChar.cs index b161d4f..432dce8 100644 --- a/BitmapChar.cs +++ b/BitmapChar.cs @@ -192,6 +192,40 @@ namespace BitmapFontEd m_data=d; m_changed=true; } + + public void DropShadow(int dx, int dy, Color col) + { + Color[,] d=new Color[m_width,m_height]; + + // I'm sure this is too convoluted... + // + for(int y=0;y=0 && nx=0 && ny + + diff --git a/DropShadowForm.cs b/DropShadowForm.cs new file mode 100644 index 0000000..ac3b55f --- /dev/null +++ b/DropShadowForm.cs @@ -0,0 +1,320 @@ +// XXX - YYY +// Copyright (C) 200X Ian Cowburn +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// 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. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// $Id$ +// + +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace BitmapFontEd +{ + /// + /// Description of DropShadowForm. + /// + public class DropShadowForm : System.Windows.Forms.Form + { + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.RadioButton m_left; + private System.Windows.Forms.Label m_color; + private System.Windows.Forms.RadioButton m_right; + private System.Windows.Forms.RadioButton m_topLeft; + private System.Windows.Forms.Button m_ok; + private System.Windows.Forms.NumericUpDown m_depth; + private System.Windows.Forms.RadioButton m_bottomLeft; + private System.Windows.Forms.RadioButton m_bottomRight; + private System.Windows.Forms.Button m_cancel; + private System.Windows.Forms.RadioButton m_topRight; + private System.Windows.Forms.RadioButton m_top; + private System.Windows.Forms.RadioButton m_bottom; + + public class Shadow + { + public Shadow(int dx, int dy) + { + m_dx=dx; + m_dy=dy; + } + + public int DX {get {return m_dx;}} + public int DY {get {return m_dy;}} + + private int m_dx; + private int m_dy; + } + + public DropShadowForm() + { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + + m_topLeft.Tag=new Shadow(-1,-1); + m_top.Tag=new Shadow(0,-1); + m_topRight.Tag=new Shadow(1,-1); + m_left.Tag=new Shadow(-1,0); + m_right.Tag=new Shadow(1,0); + m_bottomLeft.Tag=new Shadow(-1,1); + m_bottom.Tag=new Shadow(0,1); + m_bottomRight.Tag=new Shadow(1,1); + } + + #region Windows Forms Designer generated code + /// + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// + private void InitializeComponent() { + this.m_bottom = new System.Windows.Forms.RadioButton(); + this.m_top = new System.Windows.Forms.RadioButton(); + this.m_topRight = new System.Windows.Forms.RadioButton(); + this.m_cancel = new System.Windows.Forms.Button(); + this.m_bottomRight = new System.Windows.Forms.RadioButton(); + this.m_bottomLeft = new System.Windows.Forms.RadioButton(); + this.m_depth = new System.Windows.Forms.NumericUpDown(); + this.m_ok = new System.Windows.Forms.Button(); + this.m_topLeft = new System.Windows.Forms.RadioButton(); + this.m_right = new System.Windows.Forms.RadioButton(); + this.m_color = new System.Windows.Forms.Label(); + this.m_left = new System.Windows.Forms.RadioButton(); + 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_depth)).BeginInit(); + this.SuspendLayout(); + // + // m_bottom + // + this.m_bottom.Location = new System.Drawing.Point(32, 48); + this.m_bottom.Name = "m_bottom"; + this.m_bottom.Size = new System.Drawing.Size(16, 16); + this.m_bottom.TabIndex = 8; + // + // m_top + // + this.m_top.Location = new System.Drawing.Point(32, 16); + this.m_top.Name = "m_top"; + this.m_top.Size = new System.Drawing.Size(16, 16); + this.m_top.TabIndex = 2; + // + // m_topRight + // + this.m_topRight.Location = new System.Drawing.Point(48, 16); + this.m_topRight.Name = "m_topRight"; + this.m_topRight.Size = new System.Drawing.Size(16, 16); + this.m_topRight.TabIndex = 3; + // + // m_cancel + // + this.m_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.m_cancel.Location = new System.Drawing.Point(136, 120); + this.m_cancel.Name = "m_cancel"; + this.m_cancel.Size = new System.Drawing.Size(112, 24); + this.m_cancel.TabIndex = 10; + this.m_cancel.Text = "Cancel"; + this.m_cancel.Click += new System.EventHandler(this.OnOK); + // + // m_bottomRight + // + this.m_bottomRight.Checked = true; + this.m_bottomRight.Location = new System.Drawing.Point(48, 48); + this.m_bottomRight.Name = "m_bottomRight"; + this.m_bottomRight.Size = new System.Drawing.Size(16, 16); + this.m_bottomRight.TabIndex = 7; + this.m_bottomRight.TabStop = true; + // + // m_bottomLeft + // + this.m_bottomLeft.Location = new System.Drawing.Point(16, 48); + this.m_bottomLeft.Name = "m_bottomLeft"; + this.m_bottomLeft.Size = new System.Drawing.Size(16, 16); + this.m_bottomLeft.TabIndex = 6; + // + // m_depth + // + this.m_depth.Location = new System.Drawing.Point(16, 72); + this.m_depth.Maximum = new System.Decimal(new int[] { + 10, + 0, + 0, + 0}); + this.m_depth.Minimum = new System.Decimal(new int[] { + 1, + 0, + 0, + 0}); + this.m_depth.Name = "m_depth"; + this.m_depth.ReadOnly = true; + this.m_depth.Size = new System.Drawing.Size(48, 21); + this.m_depth.TabIndex = 11; + this.m_depth.Value = new System.Decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // m_ok + // + this.m_ok.Location = new System.Drawing.Point(136, 88); + this.m_ok.Name = "m_ok"; + this.m_ok.Size = new System.Drawing.Size(112, 24); + this.m_ok.TabIndex = 0; + this.m_ok.Text = "OK"; + this.m_ok.Click += new System.EventHandler(this.OnOK); + // + // m_topLeft + // + this.m_topLeft.Location = new System.Drawing.Point(16, 16); + this.m_topLeft.Name = "m_topLeft"; + this.m_topLeft.Size = new System.Drawing.Size(16, 16); + this.m_topLeft.TabIndex = 1; + // + // m_right + // + this.m_right.Location = new System.Drawing.Point(48, 32); + this.m_right.Name = "m_right"; + this.m_right.Size = new System.Drawing.Size(16, 16); + this.m_right.TabIndex = 5; + // + // m_color + // + this.m_color.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224))); + this.m_color.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.m_color.Location = new System.Drawing.Point(16, 104); + this.m_color.Name = "m_color"; + this.m_color.Size = new System.Drawing.Size(48, 40); + this.m_color.TabIndex = 13; + this.m_color.Click += new System.EventHandler(this.OnSelectColor); + // + // m_left + // + this.m_left.Location = new System.Drawing.Point(16, 32); + this.m_left.Name = "m_left"; + this.m_left.Size = new System.Drawing.Size(16, 16); + this.m_left.TabIndex = 4; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(72, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(56, 48); + this.label1.TabIndex = 9; + this.label1.Text = "Shadow Direction"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(72, 72); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(48, 24); + this.label2.TabIndex = 12; + this.label2.Text = "Shadow Depth"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(72, 104); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(56, 40); + this.label3.TabIndex = 14; + this.label3.Text = "Shadow Color"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // DropShadowForm + // + this.AcceptButton = this.m_ok; + this.AutoScaleBaseSize = new System.Drawing.Size(5, 14); + this.CancelButton = this.m_cancel; + this.ClientSize = new System.Drawing.Size(258, 154); + this.Controls.Add(this.label3); + this.Controls.Add(this.m_color); + this.Controls.Add(this.label2); + this.Controls.Add(this.m_depth); + this.Controls.Add(this.m_cancel); + this.Controls.Add(this.label1); + this.Controls.Add(this.m_left); + this.Controls.Add(this.m_ok); + this.Controls.Add(this.m_bottomLeft); + this.Controls.Add(this.m_bottom); + this.Controls.Add(this.m_bottomRight); + this.Controls.Add(this.m_right); + this.Controls.Add(this.m_topRight); + this.Controls.Add(this.m_top); + this.Controls.Add(this.m_topLeft); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "DropShadowForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Drop Shadow"; + ((System.ComponentModel.ISupportInitialize)(this.m_depth)).EndInit(); + this.ResumeLayout(false); + } + #endregion + + public Shadow ShadowSize + { + get + { + foreach (Control c in Controls) + { + if (c is RadioButton) + { + RadioButton r=(RadioButton)c; + + if (r.Checked) + { + Shadow s=(Shadow)r.Tag; + int depth=Convert.ToInt32(m_depth.Value); + + return new Shadow(s.DX*depth,s.DY*depth); + } + } + } + + return new Shadow(0,0); + } + } + + public Color ShadowColour + { + get {return m_color.BackColor;} + } + + void OnOK(object sender, System.EventArgs e) + { + DialogResult=DialogResult.OK; + Close(); + } + + void OnSelectColor(object sender, System.EventArgs e) + { + ColorDialog d=new ColorDialog(); + + d.Color=m_color.BackColor; + d.FullOpen=true; + + if (d.ShowDialog()==DialogResult.OK) + { + m_color.BackColor=d.Color; + } + } + } +} diff --git a/GfxEditor.cs b/GfxEditor.cs index d1249e6..0b09ce3 100644 --- a/GfxEditor.cs +++ b/GfxEditor.cs @@ -580,6 +580,16 @@ namespace BitmapFontEd } } + public Color SelectedForeground + { + get {return m_fgPreview.BackColor;} + } + + public Color SelectedBackground + { + get {return m_bgPreview.BackColor;} + } + #endregion // ------------------------------------------------------- @@ -1025,6 +1035,7 @@ 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(); @@ -1043,6 +1054,7 @@ 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(); diff --git a/MainForm.cs b/MainForm.cs index 6f71c5e..078741e 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -30,28 +30,42 @@ namespace BitmapFontEd /// public class MainForm : System.Windows.Forms.Form { - private System.Windows.Forms.CheckBox m_applyAll; - private System.Windows.Forms.GroupBox m_selectGroup; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.MenuItem m_helpMenu; + private System.Windows.Forms.NumericUpDown m_codeSelect; + private System.Windows.Forms.GroupBox m_globaladjustGroup; private System.Windows.Forms.GroupBox m_adjustGroup; - private System.Windows.Forms.MainMenu m_menu; - private System.Windows.Forms.ComboBox m_asciiSelect; + private System.Windows.Forms.Button m_scrollDown; + private System.Windows.Forms.Button m_scrollUp; private System.Windows.Forms.MenuItem m_fileMenu; - private System.Windows.Forms.MenuItem m_open; - private System.Windows.Forms.MenuItem menuItem6; - private System.Windows.Forms.MenuItem m_saveAs; - private System.Windows.Forms.TrackBar m_charSelect; - private System.Windows.Forms.MenuItem m_quit; - private System.Windows.Forms.MenuItem m_new; - private System.Windows.Forms.GroupBox m_editGroup; + private System.Windows.Forms.Button m_mirrorVertical; + private System.Windows.Forms.Button m_rotRight; private System.Windows.Forms.Button m_revert; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Button m_resize; + private System.Windows.Forms.Button m_dropShadow; private System.Windows.Forms.MenuItem m_about; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button m_scrollRight; + private System.Windows.Forms.CheckBox m_applyAll; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Button m_rotLeft; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TrackBar m_charSelect; + private System.Windows.Forms.MainMenu m_menu; + private System.Windows.Forms.Button m_resize; + private System.Windows.Forms.ComboBox m_asciiSelect; + private System.Windows.Forms.MenuItem m_quit; private System.Windows.Forms.MenuItem m_save; - private System.Windows.Forms.NumericUpDown m_codeSelect; - private System.Windows.Forms.GroupBox m_globaladjustGroup; - private System.Windows.Forms.MenuItem m_helpMenu; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.MenuItem m_saveAs; + private System.Windows.Forms.Button m_scrollLeft; + private System.Windows.Forms.GroupBox m_editGroup; + private System.Windows.Forms.MenuItem m_new; + private System.Windows.Forms.MenuItem m_open; + private System.Windows.Forms.MenuItem menuItem6; + private System.Windows.Forms.Button m_mirrorHorizontal; + private System.Windows.Forms.GroupBox m_selectGroup; + private System.Windows.Forms.Button m_clear; private GfxEditor m_edit; private BitmapCharList m_chars; @@ -59,6 +73,8 @@ namespace BitmapFontEd private bool m_inSelect; private string m_path; + private DropShadowForm m_shadowForm; + public MainForm() { // @@ -72,6 +88,8 @@ namespace BitmapFontEd m_edit.Location=new Point(4,16); m_editGroup.Controls.Add(m_edit); + m_shadowForm=new DropShadowForm(); + m_chars=new BitmapCharList(); for(byte c=32;c<127;c++) @@ -111,124 +129,100 @@ namespace BitmapFontEd /// not be able to load this method if it was changed manually. /// private void InitializeComponent() { - this.m_helpMenu = new System.Windows.Forms.MenuItem(); - this.m_globaladjustGroup = new System.Windows.Forms.GroupBox(); - this.m_codeSelect = new System.Windows.Forms.NumericUpDown(); - this.m_save = new System.Windows.Forms.MenuItem(); - this.m_about = new System.Windows.Forms.MenuItem(); - this.m_resize = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.m_revert = new System.Windows.Forms.Button(); - this.m_editGroup = new System.Windows.Forms.GroupBox(); - this.m_new = new System.Windows.Forms.MenuItem(); - this.m_quit = new System.Windows.Forms.MenuItem(); - this.m_charSelect = new System.Windows.Forms.TrackBar(); - this.m_saveAs = new System.Windows.Forms.MenuItem(); + this.m_clear = new System.Windows.Forms.Button(); + this.m_selectGroup = new System.Windows.Forms.GroupBox(); + this.m_mirrorHorizontal = new System.Windows.Forms.Button(); this.menuItem6 = new System.Windows.Forms.MenuItem(); this.m_open = new System.Windows.Forms.MenuItem(); - this.m_fileMenu = new System.Windows.Forms.MenuItem(); + this.m_new = new System.Windows.Forms.MenuItem(); + this.m_editGroup = new System.Windows.Forms.GroupBox(); + this.m_scrollLeft = new System.Windows.Forms.Button(); + this.m_saveAs = new System.Windows.Forms.MenuItem(); + this.label5 = new System.Windows.Forms.Label(); + this.m_save = new System.Windows.Forms.MenuItem(); + this.m_quit = new System.Windows.Forms.MenuItem(); this.m_asciiSelect = new System.Windows.Forms.ComboBox(); + this.m_resize = new System.Windows.Forms.Button(); this.m_menu = new System.Windows.Forms.MainMenu(); - this.m_adjustGroup = new System.Windows.Forms.GroupBox(); - this.m_selectGroup = new System.Windows.Forms.GroupBox(); + this.m_charSelect = new System.Windows.Forms.TrackBar(); + this.label4 = new System.Windows.Forms.Label(); + this.m_rotLeft = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); this.m_applyAll = new System.Windows.Forms.CheckBox(); - this.m_globaladjustGroup.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.m_codeSelect)).BeginInit(); + this.m_scrollRight = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.m_about = new System.Windows.Forms.MenuItem(); + this.m_dropShadow = new System.Windows.Forms.Button(); + this.m_revert = new System.Windows.Forms.Button(); + this.m_rotRight = new System.Windows.Forms.Button(); + this.m_mirrorVertical = new System.Windows.Forms.Button(); + this.m_fileMenu = new System.Windows.Forms.MenuItem(); + this.m_scrollUp = new System.Windows.Forms.Button(); + this.m_scrollDown = new System.Windows.Forms.Button(); + this.m_adjustGroup = new System.Windows.Forms.GroupBox(); + this.m_globaladjustGroup = new System.Windows.Forms.GroupBox(); + this.m_codeSelect = new System.Windows.Forms.NumericUpDown(); + this.m_helpMenu = new System.Windows.Forms.MenuItem(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.m_selectGroup.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.m_charSelect)).BeginInit(); this.m_adjustGroup.SuspendLayout(); - this.m_selectGroup.SuspendLayout(); + this.m_globaladjustGroup.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.m_codeSelect)).BeginInit(); this.SuspendLayout(); // - // m_helpMenu - // - this.m_helpMenu.Index = 1; - this.m_helpMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.m_about}); - this.m_helpMenu.Text = "&Help"; + // m_clear // - // m_globaladjustGroup - // - this.m_globaladjustGroup.Controls.Add(this.m_resize); - this.m_globaladjustGroup.Location = new System.Drawing.Point(424, 8); - this.m_globaladjustGroup.Name = "m_globaladjustGroup"; - this.m_globaladjustGroup.Size = new System.Drawing.Size(216, 48); - this.m_globaladjustGroup.TabIndex = 2; - this.m_globaladjustGroup.TabStop = false; - this.m_globaladjustGroup.Text = "Global Adjustments"; - // - // m_codeSelect - // - this.m_codeSelect.Location = new System.Drawing.Point(88, 64); - this.m_codeSelect.Maximum = new System.Decimal(new int[] { - 127, - 0, - 0, - 0}); - this.m_codeSelect.Minimum = new System.Decimal(new int[] { - 32, - 0, - 0, - 0}); - this.m_codeSelect.Name = "m_codeSelect"; - this.m_codeSelect.ReadOnly = true; - this.m_codeSelect.Size = new System.Drawing.Size(64, 21); - this.m_codeSelect.TabIndex = 9; - this.m_codeSelect.Value = new System.Decimal(new int[] { - 32, - 0, - 0, - 0}); - this.m_codeSelect.ValueChanged += new System.EventHandler(this.OnSelectByCode); - // - // m_save - // - this.m_save.Index = 2; - this.m_save.Shortcut = System.Windows.Forms.Shortcut.CtrlS; - this.m_save.Text = "&Save"; - this.m_save.Click += new System.EventHandler(this.OnSave); + this.m_clear.Location = new System.Drawing.Point(8, 40); + this.m_clear.Name = "m_clear"; + this.m_clear.Size = new System.Drawing.Size(96, 24); + this.m_clear.TabIndex = 2; + this.m_clear.Text = "Clear"; + this.m_clear.Click += new System.EventHandler(this.OnClear); // - // m_about + // m_selectGroup // - this.m_about.Index = 0; - this.m_about.Text = "&About"; - this.m_about.Click += new System.EventHandler(this.OnAbout); + this.m_selectGroup.Controls.Add(this.m_codeSelect); + this.m_selectGroup.Controls.Add(this.m_asciiSelect); + this.m_selectGroup.Controls.Add(this.m_revert); + this.m_selectGroup.Controls.Add(this.m_charSelect); + this.m_selectGroup.Controls.Add(this.label2); + this.m_selectGroup.Controls.Add(this.label1); + this.m_selectGroup.Location = new System.Drawing.Point(8, 344); + this.m_selectGroup.Name = "m_selectGroup"; + this.m_selectGroup.Size = new System.Drawing.Size(408, 104); + this.m_selectGroup.TabIndex = 1; + this.m_selectGroup.TabStop = false; + this.m_selectGroup.Text = "Character"; // - // m_resize + // m_mirrorHorizontal // - this.m_resize.Location = new System.Drawing.Point(8, 16); - this.m_resize.Name = "m_resize"; - this.m_resize.Size = new System.Drawing.Size(88, 24); - this.m_resize.TabIndex = 0; - this.m_resize.Text = "Resize All"; - this.m_resize.Click += new System.EventHandler(this.OnResize); + this.m_mirrorHorizontal.Location = new System.Drawing.Point(8, 88); + this.m_mirrorHorizontal.Name = "m_mirrorHorizontal"; + this.m_mirrorHorizontal.Size = new System.Drawing.Size(96, 24); + this.m_mirrorHorizontal.TabIndex = 4; + this.m_mirrorHorizontal.Text = "Horizontal"; + this.m_mirrorHorizontal.Click += new System.EventHandler(this.OnHorizontalMirror); // - // label1 + // menuItem6 // - this.label1.Location = new System.Drawing.Point(16, 64); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(72, 24); - this.label1.TabIndex = 1; - this.label1.Text = "ASCII Code:"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.menuItem6.Index = 4; + this.menuItem6.Text = "-"; // - // label2 + // m_open // - this.label2.Location = new System.Drawing.Point(160, 64); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(72, 24); - this.label2.TabIndex = 3; - this.label2.Text = "Character:"; - this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.m_open.Index = 1; + this.m_open.Shortcut = System.Windows.Forms.Shortcut.CtrlO; + this.m_open.Text = "&Open"; + this.m_open.Click += new System.EventHandler(this.OnOpen); // - // m_revert + // m_new // - this.m_revert.Location = new System.Drawing.Point(304, 64); - this.m_revert.Name = "m_revert"; - this.m_revert.Size = new System.Drawing.Size(88, 24); - this.m_revert.TabIndex = 6; - this.m_revert.Text = "Revert"; - this.m_revert.Click += new System.EventHandler(this.OnRevert); + this.m_new.Index = 0; + this.m_new.Shortcut = System.Windows.Forms.Shortcut.CtrlN; + this.m_new.Text = "&New"; + this.m_new.Click += new System.EventHandler(this.OnNew); // // m_editGroup // @@ -239,12 +233,37 @@ namespace BitmapFontEd this.m_editGroup.TabStop = false; this.m_editGroup.Text = "Editor"; // - // m_new + // m_scrollLeft // - this.m_new.Index = 0; - this.m_new.Shortcut = System.Windows.Forms.Shortcut.CtrlN; - this.m_new.Text = "&New"; - this.m_new.Click += new System.EventHandler(this.OnNew); + this.m_scrollLeft.Location = new System.Drawing.Point(8, 136); + this.m_scrollLeft.Name = "m_scrollLeft"; + this.m_scrollLeft.Size = new System.Drawing.Size(96, 24); + this.m_scrollLeft.TabIndex = 7; + this.m_scrollLeft.Text = "Left"; + this.m_scrollLeft.Click += new System.EventHandler(this.OnLeftScroll); + // + // m_saveAs + // + this.m_saveAs.Index = 3; + this.m_saveAs.Shortcut = System.Windows.Forms.Shortcut.F12; + this.m_saveAs.Text = "S&ave as..."; + this.m_saveAs.Click += new System.EventHandler(this.OnSaveAs); + // + // label5 + // + this.label5.Location = new System.Drawing.Point(8, 200); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(72, 16); + this.label5.TabIndex = 11; + this.label5.Text = "Rotate"; + this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // m_save + // + this.m_save.Index = 2; + this.m_save.Shortcut = System.Windows.Forms.Shortcut.CtrlS; + this.m_save.Text = "&Save"; + this.m_save.Click += new System.EventHandler(this.OnSave); // // m_quit // @@ -253,6 +272,31 @@ namespace BitmapFontEd this.m_quit.Text = "&Quit"; this.m_quit.Click += new System.EventHandler(this.OnQuit); // + // m_asciiSelect + // + this.m_asciiSelect.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.m_asciiSelect.Location = new System.Drawing.Point(224, 64); + this.m_asciiSelect.MaxDropDownItems = 20; + this.m_asciiSelect.Name = "m_asciiSelect"; + this.m_asciiSelect.Size = new System.Drawing.Size(64, 21); + this.m_asciiSelect.TabIndex = 8; + this.m_asciiSelect.SelectedIndexChanged += new System.EventHandler(this.OnSelectByChar); + // + // m_resize + // + this.m_resize.Location = new System.Drawing.Point(8, 16); + this.m_resize.Name = "m_resize"; + this.m_resize.Size = new System.Drawing.Size(88, 24); + this.m_resize.TabIndex = 0; + this.m_resize.Text = "Resize All"; + this.m_resize.Click += new System.EventHandler(this.OnResize); + // + // m_menu + // + this.m_menu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.m_fileMenu, + this.m_helpMenu}); + // // m_charSelect // this.m_charSelect.Location = new System.Drawing.Point(8, 16); @@ -262,24 +306,100 @@ namespace BitmapFontEd this.m_charSelect.TabIndex = 5; this.m_charSelect.Scroll += new System.EventHandler(this.OnSelectChar); // - // m_saveAs + // label4 // - this.m_saveAs.Index = 3; - this.m_saveAs.Shortcut = System.Windows.Forms.Shortcut.F12; - this.m_saveAs.Text = "S&ave as..."; - this.m_saveAs.Click += new System.EventHandler(this.OnSaveAs); + this.label4.Location = new System.Drawing.Point(8, 120); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(72, 16); + this.label4.TabIndex = 6; + this.label4.Text = "Scroll"; + this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // menuItem6 + // m_rotLeft // - this.menuItem6.Index = 4; - this.menuItem6.Text = "-"; + this.m_rotLeft.Location = new System.Drawing.Point(8, 216); + this.m_rotLeft.Name = "m_rotLeft"; + this.m_rotLeft.Size = new System.Drawing.Size(96, 24); + this.m_rotLeft.TabIndex = 12; + this.m_rotLeft.Text = "Left"; + this.m_rotLeft.Click += new System.EventHandler(this.OnRotateLeft); // - // m_open + // label6 // - this.m_open.Index = 1; - this.m_open.Shortcut = System.Windows.Forms.Shortcut.CtrlO; - this.m_open.Text = "&Open"; - this.m_open.Click += new System.EventHandler(this.OnOpen); + this.label6.Location = new System.Drawing.Point(8, 256); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(88, 16); + this.label6.TabIndex = 14; + this.label6.Text = "Special Effects"; + this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // m_applyAll + // + this.m_applyAll.Location = new System.Drawing.Point(8, 16); + this.m_applyAll.Name = "m_applyAll"; + this.m_applyAll.Size = new System.Drawing.Size(88, 16); + this.m_applyAll.TabIndex = 1; + this.m_applyAll.Text = "Apply To All"; + // + // m_scrollRight + // + this.m_scrollRight.Location = new System.Drawing.Point(112, 136); + this.m_scrollRight.Name = "m_scrollRight"; + this.m_scrollRight.Size = new System.Drawing.Size(96, 24); + this.m_scrollRight.TabIndex = 8; + this.m_scrollRight.Text = "Right"; + this.m_scrollRight.Click += new System.EventHandler(this.OnRightScroll); + // + // label3 + // + this.label3.Location = new System.Drawing.Point(8, 72); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(72, 16); + this.label3.TabIndex = 3; + this.label3.Text = "Mirror"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // m_about + // + this.m_about.Index = 0; + this.m_about.Text = "&About"; + this.m_about.Click += new System.EventHandler(this.OnAbout); + // + // m_dropShadow + // + this.m_dropShadow.Location = new System.Drawing.Point(8, 272); + this.m_dropShadow.Name = "m_dropShadow"; + this.m_dropShadow.Size = new System.Drawing.Size(96, 24); + this.m_dropShadow.TabIndex = 15; + this.m_dropShadow.Text = "Drop Shadow"; + this.m_dropShadow.Click += new System.EventHandler(this.OnDropShadow); + // + // m_revert + // + this.m_revert.Location = new System.Drawing.Point(304, 64); + this.m_revert.Name = "m_revert"; + this.m_revert.Size = new System.Drawing.Size(88, 24); + this.m_revert.TabIndex = 6; + this.m_revert.Text = "Revert"; + this.m_revert.Click += new System.EventHandler(this.OnRevert); + // + // m_rotRight + // + this.m_rotRight.Location = new System.Drawing.Point(112, 216); + this.m_rotRight.Name = "m_rotRight"; + this.m_rotRight.Size = new System.Drawing.Size(96, 24); + this.m_rotRight.TabIndex = 13; + this.m_rotRight.Text = "Right"; + this.m_rotRight.Click += new System.EventHandler(this.OnRotateRight); + // + // m_mirrorVertical + // + this.m_mirrorVertical.Location = new System.Drawing.Point(112, 88); + this.m_mirrorVertical.Name = "m_mirrorVertical"; + this.m_mirrorVertical.Size = new System.Drawing.Size(96, 24); + this.m_mirrorVertical.TabIndex = 5; + this.m_mirrorVertical.Text = "Vertical"; + this.m_mirrorVertical.Click += new System.EventHandler(this.OnVerticalMirror); // // m_fileMenu // @@ -293,24 +413,40 @@ namespace BitmapFontEd this.m_quit}); this.m_fileMenu.Text = "&File"; // - // m_asciiSelect + // m_scrollUp // - this.m_asciiSelect.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.m_asciiSelect.Location = new System.Drawing.Point(224, 64); - this.m_asciiSelect.MaxDropDownItems = 20; - this.m_asciiSelect.Name = "m_asciiSelect"; - this.m_asciiSelect.Size = new System.Drawing.Size(64, 21); - this.m_asciiSelect.TabIndex = 8; - this.m_asciiSelect.SelectedIndexChanged += new System.EventHandler(this.OnSelectByChar); + this.m_scrollUp.Location = new System.Drawing.Point(8, 168); + this.m_scrollUp.Name = "m_scrollUp"; + this.m_scrollUp.Size = new System.Drawing.Size(96, 24); + this.m_scrollUp.TabIndex = 9; + this.m_scrollUp.Text = "Up"; + this.m_scrollUp.Click += new System.EventHandler(this.OnUpScroll); // - // m_menu + // m_scrollDown // - this.m_menu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.m_fileMenu, - this.m_helpMenu}); + this.m_scrollDown.Location = new System.Drawing.Point(112, 168); + this.m_scrollDown.Name = "m_scrollDown"; + this.m_scrollDown.Size = new System.Drawing.Size(96, 24); + this.m_scrollDown.TabIndex = 10; + this.m_scrollDown.Text = "Down"; + this.m_scrollDown.Click += new System.EventHandler(this.OnDownScroll); // // m_adjustGroup // + this.m_adjustGroup.Controls.Add(this.m_dropShadow); + this.m_adjustGroup.Controls.Add(this.label6); + this.m_adjustGroup.Controls.Add(this.m_rotRight); + this.m_adjustGroup.Controls.Add(this.m_rotLeft); + this.m_adjustGroup.Controls.Add(this.label5); + this.m_adjustGroup.Controls.Add(this.m_scrollDown); + this.m_adjustGroup.Controls.Add(this.m_scrollUp); + this.m_adjustGroup.Controls.Add(this.m_scrollRight); + this.m_adjustGroup.Controls.Add(this.m_scrollLeft); + this.m_adjustGroup.Controls.Add(this.label4); + this.m_adjustGroup.Controls.Add(this.m_mirrorVertical); + this.m_adjustGroup.Controls.Add(this.m_mirrorHorizontal); + this.m_adjustGroup.Controls.Add(this.label3); + this.m_adjustGroup.Controls.Add(this.m_clear); this.m_adjustGroup.Controls.Add(this.m_applyAll); this.m_adjustGroup.Location = new System.Drawing.Point(424, 64); this.m_adjustGroup.Name = "m_adjustGroup"; @@ -319,32 +455,68 @@ namespace BitmapFontEd this.m_adjustGroup.TabStop = false; this.m_adjustGroup.Text = "Adjustments and Effects"; // - // m_selectGroup + // m_globaladjustGroup // - this.m_selectGroup.Controls.Add(this.m_codeSelect); - this.m_selectGroup.Controls.Add(this.m_asciiSelect); - this.m_selectGroup.Controls.Add(this.m_revert); - this.m_selectGroup.Controls.Add(this.m_charSelect); - this.m_selectGroup.Controls.Add(this.label2); - this.m_selectGroup.Controls.Add(this.label1); - this.m_selectGroup.Location = new System.Drawing.Point(8, 344); - this.m_selectGroup.Name = "m_selectGroup"; - this.m_selectGroup.Size = new System.Drawing.Size(408, 104); - this.m_selectGroup.TabIndex = 1; - this.m_selectGroup.TabStop = false; - this.m_selectGroup.Text = "Character"; + this.m_globaladjustGroup.Controls.Add(this.m_resize); + this.m_globaladjustGroup.Location = new System.Drawing.Point(424, 8); + this.m_globaladjustGroup.Name = "m_globaladjustGroup"; + this.m_globaladjustGroup.Size = new System.Drawing.Size(216, 48); + this.m_globaladjustGroup.TabIndex = 2; + this.m_globaladjustGroup.TabStop = false; + this.m_globaladjustGroup.Text = "Global Adjustments"; // - // m_applyAll + // m_codeSelect // - this.m_applyAll.Location = new System.Drawing.Point(8, 16); - this.m_applyAll.Name = "m_applyAll"; - this.m_applyAll.Size = new System.Drawing.Size(88, 16); - this.m_applyAll.TabIndex = 1; - this.m_applyAll.Text = "Apply To All"; + this.m_codeSelect.Location = new System.Drawing.Point(88, 64); + this.m_codeSelect.Maximum = new System.Decimal(new int[] { + 127, + 0, + 0, + 0}); + this.m_codeSelect.Minimum = new System.Decimal(new int[] { + 32, + 0, + 0, + 0}); + this.m_codeSelect.Name = "m_codeSelect"; + this.m_codeSelect.ReadOnly = true; + this.m_codeSelect.Size = new System.Drawing.Size(64, 20); + this.m_codeSelect.TabIndex = 9; + this.m_codeSelect.Value = new System.Decimal(new int[] { + 32, + 0, + 0, + 0}); + this.m_codeSelect.ValueChanged += new System.EventHandler(this.OnSelectByCode); + // + // m_helpMenu + // + this.m_helpMenu.Index = 1; + this.m_helpMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.m_about}); + this.m_helpMenu.Text = "&Help"; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(16, 64); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(72, 24); + this.label1.TabIndex = 1; + this.label1.Text = "ASCII Code:"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(160, 64); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(72, 24); + this.label2.TabIndex = 3; + this.label2.Text = "Character:"; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // MainForm // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 14); + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(650, 479); this.Controls.Add(this.m_adjustGroup); this.Controls.Add(this.m_globaladjustGroup); @@ -357,11 +529,11 @@ namespace BitmapFontEd this.Name = "MainForm"; this.Text = "Bitmap Font Editor"; this.Closing += new System.ComponentModel.CancelEventHandler(this.OnClosing); - this.m_globaladjustGroup.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.m_codeSelect)).EndInit(); + this.m_selectGroup.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.m_charSelect)).EndInit(); this.m_adjustGroup.ResumeLayout(false); - this.m_selectGroup.ResumeLayout(false); + this.m_globaladjustGroup.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.m_codeSelect)).EndInit(); this.ResumeLayout(false); } #endregion @@ -549,5 +721,163 @@ namespace BitmapFontEd } } + void OnClear(object sender, System.EventArgs e) + { + FetchEdit(); + + if (m_applyAll.Checked) + { + foreach (BitmapChar c in m_chars) + { + c.Clear(m_edit.SelectedBackground); + } + } + else + { + m_chars[m_selected].Clear(m_edit.SelectedBackground); + } + + m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]); + } + + void OnHorizontalMirror(object sender, System.EventArgs e) + { + FetchEdit(); + + if (m_applyAll.Checked) + { + foreach (BitmapChar c in m_chars) + { + c.MirrorHorizontal(); + } + } + else + { + m_chars[m_selected].MirrorHorizontal(); + } + + m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]); + } + + void OnVerticalMirror(object sender, System.EventArgs e) + { + FetchEdit(); + + if (m_applyAll.Checked) + { + foreach (BitmapChar c in m_chars) + { + c.MirrorVertical(); + } + } + else + { + m_chars[m_selected].MirrorVertical(); + } + + m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]); + } + + private void Scroll(int dx, int dy) + { + FetchEdit(); + + if (m_applyAll.Checked) + { + foreach (BitmapChar c in m_chars) + { + c.Scroll(dx,dy); + } + } + else + { + m_chars[m_selected].Scroll(dx,dy); + } + + m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]); + } + + void OnLeftScroll(object sender, System.EventArgs e) + { + Scroll(-1,0); + } + + void OnRightScroll(object sender, System.EventArgs e) + { + Scroll(1,0); + } + + void OnUpScroll(object sender, System.EventArgs e) + { + Scroll(0,-1); + } + + void OnDownScroll(object sender, System.EventArgs e) + { + Scroll(0,1); + } + + void OnRotateLeft(object sender, System.EventArgs e) + { + FetchEdit(); + + if (m_applyAll.Checked) + { + foreach (BitmapChar c in m_chars) + { + c.RotateLeft(); + } + } + else + { + m_chars[m_selected].RotateLeft(); + } + + m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]); + } + + void OnRotateRight(object sender, System.EventArgs e) + { + FetchEdit(); + + if (m_applyAll.Checked) + { + foreach (BitmapChar c in m_chars) + { + c.RotateRight(); + } + } + else + { + m_chars[m_selected].RotateRight(); + } + + m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]); + } + + void OnDropShadow(object sender, System.EventArgs e) + { + if (m_shadowForm.ShowDialog()==DialogResult.OK) + { + DropShadowForm.Shadow shadow=m_shadowForm.ShadowSize; + Color col=m_shadowForm.ShadowColour; + + FetchEdit(); + + if (m_applyAll.Checked) + { + foreach (BitmapChar c in m_chars) + { + c.DropShadow(shadow.DX,shadow.DY,col); + } + } + else + { + m_chars[m_selected].DropShadow(shadow.DX,shadow.DY,col); + } + + m_edit.BitmapChar=new BitmapChar(m_chars[m_selected]); + } + } } } diff --git a/Util.cs b/Util.cs index f7b3bab..c7a6b0e 100644 --- a/Util.cs +++ b/Util.cs @@ -31,26 +31,21 @@ namespace BitmapFontEd { public static bool YesNo(string s) { - return MessageBox.Show(s,"Question", + return MessageBox.Show(s,"Bitmap Font Editor", MessageBoxButtons.YesNo, MessageBoxIcon.Question)==DialogResult.Yes; } public static void Message(string s) { - MessageBox.Show(s,"Message",MessageBoxButtons.OK,MessageBoxIcon.Information); + MessageBox.Show(s,"Bitmap Font Editor",MessageBoxButtons.OK,MessageBoxIcon.Information); } public static void Error(string s) { - MessageBox.Show(s,"ERROR",MessageBoxButtons.OK,MessageBoxIcon.Error); + MessageBox.Show(s,"Bitmap Font Editor - ERROR",MessageBoxButtons.OK,MessageBoxIcon.Error); } - public static void Error(string file, string s) - { - MessageBox.Show(file+"\n\n"+s,"File Error",MessageBoxButtons.OK,MessageBoxIcon.Error); - } - public static void About() { MessageBox.Show(m_about,"About Bitmap Font Editor", -- cgit v1.2.3