예제 #1
0
파일: TracePanel.cs 프로젝트: 1907931256/jx
 public void MouseHoverHandle(EventArgs e)
 {
     if (!_monitorPoints.IsNullOrEmpty())
     {
         Point center = Bounds.CenterPoint();
         center.Offset(-Location.X, -Location.Y);
         Rectangle hintRegion = new Rectangle(center.X - MonitorPointRadius - 2 * DrawMonitorWidth, center.Y - MonitorPointRadius - 2 * DrawMonitorWidth, (2 * DrawMonitorWidth + MonitorPointRadius) * 2, (2 * DrawMonitorWidth + MonitorPointRadius) * 2);
         if (hintRegion.Contains(PointToClient(MousePosition)))
         {
             TraceMonitorPoint tmp  = _monitorPoints[0];
             String            hint = String.Format("名      称:{0}\r\n进入时间:{1}", tmp.Name, tmp.Arrive);
             ShowToolTip(hint);
         }
     }
 }
예제 #2
0
파일: TracePanel.cs 프로젝트: 1907931256/jx
        private void DrawMonitor()//Modify later to support multi
        {
            Graphics g = CreateGraphics();

            foreach (TraceMonitorPoint monitorPoint in _monitorPoints)
            {
                Pen        p      = new Pen(monitorPoint.Color, DrawMonitorWidth);
                SolidBrush sb     = new SolidBrush(monitorPoint.Color);
                Point      center = Bounds.CenterPoint();
                center.Offset(-Location.X, -Location.Y);
                g.FillEllipse(sb, new Rectangle(center.X - MonitorPointRadius, center.Y - MonitorPointRadius, MonitorPointRadius * 2, MonitorPointRadius * 2));
                g.DrawEllipse(p, center.X - MonitorPointRadius - 2 * DrawMonitorWidth, center.Y - MonitorPointRadius - 2 * DrawMonitorWidth, (2 * DrawMonitorWidth + MonitorPointRadius) * 2, (2 * DrawMonitorWidth + MonitorPointRadius) * 2);
                p.Dispose();
                sb.Dispose();
            }
            g.Dispose();
        }
예제 #3
0
파일: TracePanel.cs 프로젝트: 1907931256/jx
        private void DrawTrace()
        {
            Pen      linePen = new Pen(_traceColor, DrawTraceWidth);
            Graphics g       = CreateGraphics();

            foreach (TraceChain tc in _traceChains)
            {
                Point previous = GetAnchorPoint(tc.PreviousCtrl);//这个点以当前控件的父窗体为坐标系
                Point next     = GetAnchorPoint(tc.NextCtrl);
                if (tc.PreviousCtrl == tc.NextCtrl)
                {
                    next = Bounds.CenterPoint();
                }
                RectangleF inflateBounds = new Rectangle(Bounds.Location, Bounds.Size);
                inflateBounds.Inflate(-0.1f, -0.1f);
                if (!previous.IsEmpty && !next.IsEmpty) //不是起点和终点
                {
                    Point      anglePoint1  = new Point(previous.X, next.Y);
                    Point      anglePoint2  = new Point(next.X, previous.Y);
                    SolidBrush brushTraceBy = new SolidBrush(_traceGobyColor);
                    if (inflateBounds.Contains(anglePoint1) || inflateBounds.Contains(anglePoint2))
                    {//若有一个折点位于空间内,则以此点为中转点
                        Point anglePoint = inflateBounds.Contains(anglePoint1) ? anglePoint1 : anglePoint2;
                        previous.Offset(-Location.X, -Location.Y);
                        anglePoint.Offset(-Location.X, -Location.Y);
                        next.Offset(-Location.X, -Location.Y);
                        g.DrawLines(linePen, new[] { previous, anglePoint, next });
                        if (tc.PreviousCtrl != tc.NextCtrl)
                        {
                            g.FillEllipse(brushTraceBy, new Rectangle(anglePoint.X - TracePointRadius, anglePoint.Y - TracePointRadius, TracePointRadius * 2, TracePointRadius * 2));
                        }
                        else
                        {
                            g.FillEllipse(brushTraceBy, new Rectangle(next.X - TracePointRadius, next.Y - TracePointRadius, TracePointRadius * 2, TracePointRadius * 2));
                        }
                    }
                    else
                    {
                        Point intermediatePoint = new Point((previous.X + next.X) / 2, (previous.Y + next.Y) / 2); //中点,若中点位于空间内,则以此点作为中转点
                        if (!inflateBounds.Contains(intermediatePoint))                                            //若中点不位于空间内,则以空间中点作为中转点
                        {
                            intermediatePoint = Bounds.CenterPoint();
                        }
                        Point centerAnglePoint1    = new Point(previous.X, intermediatePoint.Y);
                        Point centerAnglePoint2    = new Point(intermediatePoint.X, previous.Y);
                        Point centerAnglePointPrev = inflateBounds.Contains(centerAnglePoint1) ? centerAnglePoint1 : centerAnglePoint2;
                        centerAnglePoint1 = new Point(next.X, intermediatePoint.Y);
                        centerAnglePoint2 = new Point(intermediatePoint.X, next.Y);
                        Point centerAnglePointNext = inflateBounds.Contains(centerAnglePoint1) ? centerAnglePoint1 : centerAnglePoint2;
                        previous.Offset(-Location.X, -Location.Y);//转变为控件本身为坐标系的点
                        centerAnglePointPrev.Offset(-Location.X, -Location.Y);
                        centerAnglePointNext.Offset(-Location.X, -Location.Y);
                        next.Offset(-Location.X, -Location.Y);
                        intermediatePoint.Offset(-Location.X, -Location.Y);
                        g.DrawLines(linePen, new[] { previous, centerAnglePointPrev, centerAnglePointNext, next });

                        g.FillEllipse(brushTraceBy, new Rectangle(intermediatePoint.X - TracePointRadius, intermediatePoint.Y - TracePointRadius, TracePointRadius * 2, TracePointRadius * 2));
                    }
                    brushTraceBy.Dispose();
                }
                else if (previous.IsEmpty && next.IsEmpty)
                {
                    continue;
                }
                else //如果是起点,或者是终点
                {
                    Point anchorPoint       = previous.IsEmpty ? next : previous;
                    Point intermediatePoint = Bounds.CenterPoint();
                    intermediatePoint.X += previous.IsEmpty ? -TracePointOffset * 2 : TracePointOffset * 2;
                    SolidBrush brushSourceDest = new SolidBrush(previous.IsEmpty ? _traceStartColor : _traceEndColor);
                    Point      anglePoint1     = new Point(anchorPoint.X, intermediatePoint.Y);
                    Point      anglePoint2     = new Point(intermediatePoint.X, anchorPoint.Y);
                    Point      anglePoint      = inflateBounds.Contains(anglePoint1) ? anglePoint1 : anglePoint2;

                    anchorPoint.Offset(-Location.X, -Location.Y);
                    anglePoint.Offset(-Location.X, -Location.Y);
                    intermediatePoint.Offset(-Location.X, -Location.Y);
                    g.DrawLines(linePen, new[] { anchorPoint, anglePoint, intermediatePoint });
                    g.FillEllipse(brushSourceDest, new Rectangle(intermediatePoint.X - TracePointRadius, intermediatePoint.Y - TracePointRadius, TracePointRadius * 2, TracePointRadius * 2));
                    brushSourceDest.Dispose();
                }
            }

            g.Dispose();
            linePen.Dispose();
        }