public GalleryCategories(IRibbonControl ribbonControl, IUICollection fromGallery)
        {
            if (ribbonControl == null)
            {
                throw new ArgumentNullException(nameof(ribbonControl));
            }
            _ribbonControl = ribbonControl;
            if (fromGallery == null)
            {
                throw new ArgumentException(ribbonControl.ToString() + " not initialized");
            }
            _collectionChanged = new UICollectionChangedEvent();
            _collectionChanged.ChangedEvent += CollectionChanged_ChangedEvent;
            _collectionChanged.Attach(fromGallery);
            uint   count;
            object item;

            fromGallery.GetCount(out count);
            for (uint i = 0; i < count; i++)
            {
                fromGallery.GetItem(i, out item);
                GalleryItemPropertySet galleryItem = GetItemPropertySet(item);
                _controlItems.Add(galleryItem);
            }
        }
Beispiel #2
0
        private void InRibbonGallery_ItemsSourceReady(object sender, EventArgs e)
        {
            // set _inRibbonGallery items
            IUICollection itemsSource = InRibbonGallery.ItemsSource;

            InRibbonGallery.ExecuteEvent += InRibbonGallery_ExecuteEvent;
            itemsSource.Clear();
            Font font = new Font("Segoe UI", 9f);

            for (int i = 0; i < 64; i++)
            {
                Bitmap   image = new Bitmap(32, 32);
                Graphics g     = Graphics.FromImage(image);
                g.FillRectangle(Brushes.Red, new Rectangle(new Point(3, 3), new Size(26, 26)));
                g.DrawString((i + 1).ToString(), font, Brushes.White, 10f, 10f);
                g.Dispose();

                itemsSource.Add(new GalleryItemPropertySet()
                {
                    ItemImage  = Ribbon.ConvertToUIImage((Bitmap)image),
                    CategoryID = (uint)(i + 1),
                    //Label = (i + 1).ToString(),
                });
                uint count;
                itemsSource.GetCount(out count);
                object item;
                itemsSource.GetItem(count - 1, out item);
                GalleryItemPropertySet set = item as GalleryItemPropertySet;
                if (set != null)
                {
                }
            }
        }
Beispiel #3
0
        public QatCommands(RibbonQuickAccessToolbar qat)
        {
            if (qat == null)
            {
                throw new ArgumentNullException(nameof(qat));
            }
            IUICollection qatitemsSource = qat.ItemsSource;

            if (qatitemsSource == null)
            {
                throw new ArgumentException("Qat not initialized");
            }
            _collectionChanged = new UICollectionChangedEvent();
            _collectionChanged.ChangedEvent += CollectionChanged_ChangedEvent;
            _collectionChanged.Attach(qatitemsSource);
            uint   count;
            object item;

            qatitemsSource.GetCount(out count);
            for (uint i = 0; i < count; i++)
            {
                qatitemsSource.GetItem(i, out item);
                GalleryCommandPropertySet galleryItem = GetCommandPropertySet(item);
                _controlCommands.Add(galleryItem);
            }
        }
Beispiel #4
0
        void _buttonDropE_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            IUICollection itemsSource1 = _comboBox1.ItemsSource;
            uint          count;

            itemsSource1.GetCount(out count);
            ++count;
            itemsSource1.Add(new GalleryItemPropertySet()
            {
                Label = "Label " + count.ToString(), CategoryID = Constants.UI_Collection_InvalidIndex
            });
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        public HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
        {
            if (key == RibbonProperties.ItemsSource)
            {
                if (_itemsSource != null)
                {
                    IUICollection itemsSource = (IUICollection)currentValue.PropVariant.Value;

                    itemsSource.Clear();
                    uint count;
                    _itemsSource.GetCount(out count);
                    for (uint i = 0; i < count; ++i)
                    {
                        object item;
                        _itemsSource.GetItem(i, out item);
                        itemsSource.Add(item);
                    }
                }
            }
            return(HRESULT.S_OK);
        }