コード例 #1
0
        /// <summary>
        /// Creates a new instance of the XQBezier class.
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="x3"></param>
        /// <param name="y3"></param>
        /// <param name="isStroked"></param>
        /// <param name="isFilled"></param>
        /// <returns></returns>
        public XQBezier QBezier(
            double x1      = 30, double y1 = 30,
            double x2      = 45, double y2 = 60,
            double x3      = 60, double y3 = 30,
            bool isStroked = true,
            bool isFilled  = false)
        {
            var qbezier = XQBezier.Create(
                x1, y1,
                x2, y2,
                x3, y3,
                Context.Editor.Project.CurrentStyleLibrary.CurrentStyle,
                Context.Editor.Project.Options.PointShape,
                isStroked,
                isFilled);

            Context.Editor.AddWithHistory(qbezier);
            return(qbezier);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new instance of the XQBezier class.
        /// </summary>
        /// <param name="point1"></param>
        /// <param name="point2"></param>
        /// <param name="point3"></param>
        /// <param name="isStroked"></param>
        /// <param name="isFilled"></param>
        /// <returns></returns>
        public XQBezier QBezier(
            XPoint point1,
            XPoint point2,
            XPoint point3,
            bool isStroked = true,
            bool isFilled  = false)
        {
            var qbezier = XQBezier.Create(
                point1,
                point2,
                point3,
                Context.Editor.Project.CurrentStyleLibrary.CurrentStyle,
                Context.Editor.Project.Options.PointShape,
                isStroked,
                isFilled);

            Context.Editor.AddWithHistory(qbezier);
            return(qbezier);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public override void LeftDown(double x, double y)
        {
            double sx = _editor.Project.Options.SnapToGrid ? Editor.Snap(x, _editor.Project.Options.SnapX) : x;
            double sy = _editor.Project.Options.SnapToGrid ? Editor.Snap(y, _editor.Project.Options.SnapY) : y;

            switch (_currentState)
            {
            case State.None:
            {
                _shape = XQBezier.Create(
                    sx, sy,
                    _editor.Project.CurrentStyleLibrary.CurrentStyle,
                    _editor.Project.Options.PointShape,
                    _editor.Project.Options.DefaultIsStroked,
                    _editor.Project.Options.DefaultIsFilled);
                if (_editor.Project.Options.TryToConnect)
                {
                    TryToConnectPoint1(_shape as XQBezier, sx, sy);
                }
                _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_shape);
                _editor.Project.CurrentContainer.WorkingLayer.Invalidate();
                ToStateOne();
                Move(_shape as XQBezier);
                _editor.Project.CurrentContainer.HelperLayer.Invalidate();
                _currentState           = State.One;
                _editor.CancelAvailable = true;
            }
            break;

            case State.One:
            {
                var qbezier = _shape as XQBezier;
                if (qbezier != null)
                {
                    qbezier.Point2.X = sx;
                    qbezier.Point2.Y = sy;
                    qbezier.Point3.X = sx;
                    qbezier.Point3.Y = sy;
                    if (_editor.Project.Options.TryToConnect)
                    {
                        TryToConnectPoint3(_shape as XQBezier, sx, sy);
                    }
                    _editor.Project.CurrentContainer.WorkingLayer.Invalidate();
                    ToStateTwo();
                    Move(_shape as XQBezier);
                    _editor.Project.CurrentContainer.HelperLayer.Invalidate();
                    _currentState = State.Two;
                }
            }
            break;

            case State.Two:
            {
                var qbezier = _shape as XQBezier;
                if (qbezier != null)
                {
                    qbezier.Point2.X = sx;
                    qbezier.Point2.Y = sy;
                    if (_editor.Project.Options.TryToConnect)
                    {
                        TryToConnectPoint2(_shape as XQBezier, sx, sy);
                    }
                    _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_shape);
                    Remove();
                    Finalize(_shape as XQBezier);
                    _editor.AddWithHistory(_shape);
                    _currentState           = State.None;
                    _editor.CancelAvailable = false;
                }
            }
            break;
            }
        }