Ejemplo n.º 1
0
 //=============================================================================
 public void Draw(ICoordinateSystem cs, DrawingContext dc)
 {
     if (cs != null && dc != null && m_bFirstPnt_Setted)
     {
         Pen _pen = new Pen(new SolidColorBrush(m_Color), m_Thickness);
         dc.DrawLine(_pen, cs.GetLocalPoint(m_FirstPnt), cs.GetLocalPoint(m_SecondPnt));
     }
 }
Ejemplo n.º 2
0
        //=============================================================================
        public void Draw(ICoordinateSystem cs, DrawingContext dc)
        {
            if (cs != null && dc != null && m_points.Count > 0)
            {
                Pen _pen = new Pen(new SolidColorBrush(m_Color), m_Thickness);

                for (int i = 1; i < m_points.Count; ++i)
                {
                    dc.DrawLine(_pen, cs.GetLocalPoint(m_points[i - 1]), cs.GetLocalPoint(m_points[i]));
                }

                if (!m_IsPlaced && m_bIsTempPointSetted)
                {
                    dc.DrawLine(_pen, cs.GetLocalPoint(m_points[m_points.Count - 1]), cs.GetLocalPoint(m_TempPoint));
                }
            }
        }
Ejemplo n.º 3
0
 //=============================================================================
 public void Draw(ICoordinateSystem cs, DrawingContext dc)
 {
     if (cs != null && dc != null && m_bFirstPnt_Setted)
     {
         Pen _pen = new Pen(new SolidColorBrush(m_Color), m_Thickness);
         //
         // If fill with transparent color then circle fill area will act in HitTest.
         // Fill with null brush will disable circle HitTest on click in fill area.
         Brush fillBrush = null;
         if (m_FillColor != Colors.Transparent)
         {
             fillBrush = new SolidColorBrush(m_FillColor);
         }
         dc.DrawRectangle(fillBrush, _pen, new Rect(cs.GetLocalPoint(m_FirstPnt), cs.GetLocalPoint(m_SecondPnt)));
     }
 }
Ejemplo n.º 4
0
        //=============================================================================
        public void Draw(ICoordinateSystem cs, DrawingContext dc)
        {
            if (!m_bCenter_IsSetted)
            {
                return;
            }

            if (cs != null && dc != null)
            {
                Pen _pen = new Pen(new SolidColorBrush(m_Color), m_Thickness);
                //
                // If fill with transparent color then circle fill area will act in HitTest.
                // Fill with null brush will disable circle HitTest on click in fill area.
                Brush fillBrush = null;
                if (m_FillColor != Colors.Transparent)
                {
                    fillBrush = new SolidColorBrush(m_FillColor);
                }

                double rScale = cs.Get_Scale();

                dc.DrawEllipse(fillBrush, _pen, cs.GetLocalPoint(m_pntCenter), m_rRadius * rScale, m_rRadius * rScale);
            }
        }
