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);
}