예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        private void InitializeZoom(EditorContext context)
        {
            border.InvalidateChild =
                (z, x, y) =>
                {
                    bool invalidate = context.Editor.Renderers[0].State.Zoom != z;
                    context.Editor.Renderers[0].State.Zoom = z;
                    context.Editor.Renderers[0].State.PanX = x;
                    context.Editor.Renderers[0].State.PanY = y;
                    if (invalidate)
                    {
                        context.InvalidateCache(isZooming: true);
                    }
                };

            border.AutoFitChild =
                (width, height) =>
                {
                    if (border != null
                        && context != null
                        && context.Editor.Project != null
                        && context.Editor.Project.CurrentContainer != null)
                    {
                        border.AutoFit(
                            width,
                            height,
                            context.Editor.Project.CurrentContainer.Width,
                            context.Editor.Project.CurrentContainer.Height);
                    }
                };

            border.MouseDown +=
                (s, e) =>
                {
                    if (e.ChangedButton == MouseButton.Middle && e.ClickCount == 2)
                    {
                        panAndZoomGrid.AutoFit();
                    }

                    if (e.ChangedButton == MouseButton.Middle && e.ClickCount == 3)
                    {
                        panAndZoomGrid.ResetZoomAndPan();
                    }
                };
        }