日期:2014-05-17 浏览次数:21443 次
private void button3_Click(object sender, EventArgs e)
{
//显示按钮
var data = textBox2.Text.Select(x => x == '1').Concat(Enumerable.Repeat(false, 256))
.Take(256).ToArray();
Graphics g = pictureBox1.CreateGraphics();
for (int i = 0; i < 16; i++)
{
for (int j = 0; j < 16; j++)
{
Brush brush = data[j * 16 + i] ? Brushes.Blue : Brushes.White;
g.FillRectangle(brush, new Rectangle() { X = i * 16, Y = j * 16, Width = 16, Height = 16 });
}
}
}
private void button1_Click(object sender, EventArgs e)
{
//字体设置
FontDialog fd = new FontDialog() { Font = textBox1.Font, FontMustExist = true };
if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
textBox1.Font = fd.Font;
}
}
private void button2_Click(object sender, EventArgs e)
{
//产生字模
Bitmap bmp = new Bitmap(16, 16);
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(Brushes.White, new Rectangle() { X = 0, Y = 0, Height = 16, Width = 16 });
g.DrawString(textBox1.Text, textBox1.Font, Brushes.Black, new PointF() { X = Convert.ToSingle(domainUpDown1.Text), Y = Convert.ToSingle(domainUpDown2.Text) });
textBox2.Text = string.Join("", Enumerable.Range(0, 256).Select(a => new { x = a % 16, y = a / 16 })
.Select(x => bmp.GetPixel(x.x, x.y).GetBrightness() > 0.5f ? "0" : "1"));
button3.PerformClick();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
//输入文字的文本框
textBox1.Text = textBox1.Text.Length > 0 ? textBox1.Text.Substring(textBox1.Text.Length - 1) : ""