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

            _ribbonTriple = ribbonTriple;
            _currentSize  = currentSize;
        }
Example #2
0
        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>
        /// Initialize a new instance of the ViewLayoutRibbonGroupTriple class.
        /// </summary>
        /// <param name="ribbon">Owning ribbon control instance.</param>
        /// <param name="ribbonTriple">Reference to triple definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewLayoutRibbonGroupTriple(KryptonRibbon ribbon,
                                           KryptonRibbonGroupTriple ribbonTriple,
                                           NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonTriple != null);
            Debug.Assert(needPaint != null);

            // Cache references
            _ribbon       = ribbon;
            _ribbonTriple = ribbonTriple;
            _needPaint    = needPaint;

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

            // Use hashtables to store relationships
            _itemToView  = new ItemToView();
            _smallCache  = new ViewToSize();
            _mediumCache = new ViewToSize();
            _largeCache  = new ViewToSize();

            // Get the initial size used for sizing and positioning
            SetCurrentSize(ribbonTriple.ItemSizeCurrent);

            // Hook into changes in the ribbon triple definition
            _ribbonTriple.PropertyChanged += new PropertyChangedEventHandler(OnTriplePropertyChanged);
            _ribbonTriple.TripleView       = 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;
            }
        }