Manually drawing the cells
This commit is contained in:
63
McBitFont/Form1.Designer.cs
generated
63
McBitFont/Form1.Designer.cs
generated
@@ -24,10 +24,10 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("adasd");
|
||||
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("ddddd", 0);
|
||||
System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("ffff");
|
||||
System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("");
|
||||
System.Windows.Forms.ListViewItem listViewItem5 = new System.Windows.Forms.ListViewItem("adasd");
|
||||
System.Windows.Forms.ListViewItem listViewItem6 = new System.Windows.Forms.ListViewItem("ddddd", 0);
|
||||
System.Windows.Forms.ListViewItem listViewItem7 = new System.Windows.Forms.ListViewItem("ffff");
|
||||
System.Windows.Forms.ListViewItem listViewItem8 = new System.Windows.Forms.ListViewItem("");
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
|
||||
this.dotPanel = new System.Windows.Forms.Panel();
|
||||
this.nudX = new System.Windows.Forms.NumericUpDown();
|
||||
@@ -51,6 +51,9 @@
|
||||
this.miniList = new System.Windows.Forms.ListView();
|
||||
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.hScroll = new System.Windows.Forms.HScrollBar();
|
||||
this.vScroll = new System.Windows.Forms.VScrollBar();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudX)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudY)).BeginInit();
|
||||
this.panel1.SuspendLayout();
|
||||
@@ -61,14 +64,16 @@
|
||||
this.dotPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dotPanel.AutoScroll = true;
|
||||
this.dotPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.dotPanel.BackColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.dotPanel.Location = new System.Drawing.Point(12, 12);
|
||||
this.dotPanel.Name = "dotPanel";
|
||||
this.dotPanel.Size = new System.Drawing.Size(613, 542);
|
||||
this.dotPanel.Size = new System.Drawing.Size(593, 518);
|
||||
this.dotPanel.TabIndex = 0;
|
||||
this.dotPanel.Scroll += new System.Windows.Forms.ScrollEventHandler(this.dotPanel_Scroll);
|
||||
this.dotPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.dotPanel_Paint);
|
||||
this.dotPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.dotPanel_MouseMove);
|
||||
this.dotPanel.Resize += new System.EventHandler(this.cbZoom_SelectedIndexChanged);
|
||||
//
|
||||
// nudX
|
||||
//
|
||||
@@ -171,6 +176,7 @@
|
||||
this.cbZoom.Size = new System.Drawing.Size(59, 21);
|
||||
this.cbZoom.TabIndex = 6;
|
||||
this.cbZoom.TabStop = false;
|
||||
this.cbZoom.SelectedIndexChanged += new System.EventHandler(this.cbZoom_SelectedIndexChanged);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
@@ -315,10 +321,10 @@
|
||||
this.miniList.GridLines = true;
|
||||
this.miniList.HideSelection = false;
|
||||
this.miniList.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
|
||||
listViewItem1,
|
||||
listViewItem2,
|
||||
listViewItem3,
|
||||
listViewItem4});
|
||||
listViewItem5,
|
||||
listViewItem6,
|
||||
listViewItem7,
|
||||
listViewItem8});
|
||||
this.miniList.LargeImageList = this.imageList1;
|
||||
this.miniList.Location = new System.Drawing.Point(634, 325);
|
||||
this.miniList.MultiSelect = false;
|
||||
@@ -339,6 +345,7 @@
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button2.Location = new System.Drawing.Point(790, 156);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
@@ -347,11 +354,44 @@
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// hScroll
|
||||
//
|
||||
this.hScroll.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| 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.TabIndex = 14;
|
||||
this.hScroll.ValueChanged += new System.EventHandler(this.hScroll_ValueChanged);
|
||||
//
|
||||
// vScroll
|
||||
//
|
||||
this.vScroll.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.vScroll.Location = new System.Drawing.Point(608, 12);
|
||||
this.vScroll.Name = "vScroll";
|
||||
this.vScroll.Size = new System.Drawing.Size(21, 518);
|
||||
this.vScroll.TabIndex = 15;
|
||||
this.vScroll.ValueChanged += new System.EventHandler(this.vScroll_ValueChanged);
|
||||
//
|
||||
// label5
|
||||
//
|
||||
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, 25);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(35, 13);
|
||||
this.label5.TabIndex = 16;
|
||||
this.label5.Text = "label5";
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(877, 566);
|
||||
this.Controls.Add(this.label5);
|
||||
this.Controls.Add(this.vScroll);
|
||||
this.Controls.Add(this.hScroll);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.miniList);
|
||||
this.Controls.Add(this.outBox);
|
||||
@@ -402,6 +442,9 @@
|
||||
private System.Windows.Forms.ListView miniList;
|
||||
private System.Windows.Forms.ImageList imageList1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.HScrollBar hScroll;
|
||||
private System.Windows.Forms.VScrollBar vScroll;
|
||||
private System.Windows.Forms.Label label5;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,10 +20,13 @@ namespace McBitFont {
|
||||
public bool[,] data;
|
||||
};
|
||||
|
||||
FrameMiniature f;
|
||||
private FrameMiniature f;
|
||||
private int cellSize = 10;
|
||||
private int dotWidth, dotHeight;
|
||||
private Panel[,] dots = new Panel[255,255];
|
||||
private int pixelOffset = 5;
|
||||
private int gap;
|
||||
private int w, h;
|
||||
//private Panel[,] dots = new Panel[255,255];
|
||||
|
||||
public Form1() {
|
||||
InitializeComponent();
|
||||
@@ -35,12 +38,10 @@ namespace McBitFont {
|
||||
dotWidth = (int)nudX.Value;
|
||||
dotHeight = (int)nudY.Value;
|
||||
|
||||
for (i = 0; i < dotWidth; i++) {
|
||||
for (j = 0; j < dotHeight; j++) {
|
||||
Panel p = new Panel();
|
||||
dots[i,j] = NewDot(i, j);
|
||||
}
|
||||
}
|
||||
gap = (cellSize < 5) ? 0 : 1;
|
||||
w = pixelOffset + dotWidth * (cellSize + gap);
|
||||
h = pixelOffset + dotHeight * (cellSize + gap);
|
||||
|
||||
|
||||
cbZoom.SelectedIndex = 3;
|
||||
cbZoom.SelectedIndexChanged += cbZoom_SelectedIndexChanged;
|
||||
@@ -52,32 +53,17 @@ namespace McBitFont {
|
||||
|
||||
}
|
||||
|
||||
private Panel NewDot(int i, int j) {
|
||||
Panel p = new Panel();
|
||||
p.Parent = dotPanel;
|
||||
p.Width = cellSize; p.Height = cellSize;
|
||||
p.BackColor = Color.White;
|
||||
p.BorderStyle = BorderStyle.None;
|
||||
p.Left = 5 + i * (cellSize + 1);
|
||||
p.Top = 5 + j * (cellSize + 1);
|
||||
p.Tag = i.ToString() + ',' + j.ToString();
|
||||
p.MouseMove += dot_MouseMove;
|
||||
p.MouseDown += dot_MouseMove;
|
||||
//p.Paint += dotPanel_Paint;
|
||||
return p;
|
||||
}
|
||||
|
||||
private void dot_MouseMove(object sender, MouseEventArgs e) {
|
||||
Panel p = (Panel)sender;
|
||||
//Panel p = (Panel)sender;
|
||||
|
||||
if (e.Button == MouseButtons.Left && p.BackColor != Color.Black) {
|
||||
p.BackColor = Color.Black;
|
||||
}
|
||||
if (e.Button == MouseButtons.Right && p.BackColor != Color.White) {
|
||||
p.BackColor = Color.White;
|
||||
}
|
||||
label3.Text = "Over: " + p.Tag;
|
||||
p.Capture = false;
|
||||
//if (e.Button == MouseButtons.Left && p.BackColor != Color.Black) {
|
||||
// p.BackColor = Color.Black;
|
||||
//}
|
||||
//if (e.Button == MouseButtons.Right && p.BackColor != Color.White) {
|
||||
// p.BackColor = Color.White;
|
||||
//}
|
||||
//label3.Text = "Over: " + p.Tag;
|
||||
//p.Capture = false;
|
||||
}
|
||||
|
||||
private void nudX_ValueChanged(object sender, EventArgs e) {
|
||||
@@ -89,211 +75,289 @@ namespace McBitFont {
|
||||
}
|
||||
|
||||
private void dotResize(int w, int h) {
|
||||
//Width
|
||||
if (w > dotWidth) {
|
||||
for (int i = dotWidth; i < w; i++) {
|
||||
for (int j = 0; j < dotHeight; j++) {
|
||||
dots[i, j] = NewDot(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (w < dotWidth) {
|
||||
for (int i = w; i < dotWidth; i++) {
|
||||
for (int j = 0; j < dotHeight; j++) {
|
||||
dots[i, j].Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
dotWidth = w;
|
||||
////Width
|
||||
//if (w > dotWidth) {
|
||||
// for (int i = dotWidth; i < w; i++) {
|
||||
// for (int j = 0; j < dotHeight; j++) {
|
||||
// dots[i, j] = NewDot(i, j);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//if (w < dotWidth) {
|
||||
// for (int i = w; i < dotWidth; i++) {
|
||||
// for (int j = 0; j < dotHeight; j++) {
|
||||
// dots[i, j].Dispose();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//dotWidth = w;
|
||||
|
||||
//Height
|
||||
if (h > dotHeight) {
|
||||
for (int i = 0; i < dotWidth; i++) {
|
||||
for (int j = dotHeight; j < h; j++) {
|
||||
dots[i, j] = NewDot(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (h < dotHeight) {
|
||||
for (int i = 0; i < dotWidth; i++) {
|
||||
for (int j = h; j < dotHeight; j++) {
|
||||
dots[i, j].Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
dotHeight = h;
|
||||
////Height
|
||||
//if (h > dotHeight) {
|
||||
// for (int i = 0; i < dotWidth; i++) {
|
||||
// for (int j = dotHeight; j < h; j++) {
|
||||
// dots[i, j] = NewDot(i, j);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//if (h < dotHeight) {
|
||||
// for (int i = 0; i < dotWidth; i++) {
|
||||
// for (int j = h; j < dotHeight; j++) {
|
||||
// dots[i, j].Dispose();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//dotHeight = h;
|
||||
}
|
||||
|
||||
private void cbZoom_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
cellSize = Convert.ToInt32(cbZoom.Text);
|
||||
dotScale();
|
||||
gap = (cellSize < 5) ? 0 : 1;
|
||||
|
||||
w = pixelOffset + dotWidth * (cellSize + gap);
|
||||
h = pixelOffset + dotHeight * (cellSize + gap);
|
||||
if (w <= dotPanel.Width) {
|
||||
hScroll.Enabled = false;
|
||||
} else {
|
||||
hScroll.Maximum = w - dotPanel.Width + 12;
|
||||
hScroll.Minimum = 0;
|
||||
hScroll.Enabled = true;
|
||||
}
|
||||
|
||||
if (h <= dotPanel.Height) {
|
||||
vScroll.Enabled = false;
|
||||
} else {
|
||||
vScroll.Maximum = h - dotPanel.Height + 12;
|
||||
vScroll.Minimum = 0;
|
||||
vScroll.Enabled = true;
|
||||
}
|
||||
|
||||
|
||||
//dotPanel.
|
||||
//dotPanel.ClientSize = s;
|
||||
dotPanel.Invalidate();
|
||||
//dotScale();
|
||||
}
|
||||
|
||||
private void btnShiftLeft_Click(object sender, EventArgs e) {
|
||||
for (int j = 0; j < dotHeight; j++) {
|
||||
Color c = dots[0, j].BackColor;
|
||||
for (int i = 0; i < dotWidth; i++) {
|
||||
if (i == dotWidth - 1) {
|
||||
dots[i, j].BackColor = c;
|
||||
} else {
|
||||
dots[i, j].BackColor = dots[i+1, j].BackColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
//for (int j = 0; j < dotHeight; j++) {
|
||||
// Color c = dots[0, j].BackColor;
|
||||
// for (int i = 0; i < dotWidth; i++) {
|
||||
// if (i == dotWidth - 1) {
|
||||
// dots[i, j].BackColor = c;
|
||||
// } else {
|
||||
// dots[i, j].BackColor = dots[i+1, j].BackColor;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void btnShiftRight_Click(object sender, EventArgs e) {
|
||||
for (int j = 0; j < dotHeight; j++) {
|
||||
Color c = dots[dotWidth - 1, j].BackColor;
|
||||
for (int i = dotWidth-1; i >= 0; i--) {
|
||||
if (i == 0) {
|
||||
dots[i, j].BackColor = c;
|
||||
} else {
|
||||
dots[i, j].BackColor = dots[i - 1, j].BackColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
//for (int j = 0; j < dotHeight; j++) {
|
||||
// Color c = dots[dotWidth - 1, j].BackColor;
|
||||
// for (int i = dotWidth-1; i >= 0; i--) {
|
||||
// if (i == 0) {
|
||||
// dots[i, j].BackColor = c;
|
||||
// } else {
|
||||
// dots[i, j].BackColor = dots[i - 1, j].BackColor;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void dotPanel_MouseMove(object sender, MouseEventArgs e) {
|
||||
Panel p = (Panel)sender;
|
||||
p.Capture = false;
|
||||
if (e.X >= w || e.X <= pixelOffset || e.Y >= h || e.Y <= pixelOffset) return;
|
||||
label3.Text = e.X.ToString() + ',' + e.Y.ToString();
|
||||
int i = (e.X - pixelOffset + hScroll.Value) / (cellSize + gap);
|
||||
int j = (e.Y - pixelOffset + vScroll.Value) / (cellSize + gap);
|
||||
label5.Text = i.ToString() + ',' + j.ToString();
|
||||
|
||||
if (e.Button == MouseButtons.Left && !f.data[i, j]) {
|
||||
Graphics g = dotPanel.CreateGraphics();
|
||||
SolidBrush sbb = new SolidBrush(Color.Black);
|
||||
f.data[i, j] = true;
|
||||
//dotPanel.Refresh();
|
||||
int x = pixelOffset + i * (cellSize + gap) - hScroll.Value;
|
||||
int y = pixelOffset + j * (cellSize + gap) - vScroll.Value;
|
||||
g.FillRectangle(sbb, x, y, cellSize, cellSize);
|
||||
}
|
||||
if (e.Button == MouseButtons.Right && f.data[i, j]) {
|
||||
Graphics g = dotPanel.CreateGraphics();
|
||||
SolidBrush sbw = new SolidBrush(Color.White);
|
||||
f.data[i, j] = false;
|
||||
//dotPanel.Refresh();
|
||||
int x = pixelOffset + i * (cellSize + gap) - hScroll.Value;
|
||||
int y = pixelOffset + j * (cellSize + gap) - vScroll.Value;
|
||||
g.FillRectangle(sbw, x, y, cellSize, cellSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btnShiftUp_Click(object sender, EventArgs e) {
|
||||
for (int i = 0; i < dotWidth; i++) {
|
||||
Color c = dots[i, 0].BackColor;
|
||||
for (int j = 0; j < dotHeight; j++) {
|
||||
if (j == dotHeight - 1) {
|
||||
dots[i, j].BackColor = c;
|
||||
} else {
|
||||
dots[i, j].BackColor = dots[i, j + 1].BackColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
//for (int i = 0; i < dotWidth; i++) {
|
||||
// Color c = dots[i, 0].BackColor;
|
||||
// for (int j = 0; j < dotHeight; j++) {
|
||||
// if (j == dotHeight - 1) {
|
||||
// dots[i, j].BackColor = c;
|
||||
// } else {
|
||||
// dots[i, j].BackColor = dots[i, j + 1].BackColor;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void btnShiftDown_Click(object sender, EventArgs e) {
|
||||
for (int i = 0; i < dotWidth; i++) {
|
||||
Color c = dots[i, dotHeight - 1].BackColor;
|
||||
for (int j = dotHeight-1; j >= 0; j--) {
|
||||
if (j == 0) {
|
||||
dots[i, j].BackColor = c;
|
||||
} else {
|
||||
dots[i, j].BackColor = dots[i, j - 1].BackColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
//for (int i = 0; i < dotWidth; i++) {
|
||||
// Color c = dots[i, dotHeight - 1].BackColor;
|
||||
// for (int j = dotHeight-1; j >= 0; j--) {
|
||||
// if (j == 0) {
|
||||
// dots[i, j].BackColor = c;
|
||||
// } else {
|
||||
// dots[i, j].BackColor = dots[i, j - 1].BackColor;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void btnInvert_Click(object sender, EventArgs e) {
|
||||
for (int i = 0; i < dotWidth; i++) {
|
||||
for (int j = 0; j < dotHeight; j++) {
|
||||
if (dots[i, j].BackColor == Color.White)
|
||||
dots[i, j].BackColor = Color.Black;
|
||||
else
|
||||
dots[i, j].BackColor = Color.White;
|
||||
}
|
||||
}
|
||||
//for (int i = 0; i < dotWidth; i++) {
|
||||
// for (int j = 0; j < dotHeight; j++) {
|
||||
// if (dots[i, j].BackColor == Color.White)
|
||||
// dots[i, j].BackColor = Color.Black;
|
||||
// else
|
||||
// dots[i, j].BackColor = Color.White;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void btnMirrorX_Click(object sender, EventArgs e) {
|
||||
int a, b, j;
|
||||
Color c;
|
||||
//int a, b, j;
|
||||
//Color c;
|
||||
|
||||
for (j = 0; j < dotHeight; j++) {
|
||||
a = 0;
|
||||
b = dotWidth - 1;
|
||||
while (a < b) {
|
||||
c = dots[a, j].BackColor;
|
||||
dots[a, j].BackColor = dots[b, j].BackColor;
|
||||
dots[b, j].BackColor = c;
|
||||
a++;
|
||||
b--;
|
||||
}
|
||||
}
|
||||
//for (j = 0; j < dotHeight; j++) {
|
||||
// a = 0;
|
||||
// b = dotWidth - 1;
|
||||
// while (a < b) {
|
||||
// c = dots[a, j].BackColor;
|
||||
// dots[a, j].BackColor = dots[b, j].BackColor;
|
||||
// dots[b, j].BackColor = c;
|
||||
// a++;
|
||||
// b--;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void btnMirrorY_Click(object sender, EventArgs e) {
|
||||
int a, b, i;
|
||||
Color c;
|
||||
//int a, b, i;
|
||||
//Color c;
|
||||
|
||||
for (i = 0; i < dotWidth; i++) {
|
||||
a = 0;
|
||||
b = dotHeight - 1;
|
||||
while (a < b) {
|
||||
c = dots[i, a].BackColor;
|
||||
dots[i, a].BackColor = dots[i, b].BackColor;
|
||||
dots[i, b].BackColor = c;
|
||||
a++;
|
||||
b--;
|
||||
}
|
||||
}
|
||||
//for (i = 0; i < dotWidth; i++) {
|
||||
// a = 0;
|
||||
// b = dotHeight - 1;
|
||||
// while (a < b) {
|
||||
// c = dots[i, a].BackColor;
|
||||
// dots[i, a].BackColor = dots[i, b].BackColor;
|
||||
// dots[i, b].BackColor = c;
|
||||
// a++;
|
||||
// b--;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e) {
|
||||
for (int i = 0; i < dotWidth; i++) {
|
||||
for (int j = 0; j < dotHeight; j++) {
|
||||
if (dots[i, j].BackColor == Color.Black) f.data[i, j] = true;
|
||||
else f.data[i, j] = false;
|
||||
}
|
||||
}
|
||||
//for (int i = 0; i < dotWidth; i++) {
|
||||
// for (int j = 0; j < dotHeight; j++) {
|
||||
// if (dots[i, j].BackColor == Color.Black) f.data[i, j] = true;
|
||||
// else f.data[i, j] = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
outBox.Clear();
|
||||
String str;
|
||||
Byte b = 0;
|
||||
for (ushort i = 0; i < dotWidth; i++) {
|
||||
str = "";
|
||||
for (ushort j = 0; j < dotHeight; j++) {
|
||||
if (j % 8 == 0) b = 0;
|
||||
if (f.data[i, j]) {
|
||||
b |= (Byte)(1 << (j % 8));
|
||||
}
|
||||
if ( ((j + 1) % 8 == 0) || j+1 == dotHeight ) {
|
||||
if (str.Length > 0) str += " ";
|
||||
str += "0x" + Convert.ToString(b, 16).PadLeft(2, '0') + ',';
|
||||
}
|
||||
}
|
||||
outBox.AppendText(str);
|
||||
outBox.AppendText(Environment.NewLine);
|
||||
}
|
||||
//outBox.Clear();
|
||||
//String str;
|
||||
//Byte b = 0;
|
||||
//for (ushort i = 0; i < dotWidth; i++) {
|
||||
// str = "";
|
||||
// for (ushort j = 0; j < dotHeight; j++) {
|
||||
// if (j % 8 == 0) b = 0;
|
||||
// if (f.data[i, j]) {
|
||||
// b |= (Byte)(1 << (j % 8));
|
||||
// }
|
||||
// if ( ((j + 1) % 8 == 0) || j+1 == dotHeight ) {
|
||||
// if (str.Length > 0) str += " ";
|
||||
// str += "0x" + Convert.ToString(b, 16).PadLeft(2, '0') + ',';
|
||||
// }
|
||||
// }
|
||||
// outBox.AppendText(str);
|
||||
// outBox.AppendText(Environment.NewLine);
|
||||
//}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e) {
|
||||
var bmp = new Bitmap(dotWidth, dotHeight);
|
||||
//var bmp = new Bitmap(dotWidth, dotHeight);
|
||||
//for (int i=0; i<dotWidth; i++) {
|
||||
// for (int j=0; j<dotHeight; j++) {
|
||||
// bmp.SetPixel(i, j, dots[i, j].BackColor);
|
||||
// }
|
||||
//}
|
||||
//imageList1.Images.RemoveByKey("32");
|
||||
//imageList1.Images.Add("32", (Image)bmp);
|
||||
//miniList.Items[0].ImageKey = "32";
|
||||
//bmp.Dispose();
|
||||
}
|
||||
|
||||
private void dotPanel_Paint(object sender, PaintEventArgs e) {
|
||||
Graphics g = dotPanel.CreateGraphics();
|
||||
SolidBrush sbb = new SolidBrush(Color.Black);
|
||||
SolidBrush sbw = new SolidBrush(Color.White);
|
||||
SolidBrush sb;
|
||||
|
||||
for (int i=0; i<dotWidth; i++) {
|
||||
for (int j=0; j<dotHeight; j++) {
|
||||
bmp.SetPixel(i, j, dots[i, j].BackColor);
|
||||
if (f.data[i, j]) sb = sbb;
|
||||
else sb = sbw;
|
||||
int x = pixelOffset + i * (cellSize + gap) - hScroll.Value;
|
||||
int y = pixelOffset + j * (cellSize + gap) - vScroll.Value;
|
||||
g.FillRectangle(sb, x, y, cellSize, cellSize);
|
||||
}
|
||||
}
|
||||
imageList1.Images.RemoveByKey("32");
|
||||
imageList1.Images.Add("32", (Image)bmp);
|
||||
miniList.Items[0].ImageKey = "32";
|
||||
bmp.Dispose();
|
||||
}
|
||||
|
||||
private void dotPanel_Scroll(object sender, ScrollEventArgs e) {
|
||||
//dotPanel.Invalidate();
|
||||
dotPanel.Refresh();
|
||||
}
|
||||
|
||||
private void hScroll_ValueChanged(object sender, EventArgs e) {
|
||||
label5.Text = hScroll.Value.ToString();
|
||||
dotPanel.Refresh();
|
||||
}
|
||||
|
||||
private void vScroll_ValueChanged(object sender, EventArgs e) {
|
||||
label5.Text = vScroll.Value.ToString();
|
||||
dotPanel.Refresh();
|
||||
}
|
||||
|
||||
private void dotScale() {
|
||||
bool large = dotWidth * dotHeight > 12 * 12;
|
||||
int gap = (cellSize < 5) ? 0 : 1;
|
||||
//bool large = dotWidth * dotHeight > 12 * 12;
|
||||
|
||||
if (large) {
|
||||
pbZoom.Maximum = dotWidth * dotHeight;
|
||||
pbZoom.Value = 0;
|
||||
pbZoom.Visible = true;
|
||||
dotPanel.Visible = false;
|
||||
}
|
||||
for (int i = 0; i < dotWidth; i++) {
|
||||
for (int j = 0; j < dotHeight; j++) {
|
||||
dots[i, j].Width = cellSize; dots[i, j].Height = cellSize;
|
||||
dots[i, j].Left = 5 + i * (cellSize + gap);
|
||||
dots[i, j].Top = 5 + j * (cellSize + gap);
|
||||
if (large) pbZoom.PerformStep();
|
||||
}
|
||||
}
|
||||
if (large) {
|
||||
dotPanel.Visible = true;
|
||||
pbZoom.Visible = false;
|
||||
}
|
||||
//if (large) {
|
||||
// pbZoom.Maximum = dotWidth * dotHeight;
|
||||
// pbZoom.Value = 0;
|
||||
// pbZoom.Visible = true;
|
||||
// dotPanel.Visible = false;
|
||||
//}
|
||||
//for (int i = 0; i < dotWidth; i++) {
|
||||
// for (int j = 0; j < dotHeight; j++) {
|
||||
// dots[i, j].Width = cellSize; dots[i, j].Height = cellSize;
|
||||
// dots[i, j].Left = pixelOffset + i * (cellSize + gap);
|
||||
// dots[i, j].Top = pixelOffset + j * (cellSize + gap);
|
||||
// if (large) pbZoom.PerformStep();
|
||||
// }
|
||||
//}
|
||||
//if (large) {
|
||||
// dotPanel.Visible = true;
|
||||
// pbZoom.Visible = false;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -125,7 +125,7 @@
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAA8
|
||||
BwAAAk1TRnQBSQFMAwEBAAEIAQABCAEAATIBAAEyAQAE/wEFAQAI/wFCAU0BdgcAAXYDAAEoAwAByAMA
|
||||
BwAAAk1TRnQBSQFMAwEBAAEoAQABKAEAATIBAAEyAQAE/wEFAQAI/wFCAU0BdgcAAXYDAAEoAwAByAMA
|
||||
ATIDAAEBAQABBAUAAYgBExgAAYACAAGAAwACgAEAAYADAAGAAQABgAEAAoACAAPAAQADgAMAAf8CAAH/
|
||||
AwAC/wEAAf8DAAH/AQAB/wEAAv8CAAP//wA1AAEPAYgB8AEAAQ8BiAHwAQABDwGIAfBZAAEHAQABgAEA
|
||||
AQcBAAFwAQABCAEAAXBZAAEHAQABgAEAAQcBAAFwAQABCAEAAXBZAAEHAQABgAEAAQcBAAFwAQABCAEA
|
||||
|
Reference in New Issue
Block a user