Inheritance: KryptonRibbonGroupContainer
Exemplo n.º 1
0
        private void OnMoveLast(object sender, EventArgs e)
        {
            if (_ribbonCluster?.Ribbon != null)
            {
                // Cast container to the correct type
                KryptonRibbonGroupLines lines = (KryptonRibbonGroupLines)_ribbonCluster.RibbonContainer;

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

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

                    RaiseComponentChanging(propertyItems);

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

                    RaiseComponentChanged(propertyItems, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    transaction?.Commit();
                }
            }
        }
Exemplo n.º 2
0
        private void OnDeleteCluster(object sender, EventArgs e)
        {
            if (_ribbonCluster?.Ribbon != null)
            {
                // Cast container to the correct type
                KryptonRibbonGroupLines lines = (KryptonRibbonGroupLines)_ribbonCluster.RibbonContainer;

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

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

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

                    // Remove the cluster from the lines
                    lines.Items.Remove(_ribbonCluster);

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

                    RaiseComponentChanged(propertyItems, null, null);
                    RaiseComponentChanged(null, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    transaction?.Commit();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonDesignGroupLines class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonLines">Associated ribbon group lines.</param>
        /// <param name="currentSize">Size the view should use.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonDesignGroupLines(KryptonRibbon ribbon,
                                              KryptonRibbonGroupLines ribbonLines,
                                              GroupItemSize currentSize,
                                              NeedPaintHandler needPaint)
            : base(ribbon, needPaint)
        {
            Debug.Assert(ribbonLines != null);

            _ribbonLines = ribbonLines;
            _currentSize = currentSize;
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonDesignGroupLines class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonLines">Associated ribbon group lines.</param>
        /// <param name="currentSize">Size the view should use.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonDesignGroupLines(KryptonRibbon ribbon,
                                              KryptonRibbonGroupLines ribbonLines,
                                              GroupItemSize currentSize,
                                              NeedPaintHandler needPaint)
            : base(ribbon, needPaint)
        {
            Debug.Assert(ribbonLines != null);

            _ribbonLines = ribbonLines;
            _currentSize = currentSize;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutRibbonGroupLines class.
        /// </summary>
        /// <param name="ribbon">Owning ribbon control instance.</param>
        /// <param name="ribbonLines">Reference to lines definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewLayoutRibbonGroupLines(KryptonRibbon ribbon,
                                          KryptonRibbonGroupLines ribbonLines,
                                          NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonLines != null);
            Debug.Assert(needPaint != null);

            // Cache references
            _ribbon      = ribbon;
            _ribbonLines = ribbonLines;
            _needPaint   = needPaint;

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

            // Use hashtable to store relationships
            _itemToView      = new ItemToView();
            _viewToItem      = new ViewToItem();
            _sizeLargeList   = new SizeList();
            _sizeMediumList  = new SizeList();
            _sizeSmallList   = new SizeList();
            _viewLargeList   = new ViewList();
            _viewMediumList  = new ViewList();
            _viewSmallList   = new ViewList();
            _viewToLargeGap  = new ViewToGap();
            _viewToMediumGap = new ViewToGap();
            _viewToSmallGap  = new ViewToGap();

            // Get the initial size used for sizing and positioning
            ApplySize(ribbonLines.ItemSizeCurrent);

            // Hook into changes in the ribbon triple definition
            _ribbonLines.PropertyChanged += new PropertyChangedEventHandler(OnLinesPropertyChanged);
            _ribbonLines.LinesView        = 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;
            }
        }
        private void OnAddLines(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 AddLines");

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

                    RaiseComponentChanging(propertyItems);

                    // Get designer to create the new lines component
                    KryptonRibbonGroupLines lines = (KryptonRibbonGroupLines)_designerHost.CreateComponent(typeof(KryptonRibbonGroupLines));
                    _ribbonGroup.Items.Add(lines);

                    // Get access to the Lines.Items property
                    MemberDescriptor propertyLinesItems = TypeDescriptor.GetProperties(lines)["Items"];

                    RaiseComponentChanging(propertyLinesItems);

                    // Get designer to create three new button components
                    KryptonRibbonGroupButton button1 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton));
                    KryptonRibbonGroupButton button2 = (KryptonRibbonGroupButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupButton));
                    lines.Items.Add(button1);
                    lines.Items.Add(button2);

                    RaiseComponentChanged(propertyLinesItems, null, null);
                    RaiseComponentChanged(propertyItems, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }
            }
        }
