Font symbols collection management - started.
This commit is contained in:
24
McBitFont/Form1.Designer.cs
generated
24
McBitFont/Form1.Designer.cs
generated
@@ -82,7 +82,7 @@
|
||||
this.dotPanel.BackColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.dotPanel.Location = new System.Drawing.Point(12, 27);
|
||||
this.dotPanel.Name = "dotPanel";
|
||||
this.dotPanel.Size = new System.Drawing.Size(593, 503);
|
||||
this.dotPanel.Size = new System.Drawing.Size(482, 503);
|
||||
this.dotPanel.TabIndex = 0;
|
||||
this.dotPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.dotPanel_Paint);
|
||||
this.dotPanel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dotPanel_MouseMove);
|
||||
@@ -161,7 +161,7 @@
|
||||
//
|
||||
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(631, 27);
|
||||
this.label3.Location = new System.Drawing.Point(682, 76);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(35, 13);
|
||||
this.label3.TabIndex = 0;
|
||||
@@ -213,7 +213,7 @@
|
||||
this.panel1.Controls.Add(this.btnShiftUp);
|
||||
this.panel1.Controls.Add(this.btnShiftRight);
|
||||
this.panel1.Controls.Add(this.btnShiftLeft);
|
||||
this.panel1.Location = new System.Drawing.Point(634, 79);
|
||||
this.panel1.Location = new System.Drawing.Point(521, 27);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(120, 121);
|
||||
this.panel1.TabIndex = 9;
|
||||
@@ -310,11 +310,11 @@
|
||||
//
|
||||
this.outBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.outBox.Font = new System.Drawing.Font("Consolas", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.outBox.Location = new System.Drawing.Point(635, 206);
|
||||
this.outBox.Location = new System.Drawing.Point(685, 105);
|
||||
this.outBox.Multiline = true;
|
||||
this.outBox.Name = "outBox";
|
||||
this.outBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.outBox.Size = new System.Drawing.Size(230, 135);
|
||||
this.outBox.Size = new System.Drawing.Size(96, 40);
|
||||
this.outBox.TabIndex = 11;
|
||||
this.outBox.Text = "Output text here";
|
||||
//
|
||||
@@ -322,19 +322,21 @@
|
||||
//
|
||||
this.miniList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.miniList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
this.miniList.GridLines = true;
|
||||
this.miniList.HideSelection = false;
|
||||
this.miniList.LargeImageList = this.ilMiniatures;
|
||||
this.miniList.Location = new System.Drawing.Point(634, 347);
|
||||
this.miniList.Location = new System.Drawing.Point(521, 154);
|
||||
this.miniList.MultiSelect = false;
|
||||
this.miniList.Name = "miniList";
|
||||
this.miniList.ShowGroups = false;
|
||||
this.miniList.Size = new System.Drawing.Size(230, 207);
|
||||
this.miniList.Size = new System.Drawing.Size(343, 400);
|
||||
this.miniList.SmallImageList = this.ilMiniatures;
|
||||
this.miniList.TabIndex = 12;
|
||||
this.miniList.TabStop = false;
|
||||
this.miniList.TileSize = new System.Drawing.Size(50, 70);
|
||||
this.miniList.TileSize = new System.Drawing.Size(50, 50);
|
||||
this.miniList.UseCompatibleStateImageBehavior = false;
|
||||
this.miniList.SelectedIndexChanged += new System.EventHandler(this.miniList_SelectedIndexChanged);
|
||||
//
|
||||
// ilMiniatures
|
||||
//
|
||||
@@ -359,7 +361,7 @@
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.hScroll.Location = new System.Drawing.Point(12, 533);
|
||||
this.hScroll.Name = "hScroll";
|
||||
this.hScroll.Size = new System.Drawing.Size(593, 21);
|
||||
this.hScroll.Size = new System.Drawing.Size(482, 21);
|
||||
this.hScroll.TabIndex = 14;
|
||||
this.hScroll.ValueChanged += new System.EventHandler(this.hScroll_ValueChanged);
|
||||
//
|
||||
@@ -368,7 +370,7 @@
|
||||
this.vScroll.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.vScroll.LargeChange = 25;
|
||||
this.vScroll.Location = new System.Drawing.Point(608, 27);
|
||||
this.vScroll.Location = new System.Drawing.Point(497, 27);
|
||||
this.vScroll.Name = "vScroll";
|
||||
this.vScroll.Size = new System.Drawing.Size(21, 503);
|
||||
this.vScroll.TabIndex = 15;
|
||||
@@ -378,7 +380,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(632, 40);
|
||||
this.label5.Location = new System.Drawing.Point(683, 89);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(35, 13);
|
||||
this.label5.TabIndex = 16;
|
||||
|
@@ -9,6 +9,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace McBitFont {
|
||||
public partial class Form1 : Form {
|
||||
@@ -34,6 +35,7 @@ namespace McBitFont {
|
||||
private int gap;
|
||||
private int w, h;
|
||||
bool monospaced = false;
|
||||
bool modified = false;
|
||||
|
||||
public Form1() {
|
||||
InitializeComponent();
|
||||
@@ -57,6 +59,21 @@ namespace McBitFont {
|
||||
miniList.Items.Add("0", "0 Single", "0");
|
||||
miniList.Refresh();
|
||||
f = frames.Find(x => x.code == 0);
|
||||
|
||||
ListViewItem_SetSpacing(miniList, 50 + 2, 50 + 22);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
public int MakeLong(short lowPart, short highPart) {
|
||||
return (int)(((ushort)lowPart) | (uint)(highPart << 16));
|
||||
}
|
||||
|
||||
public void ListViewItem_SetSpacing(ListView listview, short leftPadding, short topPadding) {
|
||||
const int LVM_FIRST = 0x1000;
|
||||
const int LVM_SETICONSPACING = LVM_FIRST + 53;
|
||||
SendMessage(listview.Handle, LVM_SETICONSPACING, IntPtr.Zero, (IntPtr)MakeLong(leftPadding, topPadding));
|
||||
}
|
||||
|
||||
private void dotPanel_MouseWheel(object sender, MouseEventArgs e) {
|
||||
@@ -188,6 +205,7 @@ namespace McBitFont {
|
||||
int x = pixelOffset + i * (cellSize + gap) - hScroll.Value;
|
||||
int y = pixelOffset + j * (cellSize + gap) - vScroll.Value;
|
||||
g.FillRectangle(sbb, x, y, cellSize, cellSize);
|
||||
modified = true;
|
||||
}
|
||||
if (e.Button == MouseButtons.Right && f.data[i, j]) {
|
||||
Graphics g = dotPanel.CreateGraphics();
|
||||
@@ -196,6 +214,7 @@ namespace McBitFont {
|
||||
int x = pixelOffset + i * (cellSize + gap) - hScroll.Value;
|
||||
int y = pixelOffset + j * (cellSize + gap) - vScroll.Value;
|
||||
g.FillRectangle(sbw, x, y, cellSize, cellSize);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -297,11 +316,19 @@ namespace McBitFont {
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e) {
|
||||
saveFrame();
|
||||
}
|
||||
|
||||
private void saveFrame() {
|
||||
int index = frames.FindIndex(x => x.code == f.code);
|
||||
frames[index] = f;
|
||||
|
||||
var sizedBMP = getMiniPictue(f);
|
||||
string s = f.code.ToString();
|
||||
ilMiniatures.Images.RemoveByKey(s);
|
||||
ilMiniatures.Images.Add(s, (Image)sizedBMP);
|
||||
sizedBMP.Dispose();
|
||||
modified = false;
|
||||
}
|
||||
|
||||
private Bitmap getMiniPictue(FrameMiniature m) {
|
||||
@@ -363,13 +390,28 @@ namespace McBitFont {
|
||||
if (form.cbSingle.Checked) {
|
||||
frames.Add( new FrameMiniature(0, neww, newh));
|
||||
//f = frames.Find(x => x.code == 0);
|
||||
append = " Single";
|
||||
append = "Single";
|
||||
} else {
|
||||
int i;
|
||||
if (form.cbNotPrintable.Checked) {
|
||||
for (i=0; i < 32; i++)
|
||||
frames.Add(new FrameMiniature(i, neww, newh));
|
||||
}
|
||||
if (form.cbLatin.Checked) {
|
||||
for (i = 32; i < 128; i++)
|
||||
frames.Add(new FrameMiniature(i, neww, newh));
|
||||
}
|
||||
if (form.cbLatin.Checked) {
|
||||
for (i = 128; i < 256; i++)
|
||||
frames.Add(new FrameMiniature(i, neww, newh));
|
||||
}
|
||||
}
|
||||
monospaced = form.rbMono.Checked;
|
||||
foreach (FrameMiniature ff in frames) {
|
||||
var s = ff.code.ToString();
|
||||
|
||||
//var c = System.Text.Encoding.ASCII.
|
||||
ilMiniatures.Images.Add(s, (Image)getMiniPictue(ff));
|
||||
miniList.Items.Add(s, s+append, s);
|
||||
miniList.Items.Add(s, s+' '+append+(char)ff.code, s);
|
||||
}
|
||||
nudX.Value =neww;
|
||||
nudY.Value = newh;
|
||||
@@ -379,6 +421,22 @@ namespace McBitFont {
|
||||
}
|
||||
}
|
||||
|
||||
private void miniList_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
if (miniList.FocusedItem == null) return;
|
||||
if (modified) {
|
||||
if (MessageBox.Show("Current symbol is modified.\nDo you want to save the changes?", "Symbol was modified!", MessageBoxButtons.YesNo) == DialogResult.Yes) {
|
||||
saveFrame();
|
||||
}
|
||||
}
|
||||
var sel = miniList.SelectedItems[0];
|
||||
int code = Convert.ToInt32(sel.ImageKey);
|
||||
FrameMiniature ff = frames.Find(x => x.code == code);
|
||||
nudX.Value = ff.width;
|
||||
nudY.Value = ff.height;
|
||||
f = ff;
|
||||
dotPanel.Refresh();
|
||||
}
|
||||
|
||||
private void hScroll_ValueChanged(object sender, EventArgs e) {
|
||||
label5.Text = hScroll.Value.ToString();
|
||||
dotPanel.Refresh();
|
||||
|
Reference in New Issue
Block a user