diff --git a/McBitFont/Form1.Designer.cs b/McBitFont/Form1.Designer.cs index c9fc319..54f7c22 100644 --- a/McBitFont/Form1.Designer.cs +++ b/McBitFont/Form1.Designer.cs @@ -73,6 +73,7 @@ this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dlgSave = new System.Windows.Forms.SaveFileDialog(); this.dlgOpen = new System.Windows.Forms.OpenFileDialog(); + this.btnBaseline = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.nudX)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudY)).BeginInit(); this.panel1.SuspendLayout(); @@ -122,7 +123,7 @@ // nudY // this.nudY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.nudY.Location = new System.Drawing.Point(717, 53); + this.nudY.Location = new System.Drawing.Point(717, 49); this.nudY.Maximum = new decimal(new int[] { 255, 0, @@ -157,7 +158,7 @@ // this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(670, 55); + this.label2.Location = new System.Drawing.Point(670, 51); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(41, 13); this.label2.TabIndex = 4; @@ -202,7 +203,7 @@ // this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(602, 29); + this.label4.Location = new System.Drawing.Point(604, 29); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(62, 13); this.label4.TabIndex = 7; @@ -304,7 +305,7 @@ // btnExport // this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnExport.Location = new System.Drawing.Point(696, 99); + this.btnExport.Location = new System.Drawing.Point(696, 109); this.btnExport.Name = "btnExport"; this.btnExport.Size = new System.Drawing.Size(75, 23); this.btnExport.TabIndex = 10; @@ -343,7 +344,7 @@ // btnApply // this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnApply.Location = new System.Drawing.Point(589, 99); + this.btnApply.Location = new System.Drawing.Point(615, 109); this.btnApply.Name = "btnApply"; this.btnApply.Size = new System.Drawing.Size(75, 23); this.btnApply.TabIndex = 13; @@ -376,7 +377,7 @@ // this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(640, 71); + this.label5.Location = new System.Drawing.Point(554, 114); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(24, 13); this.label5.TabIndex = 16; @@ -636,11 +637,23 @@ this.dlgOpen.DefaultExt = "mbf"; this.dlgOpen.Filter = "McBitFont files|*.mbf|All files|*.*"; // + // btnBaseline + // + this.btnBaseline.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnBaseline.Location = new System.Drawing.Point(615, 80); + this.btnBaseline.Name = "btnBaseline"; + this.btnBaseline.Size = new System.Drawing.Size(75, 23); + this.btnBaseline.TabIndex = 18; + this.btnBaseline.Text = "Baseline"; + this.btnBaseline.UseVisualStyleBackColor = true; + this.btnBaseline.Click += new System.EventHandler(this.btnBaseline_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(784, 561); + this.Controls.Add(this.btnBaseline); this.Controls.Add(this.btnApply); this.Controls.Add(this.btnExport); this.Controls.Add(this.label5); @@ -725,6 +738,7 @@ private System.Windows.Forms.ToolStripMenuItem appendSymbolToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem; + private System.Windows.Forms.Button btnBaseline; } } diff --git a/McBitFont/Form1.cs b/McBitFont/Form1.cs index 47eb336..1b8ce0a 100644 --- a/McBitFont/Form1.cs +++ b/McBitFont/Form1.cs @@ -37,6 +37,7 @@ namespace McBitFont { public struct SaveBlock { public bool monospaced; public int codepage; + public int baseline; public List frames; } @@ -50,11 +51,13 @@ namespace McBitFont { public bool monospaced = false; bool modified = false; bool prjModified = false; - public const string version = "1.2"; + public const string version = "1.3"; public string prjName = "Untitled"; public int codepage = 1251; private FrameMiniature fbuf; private bool fbuffer = false; + public int baseline = 0; + public bool set_base = false; public MainForm() { InitializeComponent(); @@ -275,6 +278,26 @@ namespace McBitFont { } private void dotPanel_MouseMove(object sender, MouseEventArgs e) { + if (set_base) { + + int yy = pixelOffset + baseline * (cellSize + gap) - vScroll.Value - 1; + Rectangle rect1 = new Rectangle(pixelOffset, yy, w, 3); + baseline = (e.Y - pixelOffset + vScroll.Value) / (cellSize + gap); + + if (baseline >= dotHeight) baseline = dotHeight - 1; + if (baseline < 0) baseline = 0; + + yy = pixelOffset + baseline * (cellSize + gap) - vScroll.Value - 1; + Rectangle rect2 = new Rectangle(pixelOffset, yy, w, 3); + + dotPanel.Invalidate(rect1); + dotPanel.Invalidate(rect2); + + if (e.Button == MouseButtons.Left) { + set_base = false; + return; + } + } if (e.X >= w || e.X <= pixelOffset || e.Y >= h || e.Y <= pixelOffset) return; int i = (e.X - pixelOffset + hScroll.Value) / (cellSize + gap); int j = (e.Y - pixelOffset + vScroll.Value) / (cellSize + gap); @@ -453,6 +476,16 @@ namespace McBitFont { g.FillRectangle(sb, x, y, cellSize, cellSize); } } + + if (baseline > 0 && gap > 0) { + x = pixelOffset - hScroll.Value; + y = pixelOffset + baseline * (cellSize + gap) - vScroll.Value - 1; + g.DrawLine( + new Pen(Color.Blue, 2), + x, y, + w, y + ); + } } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { @@ -597,6 +630,7 @@ namespace McBitFont { sav.monospaced = monospaced; sav.frames = frames; sav.codepage = codepage; + sav.baseline = baseline; BinaryFormatter formatter = new BinaryFormatter(); using (Stream ms = File.OpenWrite(dlgSave.FileName)) { formatter.Serialize(ms, sav); @@ -625,6 +659,7 @@ namespace McBitFont { } monospaced = sav.monospaced; codepage = sav.codepage; + baseline = sav.baseline; lblType.Text = monospaced ? "Monospaced" : "Variable width / Single"; frames = sav.frames; miniList.Items.Clear(); @@ -713,6 +748,10 @@ namespace McBitFont { form.ShowDialog(); } + private void btnBaseline_Click(object sender, EventArgs e) { + set_base = !set_base; + } + private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (prjModified) { if (MessageBox.Show("The project is modified.\nAre you sure you want to quit?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { diff --git a/McBitFont/Properties/AssemblyInfo.cs b/McBitFont/Properties/AssemblyInfo.cs index 1210f57..a9d7fc4 100644 --- a/McBitFont/Properties/AssemblyInfo.cs +++ b/McBitFont/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // Можно задать все значения или принять номера сборки и редакции по умолчанию // используя "*", как показано ниже: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.3.0.0")] +[assembly: AssemblyFileVersion("1.3.0.0")]