Exemplo 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 First", OnMoveFirst);
                _movePrevVerb       = new DesignerVerb("Move Cluster Previous", OnMovePrevious);
                _moveNextVerb       = new DesignerVerb("Move Cluster Next", OnMoveNext);
                _moveLastVerb       = new DesignerVerb("Move Cluster Last", OnMoveLast);
                _addButtonVerb      = new DesignerVerb("Add Button", OnAddButton);
                _addColorButtonVerb = new DesignerVerb("Add Color Button", OnAddColorButton);
                _clearItemsVerb     = new DesignerVerb("Clear Items", OnClearItems);
                _deleteClusterVerb  = new DesignerVerb("Delete Cluster", OnDeleteCluster);
                _verbs.AddRange(new DesignerVerb[] { _toggleHelpersVerb, _moveFirstVerb, _movePrevVerb, _moveNextVerb, _moveLastVerb,
                                                     _addButtonVerb, _addColorButtonVerb, _clearItemsVerb, _deleteClusterVerb });
            }

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

            if (_ribbonCluster?.Ribbon != null)
            {
                // Cast container to the correct type
                KryptonRibbonGroupLines lines = (KryptonRibbonGroupLines)_ribbonCluster.RibbonContainer;

                moveFirst  = (lines.Items.IndexOf(_ribbonCluster) > 0);
                movePrev   = (lines.Items.IndexOf(_ribbonCluster) > 0);
                moveNext   = (lines.Items.IndexOf(_ribbonCluster) < (lines.Items.Count - 1));
                moveLast   = (lines.Items.IndexOf(_ribbonCluster) < (lines.Items.Count - 1));
                clearItems = (_ribbonCluster.Items.Count > 0);
            }

            _moveFirstVerb.Enabled  = moveFirst;
            _movePrevVerb.Enabled   = movePrev;
            _moveNextVerb.Enabled   = moveNext;
            _moveLastVerb.Enabled   = moveLast;
            _clearItemsVerb.Enabled = clearItems;
        }
        /// <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
            _ribbonLines = (KryptonRibbonGroupLines)component;
            _ribbonLines.DesignTimeAddButton += new EventHandler(OnAddButton);
            _ribbonLines.DesignTimeAddColorButton += new EventHandler(OnAddColorButton);
            _ribbonLines.DesignTimeAddCheckBox += new EventHandler(OnAddCheckBox);
            _ribbonLines.DesignTimeAddRadioButton += new EventHandler(OnAddRadioButton);
            _ribbonLines.DesignTimeAddLabel += new EventHandler(OnAddLabel);
            _ribbonLines.DesignTimeAddCustomControl += new EventHandler(OnAddCustomControl);
            _ribbonLines.DesignTimeAddCluster += new EventHandler(OnAddCluster);
            _ribbonLines.DesignTimeAddTextBox += new EventHandler(OnAddTextBox);
            _ribbonLines.DesignTimeAddMaskedTextBox += new EventHandler(OnAddMaskedTextBox);
            _ribbonLines.DesignTimeAddRichTextBox += new EventHandler(OnAddRichTextBox);
            _ribbonLines.DesignTimeAddComboBox += new EventHandler(OnAddComboBox);
            _ribbonLines.DesignTimeAddNumericUpDown += new EventHandler(OnAddNumericUpDown);
            _ribbonLines.DesignTimeAddDomainUpDown += new EventHandler(OnAddDomainUpDown);
            _ribbonLines.DesignTimeAddDateTimePicker += new EventHandler(OnAddDateTimePicker);
            _ribbonLines.DesignTimeAddTrackBar += new EventHandler(OnAddTrackBar);
            _ribbonLines.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);
        }