상속: Border
예제 #1
0
        /// <summary>
        /// Attach project editor to container control.
        /// </summary>
        public void AttachEditor()
        {
            _projectEditor = this.DataContext as ProjectEditor;
            _containerControl = this.Find<ContainerViewControl>("containerControl");
            _zoomBorder = this.Find<ZoomBorder>("zoomBorder");

            if (_projectEditor != null && _containerControl != null && _zoomBorder != null)
            {
                _projectEditor.Invalidate = () => _containerControl.InvalidateVisual();
                _projectEditor.ResetZoom = () => _zoomBorder.Reset();
                _projectEditor.AutoFitZoom = () => _zoomBorder.AutoFit();
                _projectEditor.LoadLayout = () => { };
                _projectEditor.SaveLayout = () => { };
                _projectEditor.ResetLayout = () => { };

                _zoomBorder.InvalidatedChild = InvalidateChild;

                _inputProcessor = new InputProcessor(
                    new AvaloniaInputSource(
                        _zoomBorder,
                        _containerControl,
                        _zoomBorder.FixInvalidPointPosition), 
                    _projectEditor);
            }
        }
        public MainWindow()
        {
            this.InitializeComponent();
            this.AttachDevTools();

            zoomBorder = this.Find<ZoomBorder>("zoomBorder");
            zoomBorder.KeyDown += ZoomBorder_KeyDown;
        }
예제 #3
0
        /// <summary>
        /// Calculate scrollable properties.
        /// </summary>
        /// <param name="source">The source bounds.</param>
        /// <param name="matrix">The transform matrix.</param>
        /// <param name="extent">The extent of the scrollable content.</param>
        /// <param name="viewport">The size of the viewport.</param>
        /// <param name="offset">The current scroll offset.</param>
        public static void CalculateScrollable(Rect source, Matrix matrix, out Size extent, out Size viewport, out Vector offset)
        {
            var bounds = new Rect(0, 0, source.Width, source.Height);

            viewport = bounds.Size;

            var transformed = bounds.TransformToAABB(matrix);

            ZoomBorder.Log($"[CalculateScrollable] source: {source}, bounds: {bounds}, transformed: {transformed}");

            var width  = transformed.Size.Width;
            var height = transformed.Size.Height;

            if (width < viewport.Width)
            {
                width = viewport.Width;

                if (transformed.Position.X < 0.0)
                {
                    width += Abs(transformed.Position.X);
                }
                else
                {
                    var widthTranslated = transformed.Size.Width + transformed.Position.X;
                    if (widthTranslated > width)
                    {
                        width += widthTranslated - width;
                    }
                }
            }
            else if (!(width > viewport.Width))
            {
                width += Abs(transformed.Position.X);
            }

            if (height < viewport.Height)
            {
                height = viewport.Height;

                if (transformed.Position.Y < 0.0)
                {
                    height += Abs(transformed.Position.Y);
                }
                else
                {
                    var heightTranslated = transformed.Size.Height + transformed.Position.Y;
                    if (heightTranslated > height)
                    {
                        height += heightTranslated - height;
                    }
                }
            }
            else if (!(height > viewport.Height))
            {
                height += Abs(transformed.Position.Y);
            }

            extent = new Size(width, height);

            var ox = transformed.Position.X;
            var oy = transformed.Position.Y;

            var offsetX = ox < 0 ? Abs(ox) : 0;
            var offsetY = oy < 0 ? Abs(oy) : 0;

            offset = new Vector(offsetX, offsetY);

            ZoomBorder.Log($"[CalculateScrollable] Extent: {extent} | Offset: {offset} | Viewport: {viewport}");
        }
예제 #4
0
        /// <summary>
        /// Detach project editor from container control.
        /// </summary>
        public void DetachEditor()
        {
            if (_projectEditor != null && _containerControl != null && _zoomBorder != null)
            {
                _projectEditor.Invalidate = null;
                _projectEditor.ResetZoom = null;
                _projectEditor.AutoFitZoom = null;
                _projectEditor.LoadLayout = null;
                _projectEditor.SaveLayout = null;
                _projectEditor.ResetLayout = null;

                _zoomBorder.InvalidatedChild = null;

                _inputProcessor.Dispose();
            }

            _projectEditor = null;
            _containerControl = null;
            _zoomBorder = null;
        }