Exemple #1
0
        public void Detach()
        {
            if (!(_control.DataContext is IProjectEditor projectEditor))
            {
                return;
            }

            var zoomBorder = _control.Find <ZoomBorder>("zoomBorder");

            if (projectEditor.CanvasPlatform is IEditorCanvasPlatform canvasPlatform)
            {
                canvasPlatform.Invalidate  = null;
                canvasPlatform.ResetZoom   = null;
                canvasPlatform.AutoFitZoom = null;
                canvasPlatform.Zoom        = null;
            }

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

            _inputProcessor?.Dispose();
            _inputProcessor = null;
            _inputTarget    = null;
            _inputSource    = null;
        }
Exemple #2
0
        /// <summary>
        /// Detach project editor from container control.
        /// </summary>
        public void DetachEditor()
        {
            if (DataContext is IProjectEditor projectEditor)
            {
                if (!_isLoaded)
                {
                    return;
                }

                if (projectEditor.CanvasPlatform is IEditorCanvasPlatform canvasPlatform)
                {
                    canvasPlatform.Invalidate  = null;
                    canvasPlatform.ResetZoom   = null;
                    canvasPlatform.AutoFitZoom = null;
                    canvasPlatform.Zoom        = null;
                }

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

                _inputProcessor.Dispose();
                _inputTarget    = null;
                _inputProcessor = null;
                _inputSource    = null;

                _isLoaded = false;
            }
        }
Exemple #3
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);
        }
Exemple #4
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;
            }
        }