src/Misc/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignDocView_PanZoom.cs
/// <summary>
///     Override the base class method so that we can
///     add controls to pan, zoom in, zoom out,
///     and zoom to 100% underneath the vertical scrollbar.
/// </summary>
Override the base class method so that we can
add controls to pan, zoom in, zoom out,
and zoom to 100% underneath the vertical scrollbar.
Override the base class method so that we can add controls to pan zoom in zoom out and zoom to 100% underneath the vertical scrollbar .
public override VSDiagramView CreateDiagramView()
        {
            var view = base.CreateDiagramView();
            Debug.Assert(view.DiagramClientView != null, "DiagramClientView was null");
            view.DiagramClientView.ZoomChanged += DiagramClientView_ZoomChanged;
            var fantomPanel = view.Controls.OfType<Panel>().FirstOrDefault();
            if (fantomPanel != null)
            {
                view.Controls.Remove(fantomPanel);
            }
            var vscroll = view.Controls.OfType<VScrollBar>().FirstOrDefault();
            Debug.Assert(vscroll != null, "couldn't find the vertical scroll bar");
            var hscroll = view.Controls.OfType<HScrollBar>().FirstOrDefault();
            Debug.Assert(hscroll != null, "couldn't find the horizontal scroll bar");
            var panelHeight = hscroll.Height;
            var panelWidth = vscroll.Width;
            var panelLeft = view.Width - panelWidth;
            view.ClientSizeChanged += (sender, e) => vscroll.Height -= panelHeight * 3;
            view.Controls.Add(
                CreatePanel(
                    panelLeft,
                    view.Height - panelHeight,
                    panelWidth,
                    panelHeight,
                    "Resources.ThumbnailView.bmp",
                    Resources.AccName_ThumbnailView,
                    Resources.AccDesc_ThumbnailView,
                    mouseDownHandler: PanPanelMouseDownHandler));
            view.Controls.Add(
                CreatePanel(
                    panelLeft,
                    view.Height - panelHeight * 2,
                    panelWidth,
                    panelHeight,
                    "Resources.ZoomOutButton.bmp",
                    Resources.AccName_ZoomOutButton,
                    Resources.AccDesc_ZoomOutButton,
                    mouseClickHandler: (sender, e) => view.ZoomOut()));
            view.Controls.Add(
                CreatePanel(
                    panelLeft,
                    view.Height - panelHeight * 3,
                    panelWidth,
                    panelHeight,
                    "Resources.Zoom100Button.bmp",
                    Resources.AccName_Zoom100Button,
                    Resources.AccDesc_Zoom100Button,
                    mouseClickHandler: (sender, e) => view.ZoomAtViewCenter(1)));
            view.Controls.Add(
                CreatePanel(
                    panelLeft,
                    view.Height - panelHeight * 4,
                    panelWidth,
                    panelHeight,
                    "Resources.ZoomInButton.bmp",
                    Resources.AccName_ZoomInButton,
                    Resources.AccDesc_ZoomInButton,
                    mouseClickHandler: (sender, e) => view.ZoomIn()));
            UpdateTheme(view);
            VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged;
            return view;
        }
public override VSDiagramView CreateDiagramView ( ) { var view = base . CreateDiagramView ( ) ; Debug . Assert ( view . DiagramClientView != null , " " ) ; view . DiagramClientView . ZoomChanged += DiagramClientView_ZoomChanged ; var fantomPanel = view . Controls . OfType < Panel > ( ) . FirstOrDefault ( ) ; if ( fantomPanel != null ) { view . Controls . Remove ( fantomPanel ) ; } var vscroll = view . Controls . OfType < VScrollBar > ( ) . FirstOrDefault ( ) ; Debug . Assert ( vscroll != null , " " ) ; var hscroll = view . Controls . OfType < HScrollBar > ( ) . FirstOrDefault ( ) ; Debug . Assert ( hscroll != null , " " ) ; var panelHeight = hscroll . Height ; var panelWidth = vscroll . Width ; var panelLeft = view . Width - panelWidth ; view . ClientSizeChanged += ( sender , e ) => vscroll . Height -= panelHeight * 3 ; view . Controls . Add ( CreatePanel ( panelLeft , view . Height - panelHeight , panelWidth , panelHeight , " " , Resources . AccName_ThumbnailView , Resources . AccDesc_ThumbnailView , mouseDownHandler : PanPanelMouseDownHandler ) ) ; view . Controls . Add ( CreatePanel ( panelLeft , view . Height - panelHeight * 2 , panelWidth , panelHeight , " " , Resources . AccName_ZoomOutButton , Resources . AccDesc_ZoomOutButton , mouseClickHandler : ( sender , e ) => view . ZoomOut ( ) ) ) ; view . Controls . Add ( CreatePanel ( panelLeft , view . Height - panelHeight * 3 , panelWidth , panelHeight , " " , Resources . AccName_Zoom100Button , Resources . AccDesc_Zoom100Button , mouseClickHandler : ( sender , e ) => view . ZoomAtViewCenter ( 1 ) ) ) ; view . Controls . Add ( CreatePanel ( panelLeft , view . Height - panelHeight * 4 , panelWidth , panelHeight , " " , Resources . AccName_ZoomInButton , Resources . AccDesc_ZoomInButton , mouseClickHandler : ( sender , e ) => view . ZoomIn ( ) ) ) ; UpdateTheme ( view ) ; VSColorTheme . ThemeChanged += VSColorTheme_ThemeChanged ; return view ; }
Override the base class method so that we can
add controls to pan, zoom in, zoom out,
and zoom to 100% underneath the vertical scrollbar.
Override the base class method so that we can add controls to pan zoom in zoom out and zoom to 100% underneath the vertical scrollbar .
// Let the base class create and initialise the standard view // Add handler for ZoomChanged event so we can persist  // zoom level regardless where the change came form  // (context menu, mouse scroll, pan/zoom panel) // Standard view contains sometimes a panel that occludes the pan button // Need to resize the vertical scrollbar // every time the view is resized to account for the // pan/zoom panel. // NB the Resize and SizeChanged events fire too  // early i.e. before the VSDiagramView has resized // the vertical scroll bar. // Create the panels from bottom to top  // and set their event handlers: // Pan panel // Zoom out panel // Zoom to 100% panel // Zoom in panel // Set theme colors before returning new view. // Hookup event handler so that we can keep colors updated if user changes theme.