Example #1
0
        private static SupportingPoint CalculateSymmetricPoint(SupportingPoint symmetryCenter, SupportingPoint point)
        {
            double x = symmetryCenter.X - (point.X - symmetryCenter.X);
            double y = symmetryCenter.Y - (point.Y - symmetryCenter.Y);

            return(new SupportingPoint(x, y));
        }
Example #2
0
        private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (m_cursorMode == CursorMode.MovingPoints || m_isCurveDrawn)
            {
                return;
            }

            switch (m_lineType)
            {
            case BezierLineType.ArbitraryOrder:
            {
                var supportingPoint = new SupportingPoint(e.GetPosition(Canvas));
                AddHandlers(supportingPoint);
                m_points.Add(supportingPoint);
                Canvas.Children.Add(supportingPoint);
            }
            break;

            case BezierLineType.ThirdOrder:
            {
                if (m_points.Count == 4)
                {
                    return;
                }
                var supportingPoint = new SupportingPoint(e.GetPosition(Canvas));
                AddHandlers(supportingPoint);
                m_points.Add(supportingPoint);
                Canvas.Children.Add(supportingPoint);
            }
            break;

            case BezierLineType.CompositeThirdOrder:
            {
                var supportingPoint = new SupportingPoint(e.GetPosition(Canvas));
                AddHandlers(supportingPoint);
                m_points.Add(supportingPoint);
                Canvas.Children.Add(supportingPoint);

                if (m_points.Count % 6 == 4 || (m_points.Count > 4 && m_points.Count % 6 == 1))
                {
                    var size = m_points.Count;
                    supportingPoint = Utility.CalculateSymmetricPoint(m_points[size - 1], m_points[size - 2]);
                    AddHandlers(supportingPoint);
                    m_points.Add(supportingPoint);
                    Canvas.Children.Add(supportingPoint);
                }
            }
            break;

            default:
            {
                throw new Exception("Wrong BezierLineType");
            }
            }
        }
Example #3
0
 public void AddPoint(SupportingPoint point)
 {
     m_supportingPoints.Add(point);
 }
        public object Clone()
        {
            var result = new SupportingPoint(X, Y);

            return(result);
        }
Example #5
0
 public Edge(SupportingPoint begin, SupportingPoint middle, SupportingPoint end)
 {
     Points.Add(begin);
     Points.Add(middle);
     Points.Add(end);
 }
Example #6
0
 private void AddHandlers(SupportingPoint supportingPoint)
 {
     supportingPoint.MouseLeftButtonDown += PointStartMoving;
     supportingPoint.MouseMove           += PointMoving;
     supportingPoint.MouseLeftButtonUp   += PointEndMoving;
 }