Ejemplo n.º 1
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 = XText.Create(
                    sx, sy,
                    _editor.Project.CurrentStyleLibrary.CurrentStyle,
                    _editor.Project.Options.PointShape,
                    "Text",
                    _editor.Project.Options.DefaultIsStroked);
                if (_editor.Project.Options.TryToConnect)
                {
                    TryToConnectTopLeft(_shape as XText, sx, sy);
                }
                _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Add(_shape);
                _editor.Project.CurrentContainer.WorkingLayer.Invalidate();
                ToStateOne();
                Move(_shape);
                _editor.Project.CurrentContainer.HelperLayer.Invalidate();
                _currentState           = State.One;
                _editor.CancelAvailable = true;
            }
            break;

            case State.One:
            {
                var text = _shape as XText;
                if (text != null)
                {
                    text.BottomRight.X = sx;
                    text.BottomRight.Y = sy;
                    if (_editor.Project.Options.TryToConnect)
                    {
                        TryToConnectBottomRight(_shape as XText, sx, sy);
                    }
                    _editor.Project.CurrentContainer.WorkingLayer.Shapes = _editor.Project.CurrentContainer.WorkingLayer.Shapes.Remove(_shape);
                    Remove();
                    Finalize(_shape);
                    _editor.AddWithHistory(_shape);
                    _currentState           = State.None;
                    _editor.CancelAvailable = false;
                }
            }
            break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of the XText class.
        /// </summary>
        /// <param name="topLeft"></param>
        /// <param name="bottomRight"></param>
        /// <param name="text"></param>
        /// <param name="isStroked"></param>
        /// <returns></returns>
        public XText Text(
            XPoint topLeft,
            XPoint bottomRight,
            string text    = "Text",
            bool isStroked = true)
        {
            var txt = XText.Create(
                topLeft,
                bottomRight,
                Context.Editor.Project.CurrentStyleLibrary.CurrentStyle,
                Context.Editor.Project.Options.PointShape,
                text,
                isStroked);

            Context.Editor.AddWithHistory(txt);
            return(txt);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new instance of the XText class.
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="text"></param>
        /// <param name="isStroked"></param>
        /// <returns></returns>
        public XText Text(
            double x1      = 30, double y1 = 30,
            double x2      = 60, double y2 = 60,
            string text    = "Text",
            bool isStroked = true)
        {
            var txt = XText.Create(
                x1, y1,
                x2, y2,
                Context.Editor.Project.CurrentStyleLibrary.CurrentStyle,
                Context.Editor.Project.Options.PointShape,
                text,
                isStroked);

            Context.Editor.AddWithHistory(txt);
            return(txt);
        }