修复Setting.Designer.cs中btnEraseTempDiff按钮的初始化问题
This commit is contained in:
@@ -46,6 +46,7 @@ namespace JoyD.Windows.CS
|
||||
this.btnBrushSize10 = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnBrushSize15 = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnBrushSize25 = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnEraseTempDiff = new System.Windows.Forms.ToolStripButton();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
|
||||
this.splitContainer.Panel1.SuspendLayout();
|
||||
this.splitContainer.Panel2.SuspendLayout();
|
||||
@@ -147,12 +148,14 @@ namespace JoyD.Windows.CS
|
||||
this.btnDrawTempDiff,
|
||||
this.btnAddTempDiff,
|
||||
this.btnDeleteTempDiff,
|
||||
new System.Windows.Forms.ToolStripSeparator(),
|
||||
this.btnBrushSize1,
|
||||
this.btnBrushSize3,
|
||||
this.btnBrushSize5,
|
||||
this.btnBrushSize10,
|
||||
this.btnBrushSize15,
|
||||
this.btnBrushSize25});
|
||||
this.btnBrushSize25,
|
||||
this.btnEraseTempDiff});
|
||||
this.toolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
|
||||
this.toolStrip.Location = new System.Drawing.Point(3, 0);
|
||||
this.toolStrip.MaximumSize = new System.Drawing.Size(0, 100);
|
||||
@@ -284,6 +287,16 @@ namespace JoyD.Windows.CS
|
||||
this.btnBrushSize25.ToolTipText = "选择25像素画笔";
|
||||
this.btnBrushSize25.Click += new System.EventHandler(this.BtnBrushSize25_Click);
|
||||
//
|
||||
// btnEraseTempDiff
|
||||
//
|
||||
this.btnEraseTempDiff.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.btnEraseTempDiff.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnEraseTempDiff.Name = "btnEraseTempDiff";
|
||||
this.btnEraseTempDiff.Size = new System.Drawing.Size(23, 4);
|
||||
this.btnEraseTempDiff.Text = "擦除温差图";
|
||||
this.btnEraseTempDiff.ToolTipText = "使用透明色擦除温差图";
|
||||
this.btnEraseTempDiff.Click += new System.EventHandler(this.BtnEraseTempDiff_Click);
|
||||
//
|
||||
// Setting
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
|
||||
@@ -332,6 +345,7 @@ namespace JoyD.Windows.CS
|
||||
private System.Windows.Forms.ToolStripButton btnBrushSize10;
|
||||
private System.Windows.Forms.ToolStripButton btnBrushSize15;
|
||||
private System.Windows.Forms.ToolStripButton btnBrushSize25;
|
||||
private System.Windows.Forms.ToolStripButton btnEraseTempDiff;
|
||||
private System.Windows.Forms.DataGridView dataGridViewTempDiff;
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ namespace JoyD.Windows.CS
|
||||
private Point _lastDrawPoint = Point.Empty; // 上一个绘制点的位置
|
||||
private bool _isDrawingRectangle = false; // 是否正在绘制矩形
|
||||
private Point _rectangleStartPoint = Point.Empty; // 矩形起始点
|
||||
private bool _isEraseMode = false; // 擦除模式标志
|
||||
|
||||
public Setting()
|
||||
{
|
||||
@@ -87,6 +88,11 @@ namespace JoyD.Windows.CS
|
||||
// 初始状态下隐藏添加和删除温差图例按钮
|
||||
btnAddTempDiff.Visible = false;
|
||||
btnDeleteTempDiff.Visible = false;
|
||||
// 初始化擦除按钮并设置为隐藏
|
||||
if (btnEraseTempDiff != null)
|
||||
{
|
||||
btnEraseTempDiff.Visible = false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -163,6 +169,37 @@ namespace JoyD.Windows.CS
|
||||
UpdateBrushSizeButtonSelection(25);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 擦除温差图按钮点击事件
|
||||
/// </summary>
|
||||
private void BtnEraseTempDiff_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 切换擦除模式
|
||||
_isEraseMode = !_isEraseMode;
|
||||
btnEraseTempDiff.Checked = _isEraseMode;
|
||||
|
||||
if (_isEraseMode)
|
||||
{
|
||||
btnEraseTempDiff.ToolTipText = "擦除模式已启用,点击图片区域进行擦除(点击关闭)";
|
||||
}
|
||||
else
|
||||
{
|
||||
btnEraseTempDiff.ToolTipText = "使用透明色擦除温差图";
|
||||
}
|
||||
|
||||
// 重置上一个绘制点,确保下一次绘制/擦除是新的起点
|
||||
_lastDrawPoint = Point.Empty;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("擦除模式切换失败: " + ex.Message);
|
||||
_isEraseMode = false;
|
||||
btnEraseTempDiff.Checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建表示画笔大小的图标
|
||||
/// </summary>
|
||||
@@ -708,6 +745,7 @@ namespace JoyD.Windows.CS
|
||||
dataGridViewTempDiff.Visible = false; // 隐藏温差图例表格
|
||||
btnAddTempDiff.Visible = false; // 隐藏添加温差图例按钮
|
||||
btnDeleteTempDiff.Visible = false; // 隐藏删除温差图例按钮
|
||||
btnEraseTempDiff.Visible = false; // 隐藏擦除按钮
|
||||
// 隐藏所有画笔大小按钮
|
||||
btnBrushSize1.Visible = false;
|
||||
btnBrushSize3.Visible = false;
|
||||
@@ -729,6 +767,7 @@ namespace JoyD.Windows.CS
|
||||
dataGridViewTempDiff.Visible = false; // 隐藏温差图例表格
|
||||
btnAddTempDiff.Visible = false; // 隐藏添加温差图例按钮
|
||||
btnDeleteTempDiff.Visible = false; // 隐藏删除温差图例按钮
|
||||
btnEraseTempDiff.Visible = false; // 隐藏擦除按钮
|
||||
// 隐藏所有画笔大小按钮
|
||||
btnBrushSize1.Visible = false;
|
||||
btnBrushSize3.Visible = false;
|
||||
@@ -750,6 +789,7 @@ namespace JoyD.Windows.CS
|
||||
dataGridViewTempDiff.Visible = false; // 隐藏温差图例表格
|
||||
btnAddTempDiff.Visible = false; // 隐藏添加温差图例按钮
|
||||
btnDeleteTempDiff.Visible = false; // 隐藏删除温差图例按钮
|
||||
btnEraseTempDiff.Visible = false; // 隐藏擦除按钮
|
||||
// 隐藏所有画笔大小按钮
|
||||
btnBrushSize1.Visible = false;
|
||||
btnBrushSize3.Visible = false;
|
||||
@@ -771,6 +811,7 @@ namespace JoyD.Windows.CS
|
||||
dataGridViewTempDiff.Visible = true; // 显示温差图例表格
|
||||
btnAddTempDiff.Visible = true; // 显示添加温差图例按钮
|
||||
btnDeleteTempDiff.Visible = true; // 显示删除温差图例按钮
|
||||
btnEraseTempDiff.Visible = true; // 显示擦除按钮
|
||||
// 初始隐藏画笔大小按钮,等待用户选择温差图例后在SelectionChanged事件中显示
|
||||
btnBrushSize1.Visible = false;
|
||||
btnBrushSize3.Visible = false;
|
||||
@@ -889,6 +930,8 @@ namespace JoyD.Windows.CS
|
||||
_lastDrawPoint = Point.Empty;
|
||||
_isTempDiffDrawingMode = false;
|
||||
btnDrawTempDiff.Checked = false;
|
||||
_isEraseMode = false; // 重置擦除模式
|
||||
btnEraseTempDiff.Checked = false;
|
||||
|
||||
// 重置鼠标光标并安全释放自定义光标资源
|
||||
try
|
||||
@@ -912,9 +955,20 @@ namespace JoyD.Windows.CS
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("重置光标资源时发生异常: " + ex.Message);
|
||||
}
|
||||
|
||||
// 更新按钮提示文本
|
||||
try
|
||||
{
|
||||
btnDrawTempDiff.ToolTipText = "绘制温差图";
|
||||
btnEraseTempDiff.ToolTipText = "使用透明色擦除温差图";
|
||||
// 确保光标设置为默认值
|
||||
picBoxTemp.Cursor = Cursors.Default;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("更新按钮提示文本时发生异常: " + ex.Message);
|
||||
}
|
||||
|
||||
// 更新按钮提示文本
|
||||
btnDrawTempDiff.ToolTipText = "绘制温差图";
|
||||
@@ -1207,7 +1261,7 @@ namespace JoyD.Windows.CS
|
||||
catch {}
|
||||
}
|
||||
|
||||
// 处理矩形绘制(按住Ctrl键)
|
||||
// 处理矩形绘制/擦除(按住Ctrl键)
|
||||
if (_isDrawingRectangle && e.Button == MouseButtons.Left && picBoxTemp.Image != null)
|
||||
{
|
||||
// 获取相对于图像的当前坐标
|
||||
@@ -1228,16 +1282,27 @@ namespace JoyD.Windows.CS
|
||||
int height = Math.Abs(currentImagePoint.Y - _rectangleStartPoint.Y);
|
||||
Rectangle rect = new Rectangle(x, y, width, height);
|
||||
|
||||
// 创建半透明的填充颜色
|
||||
Color fillColor = Color.FromArgb(128, selectedColor);
|
||||
|
||||
// 绘制填充矩形
|
||||
g.FillRectangle(new SolidBrush(fillColor), rect);
|
||||
|
||||
// 绘制矩形边框
|
||||
using (Pen pen = new Pen(selectedColor, _currentBrushSize))
|
||||
if (_isEraseMode)
|
||||
{
|
||||
g.DrawRectangle(pen, rect);
|
||||
// 擦除模式:使用透明色填充整个矩形区域
|
||||
g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
|
||||
g.FillRectangle(Brushes.Transparent, rect);
|
||||
g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 普通绘制模式:使用半透明填充和边框
|
||||
// 创建半透明的填充颜色
|
||||
Color fillColor = Color.FromArgb(128, selectedColor);
|
||||
|
||||
// 绘制填充矩形
|
||||
g.FillRectangle(new SolidBrush(fillColor), rect);
|
||||
|
||||
// 绘制矩形边框
|
||||
using (Pen pen = new Pen(selectedColor, _currentBrushSize))
|
||||
{
|
||||
g.DrawRectangle(pen, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1251,7 +1316,7 @@ namespace JoyD.Windows.CS
|
||||
// 触发重绘
|
||||
picBoxTemp.Invalidate();
|
||||
}
|
||||
// 普通绘制操作(未按住Ctrl键)
|
||||
// 普通绘制/擦除操作(未按住Ctrl键)
|
||||
else if (e.Button == MouseButtons.Left && !_isDrawingRectangle && picBoxTemp.Image != null)
|
||||
{
|
||||
// 初始化温差层图像(如果不存在或尺寸不匹配)
|
||||
@@ -1265,26 +1330,24 @@ namespace JoyD.Windows.CS
|
||||
// 获取相对于图像的坐标
|
||||
Point imagePoint = ControlPointToImagePoint(e.Location);
|
||||
|
||||
// 在温差层图像上绘制
|
||||
// 在温差层图像上绘制/擦除
|
||||
using (Graphics g = Graphics.FromImage(_tempDiffOverlayImage))
|
||||
{
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
|
||||
// 使用当前选中的颜色和画笔大小绘制
|
||||
using (Pen pen = new Pen(selectedColor, _currentBrushSize))
|
||||
if (_isEraseMode)
|
||||
{
|
||||
pen.StartCap = LineCap.Round;
|
||||
pen.EndCap = LineCap.Round;
|
||||
pen.LineJoin = LineJoin.Round;
|
||||
// 擦除模式:使用透明色填充,设置CompositingMode为清除
|
||||
g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
|
||||
|
||||
// 如果是首次绘制或上一个点无效,记录当前点作为起点
|
||||
// 如果是首次擦除或上一个点无效,记录当前点作为起点
|
||||
if (_lastDrawPoint == Point.Empty)
|
||||
{
|
||||
_lastDrawPoint = imagePoint;
|
||||
// 绘制起始点的圆形
|
||||
// 绘制起始点的圆形(擦除区域)
|
||||
int radius = _currentBrushSize / 2;
|
||||
g.FillEllipse(new SolidBrush(selectedColor),
|
||||
g.FillEllipse(Brushes.Transparent,
|
||||
imagePoint.X - radius,
|
||||
imagePoint.Y - radius,
|
||||
_currentBrushSize,
|
||||
@@ -1292,11 +1355,50 @@ namespace JoyD.Windows.CS
|
||||
}
|
||||
else
|
||||
{
|
||||
// 绘制连线
|
||||
g.DrawLine(pen, _lastDrawPoint, imagePoint);
|
||||
// 使用透明色绘制粗线条进行擦除
|
||||
using (Pen pen = new Pen(Color.Transparent, _currentBrushSize))
|
||||
{
|
||||
pen.StartCap = LineCap.Round;
|
||||
pen.EndCap = LineCap.Round;
|
||||
pen.LineJoin = LineJoin.Round;
|
||||
g.DrawLine(pen, _lastDrawPoint, imagePoint);
|
||||
}
|
||||
// 更新上一个点
|
||||
_lastDrawPoint = imagePoint;
|
||||
}
|
||||
|
||||
// 恢复默认的合成模式
|
||||
g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 普通绘制模式
|
||||
using (Pen pen = new Pen(selectedColor, _currentBrushSize))
|
||||
{
|
||||
pen.StartCap = LineCap.Round;
|
||||
pen.EndCap = LineCap.Round;
|
||||
pen.LineJoin = LineJoin.Round;
|
||||
|
||||
// 如果是首次绘制或上一个点无效,记录当前点作为起点
|
||||
if (_lastDrawPoint == Point.Empty)
|
||||
{
|
||||
_lastDrawPoint = imagePoint;
|
||||
// 绘制起始点的圆形
|
||||
int radius = _currentBrushSize / 2;
|
||||
g.FillEllipse(new SolidBrush(selectedColor),
|
||||
imagePoint.X - radius,
|
||||
imagePoint.Y - radius,
|
||||
_currentBrushSize,
|
||||
_currentBrushSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 绘制连线
|
||||
g.DrawLine(pen, _lastDrawPoint, imagePoint);
|
||||
// 更新上一个点
|
||||
_lastDrawPoint = imagePoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1865,6 +1967,40 @@ namespace JoyD.Windows.CS
|
||||
Console.WriteLine("温差图按钮图标设置失败: " + ex.Message);
|
||||
}
|
||||
|
||||
// 设置擦除按钮的图标
|
||||
try
|
||||
{
|
||||
Bitmap eraseTempDiffIcon = new Bitmap(24, 24);
|
||||
using (Graphics g = Graphics.FromImage(eraseTempDiffIcon))
|
||||
{
|
||||
// 设置高质量绘图
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
// 清除背景为透明
|
||||
g.Clear(Color.Transparent);
|
||||
|
||||
// 绘制橡皮擦图标 - 一个矩形表示橡皮擦
|
||||
// 绘制橡皮擦主体
|
||||
using (Pen pen = new Pen(Color.Black, 2))
|
||||
{
|
||||
g.DrawRectangle(pen, 6, 8, 12, 10);
|
||||
}
|
||||
// 绘制橡皮擦手柄
|
||||
using (Pen pen = new Pen(Color.Black, 1.5f))
|
||||
{
|
||||
g.DrawLine(pen, 12, 8, 12, 4);
|
||||
g.DrawLine(pen, 10, 4, 14, 4);
|
||||
}
|
||||
}
|
||||
|
||||
btnEraseTempDiff.Image = eraseTempDiffIcon;
|
||||
btnEraseTempDiff.ImageTransparentColor = Color.Transparent;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("擦除按钮图标设置失败: " + ex.Message);
|
||||
}
|
||||
|
||||
// 设置添加温差图例按钮的图标
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user