Exemplo n.º 1
0
        /// <summary>
        /// Attach project editor to container control.
        /// </summary>
        public void AttachEditor()
        {
            _projectEditor = DataContext as ProjectEditor;

            if (_projectEditor != null)
            {
                _projectEditor.CanvasPlatform.Invalidate  = () => { };
                _projectEditor.CanvasPlatform.ResetZoom   = () => zoomBorder.Reset();
                _projectEditor.CanvasPlatform.AutoFitZoom = () => zoomBorder.AutoFit();

                _projectEditor.LayoutPlatform.LoadLayout  = () => OnLoadLayout();
                _projectEditor.LayoutPlatform.SaveLayout  = () => OnSaveLayout();
                _projectEditor.LayoutPlatform.ResetLayout = () => OnResetLayout();

                zoomBorder.InvalidatedChild = InvalidateChild;

                _inputSource    = new WpfInputSource(zoomBorder, drawableControl, (point) => point);
                _inputProcessor = new InputProcessor();
                _inputProcessor.Connect(_inputSource, _projectEditor);

                zoomBorder.AllowDrop  = true;
                zoomBorder.DragEnter += ZoomBorder_DragEnter;
                zoomBorder.Drop      += ZoomBorder_Drop;
            }
        }
Exemplo n.º 2
0
        public void Attach()
        {
            if (!(_control.DataContext is IProjectEditor projectEditor))
            {
                return;
            }

            var presenterControlData     = _control.Find <Control>("presenterControlData");
            var presenterControlTemplate = _control.Find <Control>("presenterControlTemplate");
            var presenterControlEditor   = _control.Find <Control>("presenterControlEditor");
            var zoomBorder = _control.Find <ZoomBorder>("zoomBorder");

            if (projectEditor.CanvasPlatform is IEditorCanvasPlatform canvasPlatform)
            {
                canvasPlatform.Invalidate = () =>
                {
                    presenterControlData?.InvalidateVisual();
                    presenterControlTemplate?.InvalidateVisual();
                    presenterControlEditor?.InvalidateVisual();
                };
                canvasPlatform.ResetZoom   = () => zoomBorder?.Reset();
                canvasPlatform.AutoFitZoom = () => zoomBorder?.AutoFit();
                canvasPlatform.Zoom        = zoomBorder;
            }

            if (zoomBorder != null)
            {
                zoomBorder.InvalidatedChild = InvalidateChild;
            }

            _inputSource    = new AvaloniaInputSource(zoomBorder, presenterControlEditor, p => p);
            _inputTarget    = new ProjectEditorInputTarget(projectEditor);
            _inputProcessor = new InputProcessor();
            _inputProcessor.Connect(_inputSource, _inputTarget);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Attach project editor to container control.
        /// </summary>
        public void AttachEditor()
        {
            if (DataContext is IProjectEditor projectEditor)
            {
                if (_isLoaded)
                {
                    return;
                }

                if (projectEditor.CanvasPlatform is IEditorCanvasPlatform canvasPlatform)
                {
                    canvasPlatform.Invalidate = () =>
                    {
                        _containerControlData?.InvalidateVisual();
                        _containerControlTemplate?.InvalidateVisual();
                        _containerControlEditor?.InvalidateVisual();
                    };
                    canvasPlatform.ResetZoom   = () => _zoomBorder?.Reset();
                    canvasPlatform.AutoFitZoom = () => _zoomBorder?.AutoFit();
                    canvasPlatform.Zoom        = _zoomBorder;
                }

                if (_zoomBorder != null)
                {
                    _zoomBorder.InvalidatedChild = InvalidateChild;
                }

                _inputSource = new AvaloniaInputSource(
                    _zoomBorder,
                    _containerControlEditor,
                    p => p);
                _inputTarget    = new ProjectEditorInputTarget(projectEditor);
                _inputProcessor = new InputProcessor();
                _inputProcessor.Connect(_inputSource, _inputTarget);

                _isLoaded = true;
            }
        }