/// <summary> /// Initialize a new instance of the ViewLayoutRibbonScrollPort class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="orientation">Viewport orientation.</param> /// <param name="viewFiller">View to size and position.</param> /// <param name="insetForTabs">Should scoller be inset for use in tabs area.</param> /// <param name="scrollSpeed">Scrolling speed.</param> /// <param name="needPaintDelegate">Delegate for notifying paint/layout requests.</param> public ViewLayoutRibbonScrollPort(KryptonRibbon ribbon, Orientation orientation, ViewBase viewFiller, bool insetForTabs, int scrollSpeed, NeedPaintHandler needPaintDelegate) { Debug.Assert(ribbon != null); Debug.Assert(viewFiller != null); Debug.Assert(needPaintDelegate != null); // Remember initial settings _ribbon = ribbon; _orientation = orientation; _viewFiller = viewFiller; _needPaintDelegate = needPaintDelegate; _scrollSpeed = scrollSpeed; _ribbonTabs = viewFiller as ViewLayoutRibbonTabs; // Default to left hand scroll position _scrollOffset = 0; // Place the child view inside a actual control, so that the contents of the // filler are clipped to the control size. This is needed if the child view // contains controls and need clipping inside this area and so prevent them // from drawing over the end scrollers. _viewControlContent = new RibbonViewControl(ribbon); _viewControlContent.PaintBackground += new PaintEventHandler(OnViewControlPaintBackground); _viewControl = new ViewLayoutControl(_viewControlContent, ribbon, _viewFiller); // For ribbon tabs we want to monitor and intercept the WM_NCHITTEST so that the remainder of the // tabs area acts like the application title bar and can be used to manipulate the application if (_ribbonTabs != null) _viewControl.ChildControl.WndProcHitTest += new EventHandler<ViewControlHitTestArgs>(OnChildWndProcHitTest); // Create the two scrollers used when not enough space for filler _nearScroller = new ViewLayoutRibbonScroller(ribbon, NearOrientation, insetForTabs, needPaintDelegate); _farScroller = new ViewLayoutRibbonScroller(ribbon, FarOrientation, insetForTabs, needPaintDelegate); // Hook into scroller events _nearScroller.Click += new EventHandler(OnNearClick); _farScroller.Click += new EventHandler(OnFarClick); // Add elements in correct order Add(_viewControl); Add(_nearScroller); Add(_farScroller); }
/// <summary> /// Initialize a new instance of the ViewLayoutScrollViewport class. /// </summary> /// <param name="rootControl">Top level visual control.</param> /// <param name="viewportFiller">View element to place inside viewport.</param> /// <param name="paletteBorderEdge">Palette for use with the border edge.</param> /// <param name="paletteMetrics">Palette source for metrics.</param> /// <param name="metricPadding">Metric used to get view padding.</param> /// <param name="metricOvers">Metric used to get overposition.</param> /// <param name="orientation">Orientation for the viewport children.</param> /// <param name="alignment">Alignment of the children within the viewport.</param> /// <param name="animateChange">Animate changes in the viewport.</param> /// <param name="vertical">Is the viewport vertical.</param> /// <param name="needPaintDelegate">Delegate for notifying paint requests.</param> public ViewLayoutScrollViewport(VisualControl rootControl, ViewBase viewportFiller, PaletteBorderEdge paletteBorderEdge, IPaletteMetric paletteMetrics, PaletteMetricPadding metricPadding, PaletteMetricInt metricOvers, VisualOrientation orientation, RelativePositionAlign alignment, bool animateChange, bool vertical, NeedPaintHandler needPaintDelegate) { Debug.Assert(rootControl != null); Debug.Assert(viewportFiller != null); Debug.Assert(needPaintDelegate != null); // We need a way to notify changes in layout _needPaintDelegate = needPaintDelegate; // By default we are showing the contained viewport in vertical scrolling _viewportVertical = vertical; // Our initial visual orientation should match the parameter Orientation = orientation; // Create the child viewport _viewport = new ViewLayoutViewport(paletteMetrics, metricPadding, metricOvers, ViewportOrientation(_viewportVertical), alignment, animateChange) { // Default to same alignment for both directions CounterAlignment = alignment, // We always want the viewport to fill any remainder space FillSpace = true }; // Put the provided element inside the viewport _viewport.Add(viewportFiller); // Hook into animation step events _viewport.AnimateStep += new EventHandler(OnAnimateStep); // To prevent the contents of the viewport from being able to draw outside // the viewport (such as having child controls) we use a ViewLayoutControl // that uses a child control to restrict the drawing region. _viewControl = new ViewLayoutControl(rootControl, _viewport) { InDesignMode = rootControl.InDesignMode }; // Create the scrollbar and matching border edge _scrollbarV = new ViewDrawScrollBar(true); _scrollbarH = new ViewDrawScrollBar(false); _borderEdgeV = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Vertical); _borderEdgeH = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Horizontal); // Hook into scroll position changes _scrollbarV.ScrollChanged += new EventHandler(OnScrollVChanged); _scrollbarH.ScrollChanged += new EventHandler(OnScrollHChanged); // Add with appropriate docking style Add(_viewControl, ViewDockStyle.Fill); Add(_borderEdgeV, ViewDockStyle.Right); Add(_borderEdgeH, ViewDockStyle.Bottom); Add(_scrollbarV, ViewDockStyle.Right); Add(_scrollbarH, ViewDockStyle.Bottom); }
/// <summary> /// Initialize a new instance of the ViewLayoutScrollViewport class. /// </summary> /// <param name="rootControl">Top level visual control.</param> /// <param name="viewportFiller">View element to place inside viewport.</param> /// <param name="paletteBorderEdge">Palette for use with the border edge.</param> /// <param name="paletteMetrics">Palette source for metrics.</param> /// <param name="metricPadding">Metric used to get view padding.</param> /// <param name="metricOvers">Metric used to get overposition.</param> /// <param name="orientation">Orientation for the viewport children.</param> /// <param name="alignment">Alignment of the children within the viewport.</param> /// <param name="animateChange">Animate changes in the viewport.</param> /// <param name="vertical">Is the viewport vertical.</param> /// <param name="needPaintDelegate">Delegate for notifying paint requests.</param> public ViewLayoutScrollViewport(VisualControl rootControl, ViewBase viewportFiller, PaletteBorderEdge paletteBorderEdge, IPaletteMetric paletteMetrics, PaletteMetricPadding metricPadding, PaletteMetricInt metricOvers, VisualOrientation orientation, RelativePositionAlign alignment, bool animateChange, bool vertical, NeedPaintHandler needPaintDelegate) { Debug.Assert(rootControl != null); Debug.Assert(viewportFiller != null); Debug.Assert(needPaintDelegate != null); // We need a way to notify changes in layout _needPaintDelegate = needPaintDelegate; // By default we are showing the contained viewport in vertical scrolling _viewportVertical = vertical; // Our initial visual orientation should match the parameter Orientation = orientation; // Create the child viewport _viewport = new ViewLayoutViewport(paletteMetrics, metricPadding, metricOvers, ViewportOrientation(_viewportVertical), alignment, animateChange); // Default to same alignment for both directions _viewport.CounterAlignment = alignment; // We always want the viewport to fill any remainder space _viewport.FillSpace = true; // Put the provided element inside the viewport _viewport.Add(viewportFiller); // Hook into animation step events _viewport.AnimateStep += new EventHandler(OnAnimateStep); // To prevent the contents of the viewport from being able to draw outside // the viewport (such as having child controls) we use a ViewLayoutControl // that uses a child control to restrict the drawing region. _viewControl = new ViewLayoutControl(rootControl, _viewport); _viewControl.InDesignMode = rootControl.InDesignMode; // Create the scrollbar and matching border edge _scrollbarV = new ViewDrawScrollBar(true); _scrollbarH = new ViewDrawScrollBar(false); _borderEdgeV = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Vertical); _borderEdgeH = new ViewDrawBorderEdge(paletteBorderEdge, System.Windows.Forms.Orientation.Horizontal); // Hook into scroll position changes _scrollbarV.ScrollChanged += new EventHandler(OnScrollVChanged); _scrollbarH.ScrollChanged += new EventHandler(OnScrollHChanged); // Add with appropriate docking style Add(_viewControl, ViewDockStyle.Fill); Add(_borderEdgeV, ViewDockStyle.Right); Add(_borderEdgeH, ViewDockStyle.Bottom); Add(_scrollbarV, ViewDockStyle.Right); Add(_scrollbarH, ViewDockStyle.Bottom); }