Ejemplo n.º 5
0
        //=============================================================================
        public void Draw(ICoordinateSystem cs, DrawingContext dc)
        {
            if (cs != null && dc != null && m_bFirstPnt_IsSetted)
            {
                Pen _pen = new Pen(new SolidColorBrush(m_Color), m_Thickness);

                PathFigure pf = new PathFigure();
                if (!m_bInvalidData && m_bSecondPnt_IsSetted)
                {
                    double scaledRadius = m_rRadius * cs.Get_Scale();

                    double rFirstAngle = Math.Atan2(m_FirstPnt.Y - m_CenterPnt.Y, m_FirstPnt.X - m_CenterPnt.X);
                    // Atan2 return result in [-pi, pi]. Convert it to [0, 2pi].
                    if (rFirstAngle < 0)
                    {
                        rFirstAngle += 2 * Math.PI;
                    }
                    double rSecondAngle = Math.Atan2(m_SecondPnt.Y - m_CenterPnt.Y, m_SecondPnt.X - m_CenterPnt.X);
                    if (rSecondAngle < 0)
                    {
                        rSecondAngle += 2 * Math.PI;
                    }
                    double rThirdAngle = Math.Atan2(m_ThirdPnt.Y - m_CenterPnt.Y, m_ThirdPnt.X - m_CenterPnt.X);
                    if (rThirdAngle < 0)
                    {
                        rThirdAngle += 2 * Math.PI;
                    }

                    Point          startPnt    = m_FirstPnt;
                    Point          endPnt      = new Point(0, 0);
                    SweepDirection sd          = SweepDirection.Clockwise;
                    bool           bIsLargeArc = false;
                    if (rFirstAngle > rSecondAngle)
                    {
                        if (rFirstAngle > rThirdAngle)
                        {
                            if (rSecondAngle > rThirdAngle)
                            {
                                endPnt = m_ThirdPnt;
                                sd     = SweepDirection.Clockwise;
                                //sd = SweepDirection.Counterclockwise;
                                bIsLargeArc = (rFirstAngle - rThirdAngle) >= Math.PI;
                            }
                            else
                            {
                                endPnt = m_ThirdPnt;
                                sd     = SweepDirection.Counterclockwise;
                                //sd = SweepDirection.Clockwise;
                                bIsLargeArc = (2 * Math.PI - (rFirstAngle - rThirdAngle)) >= Math.PI;
                            }
                        }
                        else
                        {
                            endPnt = m_ThirdPnt;
                            sd     = SweepDirection.Clockwise;
                            //sd = SweepDirection.Counterclockwise;

                            double rDiff = rFirstAngle - rThirdAngle;
                            rDiff      += 2 * Math.PI;
                            bIsLargeArc = rDiff >= Math.PI;
                        }
                    }
                    else
                    {
                        if (rFirstAngle > rThirdAngle)
                        {
                            endPnt = m_ThirdPnt;
                            sd     = SweepDirection.Counterclockwise;
                            //sd = SweepDirection.Clockwise;

                            double rDiff = rFirstAngle - rThirdAngle;
                            rDiff      -= 2 * Math.PI;
                            bIsLargeArc = Math.Abs(rDiff) >= Math.PI;
                        }
                        else
                        {
                            if (rSecondAngle > rThirdAngle)
                            {
                                endPnt = m_ThirdPnt;
                                sd     = SweepDirection.Clockwise;
                                //sd = SweepDirection.Counterclockwise;

                                double rDiff = rFirstAngle - rThirdAngle;
                                rDiff      += 2 * Math.PI;
                                bIsLargeArc = Math.Abs(rDiff) >= Math.PI;
                            }
                            else
                            {
                                endPnt = m_ThirdPnt;
                                sd     = SweepDirection.Counterclockwise;
                                //sd = SweepDirection.Clockwise;

                                double rDiff = rFirstAngle - rThirdAngle;
                                //if (true || rDiff > 0)
                                //	rDiff += 2 * Math.PI;
                                bIsLargeArc = Math.Abs(rDiff) >= Math.PI;
                            }
                        }
                    }
                    pf.StartPoint = cs.GetLocalPoint(startPnt);
                    // draw arc
                    pf.Segments.Add(new ArcSegment(cs.GetLocalPoint(endPnt), new Size(scaledRadius, scaledRadius), 0, bIsLargeArc, sd, true));

                    // DEBUG INFO
                    if (false)
                    {
                        string str = string.Format("{0:F2}, {1:F2}, {2:F2}", rFirstAngle, rSecondAngle, rThirdAngle);
                        Debug.WriteLine(str);

                        Vector vec  = new Vector(4.0, 4.0);
                        Point  pnt  = cs.GetLocalPoint(m_SecondPnt);
                        Point  pnt1 = pnt - vec;
                        Point  pnt2 = pnt + vec;
                        Rect   rect = new Rect(pnt1, pnt2);
                        dc.DrawRectangle(Brushes.Aqua, _pen, rect);

                        pnt  = cs.GetLocalPoint(m_CenterPnt);
                        pnt1 = pnt - vec;
                        pnt2 = pnt + vec;
                        rect = new Rect(pnt1, pnt2);
                        dc.DrawRectangle(Brushes.Red, _pen, rect);

                        dc.DrawEllipse(null, new Pen(new SolidColorBrush(Colors.Red), 3), cs.GetLocalPoint(m_CenterPnt), scaledRadius, scaledRadius);
                    }
                }
                else
                {
                    pf.StartPoint = cs.GetLocalPoint(m_FirstPnt);
                    // draw line
                    pf.Segments.Add(new LineSegment(cs.GetLocalPoint(m_SecondPnt), true));
                }

                PathGeometry pg = new PathGeometry(new[] { pf });

                dc.DrawGeometry(null, _pen, pg);
            }
        }