Inheritance: KryptonRibbonGroupContainer
        private void OnDeleteButton(object sender, EventArgs e)
        {
            if (_ribbonColorButton?.Ribbon != null)
            {
                // Cast container to the correct type
                KryptonRibbonGroupCluster cluster = (KryptonRibbonGroupCluster)_ribbonColorButton.RibbonContainer;

                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupColorClusterButton DeleteButton");

                try
                {
                    // Get access to the Items property
                    MemberDescriptor propertyItems = TypeDescriptor.GetProperties(cluster)["Items"];

                    // Remove the ribbon group from the ribbon tab
                    RaiseComponentChanging(null);
                    RaiseComponentChanging(propertyItems);

                    // Remove the button from the group
                    cluster.Items.Remove(_ribbonColorButton);

                    // Get designer to destroy it
                    _designerHost.DestroyComponent(_ribbonColorButton);

                    RaiseComponentChanged(propertyItems, null, null);
                    RaiseComponentChanged(null, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    transaction?.Commit();
                }
            }
        }
        private void OnMoveLast(object sender, EventArgs e)
        {
            if (_ribbonColorButton?.Ribbon != null)
            {
                // Cast container to the correct type
                KryptonRibbonGroupCluster cluster = (KryptonRibbonGroupCluster)_ribbonColorButton.RibbonContainer;

                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupColorClusterButton MoveLast");

                try
                {
                    // Get access to the Items property
                    MemberDescriptor propertyItems = TypeDescriptor.GetProperties(cluster)["Items"];

                    RaiseComponentChanging(propertyItems);

                    // Move position of the triple
                    cluster.Items.Remove(_ribbonColorButton);
                    cluster.Items.Insert(cluster.Items.Count, _ribbonColorButton);
                    UpdateVerbStatus();

                    RaiseComponentChanged(propertyItems, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    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
            _ribbonCluster = (KryptonRibbonGroupCluster)component;
            _ribbonCluster.DesignTimeAddButton      += new EventHandler(OnAddButton);
            _ribbonCluster.DesignTimeAddColorButton += new EventHandler(OnAddColorButton);
            _ribbonCluster.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.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
            _changeService.ComponentChanged  += new ComponentChangedEventHandler(OnComponentChanged);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initialize a new instance of the ViewDrawRibbonDesignCluster class.
 /// </summary>
 /// <param name="ribbon">Reference to owning ribbon control.</param>
 /// <param name="ribbonCluster">Reference to cluster definition.</param>
 /// <param name="needPaint">Delegate for notifying paint requests.</param>
 public ViewDrawRibbonDesignCluster(KryptonRibbon ribbon,
                                    KryptonRibbonGroupCluster ribbonCluster,
                                    NeedPaintHandler needPaint)
     : base(ribbon, needPaint)
 {
     Debug.Assert(ribbonCluster != null);
     _ribbonCluster = ribbonCluster;
 }
 /// <summary>
 /// Initialize a new instance of the ViewDrawRibbonDesignCluster class.
 /// </summary>
 /// <param name="ribbon">Reference to owning ribbon control.</param>
 /// <param name="ribbonCluster">Reference to cluster definition.</param>
 /// <param name="needPaint">Delegate for notifying paint requests.</param>
 public ViewDrawRibbonDesignCluster(KryptonRibbon ribbon,
                                    KryptonRibbonGroupCluster ribbonCluster,
                                    NeedPaintHandler needPaint)
     : base(ribbon, needPaint)
 {
     Debug.Assert(ribbonCluster != null);
     _ribbonCluster = ribbonCluster;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutRibbonGroupCluster class.
        /// </summary>
        /// <param name="ribbon">Owning ribbon control instance.</param>
        /// <param name="ribbonCluster">Reference to cluster definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewLayoutRibbonGroupCluster(KryptonRibbon ribbon,
                                            KryptonRibbonGroupCluster ribbonCluster,
                                            NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonCluster != null);
            Debug.Assert(needPaint != null);

            // Cache references
            _ribbon        = ribbon;
            _ribbonCluster = ribbonCluster;
            _needPaint     = needPaint;
            _currentSize   = GroupItemSize.Medium;

            // Associate the component with this view element for design time selection
            Component = _ribbonCluster;

            // Create the start and end separators
            _startSep        = new ViewDrawRibbonGroupClusterSeparator(_ribbon, true);
            _endSep          = new ViewDrawRibbonGroupClusterSeparator(_ribbon, false);
            _startSepVisible = false;
            _endSepVisible   = false;

            // Create palette used to supply a width to a border edge view
            PaletteBorderEdgeRedirect borderEdgeRedirect = new PaletteBorderEdgeRedirect(_ribbon.StateCommon.RibbonGroupClusterButton.Border, needPaint);

            _paletteBorderEdge = new PaletteBorderEdge(borderEdgeRedirect, needPaint);
            _lastShape         = PaletteRibbonShape.Office2007;

            // Use hashtable to store relationships
            _itemToView       = new ItemToView();
            _viewToEdge       = new ViewToEdge();
            _viewToSizeMedium = new ViewToSize();
            _viewToSizeSmall  = new ViewToSize();

            // Hook into changes in the ribbon cluster definition
            _ribbonCluster.PropertyChanged += new PropertyChangedEventHandler(OnClusterPropertyChanged);
            _ribbonCluster.ClusterView      = this;

            // At design time we want to track the mouse and show feedback
            if (_ribbon.InDesignMode)
            {
                ViewHightlightController controller = new ViewHightlightController(this, needPaint);
                controller.ContextClick += new MouseEventHandler(OnContextClick);
                MouseController          = controller;
            }
        }
Ejemplo n.º 7
0
        private void UpdateVerbStatus()
        {
            // Create verbs first time around
            if (_verbs == null)
            {
                _verbs             = new DesignerVerbCollection();
                _toggleHelpersVerb = new DesignerVerb("Toggle Helpers", OnToggleHelpers);
                _moveFirstVerb     = new DesignerVerb("Move Cluster Button First", OnMoveFirst);
                _movePrevVerb      = new DesignerVerb("Move Cluster Button Previous", OnMovePrevious);
                _moveNextVerb      = new DesignerVerb("Move Cluster Button Next", OnMoveNext);
                _moveLastVerb      = new DesignerVerb("Move Cluster Button Last", OnMoveLast);
                _deleteButtonVerb  = new DesignerVerb("Delete Cluster Button", OnDeleteButton);
                _verbs.AddRange(new DesignerVerb[] { _toggleHelpersVerb, _moveFirstVerb, _movePrevVerb,
                                                     _moveNextVerb, _moveLastVerb, _deleteButtonVerb });
            }

            bool moveFirst = false;
            bool movePrev  = false;
            bool moveNext  = false;
            bool moveLast  = false;

            if (_ribbonButton?.Ribbon != null)
            {
                // Cast container to the correct type
                KryptonRibbonGroupCluster cluster = (KryptonRibbonGroupCluster)_ribbonButton.RibbonContainer;

                moveFirst = (cluster.Items.IndexOf(_ribbonButton) > 0);
                movePrev  = (cluster.Items.IndexOf(_ribbonButton) > 0);
                moveNext  = (cluster.Items.IndexOf(_ribbonButton) < (cluster.Items.Count - 1));
                moveLast  = (cluster.Items.IndexOf(_ribbonButton) < (cluster.Items.Count - 1));
            }

            _moveFirstVerb.Enabled = moveFirst;
            _movePrevVerb.Enabled  = movePrev;
            _moveNextVerb.Enabled  = moveNext;
            _moveLastVerb.Enabled  = moveLast;
        }
        /// <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
            _ribbonCluster = (KryptonRibbonGroupCluster)component;
            _ribbonCluster.DesignTimeAddButton += new EventHandler(OnAddButton);
            _ribbonCluster.DesignTimeAddColorButton += new EventHandler(OnAddColorButton);
            _ribbonCluster.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.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
            _changeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
        }