优化温差图绘制状态:1、当没有任何温差图例时隐藏删除温差图例按钮;2、当没有选定绘制时使用的温差图例时,鼠标光标不变为绘制光标且不进行绘制操作
This commit is contained in:
@@ -1185,7 +1185,7 @@ namespace JoyD.Windows.CS
|
|||||||
dataGridViewTempDiff.Visible = true; // 显示温差图例表格
|
dataGridViewTempDiff.Visible = true; // 显示温差图例表格
|
||||||
dataGridViewTempDiff.ReadOnly = false; // 温差图绘制状态下可编辑
|
dataGridViewTempDiff.ReadOnly = false; // 温差图绘制状态下可编辑
|
||||||
btnAddTempDiff.Visible = true; // 显示添加温差图例按钮
|
btnAddTempDiff.Visible = true; // 显示添加温差图例按钮
|
||||||
btnDeleteTempDiff.Visible = true; // 显示删除温差图例按钮
|
btnDeleteTempDiff.Visible = tempDiffData.Count > 0; // 当有温差图例时显示删除按钮
|
||||||
btnEraseTempDiff.Visible = true; // 显示擦除按钮
|
btnEraseTempDiff.Visible = true; // 显示擦除按钮
|
||||||
// 隐藏六个新按钮
|
// 隐藏六个新按钮
|
||||||
btnNewTempRegion.Visible = false;
|
btnNewTempRegion.Visible = false;
|
||||||
@@ -1677,11 +1677,11 @@ namespace JoyD.Windows.CS
|
|||||||
// 温差图绘制模式下,使用自定义画笔光标
|
// 温差图绘制模式下,使用自定义画笔光标
|
||||||
if (_isTempDiffDrawingMode)
|
if (_isTempDiffDrawingMode)
|
||||||
{
|
{
|
||||||
// 获取当前选中的温差图例颜色
|
// 检查是否有选中的温差图例
|
||||||
Color selectedColor = Color.Black; // 默认颜色
|
|
||||||
int selectedRowIndex = -1;
|
int selectedRowIndex = -1;
|
||||||
|
bool hasSelectedLegend = false;
|
||||||
|
|
||||||
// 尝试获取选中行的颜色
|
// 尝试获取选中行索引
|
||||||
if (dataGridViewTempDiff.SelectedRows.Count > 0)
|
if (dataGridViewTempDiff.SelectedRows.Count > 0)
|
||||||
{
|
{
|
||||||
selectedRowIndex = dataGridViewTempDiff.SelectedRows[0].Index;
|
selectedRowIndex = dataGridViewTempDiff.SelectedRows[0].Index;
|
||||||
@@ -1691,11 +1691,14 @@ namespace JoyD.Windows.CS
|
|||||||
selectedRowIndex = dataGridViewTempDiff.SelectedCells[0].RowIndex;
|
selectedRowIndex = dataGridViewTempDiff.SelectedCells[0].RowIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果选中行索引有效,获取对应的颜色
|
// 检查选中行索引是否有效
|
||||||
if (selectedRowIndex >= 0 && selectedRowIndex < tempDiffData.Count)
|
hasSelectedLegend = selectedRowIndex >= 0 && selectedRowIndex < tempDiffData.Count;
|
||||||
|
|
||||||
|
// 只有在有选中的温差图例时才设置自定义光标
|
||||||
|
if (hasSelectedLegend)
|
||||||
{
|
{
|
||||||
selectedColor = (Color)tempDiffData[selectedRowIndex]["color"];
|
// 获取当前选中的温差图例颜色
|
||||||
}
|
Color selectedColor = (Color)tempDiffData[selectedRowIndex]["color"];
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1733,9 +1736,32 @@ namespace JoyD.Windows.CS
|
|||||||
}
|
}
|
||||||
catch {}
|
catch {}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 没有选中的温差图例时,使用默认光标
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (picBoxTemp.Cursor != Cursors.Default)
|
||||||
|
{
|
||||||
|
// 释放旧光标
|
||||||
|
Cursor oldCursor = picBoxTemp.Cursor;
|
||||||
|
picBoxTemp.Cursor = Cursors.Default;
|
||||||
|
|
||||||
// 处理矩形绘制/擦除(按住Ctrl键)
|
// 只释放自定义光标,不释放系统光标
|
||||||
if (_isDrawingRectangle && e.Button == MouseButtons.Left && picBoxTemp.Image != null)
|
if (oldCursor != null && oldCursor != Cursors.Default &&
|
||||||
|
oldCursor != Cursors.Cross && oldCursor != Cursors.Hand &&
|
||||||
|
oldCursor != Cursors.IBeam && oldCursor != Cursors.WaitCursor)
|
||||||
|
{
|
||||||
|
oldCursor.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理矩形绘制/擦除(按住Ctrl键)- 只有在有选中的温差图例时才进行绘制
|
||||||
|
if (_isDrawingRectangle && e.Button == MouseButtons.Left && picBoxTemp.Image != null && hasSelectedLegend)
|
||||||
{
|
{
|
||||||
// 获取相对于图像的当前坐标
|
// 获取相对于图像的当前坐标
|
||||||
Point currentImagePoint = ControlPointToImagePoint(e.Location);
|
Point currentImagePoint = ControlPointToImagePoint(e.Location);
|
||||||
@@ -3649,8 +3675,24 @@ namespace JoyD.Windows.CS
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void PicBoxTemp_MouseClick(object sender, MouseEventArgs e)
|
private void PicBoxTemp_MouseClick(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
// 温差图绘制状态下处理左键单击
|
// 温差图绘制状态下处理左键单击 - 只有在有选中的温差图例时才进行绘制
|
||||||
if (_isTempDiffDrawingMode && e.Button == MouseButtons.Left && picBoxTemp.Image != null && !_isDrawingRectangle)
|
bool hasSelectedLegend = false;
|
||||||
|
int selectedRowIndex = -1;
|
||||||
|
|
||||||
|
// 检查是否有选中的温差图例
|
||||||
|
if (dataGridViewTempDiff.SelectedRows.Count > 0)
|
||||||
|
{
|
||||||
|
selectedRowIndex = dataGridViewTempDiff.SelectedRows[0].Index;
|
||||||
|
}
|
||||||
|
else if (dataGridViewTempDiff.SelectedCells.Count > 0)
|
||||||
|
{
|
||||||
|
selectedRowIndex = dataGridViewTempDiff.SelectedCells[0].RowIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查选中行索引是否有效
|
||||||
|
hasSelectedLegend = selectedRowIndex >= 0 && selectedRowIndex < tempDiffData.Count;
|
||||||
|
|
||||||
|
if (_isTempDiffDrawingMode && e.Button == MouseButtons.Left && picBoxTemp.Image != null && !_isDrawingRectangle && hasSelectedLegend)
|
||||||
{
|
{
|
||||||
// 初始化温差层图像(如果不存在或尺寸不匹配)
|
// 初始化温差层图像(如果不存在或尺寸不匹配)
|
||||||
if (_tempDiffOverlayImage == null ||
|
if (_tempDiffOverlayImage == null ||
|
||||||
|
|||||||
Reference in New Issue
Block a user