/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupGallery class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonGallery">Reference to source gallery.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> 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); }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupGalleryText class. /// </summary> /// <param name="ribbon">Source ribbon control.</param> /// <param name="ribbonGallery">Group gallery button to display title for.</param> /// <param name="firstText">Should show the first button text.</param> public ViewDrawRibbonGroupGalleryText(KryptonRibbon ribbon, KryptonRibbonGroupGallery ribbonGallery, bool firstText) { Debug.Assert(ribbon != null); Debug.Assert(ribbonGallery != null); _ribbon = ribbon; _ribbonGallery = ribbonGallery; _firstText = firstText; // Use a class to convert from ribbon group to content interface _contentProvider = new RibbonGroupNormalDisabledTextToContent(ribbon.StateCommon.RibbonGeneral, ribbon.StateNormal.RibbonGroupButtonText, ribbon.StateDisabled.RibbonGroupButtonText); }
/// <summary> /// Initializes the designer with the specified component. /// </summary> /// <param name="component">The IComponent to associate the designer with.</param> public override void Initialize(IComponent component) { Debug.Assert(component != null); // Validate the parameter reference if (component == null) { throw new ArgumentNullException("component"); } // Let base class do standard stuff base.Initialize(component); // Cast to correct type _ribbonGallery = (KryptonRibbonGroupGallery)component; _ribbonGallery.GalleryDesigner = this; // Update designer properties with actual starting values Visible = _ribbonGallery.Visible; Enabled = _ribbonGallery.Enabled; // Update visible/enabled to always be showing/enabled at design time _ribbonGallery.Visible = true; _ribbonGallery.Enabled = true; // Tell the embedded gallery it is in design mode _ribbonGallery.Gallery.InRibbonDesignMode = true; // Hook into events _ribbonGallery.DesignTimeContextMenu += new MouseEventHandler(OnContextMenu); // Get access to the services _designerHost = (IDesignerHost)GetService(typeof(IDesignerHost)); _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); // We need to know when we are being removed/changed _changeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); }