|
|
@@ -3,6 +3,7 @@ using OTSModelSharp.ServiceCenter;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Drawing;
|
|
|
+using System.Drawing.Drawing2D;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
|
|
|
@@ -13,21 +14,23 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
|
|
|
public PointF LTPoint;
|
|
|
public PointF RBPoint;
|
|
|
public PointF TheThirdPoint;
|
|
|
- public bool IsOK = false;
|
|
|
public bool IsInclinedPlaneFocus = false;
|
|
|
-
|
|
|
-
|
|
|
OTSCommon.Language lan;
|
|
|
Hashtable table;
|
|
|
-
|
|
|
CSlopFocusParam slopFocusParam;
|
|
|
|
|
|
-
|
|
|
public frmInitializeTwoPointRectangle()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
lan = new OTSCommon.Language(this);
|
|
|
table = lan.GetNameTable(this.Name);
|
|
|
+ if (panel1 != null)
|
|
|
+ {
|
|
|
+ panel1.Paint += Panel1_Paint;
|
|
|
+ panel1.MouseMove += Panel1_MouseMove;
|
|
|
+ panel1.MouseLeave += Panel1_MouseLeave;
|
|
|
+ panel1.Resize += Panel1_Resize;
|
|
|
+ }
|
|
|
}
|
|
|
private void bn_FirstPoint_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
@@ -45,12 +48,14 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
|
|
|
{
|
|
|
tB_LTPointWD.Text = WD.ToString();
|
|
|
}
|
|
|
+ if (panel1 != null) panel1.Invalidate();
|
|
|
}
|
|
|
private void bn_SecondPoint_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
double Px = 0;
|
|
|
double Py = 0;
|
|
|
double Pr = 0;
|
|
|
+
|
|
|
if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
|
|
|
{
|
|
|
tB_RBPointX.Text = Px.ToString();
|
|
|
@@ -58,17 +63,33 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
|
|
|
RBPoint = new PointF((float)Px, (float)Py);
|
|
|
}
|
|
|
double WD = 0;
|
|
|
+
|
|
|
+
|
|
|
if (cfun.GetWorkingDistance(ref WD))
|
|
|
{
|
|
|
- tB_RBPointX.Text = WD.ToString();
|
|
|
+ tBx_RBPointWD.Text = WD.ToString();
|
|
|
}
|
|
|
+ if (panel1 != null) panel1.Invalidate();
|
|
|
}
|
|
|
private void frmInitializeTwoPointRectangle_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
if (cfun == null){cfun = SemController.GetSEMController();}
|
|
|
cB_Inclinedplanefocus.Checked=true;double val=0;
|
|
|
if(cfun.GetMagnification(ref val)) tBx_Magnification.Text=val.ToString();
|
|
|
+ InitializeDrawingAreas();
|
|
|
+ panel1.Invalidate();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (tB_LTPointWD.Text == "")
|
|
|
@@ -81,11 +102,6 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
|
|
|
double wd = Convert.ToDouble(tB_LTPointWD.Text);
|
|
|
if (cfun.MoveSEMToPoint(Px, Py)) cfun.SetWorkingDistance(wd);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (tBx_RBPointWD.Text == "")
|
|
|
@@ -101,7 +117,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
|
|
|
cfun.SetWorkingDistance(wd);
|
|
|
}
|
|
|
}
|
|
|
- private void bn_TheThirdPoint_Click_1(object sender, EventArgs e)
|
|
|
+ private void bn_TheThirdPoint_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
double Px = 0;
|
|
|
double Py = 0;
|
|
|
@@ -117,6 +133,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
|
|
|
{
|
|
|
tBx_TheThirdPointWD.Text = WD.ToString();
|
|
|
}
|
|
|
+ if (panel1 != null) panel1.Invalidate();
|
|
|
}
|
|
|
private void btn_gtTheThirdPoint_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
@@ -135,20 +152,20 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
|
|
|
}
|
|
|
private void bn_OK_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
-
|
|
|
- IsOK = true;
|
|
|
double iPX1, iPY1, iPX2, iPY2, iPX3, iPY3;
|
|
|
iPX1 = iPY1 = iPX2 = iPY2 = iPX3 = iPY3 = 0;
|
|
|
double dPW1, dPW2, dPW3;
|
|
|
dPW1 = dPW2 = dPW3 = 0;
|
|
|
if (!double.TryParse(tB_LTPointX.Text, out iPX1) || !double.TryParse(tB_LTPointY.Text, out iPY1) || !double.TryParse(tB_RBPointX.Text, out iPX2) || !double.TryParse(tB_RBPointY.Text, out iPY2) || !double.TryParse(tB_LTPointWD.Text, out dPW1) || !double.TryParse(tBx_RBPointWD.Text, out dPW2) )
|
|
|
{
|
|
|
- MessageBox.Show("Please check Params!");
|
|
|
+ DialogResult result= MessageBox.Show("Please check Params!");
|
|
|
+ this.DialogResult= DialogResult.None;
|
|
|
return;
|
|
|
}
|
|
|
if (tB_LTPointX.Text == tB_RBPointX.Text && tB_LTPointY.Text == tB_RBPointY.Text)
|
|
|
{
|
|
|
- MessageBox.Show("Please select different points!");
|
|
|
+ DialogResult result= MessageBox.Show("Please select different points!");
|
|
|
+ this.DialogResult = DialogResult.None;
|
|
|
return;
|
|
|
}
|
|
|
if(cB_Inclinedplanefocus.Checked)
|
|
|
@@ -157,14 +174,27 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
|
|
|
if(!double.TryParse(tBx_TheThirdPointX.Text, out iPX3) || !double.TryParse(tBx_TheThirdPointY.Text, out iPY3) || !double.TryParse(tBx_TheThirdPointWD.Text, out dPW3))
|
|
|
{
|
|
|
MessageBox.Show("Please check Params!");
|
|
|
+ this.DialogResult = DialogResult.None;
|
|
|
return;
|
|
|
}
|
|
|
if((tB_LTPointX.Text == tBx_TheThirdPointX.Text && tB_LTPointX.Text ==tBx_TheThirdPointY.Text) || (tB_LTPointX.Text == tBx_TheThirdPointY.Text && tB_RBPointY.Text == tBx_TheThirdPointY.Text))
|
|
|
{
|
|
|
MessageBox.Show("Please check Params!");
|
|
|
+ this.DialogResult = DialogResult.None;
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ LTPoint = new PointF((float)iPX1, (float)iPY1);
|
|
|
+ RBPoint = new PointF((float)iPX2, (float)iPY2);
|
|
|
+ TheThirdPoint = new PointF((float)iPX3, (float)iPY3);
|
|
|
if (slopFocusParam == null)
|
|
|
{
|
|
|
slopFocusParam = new CSlopFocusParam();
|
|
|
@@ -182,19 +212,478 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
|
|
|
{
|
|
|
this.Close();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
private void cB_Inclinedplanefocus_CheckedChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- if(cB_Inclinedplanefocus.Checked)IsInclinedPlaneFocus = true;
|
|
|
- else IsInclinedPlaneFocus = false;
|
|
|
+ if (cB_Inclinedplanefocus.Checked)
|
|
|
+ {
|
|
|
+ IsInclinedPlaneFocus = true;
|
|
|
+
|
|
|
+ groupBox3.Enabled =true;
|
|
|
+ foreach (Control c in groupBox3.Controls)
|
|
|
+ {
|
|
|
+ c.Enabled = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IsInclinedPlaneFocus = false;
|
|
|
+ isMouseInThirdPoint = false;
|
|
|
+ UpdateGroupBoxHighlight(groupBox3, false); // 需要确认存在groupBox3控件
|
|
|
+ groupBox3.Enabled =false;
|
|
|
+ foreach (Control c in groupBox3.Controls)
|
|
|
+ {
|
|
|
+ c.Enabled = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (panel1 != null)
|
|
|
+ {
|
|
|
+ panel1.Invalidate();
|
|
|
+ }
|
|
|
}
|
|
|
public CSlopFocusParam GetCSlopFocusParam()
|
|
|
{
|
|
|
return slopFocusParam;
|
|
|
}
|
|
|
+ public double GetMagnification()
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ double dMagnification = 0;
|
|
|
+ double.TryParse(tBx_Magnification.Text, out dMagnification);
|
|
|
+ return dMagnification;
|
|
|
+ }
|
|
|
+ private RectangleF rectangleArea;
|
|
|
+ private RectangleF topLeftCircle;
|
|
|
+ private RectangleF bottomRightCircle;
|
|
|
+ private RectangleF thirdPointCircle;
|
|
|
+ private bool isMouseInTopLeft = false;
|
|
|
+ private bool isMouseInBottomRight = false;
|
|
|
+ private bool isMouseInThirdPoint = false;
|
|
|
+
|
|
|
+ private void Panel1_Resize(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ InitializeDrawingAreas();
|
|
|
+ panel1.Invalidate();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 初始化绘图区域
|
|
|
+ private void InitializeDrawingAreas()
|
|
|
+ {
|
|
|
+ if (panel1 == null) return;
|
|
|
+
|
|
|
+ // 定义矩形区域(居中显示)
|
|
|
+ int margin = 30;
|
|
|
+ rectangleArea = new RectangleF(
|
|
|
+ margin,
|
|
|
+ margin,
|
|
|
+ panel1.Width - 2 * margin,
|
|
|
+ panel1.Height - 2 * margin);
|
|
|
+
|
|
|
+ // 定义圆圈区域(直径16像素)
|
|
|
+ float circleDiameter = 16f;
|
|
|
+ float circleRadius = circleDiameter / 2;
|
|
|
+
|
|
|
+ topLeftCircle = new RectangleF(
|
|
|
+ rectangleArea.Left - circleRadius,
|
|
|
+ rectangleArea.Top - circleRadius,
|
|
|
+ circleDiameter, circleDiameter);
|
|
|
+
|
|
|
+ bottomRightCircle = new RectangleF(
|
|
|
+ rectangleArea.Right - circleRadius,
|
|
|
+ rectangleArea.Bottom - circleRadius,
|
|
|
+ circleDiameter, circleDiameter);
|
|
|
+
|
|
|
+ // 第三个点位于矩形内部,靠近右边但不在对角线上
|
|
|
+ thirdPointCircle = new RectangleF(
|
|
|
+ rectangleArea.Right - circleRadius - 30,
|
|
|
+ rectangleArea.Top + rectangleArea.Height / 3 - circleRadius,
|
|
|
+ circleDiameter, circleDiameter);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Panel 绘制事件 - 创建高级视觉效果
|
|
|
+ private void Panel1_Paint(object sender, PaintEventArgs e)
|
|
|
+ {
|
|
|
+ Graphics g = e.Graphics;
|
|
|
+ g.SmoothingMode = SmoothingMode.AntiAlias;
|
|
|
+ g.CompositingQuality = CompositingQuality.HighQuality;
|
|
|
+
|
|
|
+ // 确保绘图区域已初始化
|
|
|
+ if (rectangleArea.IsEmpty)
|
|
|
+ {
|
|
|
+ InitializeDrawingAreas();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 绘制高级效果矩形(绿色背景)
|
|
|
+ DrawAdvancedRectangle(g, rectangleArea);
|
|
|
+
|
|
|
+ // 绘制带渐变的圆圈(黄色)
|
|
|
+ DrawAdvancedCircle(g, topLeftCircle, isMouseInTopLeft);
|
|
|
+ DrawAdvancedCircle(g, bottomRightCircle, isMouseInBottomRight);
|
|
|
+
|
|
|
+ // 如果选中了倾斜平面焦点选项,绘制第三个点
|
|
|
+ if (cB_Inclinedplanefocus.Checked)
|
|
|
+ {
|
|
|
+ DrawAdvancedCircle(g, thirdPointCircle, isMouseInThirdPoint);
|
|
|
+
|
|
|
+ // 在第三个点上方绘制"任意非对角线点"文字
|
|
|
+ DrawNonDiagonalPointLabel(g, thirdPointCircle);
|
|
|
+
|
|
|
+ // 显示第三个点坐标
|
|
|
+ if (tBx_TheThirdPointX.Text != "" && tBx_TheThirdPointY.Text != "")
|
|
|
+ {
|
|
|
+ DrawPointCoordinates(g, thirdPointCircle, tBx_TheThirdPointX.Text, tBx_TheThirdPointY.Text, "THIRD");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示左上角点坐标
|
|
|
+ if (tB_LTPointX.Text != "" && tB_LTPointY.Text != "")
|
|
|
+ {
|
|
|
+ DrawPointCoordinates(g, topLeftCircle, tB_LTPointX.Text, tB_LTPointY.Text, "LT");
|
|
|
+ }
|
|
|
+ // 显示右下角点坐标
|
|
|
+ if (tB_RBPointX.Text != "" && tB_RBPointY.Text != "")
|
|
|
+ {
|
|
|
+ DrawPointCoordinates(g, bottomRightCircle, tB_RBPointX.Text, tB_RBPointY.Text, "RB");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 绘制坐标值
|
|
|
+ private void DrawPointCoordinates(Graphics g, RectangleF circleRect, string xValue, string yValue, string Pointlocation)
|
|
|
+ {
|
|
|
+ string coordinates = $"({xValue}, {yValue})";
|
|
|
+
|
|
|
+ // 使用高质量文本渲染
|
|
|
+ g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
|
|
|
+
|
|
|
+ // 定义字体
|
|
|
+ using (Font font = new Font("微软雅黑", 8, FontStyle.Regular))
|
|
|
+ {
|
|
|
+ // 测量文字大小
|
|
|
+ SizeF textSize = g.MeasureString(coordinates, font);
|
|
|
+
|
|
|
+ float textX, textY;
|
|
|
+
|
|
|
+ if (Pointlocation == "LT")
|
|
|
+ {
|
|
|
+ // 左上角点:坐标显示在右下方
|
|
|
+ textX = circleRect.Right + 5;
|
|
|
+ textY = circleRect.Bottom + 5;
|
|
|
+ }
|
|
|
+ else if (Pointlocation == "RB")
|
|
|
+ {
|
|
|
+ // 右下角点:坐标显示在左上方
|
|
|
+ textX = circleRect.Left - textSize.Width - 5;
|
|
|
+ textY = circleRect.Top - textSize.Height - 5;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 对于其他点(包括第三个点):坐标显示在下方
|
|
|
+ textX = circleRect.X + (circleRect.Width - textSize.Width) / 2; // 居中
|
|
|
+ textY = circleRect.Bottom + 5; // 下方5像素
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确保文字不会超出边界
|
|
|
+ if (textX < 0) textX = 0;
|
|
|
+ if (textY < 0) textY = 0;
|
|
|
+ if (textX + textSize.Width > panel1.Width) textX = panel1.Width - textSize.Width;
|
|
|
+ if (textY + textSize.Height > panel1.Height) textY = panel1.Height - textSize.Height;
|
|
|
+ // 绘制坐标文字(银白色)
|
|
|
+ using (SolidBrush textBrush = new SolidBrush(Color.White))
|
|
|
+ {
|
|
|
+ g.DrawString(coordinates, font, textBrush, textX, textY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 绘制"任意非对角线点"文字标识
|
|
|
+ private void DrawNonDiagonalPointLabel(Graphics g, RectangleF circleRect)
|
|
|
+ {
|
|
|
+ string labelText = "任意非对角线点";
|
|
|
+
|
|
|
+ // 使用高质量文本渲染
|
|
|
+ g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
|
|
|
+
|
|
|
+ // 定义字体
|
|
|
+ using (Font font = new Font("微软雅黑", 9, FontStyle.Bold))
|
|
|
+ {
|
|
|
+ // 测量文字大小
|
|
|
+ SizeF textSize = g.MeasureString(labelText, font);
|
|
|
+
|
|
|
+ // 计算文字位置(在圆圈上方居中)
|
|
|
+ float textX = circleRect.X + (circleRect.Width - textSize.Width) / 2;
|
|
|
+ float textY = circleRect.Y - textSize.Height - 5; // 上方5像素间距
|
|
|
+
|
|
|
+ // 创建文字路径以实现轮廓效果
|
|
|
+ using (GraphicsPath textPath = new GraphicsPath())
|
|
|
+ {
|
|
|
+ textPath.AddString(
|
|
|
+ labelText,
|
|
|
+ FontFamily.GenericSansSerif,
|
|
|
+ (int)FontStyle.Bold,
|
|
|
+ g.DpiY * 9 / 72, // 9pt 转换为像素
|
|
|
+ new PointF(textX, textY),
|
|
|
+ StringFormat.GenericDefault);
|
|
|
+
|
|
|
+ // 绘制文字阴影效果
|
|
|
+ using (Matrix translateMatrix = new Matrix())
|
|
|
+ {
|
|
|
+ translateMatrix.Translate(1, 1);
|
|
|
+ textPath.Transform(translateMatrix);
|
|
|
+
|
|
|
+ using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(120, 0, 0, 0)))
|
|
|
+ {
|
|
|
+ g.FillPath(shadowBrush, textPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 恢复原始位置
|
|
|
+ translateMatrix.Reset();
|
|
|
+ translateMatrix.Translate(-1, -1);
|
|
|
+ textPath.Transform(translateMatrix);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 绘制文字主体(深绿色)
|
|
|
+ using (SolidBrush textBrush = new SolidBrush(Color.DarkGreen))
|
|
|
+ {
|
|
|
+ g.FillPath(textBrush, textPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 绘制文字边框(可选)
|
|
|
+ using (Pen textPen = new Pen(Color.FromArgb(180, Color.ForestGreen), 0.5f))
|
|
|
+ {
|
|
|
+ g.DrawPath(textPen, textPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 绘制高级效果矩形(绿色背景)
|
|
|
+ private void DrawAdvancedRectangle(Graphics g, RectangleF rect)
|
|
|
+ {
|
|
|
+ // 创建圆角矩形路径
|
|
|
+ using (GraphicsPath path = new GraphicsPath())
|
|
|
+ {
|
|
|
+ float radius = 10f;
|
|
|
+ path.AddArc(rect.X, rect.Y, radius, radius, 180, 90);
|
|
|
+ path.AddArc(rect.Right - radius, rect.Y, radius, radius, 270, 90);
|
|
|
+ path.AddArc(rect.Right - radius, rect.Bottom - radius, radius, radius, 0, 90);
|
|
|
+ path.AddArc(rect.X, rect.Bottom - radius, radius, radius, 90, 90);
|
|
|
+ path.CloseFigure();
|
|
|
+
|
|
|
+ // 填充绿色渐变背景
|
|
|
+ using (LinearGradientBrush brush = new LinearGradientBrush(
|
|
|
+ rect, Color.FromArgb(144, 238, 144), Color.FromArgb(0, 100, 0), 45f)) // 浅绿到深绿
|
|
|
+ {
|
|
|
+ g.FillPath(brush, path);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 绘制外边框
|
|
|
+ using (Pen pen = new Pen(Color.FromArgb(0, 100, 0), 2)) // 深绿色边框
|
|
|
+ {
|
|
|
+ g.DrawPath(pen, path);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 添加内部发光效果
|
|
|
+ using (Pen innerPen = new Pen(Color.FromArgb(144, 255, 144), 1)) // 浅绿色内边框
|
|
|
+ {
|
|
|
+ innerPen.Alignment = PenAlignment.Inset;
|
|
|
+ RectangleF innerRect = new RectangleF(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
|
|
|
+ using (GraphicsPath innerPath = new GraphicsPath())
|
|
|
+ {
|
|
|
+ float innerRadius = 8f;
|
|
|
+ innerPath.AddArc(innerRect.X, innerRect.Y, innerRadius, innerRadius, 180, 90);
|
|
|
+ innerPath.AddArc(innerRect.Right - innerRadius, innerRect.Y, innerRadius, innerRadius, 270, 90);
|
|
|
+ innerPath.AddArc(innerRect.Right - innerRadius, innerRect.Bottom - innerRadius, innerRadius, innerRadius, 0, 90);
|
|
|
+ innerPath.AddArc(innerRect.X, innerRect.Bottom - innerRadius, innerRadius, innerRadius, 90, 90);
|
|
|
+ innerPath.CloseFigure();
|
|
|
+ g.DrawPath(innerPen, innerPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加阴影效果
|
|
|
+ using (Pen shadowPen = new Pen(Color.FromArgb(50, 0, 0, 0), 3))
|
|
|
+ {
|
|
|
+ shadowPen.Alignment = PenAlignment.Outset;
|
|
|
+ g.DrawPath(shadowPen, path);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 绘制高级效果圆圈(黄色)
|
|
|
+ private void DrawAdvancedCircle(Graphics g, RectangleF circleRect, bool isHovered)
|
|
|
+ {
|
|
|
+ // 创建圆形路径
|
|
|
+ using (GraphicsPath path = new GraphicsPath())
|
|
|
+ {
|
|
|
+ path.AddEllipse(circleRect);
|
|
|
+
|
|
|
+ // 使用黄色系
|
|
|
+ Color centerColor = isHovered ? Color.Gold : Color.Yellow; // 悬停时用金色,正常时用黄色
|
|
|
+ Color rimColor = isHovered ? Color.Orange : Color.Goldenrod; // 悬停时用橙色,正常时用金麒麟色
|
|
|
+
|
|
|
+ // 径向渐变画刷
|
|
|
+ using (PathGradientBrush brush = new PathGradientBrush(path))
|
|
|
+ {
|
|
|
+ brush.CenterColor = centerColor;
|
|
|
+ brush.SurroundColors = new Color[] { rimColor };
|
|
|
+ brush.CenterPoint = new PointF(
|
|
|
+ circleRect.X + circleRect.Width / 2,
|
|
|
+ circleRect.Y + circleRect.Height / 2);
|
|
|
+
|
|
|
+ // 设置焦点缩放以创建更好的渐变效果
|
|
|
+ brush.FocusScales = new PointF(0.3f, 0.3f);
|
|
|
+
|
|
|
+ g.FillPath(brush, path);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加高光效果(左上角的小圆形高光)
|
|
|
+ RectangleF highlightRect = new RectangleF(
|
|
|
+ circleRect.X + circleRect.Width * 0.15f,
|
|
|
+ circleRect.Y + circleRect.Height * 0.15f,
|
|
|
+ circleRect.Width * 0.3f,
|
|
|
+ circleRect.Height * 0.3f);
|
|
|
+
|
|
|
+ using (SolidBrush highlightBrush = new SolidBrush(Color.FromArgb(200, Color.White)))
|
|
|
+ {
|
|
|
+ g.FillEllipse(highlightBrush, highlightRect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加边框
|
|
|
+ using (Pen pen = new Pen(Color.FromArgb(200, Color.SaddleBrown), isHovered ? 2.5f : 1.5f))
|
|
|
+ {
|
|
|
+ g.DrawEllipse(pen, circleRect);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加外发光效果
|
|
|
+ if (isHovered)
|
|
|
+ {
|
|
|
+ using (Pen glowPen = new Pen(Color.FromArgb(100, Color.Orange), 3))
|
|
|
+ {
|
|
|
+ glowPen.Alignment = PenAlignment.Outset;
|
|
|
+ g.DrawEllipse(glowPen, circleRect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 鼠标移动事件处理
|
|
|
+ private void Panel1_MouseMove(object sender, MouseEventArgs e)
|
|
|
+ {
|
|
|
+ bool wasInTopLeft = isMouseInTopLeft;
|
|
|
+ bool wasInBottomRight = isMouseInBottomRight;
|
|
|
+ bool wasInThirdPoint = isMouseInThirdPoint;
|
|
|
+
|
|
|
+ // 检测鼠标是否在圆圈内
|
|
|
+ isMouseInTopLeft = IsPointInCircle(e.Location, topLeftCircle);
|
|
|
+ isMouseInBottomRight = IsPointInCircle(e.Location, bottomRightCircle);
|
|
|
+
|
|
|
+ // 只有在选中倾斜平面焦点时才检查第三个点
|
|
|
+ if (cB_Inclinedplanefocus.Checked)
|
|
|
+ {
|
|
|
+ isMouseInThirdPoint = IsPointInCircle(e.Location, thirdPointCircle);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ isMouseInThirdPoint = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果状态发生变化,刷新显示并更新GroupBox高亮
|
|
|
+ if (wasInTopLeft != isMouseInTopLeft ||
|
|
|
+ wasInBottomRight != isMouseInBottomRight ||
|
|
|
+ wasInThirdPoint != isMouseInThirdPoint)
|
|
|
+ {
|
|
|
+ panel1.Invalidate();
|
|
|
+
|
|
|
+ // 更新GroupBox高亮状态
|
|
|
+ if (wasInTopLeft != isMouseInTopLeft)
|
|
|
+ UpdateGroupBoxHighlight(groupBox1, isMouseInTopLeft);
|
|
|
+
|
|
|
+ if (wasInBottomRight != isMouseInBottomRight)
|
|
|
+ UpdateGroupBoxHighlight(groupBox2, isMouseInBottomRight);
|
|
|
+
|
|
|
+ if (wasInThirdPoint != isMouseInThirdPoint)
|
|
|
+ UpdateGroupBoxHighlight(groupBox3, isMouseInThirdPoint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 鼠标离开Panel区域
|
|
|
+ private void Panel1_MouseLeave(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ bool wasInTopLeft = isMouseInTopLeft;
|
|
|
+ bool wasInBottomRight = isMouseInBottomRight;
|
|
|
+ bool wasInThirdPoint = isMouseInThirdPoint;
|
|
|
+
|
|
|
+ isMouseInTopLeft = false;
|
|
|
+ isMouseInBottomRight = false;
|
|
|
+ isMouseInThirdPoint = false;
|
|
|
+
|
|
|
+ panel1.Invalidate();
|
|
|
+
|
|
|
+ // 取消GroupBox高亮
|
|
|
+ if (wasInTopLeft)
|
|
|
+ UpdateGroupBoxHighlight(groupBox1, false);
|
|
|
+ if (wasInBottomRight)
|
|
|
+ UpdateGroupBoxHighlight(groupBox2, false);
|
|
|
+ if (wasInThirdPoint)
|
|
|
+ UpdateGroupBoxHighlight(groupBox3, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查点是否在圆内
|
|
|
+ private bool IsPointInCircle(Point point, RectangleF circle)
|
|
|
+ {
|
|
|
+ if (circle.IsEmpty) return false;
|
|
|
+
|
|
|
+ float centerX = circle.X + circle.Width / 2;
|
|
|
+ float centerY = circle.Y + circle.Height / 2;
|
|
|
+ float radius = circle.Width / 2;
|
|
|
+
|
|
|
+ float distance = (float)Math.Sqrt(
|
|
|
+ Math.Pow(point.X - centerX, 2) +
|
|
|
+ Math.Pow(point.Y - centerY, 2));
|
|
|
+
|
|
|
+ return distance <= radius;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新GroupBox高亮效果
|
|
|
+ private void UpdateGroupBoxHighlight(GroupBox groupBox, bool isHighlighted)
|
|
|
+ {
|
|
|
+ if (groupBox == null) return;
|
|
|
+
|
|
|
+ if (isHighlighted)
|
|
|
+ {
|
|
|
+ // 高亮效果:黄色边框和浅绿色背景
|
|
|
+ groupBox.BackColor = Color.FromArgb(240, 255, 240);
|
|
|
+ groupBox.ForeColor = Color.DarkGreen;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // 恢复默认样式
|
|
|
+ groupBox.BackColor = SystemColors.Control;
|
|
|
+ groupBox.ForeColor = SystemColors.ControlText;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 强制刷新GroupBox显示
|
|
|
+ groupBox.Invalidate();
|
|
|
+ }
|
|
|
}
|
|
|
}
|