This commit is contained in:
zhougf committed 2025-03-31 13:39:28 +08:00
1 parent 2b56f8e7d3
commit 60cafc4f8c
6 files changed
+384 -91

No files matched your search

+48 -14
View File
@@ -35,7 +35,7 @@ namespace WindowsFormsApp1
public ImageDisplayForm()
{
InitializeComponent();
SetCurrentName("123");
SetCurrentName("test");
// 初始化自动更新定时器
autoUpdateTimer = new Timer();
@@ -153,19 +153,31 @@ namespace WindowsFormsApp1
// 标记位置
if (originalImage != null)
{
DrawMark(pos.x, pos.y);
isBlinking = true;
isBlinking = true; // 设置为 true 后不再切换
currentRadius = MIN_RADIUS; // 重置半径
blinkTimer.Start();
DrawMark(pos.x, pos.y);
}
}
}
catch (Exception ex)
{
// 记录错误但不显示消息框,避免频繁弹窗
Console.WriteLine($"查询坐标失败:{ex.Message}");
}
}
private float breathScale = 1.0f; // 添加这个字段到类的顶部
private const float MIN_SCALE = 0.6f;
private const float MAX_SCALE = 1.4f;
private bool scaleIncreasing = true;
// 修改半径相关的常量
private float currentRadius = 20f; // 增大初始半径
private const float MIN_RADIUS = 20f; // 最小半径
private const float MAX_RADIUS = 50f; // 增大最大半径
private bool isExpanding = true;
private const float RADIUS_CHANGE_SPEED = 2f;
private void DrawMark(int x, int y)
{
markedImage = new Bitmap(originalImage);
@@ -173,14 +185,37 @@ namespace WindowsFormsApp1
{
if (isBlinking)
{
// 绘制放大加粗的红色感叹号
using (Brush brush = new SolidBrush(Color.Red))
using (Pen pen = new Pen(Color.Red, 4)) // 加粗线条
// 设置高质量绘图模式
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// 只绘制白色圆
using (Brush whiteBrush = new SolidBrush(Color.Yellow))
{
// 放大的感叹号圆点
g.FillEllipse(brush, x - 6, y + 8, 12, 12);
// 放大的感叹号竖线
g.DrawLine(pen, x, y - 20, x, y);
g.FillEllipse(whiteBrush,
x - currentRadius,
y - currentRadius,
currentRadius * 2,
currentRadius * 2);
}
// 更新半径
if (isExpanding)
{
currentRadius += RADIUS_CHANGE_SPEED;
if (currentRadius >= MAX_RADIUS)
{
currentRadius = MAX_RADIUS;
isExpanding = false;
}
}
else
{
currentRadius -= RADIUS_CHANGE_SPEED;
if (currentRadius <= MIN_RADIUS)
{
currentRadius = MIN_RADIUS;
isExpanding = true;
}
}
}
}
@@ -189,7 +224,7 @@ namespace WindowsFormsApp1
private void BlinkTimer_Tick(object sender, EventArgs e)
{
isBlinking = !isBlinking;
// 移除 isBlinking 切换,保持为 true
if (!int.TryParse(txtX.Text, out int x) || !int.TryParse(txtY.Text, out int y))
return;
DrawMark(x, y);
@@ -490,8 +525,7 @@ namespace WindowsFormsApp1
this.pictureBox.Click += new System.EventHandler(this.PictureBox_Click);
//
// blinkTimer
//
this.blinkTimer.Interval = 500;
this.blinkTimer.Interval = 50; // 修改为50毫秒
this.blinkTimer.Tick += new System.EventHandler(this.BlinkTimer_Tick);
//
// ImageDisplayForm