/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupButton class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonButton">Reference to source button definition.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewDrawRibbonGroupButton(KryptonRibbon ribbon, KryptonRibbonGroupButton ribbonButton, NeedPaintHandler needPaint) { Debug.Assert(ribbon != null); Debug.Assert(ribbonButton != null); Debug.Assert(needPaint != null); // Remember incoming references _ribbon = ribbon; _ribbonButton = ribbonButton; _needPaint = needPaint; _currentSize = _ribbonButton.ItemSizeCurrent; // Associate this view with the source component (required for design time selection) Component = _ribbonButton; // Create the different views for different sizes of the button CreateLargeButtonView(); CreateMediumSmallButtonView(); // Update all views to reflect current button state UpdateEnabledState(); UpdateCheckedState(); UpdateDropDownState(); UpdateItemSizeState(); // Hook into changes in the ribbon button definition _ribbonButton.PropertyChanged += new PropertyChangedEventHandler(OnButtonPropertyChanged); }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupButtonImage class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonButton">Reference to ribbon group button definition.</param> /// <param name="large">Show the large image.</param> public ViewDrawRibbonGroupButtonImage(KryptonRibbon ribbon, KryptonRibbonGroupButton ribbonButton, bool large) : base(ribbon) { Debug.Assert(ribbonButton != null); _ribbonButton = ribbonButton; _large = large; }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupButtonText class. /// </summary> /// <param name="ribbon">Source ribbon control.</param> /// <param name="ribbonButton">Group button to display title for.</param> /// <param name="firstText">Should show the first button text.</param> public ViewDrawRibbonGroupButtonText(KryptonRibbon ribbon, KryptonRibbonGroupButton ribbonButton, bool firstText) { Debug.Assert(ribbon != null); Debug.Assert(ribbonButton != null); _ribbon = ribbon; _ribbonButton = ribbonButton; _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> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { if (_ribbonButton != null) { // Must unhook to prevent memory leaks _ribbonButton.PropertyChanged -= new PropertyChangedEventHandler(OnButtonPropertyChanged); // Remove association with definition _ribbonButton.ButtonView = null; _ribbonButton = null; } } base.Dispose(disposing); }
private void OnAddTriple(object sender, EventArgs e) { if ((_ribbonGroup != null) && (_ribbonGroup.Ribbon != null) && _ribbonGroup.RibbonTab.Groups.Contains(_ribbonGroup)) { // Use a transaction to support undo/redo actions DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroup AddTriple"); try { // Get access to the Items property MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonGroup)["Items"]; RaiseComponentChanging(propertyItems); // Get designer to create the new triple component KryptonRibbonGroupTriple triple = (KryptonRibbonGroupTriple)_designerHost.CreateComponent(typeof(KryptonRibbonGroupTriple)); _ribbonGroup.Items.Add(triple); // Get access to the Triple.Items property MemberDescriptor propertyTripleItems = TypeDescriptor.GetProperties(triple)["Items"]; RaiseComponentChanging(propertyTripleItems); // Get designer to create three new button components KryptonRibbonGroupButton button1 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton)); KryptonRibbonGroupButton button2 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton)); KryptonRibbonGroupButton button3 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton)); triple.Items.Add(button1); triple.Items.Add(button2); triple.Items.Add(button3); RaiseComponentChanged(propertyTripleItems, null, null); RaiseComponentChanged(propertyItems, null, null); } finally { // If we managed to create the transaction, then do it if (transaction != null) { transaction.Commit(); } } } }
/// <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 _ribbonButton = (KryptonRibbonGroupButton)component; _ribbonButton.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); }