コード例 #1
0
        /// <summary>
        /// Creates a new instance of the XImage class.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="topLeft"></param>
        /// <param name="bottomRight"></param>
        /// <param name="isStroked"></param>
        /// <param name="isFilled"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public XImage Image(
            string path,
            XPoint topLeft,
            XPoint bottomRight,
            bool isStroked = false,
            bool isFilled  = false,
            string text    = null)
        {
            var image = XImage.Create(
                topLeft,
                bottomRight,
                Context.Editor.Project.CurrentStyleLibrary.CurrentStyle,
                Context.Editor.Project.Options.PointShape,
                path,
                isStroked,
                isFilled,
                text);

            Context.Editor.AddWithHistory(image);
            return(image);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new instance of the XImage class.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="isStroked"></param>
        /// <param name="isFilled"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public XImage Image(
            string path,
            double x1      = 30, double y1  = 30,
            double x2      = 120, double y2 = 120,
            bool isStroked = false,
            bool isFilled  = false,
            string text    = null)
        {
            var image = XImage.Create(
                x1, y1,
                x2, y2,
                Context.Editor.Project.CurrentStyleLibrary.CurrentStyle,
                Context.Editor.Project.Options.PointShape,
                path,
                isStroked,
                isFilled,
                text);

            Context.Editor.AddWithHistory(image);
            return(image);
        }
コード例 #3
0
ファイル: ImageHelper.cs プロジェクト: monocraft/Core2D
        /// <summary>
        ///
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public override async 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:
            {
                if (_editor.GetImageKey == null)
                {
                    return;
                }

                var path = await _editor.GetImageKey();

                if (path == null || string.IsNullOrEmpty(path))
                {
                    return;
                }

                _shape = XImage.Create(
                    sx, sy,
                    _editor.Project.CurrentStyleLibrary.CurrentStyle,
                    _editor.Project.Options.PointShape,
                    path);
                if (_editor.Project.Options.TryToConnect)
                {
                    TryToConnectTopLeft(_shape as XImage, 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 image = _shape as XImage;
                if (image != null)
                {
                    image.BottomRight.X = sx;
                    image.BottomRight.Y = sy;
                    if (_editor.Project.Options.TryToConnect)
                    {
                        TryToConnectBottomRight(_shape as XImage, 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;
            }
        }