diff --git a/McBitFont/Export.cs b/McBitFont/Export.cs index 9bd7b4c..338ad2c 100644 --- a/McBitFont/Export.cs +++ b/McBitFont/Export.cs @@ -233,7 +233,9 @@ namespace McBitFont { if (com && lines != 1 && fcount > 1) { // Comments enabled and other than "1 symbol per line" selected // Print a symbol comment before its data - output += " // " + f.code.ToString() + " --> " + mainForm.DecodeSymbol(f.code) + "\n"; + output += " // " + f.code.ToString() + " --> " + mainForm.DecodeSymbol(f.code); + if (f.note != "" && f.note != null) output += " (" + f.note.ToString() + ")"; + output += "\n"; } if (lines == 1) { // "1 symbol per line" - new line offset @@ -370,6 +372,7 @@ namespace McBitFont { if (com && fcount > 1) { //...with a comment output += " // " + f.code.ToString() + " --> " + mainForm.DecodeSymbol(f.code); + if (f.note != "" && f.note != null) output += " (" + f.note.ToString() + ")"; } output += "\n"; } diff --git a/McBitFont/Form1.Designer.cs b/McBitFont/Form1.Designer.cs index 5ae003f..d8829d9 100644 --- a/McBitFont/Form1.Designer.cs +++ b/McBitFont/Form1.Designer.cs @@ -124,6 +124,10 @@ pnlRightButtons = new System.Windows.Forms.Panel(); lblBrush = new System.Windows.Forms.Label(); pnlInfo = new System.Windows.Forms.Panel(); + cmBaseline = new System.Windows.Forms.ContextMenuStrip(components); + tsmiTopline = new System.Windows.Forms.ToolStripMenuItem(); + tsmiMidline = new System.Windows.Forms.ToolStripMenuItem(); + tsmiBaseline = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)nudX).BeginInit(); ((System.ComponentModel.ISupportInitialize)nudY).BeginInit(); panel1.SuspendLayout(); @@ -132,6 +136,7 @@ ((System.ComponentModel.ISupportInitialize)nudBrush).BeginInit(); pnlRightButtons.SuspendLayout(); pnlInfo.SuspendLayout(); + cmBaseline.SuspendLayout(); SuspendLayout(); // // dotPanel @@ -642,7 +647,7 @@ // // exportFontLayoutPNGToolStripMenuItem // - exportFontLayoutPNGToolStripMenuItem.Image = Properties.Resources.picture_go; + exportFontLayoutPNGToolStripMenuItem.Image = Properties.Resources.picture_save; exportFontLayoutPNGToolStripMenuItem.Name = "exportFontLayoutPNGToolStripMenuItem"; exportFontLayoutPNGToolStripMenuItem.Size = new System.Drawing.Size(224, 22); exportFontLayoutPNGToolStripMenuItem.Text = "Export font layout PNG"; @@ -656,7 +661,7 @@ frameScreenshotToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P; frameScreenshotToolStripMenuItem.Size = new System.Drawing.Size(224, 22); frameScreenshotToolStripMenuItem.Text = "Frame Screenshot"; - frameScreenshotToolStripMenuItem.ToolTipText = "Make a screenshot of the current frame"; + frameScreenshotToolStripMenuItem.ToolTipText = "Make a screenshot of the current frame and save it to a file or copy to clipboard"; frameScreenshotToolStripMenuItem.Click += frameScreenshotToolStripMenuItem_Click; // // toolStripSeparator2 @@ -1021,18 +1026,18 @@ // // btnBaseline // - btnBaseline.Image = Properties.Resources.fam_base; - btnBaseline.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; + btnBaseline.Image = Properties.Resources.fam_lines; btnBaseline.Location = new System.Drawing.Point(94, 81); btnBaseline.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); btnBaseline.Name = "btnBaseline"; btnBaseline.Size = new System.Drawing.Size(88, 27); btnBaseline.TabIndex = 18; - btnBaseline.Text = " Baseline"; + btnBaseline.Text = " Lines"; btnBaseline.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; - toolTip1.SetToolTip(btnBaseline, "Set irtual base line for the font"); + toolTip1.SetToolTip(btnBaseline, "Set irtual base lines for the font"); btnBaseline.UseVisualStyleBackColor = true; btnBaseline.Click += btnBaseline_Click; + btnBaseline.Paint += btnBaseline_Paint; // // toolTip1 // @@ -1207,6 +1212,39 @@ pnlInfo.Size = new System.Drawing.Size(103, 154); pnlInfo.TabIndex = 28; // + // cmBaseline + // + cmBaseline.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { tsmiTopline, tsmiMidline, tsmiBaseline }); + cmBaseline.Name = "cmBaseline"; + cmBaseline.Size = new System.Drawing.Size(181, 92); + // + // tsmiTopline + // + tsmiTopline.Image = Properties.Resources.fam_top; + tsmiTopline.Name = "tsmiTopline"; + tsmiTopline.Size = new System.Drawing.Size(180, 22); + tsmiTopline.Text = "Top line"; + tsmiTopline.ToolTipText = "Set top base line"; + tsmiTopline.Click += tsmiTopline_Click; + // + // tsmiMidline + // + tsmiMidline.Image = Properties.Resources.fam_mid; + tsmiMidline.Name = "tsmiMidline"; + tsmiMidline.Size = new System.Drawing.Size(180, 22); + tsmiMidline.Text = "Mid line"; + tsmiMidline.ToolTipText = "Set middle base line"; + tsmiMidline.Click += tsmiMidline_Click; + // + // tsmiBaseline + // + tsmiBaseline.Image = Properties.Resources.fam_base; + tsmiBaseline.Name = "tsmiBaseline"; + tsmiBaseline.Size = new System.Drawing.Size(180, 22); + tsmiBaseline.Text = "Base line"; + tsmiBaseline.ToolTipText = "Set bottom (base) line"; + tsmiBaseline.Click += tsmiBaseline_Click; + // // MainForm // AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -1221,6 +1259,7 @@ Controls.Add(dotPanel); Controls.Add(menuStrip1); Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon"); + KeyPreview = true; MainMenuStrip = menuStrip1; Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); MinimumSize = new System.Drawing.Size(931, 686); @@ -1229,6 +1268,8 @@ Text = "McBitFont"; FormClosing += MainForm_FormClosing; Load += Form1_Load; + KeyDown += MainForm_KeyDown; + KeyUp += MainForm_KeyUp; ((System.ComponentModel.ISupportInitialize)nudX).EndInit(); ((System.ComponentModel.ISupportInitialize)nudY).EndInit(); panel1.ResumeLayout(false); @@ -1241,6 +1282,7 @@ pnlRightButtons.PerformLayout(); pnlInfo.ResumeLayout(false); pnlInfo.PerformLayout(); + cmBaseline.ResumeLayout(false); ResumeLayout(false); PerformLayout(); @@ -1347,6 +1389,10 @@ private System.Windows.Forms.Label lblBrush; private System.Windows.Forms.ToolStripMenuItem frameScreenshotToolStripMenuItem; private System.Windows.Forms.TextBox tbFrameNote; + private System.Windows.Forms.ContextMenuStrip cmBaseline; + private System.Windows.Forms.ToolStripMenuItem tsmiBaseline; + private System.Windows.Forms.ToolStripMenuItem tsmiMidline; + private System.Windows.Forms.ToolStripMenuItem tsmiTopline; } } diff --git a/McBitFont/Form1.cs b/McBitFont/Form1.cs index 4446c51..01d977b 100644 --- a/McBitFont/Form1.cs +++ b/McBitFont/Form1.cs @@ -45,11 +45,22 @@ namespace McBitFont { [Key(5)] public int codepage; [Key(6)] - public int baseline; + public int baseline1; + [Key(9)] + public int baseline2; + [Key(10)] + public int baseline3; [Key(7)] public List frames; } + public enum SetLines { + SL_None = 0, + SL_Base, + SL_Mid, + SL_Top + } + public FrameMiniature f; public List frames = new List(); //private CanvasHistory history = new(); @@ -62,14 +73,14 @@ namespace McBitFont { public bool monospaced = false; private bool modified = false; private bool prjModified = false; - public const string version = "2.8"; + public const string version = "2.9"; public string prjName = "Untitled"; public string prjFileName = ""; public int codepage = 1251; private FrameMiniature fbuf; private readonly DataFormats.Format clpbFormat = DataFormats.GetFormat("McBitFontFrame"); - private int baseline = 0; - private bool set_base = false; + private int baseline1 = 0, baseline2 = 0, baseline3 = 0; + private SetLines set_lines = SetLines.SL_None; private Point selection1, selection2; private Point[,] sidebarLocs = new Point[2, 3]; @@ -173,7 +184,7 @@ namespace McBitFont { SideBarRecalc(); // Create default cursor - dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap); + SetPanelCursor(); } @@ -351,7 +362,7 @@ namespace McBitFont { vScroll.Enabled = true; } - if (!chkRectSelect.Checked) dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap); + SetPanelCursor(); dotPanel.Refresh(); } @@ -490,16 +501,22 @@ namespace McBitFont { mouseDownMiddle = true; mouseX = e.X; mouseY = e.Y; + SetPanelCursor(); } if (mouseDownMiddle && e.Button == MouseButtons.None) { mouseDownMiddle = false; + SetPanelCursor(); } } // Moving baseline Rectangle rect1, rect2; - if (set_base) { + if (set_lines > SetLines.SL_None) { + int baseline = 0; + if (set_lines == SetLines.SL_Base) baseline = baseline1; + if (set_lines == SetLines.SL_Mid) baseline = baseline2; + if (set_lines == SetLines.SL_Top) baseline = baseline3; int yy = pixelOffset + baseline * (cellSize + gap) - vScroll.Value - 1; rect1 = new Rectangle(pixelOffset, yy, w, 2); @@ -511,11 +528,17 @@ namespace McBitFont { yy = pixelOffset + baseline * (cellSize + gap) - vScroll.Value - 1; rect2 = new Rectangle(pixelOffset, yy, w, 2); + if (set_lines == SetLines.SL_Base) baseline1 = baseline; + if (set_lines == SetLines.SL_Mid) baseline2 = baseline; + if (set_lines == SetLines.SL_Top) baseline3 = baseline; + dotPanel.Invalidate(rect1); dotPanel.Invalidate(rect2); if (e.Button == MouseButtons.Left) { - set_base = false; + set_lines = SetLines.SL_None; + SetPanelCursor(); + SetModified(true, true); return; } } @@ -534,7 +557,7 @@ namespace McBitFont { selection2.Y = j; } } - if (e.Button != MouseButtons.None && !mouseDown) { + if ((e.Button == MouseButtons.Left || e.Button == MouseButtons.Right) && !mouseDown) { // Started to move a mouse with button held mouseDown = true; if (rectSel) { @@ -594,7 +617,7 @@ namespace McBitFont { // Check for Shift / Ctrl keys for straight lines if (ModifierKeys.HasFlag(Keys.Shift) && mouseDown) { j = lastY; - } else if (ModifierKeys.HasFlag(Keys.Control) && mouseDown) { + } else if (ModifierKeys.HasFlag(Keys.Control) && mouseDown && !CAKeyDown) { i = lastX; } lastX = i; @@ -774,21 +797,36 @@ namespace McBitFont { // Fill the cell with color if (f.data[i, j]) sb = sbb; else sb = sbw; - g.FillRectangle(sb, x, (baseline == j ? y + 1 : y), cellSize, (baseline == j ? cellSize - 1 : cellSize)); + g.FillRectangle(sb, x, ((baseline1 == j || baseline2 == j || baseline3 == j) ? y + 1 : y), cellSize, ((baseline1 == j || baseline2 == j || baseline3 == j) ? cellSize - 1 : cellSize)); } } - // Draw the baseline - if (baseline > 0 && gap > 0) { + // Draw the base lines + if (baseline1 > 0 || baseline2 > 0 || baseline3 > 0) { x = pixelOffset - hScroll.Value; - y = pixelOffset + baseline * (cellSize + gap) - vScroll.Value; - - Pen sbBase = new(Color.Blue, 2); - g.DrawLine(sbBase, x, y, w, y); + // Base line + if (baseline1 > 0) { + Pen sbBase = new(Color.Blue, gap > 0 ? 2 : 1); + y = pixelOffset + baseline1 * (cellSize + gap) - vScroll.Value; + g.DrawLine(sbBase, x, y, w, y); + } + // Mid line + if (baseline2 > 0) { + Pen sbBase = new(Color.MediumPurple, gap > 0 ? 2 : 1); + y = pixelOffset + baseline2 * (cellSize + gap) - vScroll.Value; + g.DrawLine(sbBase, x, y, w, y); + } + // Top line + if (baseline3 > 0) { + Pen sbBase = new(Color.FromArgb(0x16, 0x8b, 0x76), gap > 0 ? 2 : 1); + y = pixelOffset + baseline3 * (cellSize + gap) - vScroll.Value; + g.DrawLine(sbBase, x, y, w, y); + } } + // Draw the Rect selection - if (chkRectSelect.Checked) { + if (chkRectSelect.Checked || CAKeyDown) { Point p1 = new(selection1.X, selection1.Y); Point p2 = new(selection2.X, selection2.Y); NormPoints(ref p1, ref p2); @@ -903,7 +941,9 @@ namespace McBitFont { f = CopyFrame(frames.First()); form.Dispose(); - baseline = 0; + baseline1 = 0; + baseline2 = 0; + baseline3 = 0; prjName = "Untitled"; prjFileName = ""; @@ -1004,7 +1044,9 @@ namespace McBitFont { } monospaced = sav.monospaced; codepage = sav.codepage; - baseline = sav.baseline; + baseline1 = sav.baseline1; + baseline2 = sav.baseline2; + baseline3 = sav.baseline3; lblType.Text = monospaced ? "Monospaced" : "Variable width / Single"; frames = sav.frames; makeVarWidthToolStripMenuItem.Visible = monospaced; @@ -1053,7 +1095,9 @@ namespace McBitFont { sav.monospaced = monospaced; sav.frames = frames; sav.codepage = codepage; - sav.baseline = baseline; + sav.baseline1 = baseline1; + sav.baseline2 = baseline2; + sav.baseline3 = baseline3; using (Stream ms = File.OpenWrite(filename)) { MessagePackSerializer.Serialize(ms, sav); @@ -1187,7 +1231,7 @@ namespace McBitFont { } private void btnBaseline_Click(object sender, EventArgs e) { - set_base = !set_base; + cmBaseline.Show(btnBaseline, new Point(0, btnBaseline.Height)); } // Check modified / Save frame @@ -1195,8 +1239,8 @@ namespace McBitFont { if (modified) { if (MessageBox.Show("Current symbol is modified.\nDo you want to save the changes?", "Symbol was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) { SaveFrame(); + SetModified(false); } - SetModified(false); } } @@ -1403,8 +1447,7 @@ namespace McBitFont { lblSelection.Visible = lblSelectionLabel.Visible = chkRectSelect.Checked; selectAllToolStripMenuItem.Enabled = chkRectSelect.Checked; - if (chkRectSelect.Checked) dotPanel.Cursor = McCursor.GetCursorSelect(); - else dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap); + SetPanelCursor(); dotPanel.Refresh(); } @@ -1534,7 +1577,7 @@ namespace McBitFont { } private void TestFont_Click(object sender, EventArgs e) { - var tester = new FontTester(codepage, dotHeight, baseline, frames); + var tester = new FontTester(codepage, dotHeight, baseline1, frames); tester.ShowDialog(); } @@ -1700,7 +1743,7 @@ namespace McBitFont { } private void nudBrush_ValueChanged(object sender, EventArgs e) { - if (!chkRectSelect.Checked) dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap); + SetPanelCursor(); } private void frameScreenshotToolStripMenuItem_Click(object sender, EventArgs e) { @@ -1715,5 +1758,63 @@ namespace McBitFont { SetModified(); } } + + static bool CAKeyDown = false; + private void MainForm_KeyDown(object sender, KeyEventArgs e) { + if (CAKeyDown) return; + if (chkRectSelect.Checked && e.Control && e.Alt) { + chkRectSelect.Checked = false; + CAKeyDown = true; + dotPanel.Invalidate(); + e.Handled = true; + } + } + + private void MainForm_KeyUp(object sender, KeyEventArgs e) { + if (CAKeyDown && !e.Control && !e.Alt) { + chkRectSelect.Checked = true; + CAKeyDown = false; + e.Handled = true; + } + } + + private void btnBaseline_Paint(object sender, PaintEventArgs e) { + Button btn = (sender as Button); + int arrowX = btn.ClientRectangle.Width - btn.Padding.Right - 14; + int arrowY = btn.ClientRectangle.Height / 2 - 1; + + Color color = btn.Enabled ? ForeColor : SystemColors.ControlDark; + using Brush brush = new SolidBrush(color); + using Pen pen = new Pen(color); + Point[] arrow = [new Point(arrowX, arrowY), new Point(arrowX + 7, arrowY), new Point(arrowX + 3, arrowY + 4)]; + + e.Graphics.FillPolygon(brush, arrow); + e.Graphics.DrawLine(pen, arrowX - 5, btn.ClientRectangle.Top + 4, arrowX - 5, btn.ClientRectangle.Bottom - 4); + } + + private void tsmiBaseline_Click(object sender, EventArgs e) { + if (set_lines == SetLines.SL_Base) set_lines = SetLines.SL_None; + else set_lines = SetLines.SL_Base; + SetPanelCursor(); + } + + private void tsmiMidline_Click(object sender, EventArgs e) { + if (set_lines == SetLines.SL_Mid) set_lines = SetLines.SL_None; + else set_lines = SetLines.SL_Mid; + SetPanelCursor(); + } + + private void tsmiTopline_Click(object sender, EventArgs e) { + if (set_lines == SetLines.SL_Top) set_lines = SetLines.SL_None; + else set_lines = SetLines.SL_Top; + SetPanelCursor(); + } + + private void SetPanelCursor() { + if (mouseDownMiddle) dotPanel.Cursor = McCursor.GetCursorDrag(); + else if (set_lines > SetLines.SL_None) dotPanel.Cursor = McCursor.GetCursorLines(); + else if (chkRectSelect.Checked) dotPanel.Cursor = McCursor.GetCursorSelect(); + else dotPanel.Cursor = McCursor.GetCursor((int)nudBrush.Value, cellSize, gap); + } } } diff --git a/McBitFont/Form1.resx b/McBitFont/Form1.resx index 5800d67..293aef1 100644 --- a/McBitFont/Form1.resx +++ b/McBitFont/Form1.resx @@ -138,6 +138,9 @@ 644, 17 + + 763, 17 + diff --git a/McBitFont/FrameScreenshot.Designer.cs b/McBitFont/FrameScreenshot.Designer.cs index d465e2b..1bfd8bd 100644 --- a/McBitFont/FrameScreenshot.Designer.cs +++ b/McBitFont/FrameScreenshot.Designer.cs @@ -29,29 +29,35 @@ toolTip1 = new System.Windows.Forms.ToolTip(components); nudUpscale = new System.Windows.Forms.NumericUpDown(); chkTransparent = new System.Windows.Forms.CheckBox(); + chkBlackBG = new System.Windows.Forms.CheckBox(); + btnCopy = new System.Windows.Forms.Button(); dlgSaveImage = new System.Windows.Forms.SaveFileDialog(); lblUpscale = new System.Windows.Forms.Label(); - chkBlackBG = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)nudUpscale).BeginInit(); SuspendLayout(); // // btnClose // - btnClose.Location = new System.Drawing.Point(144, 67); + btnClose.Location = new System.Drawing.Point(234, 67); btnClose.Name = "btnClose"; btnClose.Size = new System.Drawing.Size(88, 27); btnClose.TabIndex = 3; btnClose.Text = "Close"; + toolTip1.SetToolTip(btnClose, "Close the dialog"); btnClose.UseVisualStyleBackColor = true; btnClose.Click += btnClose_Click; // // btnOK // + btnOK.Image = Properties.Resources.Famfamfam_Silk_Disk_16; + btnOK.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; btnOK.Location = new System.Drawing.Point(12, 67); btnOK.Name = "btnOK"; btnOK.Size = new System.Drawing.Size(88, 27); btnOK.TabIndex = 1; btnOK.Text = "Save"; + btnOK.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + toolTip1.SetToolTip(btnOK, "Save to file"); btnOK.UseVisualStyleBackColor = true; btnOK.Click += btnOK_Click; // @@ -63,7 +69,7 @@ // // nudUpscale // - nudUpscale.Location = new System.Drawing.Point(12, 27); + nudUpscale.Location = new System.Drawing.Point(71, 27); nudUpscale.Maximum = new decimal(new int[] { 255, 0, 0, 0 }); nudUpscale.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); nudUpscale.Name = "nudUpscale"; @@ -75,15 +81,41 @@ // chkTransparent // chkTransparent.AutoSize = true; - chkTransparent.Location = new System.Drawing.Point(85, 18); + chkTransparent.Location = new System.Drawing.Point(144, 18); chkTransparent.Name = "chkTransparent"; chkTransparent.Size = new System.Drawing.Size(155, 19); chkTransparent.TabIndex = 5; chkTransparent.Text = "Transparent background"; - toolTip1.SetToolTip(chkTransparent, "Make background transparent"); + toolTip1.SetToolTip(chkTransparent, "Make background transparent (Doesn't work with clipboard - background will be gray)"); chkTransparent.UseVisualStyleBackColor = true; chkTransparent.CheckedChanged += chkTransparent_CheckedChanged; // + // chkBlackBG + // + chkBlackBG.AutoSize = true; + chkBlackBG.Enabled = false; + chkBlackBG.Location = new System.Drawing.Point(144, 35); + chkBlackBG.Name = "chkBlackBG"; + chkBlackBG.Size = new System.Drawing.Size(132, 19); + chkBlackBG.TabIndex = 6; + chkBlackBG.Text = "Background is black"; + toolTip1.SetToolTip(chkBlackBG, "White color is considered as background by default. Check this to invert that"); + chkBlackBG.UseVisualStyleBackColor = true; + // + // btnCopy + // + btnCopy.Image = Properties.Resources.Famfamfam_Silk_Page_copy_16; + btnCopy.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; + btnCopy.Location = new System.Drawing.Point(122, 67); + btnCopy.Name = "btnCopy"; + btnCopy.Size = new System.Drawing.Size(88, 27); + btnCopy.TabIndex = 7; + btnCopy.Text = "Copy"; + btnCopy.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText; + toolTip1.SetToolTip(btnCopy, "Copy to clipboard"); + btnCopy.UseVisualStyleBackColor = true; + btnCopy.Click += btnCopy_Click; + // // dlgSaveImage // dlgSaveImage.DefaultExt = "png"; @@ -92,31 +124,20 @@ // lblUpscale // lblUpscale.AutoSize = true; - lblUpscale.Location = new System.Drawing.Point(12, 9); + lblUpscale.Location = new System.Drawing.Point(71, 9); lblUpscale.Name = "lblUpscale"; lblUpscale.Size = new System.Drawing.Size(51, 15); lblUpscale.TabIndex = 4; lblUpscale.Text = "Upscale:"; // - // chkBlackBG - // - chkBlackBG.AutoSize = true; - chkBlackBG.Enabled = false; - chkBlackBG.Location = new System.Drawing.Point(85, 35); - chkBlackBG.Name = "chkBlackBG"; - chkBlackBG.Size = new System.Drawing.Size(132, 19); - chkBlackBG.TabIndex = 6; - chkBlackBG.Text = "Background is black"; - toolTip1.SetToolTip(chkBlackBG, "White color is considered as background by default. Check this to invert that"); - chkBlackBG.UseVisualStyleBackColor = true; - // // FrameScreenshot // AcceptButton = btnClose; AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; CancelButton = btnClose; - ClientSize = new System.Drawing.Size(244, 111); + ClientSize = new System.Drawing.Size(334, 111); + Controls.Add(btnCopy); Controls.Add(chkBlackBG); Controls.Add(chkTransparent); Controls.Add(nudUpscale); @@ -143,5 +164,6 @@ private System.Windows.Forms.NumericUpDown nudUpscale; private System.Windows.Forms.CheckBox chkTransparent; private System.Windows.Forms.CheckBox chkBlackBG; + private System.Windows.Forms.Button btnCopy; } } \ No newline at end of file diff --git a/McBitFont/FrameScreenshot.cs b/McBitFont/FrameScreenshot.cs index 4abcf54..469fe9f 100644 --- a/McBitFont/FrameScreenshot.cs +++ b/McBitFont/FrameScreenshot.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Imaging; +using System.IO; using System.Linq; using System.Security.Policy; using System.Text; @@ -21,26 +22,34 @@ namespace McBitFont { f = frame; } - private void btnOK_Click(object sender, EventArgs e) { - if (dlgSaveImage.ShowDialog() == DialogResult.OK) { - int upscale = (int)nudUpscale.Value; - int x, y; - bool transp = chkTransparent.Checked; - bool blackBG = chkBlackBG.Checked; + private Bitmap GenerateScreenshot() { + int upscale = (int)nudUpscale.Value; + int x, y; + bool transp = chkTransparent.Checked; + bool blackBG = chkBlackBG.Checked; - Bitmap bmp = new(f.width * upscale, f.height * upscale); - SolidBrush bb = new(Color.Black); - SolidBrush bw = new(Color.White); - using (Graphics g = Graphics.FromImage(bmp)) { - for (x = 0; x < f.width; x++) { - for (y = 0; y < f.height; y++) { - if (f.data[x, y]) { - if (!transp || (transp && !blackBG)) g.FillRectangle(bb, x * upscale, y * upscale, upscale, upscale); - } else - if (!transp || (transp && blackBG)) g.FillRectangle(bw, x * upscale, y * upscale, upscale, upscale); - } + Bitmap bmp = new(f.width * upscale, f.height * upscale); + SolidBrush bb = new(Color.Black); + SolidBrush bw = new(Color.White); + using (Graphics g = Graphics.FromImage(bmp)) { + for (x = 0; x < f.width; x++) { + for (y = 0; y < f.height; y++) { + if (f.data[x, y]) { + if (!transp || (transp && !blackBG)) g.FillRectangle(bb, x * upscale, y * upscale, upscale, upscale); + } else + if (!transp || (transp && blackBG)) g.FillRectangle(bw, x * upscale, y * upscale, upscale, upscale); } } + } + + return bmp; + } + + private void btnOK_Click(object sender, EventArgs e) { + if (dlgSaveImage.ShowDialog() == DialogResult.OK) { + + Bitmap bmp = GenerateScreenshot(); + bool err = false; try { bmp.Save(dlgSaveImage.FileName, ImageFormat.Png); @@ -65,5 +74,14 @@ namespace McBitFont { private void chkTransparent_CheckedChanged(object sender, EventArgs e) { chkBlackBG.Enabled = chkTransparent.Checked; } + + private void btnCopy_Click(object sender, EventArgs e) { + Bitmap bmp = GenerateScreenshot(); + using MemoryStream stream = new(); + bmp.Save(stream, ImageFormat.Png); + DataObject data = new("PNG", stream); + data.SetImage(bmp); + Clipboard.SetDataObject(data, true); + } } } diff --git a/McBitFont/McBitFont.csproj b/McBitFont/McBitFont.csproj index 945ed93..094edfd 100644 --- a/McBitFont/McBitFont.csproj +++ b/McBitFont/McBitFont.csproj @@ -20,9 +20,9 @@ true true icon_64.ico - 2.8.0.0 - 2.8.0.0 - $(VersionPrefix)2.8.0 + 2.9.0.0 + 2.9.0.0 + $(VersionPrefix)2.9.0 Anton Mukhin diff --git a/McBitFont/McCursor.cs b/McBitFont/McCursor.cs index a2cb6e4..d93d40f 100644 --- a/McBitFont/McCursor.cs +++ b/McBitFont/McCursor.cs @@ -127,5 +127,46 @@ namespace McBitFont { return CreateCursorNoResize(bmp, 1, 1); } + public static Cursor GetCursorLines() { + Point[] arrow = { new(1, 1), new(12, 12), new(11, 13), new(6, 13), new(2, 17), new(1, 16) }; + Rectangle line = new(0, 18, 20, 5); + + Bitmap bmp = new(21, 24); + Pen pb = new(Color.Black, 1); + Pen pw = new(Color.White, 1); + SolidBrush bw = new(Color.White); + SolidBrush bb = new(Color.Black); + using (Graphics g = Graphics.FromImage(bmp)) { + g.FillPolygon(bw, arrow); + g.DrawPolygon(pb, arrow); + g.FillRectangle(bb, line); + g.DrawRectangle(pw, line); + } + + return CreateCursorNoResize(bmp, 1, 1); + } + + public static Cursor GetCursorDrag() { + Point[] arrow1 = { new(11, 0), new(15, 4), new(13, 4), new(13, 7), new(9, 7), new(9, 4), new(7, 4) }; + Point[] arrow2 = { new(22, 11), new(18, 15), new(18, 13), new(15, 13), new(15, 9), new(18, 9), new(18, 7) }; + Point[] arrow3 = { new(11, 22), new(7, 18), new(9, 18), new(9, 15), new(13, 15), new(13, 18), new(15, 18) }; + Point[] arrow4 = { new(0, 11), new(4, 7), new(4, 9), new(7, 9), new(7, 13), new(4, 13), new(4, 15) }; + + Bitmap bmp = new(23, 23); + Pen pb = new(Color.Black, 1); + SolidBrush bw = new(Color.White); + using (Graphics g = Graphics.FromImage(bmp)) { + g.FillPolygon(bw, arrow1); + g.DrawPolygon(pb, arrow1); + g.FillPolygon(bw, arrow2); + g.DrawPolygon(pb, arrow2); + g.FillPolygon(bw, arrow3); + g.DrawPolygon(pb, arrow3); + g.FillPolygon(bw, arrow4); + g.DrawPolygon(pb, arrow4); + } + return CreateCursorNoResize(bmp, 11, 11); + } + } } diff --git a/McBitFont/Properties/Resources.Designer.cs b/McBitFont/Properties/Resources.Designer.cs index ee6c114..17896b4 100644 --- a/McBitFont/Properties/Resources.Designer.cs +++ b/McBitFont/Properties/Resources.Designer.cs @@ -180,6 +180,26 @@ namespace McBitFont.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap fam_lines { + get { + object obj = ResourceManager.GetObject("fam_lines", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap fam_mid { + get { + object obj = ResourceManager.GetObject("fam_mid", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -190,6 +210,16 @@ namespace McBitFont.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap fam_top { + get { + object obj = ResourceManager.GetObject("fam_top", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -340,6 +370,16 @@ namespace McBitFont.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap picture_save { + get { + object obj = ResourceManager.GetObject("picture_save", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/McBitFont/Properties/Resources.resx b/McBitFont/Properties/Resources.resx index b2051b4..060b557 100644 --- a/McBitFont/Properties/Resources.resx +++ b/McBitFont/Properties/Resources.resx @@ -118,6 +118,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\fam_mid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\arrow_left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -130,6 +133,9 @@ ..\Resources\Famfamfam-Silk-Page-paste.16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\folder_table.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\folder_open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -145,6 +151,9 @@ ..\Resources\font.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\picture_save.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\redo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -190,6 +199,9 @@ ..\Resources\icon_32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\fam_lines.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\tick.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -217,8 +229,8 @@ ..\Resources\Famfamfam-Silk-Disk.16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\folder_table.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\text_letterspacing2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\Canvas_Fill.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -241,7 +253,7 @@ ..\Resources\icon_64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\text_letterspacing2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\fam_top.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/McBitFont/Resources/fam_lines.png b/McBitFont/Resources/fam_lines.png new file mode 100644 index 0000000..437bfc0 Binary files /dev/null and b/McBitFont/Resources/fam_lines.png differ diff --git a/McBitFont/Resources/fam_mid.png b/McBitFont/Resources/fam_mid.png new file mode 100644 index 0000000..3b82f68 Binary files /dev/null and b/McBitFont/Resources/fam_mid.png differ diff --git a/McBitFont/Resources/fam_top.png b/McBitFont/Resources/fam_top.png new file mode 100644 index 0000000..06704b6 Binary files /dev/null and b/McBitFont/Resources/fam_top.png differ diff --git a/McBitFont/Resources/picture_save.png b/McBitFont/Resources/picture_save.png new file mode 100644 index 0000000..777fb5d Binary files /dev/null and b/McBitFont/Resources/picture_save.png differ diff --git a/README.md b/README.md index 4e7626c..25c5704 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Some basic hints on the interface: - Shift + scroll to scroll left and right - Crtl + scroll to zoom - Alt + Scroll to change painting brush size +- When Rectangle selection tool is active hold Ctrl+Alt to temporary disable it to be able to draw Download in the [Releases](https://gitea.mcflyer.ru/McFLY/McBitFont/releases) section! diff --git a/TODO.txt b/TODO.txt index 71ea186..166aa22 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,10 +1,14 @@ Application: - Consider migrating to WPF in order to make DPI aware UI +V Special cursor to indicate baseline set +V Special cursor when dragging canvas with middle mouse button Functionality: -V Screensot a frame function -V Frame note field to store a frame description -- Show note field in Export comments +V Show note field in Export comments +V When Rectangle selection tool is active hold Ctrl+Alt to temporary disable it to be able to draw +V Frame screenshot can be copied to clipboard with some limitations (no transparency) +V Beside Baseline, also make top and mid lines Bugs: - +V Fixed "Frame modified" check. It leaves modified flag if user refused to save changes. +V Middle mouse button tries to change selection while dragging canvas with rectSelection tool active \ No newline at end of file diff --git a/examples/Cursors.mbfont b/examples/Cursors.mbfont new file mode 100644 index 0000000..ee26711 Binary files /dev/null and b/examples/Cursors.mbfont differ diff --git a/examples/Font_9x17_Alagard_cyr_vw.mbfont b/examples/Font_9x17_Alagard_cyr_vw.mbfont index 4720ecd..8e4603e 100644 Binary files a/examples/Font_9x17_Alagard_cyr_vw.mbfont and b/examples/Font_9x17_Alagard_cyr_vw.mbfont differ diff --git a/examples/SelectionCursor.mbfont b/examples/SelectionCursor.mbfont deleted file mode 100644 index dcd90e2..0000000 Binary files a/examples/SelectionCursor.mbfont and /dev/null differ diff --git a/icons/famfamfam/fam_lines.png b/icons/famfamfam/fam_lines.png new file mode 100644 index 0000000..437bfc0 Binary files /dev/null and b/icons/famfamfam/fam_lines.png differ diff --git a/icons/famfamfam/fam_mid.png b/icons/famfamfam/fam_mid.png new file mode 100644 index 0000000..3b82f68 Binary files /dev/null and b/icons/famfamfam/fam_mid.png differ diff --git a/icons/famfamfam/fam_top.png b/icons/famfamfam/fam_top.png new file mode 100644 index 0000000..06704b6 Binary files /dev/null and b/icons/famfamfam/fam_top.png differ diff --git a/icons/famfamfam/picture_save.png b/icons/famfamfam/picture_save.png new file mode 100644 index 0000000..777fb5d Binary files /dev/null and b/icons/famfamfam/picture_save.png differ diff --git a/images/Screenshot_Frame-screenshot.png b/images/Screenshot_Frame-screenshot.png index c456ef0..ebb5eac 100644 Binary files a/images/Screenshot_Frame-screenshot.png and b/images/Screenshot_Frame-screenshot.png differ diff --git a/images/Screenshot_Main.png b/images/Screenshot_Main.png index 25e4475..0ae6da6 100644 Binary files a/images/Screenshot_Main.png and b/images/Screenshot_Main.png differ