添加10像素和15像素画笔大小按钮,并将CreateBrushSizeImage方法迁移到Setting.cs

This commit is contained in:
zqm
2025-11-10 11:31:38 +08:00
parent 53db7ff081
commit 7d7b85b239
3 changed files with 157 additions and 35 deletions

View File

@@ -163,6 +163,30 @@ namespace JoyD.Windows.CS
this.btnBrushSize5.ToolTipText = "选择5像素画笔";
this.btnBrushSize5.Click += new System.EventHandler(this.BtnBrushSize5_Click);
//
// btnBrushSize10
//
this.btnBrushSize10 = new System.Windows.Forms.ToolStripButton();
this.btnBrushSize10.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.btnBrushSize10.Image = this.CreateBrushSizeImage(10, System.Drawing.Color.Purple);
this.btnBrushSize10.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnBrushSize10.Name = "btnBrushSize10";
this.btnBrushSize10.Size = new System.Drawing.Size(23, 22);
this.btnBrushSize10.Text = "画笔大小10px";
this.btnBrushSize10.ToolTipText = "选择10像素画笔";
this.btnBrushSize10.Click += new System.EventHandler(this.BtnBrushSize10_Click);
//
// btnBrushSize15
//
this.btnBrushSize15 = new System.Windows.Forms.ToolStripButton();
this.btnBrushSize15.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.btnBrushSize15.Image = this.CreateBrushSizeImage(15, System.Drawing.Color.Orange);
this.btnBrushSize15.ImageTransparentColor = System.Drawing.Color.Magenta;
this.btnBrushSize15.Name = "btnBrushSize15";
this.btnBrushSize15.Size = new System.Drawing.Size(23, 22);
this.btnBrushSize15.Text = "画笔大小15px";
this.btnBrushSize15.ToolTipText = "选择15像素画笔";
this.btnBrushSize15.Click += new System.EventHandler(this.BtnBrushSize15_Click);
//
// toolStrip
//
this.toolStrip.AllowDrop = true;
@@ -178,7 +202,9 @@ namespace JoyD.Windows.CS
new System.Windows.Forms.ToolStripSeparator(),
this.btnBrushSize1,
this.btnBrushSize3,
this.btnBrushSize5});
this.btnBrushSize5,
this.btnBrushSize10,
this.btnBrushSize15});
this.toolStrip.Location = new System.Drawing.Point(3, 0);
this.toolStrip.Name = "toolStrip";
this.toolStrip.Size = new System.Drawing.Size(104, 25);
@@ -291,30 +317,8 @@ namespace JoyD.Windows.CS
private System.Windows.Forms.ToolStripButton btnBrushSize1;
private System.Windows.Forms.ToolStripButton btnBrushSize3;
private System.Windows.Forms.ToolStripButton btnBrushSize5;
private System.Windows.Forms.ToolStripButton btnBrushSize10;
private System.Windows.Forms.ToolStripButton btnBrushSize15;
private System.Windows.Forms.DataGridView dataGridViewTempDiff;
/// <summary>
/// 创建表示画笔大小的图标
/// </summary>
/// <param name="size">画笔大小(像素)</param>
/// <param name="color">画笔颜色</param>
/// <returns>表示画笔大小的图标</returns>
private System.Drawing.Bitmap CreateBrushSizeImage(int size, System.Drawing.Color color)
{
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(20, 20);
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp))
{
// 填充背景为透明色
g.Clear(System.Drawing.Color.Magenta);
// 计算正方形位置,使其居中
int x = (20 - size) / 2;
int y = (20 - size) / 2;
// 绘制正方形表示画笔大小
g.FillRectangle(new System.Drawing.SolidBrush(color), x, y, size, size);
// 添加边框
g.DrawRectangle(new System.Drawing.Pen(System.Drawing.Color.Black), x, y, size - 1, size - 1);
}
return bmp;
}
}
}