예제 #1
0
        private void InitalCursor(string CursorName)
        {
            Font   font   = new Font("宋体", 8);
            string format = "{0:0.00}";
            double ang    = 45;

            if (CursorName == "Ref")
            {
                RefCursor            = new FigCursor();
                RefCursor.color      = Color.Red;
                RefCursor.InfoFont   = font;
                RefCursor.InfoFormat = format;
                RefCursor.p          = new Point(0, 0);
                RefCursor.angle      = ang;
                RefCursor.beamPx     = 45;
                RefCursor.Name       = "Ref";
            }
            if (CursorName == "Mea")
            {
                MeaCursor            = new FigCursor();
                MeaCursor.color      = Color.Blue;
                MeaCursor.InfoFont   = font;
                MeaCursor.InfoFormat = format;
                MeaCursor.p          = new Point(0, 0);
                MeaCursor.angle      = ang;
                MeaCursor.beamPx     = 90;
                MeaCursor.Name       = "Mea";
            }
            MouseState = "+";
        }
예제 #2
0
 /// <summary>
 /// 控件缩放时重置光标位置
 /// </summary>
 /// <param name="csor"></param>
 /// <param name="CurrentPf"></param>
 private void ResetCursorPos(FigCursor csor, double[] CurrentPf)
 {
     if (csor != null)
     {
         csor.p = new Point((int)(Math.Round((CurrentPf[0] - _sx) / kx)),
                            (int)(Math.Round(CurrentPf[1] - _ey) / ky));
     }
 }
예제 #3
0
 private void ResetCurrentCursor(FigCursor csor)
 {
     if (csor != null)
     {
         double[] tmp = ReWriteAxisData(csor.pdata.X, csor.pdata.Y);
         if (csor.Name == "Ref")
         {
             CurrentRefP = tmp;
         }
         else
         {
             CurrentMeaP = tmp;
         }
         ResetCursorPos(csor, tmp);
     }
 }
예제 #4
0
 private void ResetCurrentCursor(FigCursor csor, int x, int y)
 {
     if (csor != null)
     {
         double[] tmp = ReWriteAxisData(x * kx + _sx, y * ky + _ey);
         csor.pdata.X = (float)tmp[0];
         csor.pdata.Y = (float)tmp[1];
         if (csor.Name == "Ref")
         {
             CurrentRefP = tmp;
         }
         if (csor.Name == "Mea")
         {
             CurrentMeaP = tmp;
         }
         ResetCursorPos(csor, tmp);
     }
 }
예제 #5
0
        private void StateCursor(FigCursor csor, Point p)
        {
            string tmp;

            if (csor != null)
            {
                tmp = csor.MouseState(p);

                if (tmp == "X")
                {
                    Cursor     = Cursors.VSplit;
                    MouseState = csor.Name + "X";
                }
                if (tmp == "Y")
                {
                    Cursor     = Cursors.HSplit;
                    MouseState = csor.Name + "Y";
                }
                if (tmp == null)
                {
                    MouseState = "+";
                }
            }
        }
예제 #6
0
        private void UltraToolLayout_MouseUp(object sender, MouseEventArgs e)
        {
            ///重置缩放区域
            if (zoomRegion != null && zoomRegion.width != 0 && zoomRegion.height != 0)
            {
                FigCursor ft = new FigCursor();
                ResetCurrentCursor(ft, zoomRegion.minX, zoomRegion.minY);
                double sx = ft.pdata.X;
                double ey = ft.pdata.Y;
                int    xa = ft.p.X;
                int    ya = ft.p.Y;
                ResetCurrentCursor(ft, zoomRegion.minX + zoomRegion.width - 1, zoomRegion.minY + zoomRegion.height - 1);
                double ex = ft.pdata.X;
                double sy = ft.pdata.Y;
                int    xb = ft.p.X;
                int    yb = ft.p.Y;
                startX = sx;
                endX   = ex;
                startY = sy;
                endY   = ey;
                Console.WriteLine(new Rectangle(xa, ya, xb - xa, yb - ya));
                Console.WriteLine("sx=" + sx.ToString());
                Console.WriteLine("ex=" + ex.ToString());
                Console.WriteLine("sy=" + sy.ToString());
                Console.WriteLine("ey=" + ey.ToString());

                if (xb > xa & yb > ya)
                {
                    RangeChanged?.Invoke(new float[] { xa, ya, xb - xa, yb - ya,
                                                       (float)sx, (float)ex, (float)sy, (float)ey });
                }
            }
            zoomRegion = null;

            ///1 鼠标双击时,设置光标,并获取当前光标相对位置
            ///2 重置双击状态
            if (MouseIsDoubleClick)
            {
                kx = (_ex - _sx) / (Width - 1.0);
                ky = (_sy - _ey) / (Height - 1.0);
                if (e.Button == MouseButtons.Left)
                {
                    InitalCursor("Ref", e.Location);
                    ResetCurrentCursor(RefCursor, e.X, e.Y);
                }
                else
                {
                    InitalCursor("Mea", e.Location);
                    ResetCurrentCursor(MeaCursor, e.X, e.Y);
                }
                MouseIsDoubleClick = false;
            }
            Invalidate();

            ///重置光标选定信息和状态信息
            MouseLeftIsDown = false;
            if (RefCursor != null)
            {
                RefCursor.Selected = false;
            }
            if (MeaCursor != null)
            {
                MeaCursor.Selected = false;
            }
            MouseState = "+";
        }