实现选中区域时右击鼠标退出选中状态的功能
This commit is contained in:
@@ -1035,11 +1035,34 @@ namespace JoyD.Windows.CS
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 鼠标点击事件 - 处理区域选中
|
/// 鼠标点击事件 - 处理区域选中和右击退出选中状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void PicBoxTemp_MouseClick(object sender, MouseEventArgs e)
|
private void PicBoxTemp_MouseClick(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
// 仅在就绪状态(非绘制模式)下处理
|
// 处理右键点击 - 退出选中状态
|
||||||
|
if (!_isDrawingMode && e.Button == MouseButtons.Right && _selectedRegionIndex != -1)
|
||||||
|
{
|
||||||
|
// 取消选中状态
|
||||||
|
_selectedRegionIndex = -1;
|
||||||
|
|
||||||
|
// 更新按钮的可见性
|
||||||
|
try
|
||||||
|
{
|
||||||
|
btnDeleteRegion.Visible = false;
|
||||||
|
btnSelectColor.Visible = false;
|
||||||
|
btnDrawRegion.Visible = true; // 取消选中后显示绘制按钮
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine("更新按钮可见性失败: " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 刷新绘制
|
||||||
|
picBoxTemp.Invalidate();
|
||||||
|
return; // 处理完右键事件后返回
|
||||||
|
}
|
||||||
|
|
||||||
|
// 仅在就绪状态(非绘制模式)下处理左键点击
|
||||||
if (!_isDrawingMode && e.Button == MouseButtons.Left && picBoxTemp.Image != null && !_isResizing)
|
if (!_isDrawingMode && e.Button == MouseButtons.Left && picBoxTemp.Image != null && !_isResizing)
|
||||||
{
|
{
|
||||||
// 将控件坐标转换为图像坐标
|
// 将控件坐标转换为图像坐标
|
||||||
|
|||||||
Reference in New Issue
Block a user