public ViewDrawRibbonGroupGallery(KryptonRibbon ribbon,
KryptonRibbonGroupGallery ribbonGallery,
NeedPaintHandler needPaint)
{
Debug.Assert(ribbon != null);
Debug.Assert(ribbonGallery != null);
Debug.Assert(needPaint != null);
// Remember incoming references
_ribbon = ribbon;
_ribbonGallery = ribbonGallery;
_needPaint = needPaint;
_currentSize = _ribbonGallery.ItemSizeCurrent;
// Create the button view used in small setting
CreateLargeButtonView();
// Hook into the gallery events
_ribbonGallery.MouseEnterControl += new EventHandler(OnMouseEnterControl);
_ribbonGallery.MouseLeaveControl += new EventHandler(OnMouseLeaveControl);
// Associate this view with the source component (required for design time selection)
Component = _ribbonGallery;
if (_ribbon.InDesignMode)
{
// At design time we need to know when the user right clicks the gallery
ContextClickController controller = new ContextClickController();
controller.ContextClick += new MouseEventHandler(OnContextClick);
MouseController = controller;
}
// Create controller needed for handling focus and key tip actions
_controller = new GalleryController(_ribbon, _ribbonGallery, this);
SourceController = _controller;
KeyController = _controller;
// We need to rest visibility of the gallery for each layout cycle
_ribbon.ViewRibbonManager.LayoutBefore += new EventHandler(OnLayoutAction);
_ribbon.ViewRibbonManager.LayoutAfter += new EventHandler(OnLayoutAction);
// Define back reference to view for the gallery definition
_ribbonGallery.GalleryView = this;
// Give paint delegate to gallery so its palette changes are redrawn
_ribbonGallery.ViewPaintDelegate = needPaint;
// Hook into changes in the ribbon custom definition
_ribbonGallery.PropertyChanged += new PropertyChangedEventHandler(OnGalleryPropertyChanged);
}