コード例 #1
0
ファイル: QatCommands.cs プロジェクト: wbskyboy/WindowsRibbon
        private void CollectionChanged_ChangedEvent(object sender, UICollectionChangedEventArgs e)
        {
            GalleryCommandPropertySet newGalleryItem = GetCommandPropertySet(e.NewItem);

            //GalleryCommandPropertySet oldGalleryItem = GetCommandPropertySet(e.OldItem);
            switch (e.Action)
            {
            case CollectionChange.Insert:
                _controlCommands.Insert((int)e.NewIndex, newGalleryItem);
                break;

            case CollectionChange.Remove:
                _controlCommands.RemoveAt((int)e.OldIndex);
                break;

            case CollectionChange.Replace:
                _controlCommands[(int)e.NewIndex] = newGalleryItem;
                break;

            case CollectionChange.Reset:
                _controlCommands.Clear();
                break;

            default:
                break;
            }
        }
コード例 #2
0
        //IList<GalleryCommandPropertySet>

        private GalleryCommandPropertySet GetCommandPropertySet(object item)
        {
            GalleryCommandPropertySet galleryItem;

            galleryItem = item as GalleryCommandPropertySet;
            if (galleryItem == null)
            {
                IUISimplePropertySet newItem = item as IUISimplePropertySet;
                if (newItem != null)
                {
                    PropVariant propVariant;
                    newItem.GetValue(ref RibbonProperties.CommandID, out propVariant);
                    uint cmdID = (uint)propVariant.Value;
                    newItem.GetValue(ref RibbonProperties.CategoryID, out propVariant);
                    uint categoryID = (uint)propVariant.Value;
                    newItem.GetValue(ref RibbonProperties.CommandType, out propVariant);
                    CommandType commandType = (CommandType)(uint)propVariant.Value;
                    galleryItem = new GalleryCommandPropertySet()
                    {
                        CommandID = cmdID, CommandType = commandType, CategoryID = categoryID
                    };
                }
            }
            return(galleryItem);
        }
コード例 #3
0
ファイル: QatCommands.cs プロジェクト: wbskyboy/WindowsRibbon
        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);
            }
        }
コード例 #4
0
        public GalleryCommands(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);
                GalleryCommandPropertySet galleryItem = GetCommandPropertySet(item);
                _controlCommands.Add(galleryItem);
            }
        }