Esempio n. 1
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);
        }
Esempio n. 2
0
        void _recentItems_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            if (e.Key.PropertyKey == RibbonProperties.RecentItems)
            {
                // go over recent items
                object[] objectArray = (object[])e.CurrentValue.PropVariant.Value;
                for (int i = 0; i < objectArray.Length; ++i)
                {
                    IUISimplePropertySet propertySet = objectArray[i] as IUISimplePropertySet;

                    if (propertySet != null)
                    {
                        PropVariant propLabel;
                        propertySet.GetValue(ref RibbonProperties.Label,
                                             out propLabel);
                        string label = (string)propLabel.Value;

                        PropVariant propLabelDescription;
                        propertySet.GetValue(ref RibbonProperties.LabelDescription,
                                             out propLabelDescription);
                        string labelDescription = (string)propLabelDescription.Value;

                        PropVariant propPinned;
                        propertySet.GetValue(ref RibbonProperties.Pinned,
                                             out propPinned);
                        bool pinned = (bool)propPinned.Value;

                        // update pinned value
                        _recentItems[i].Pinned = pinned;
                    }
                }
            }
            else if (e.Key.PropertyKey == RibbonProperties.SelectedItem)
            {
                // get selected item index
                uint selectedItem = (uint)e.CurrentValue.PropVariant.Value;

                // get selected item label
                PropVariant propLabel;
                e.CommandExecutionProperties.GetValue(ref RibbonProperties.Label,
                                                      out propLabel);
                string label = (string)propLabel.Value;

                // get selected item label description
                PropVariant propLabelDescription;
                e.CommandExecutionProperties.GetValue(ref RibbonProperties.LabelDescription,
                                                      out propLabelDescription);
                string labelDescription = (string)propLabelDescription.Value;

                // get selected item pinned value
                PropVariant propPinned;
                e.CommandExecutionProperties.GetValue(ref RibbonProperties.Pinned,
                                                      out propPinned);
                bool pinned = (bool)propPinned.Value;
            }
        }
        private GalleryItemPropertySet GetGalleryItem(IUISimplePropertySet newItem)
        {
            PropVariant propVariant;

            newItem.GetValue(ref RibbonProperties.Label, out propVariant);
            string label = (string)propVariant.Value;

            newItem.GetValue(ref RibbonProperties.CategoryID, out propVariant);
            uint categoryID = (uint)propVariant.Value;

            return(GetGalleryItem(newItem, label, categoryID));
        }
Esempio n. 4
0
        protected override GalleryItemPropertySet GetGalleryItem(IUISimplePropertySet newItem, string label, uint categoryID)
        {
            if (_ribbonControl is RibbonComboBox)
            {
                return(base.GetGalleryItem(newItem, label, categoryID));
            }
            PropVariant propVariant = PropVariant.Empty;

            newItem.GetValue(ref RibbonProperties.ItemImage, out propVariant);
            IUIImage itemImage = (IUIImage)propVariant.Value;

            return(new GalleryItemPropertySet()
            {
                Label = label, ItemImage = itemImage, CategoryID = categoryID
            });
        }
Esempio n. 5
0
        void _buttonDropC_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            // enumerate over items
            IEnumUnknown itemsSource = (IEnumUnknown)_comboBox1.ItemsSource;

            itemsSource.Reset();
            object[] items = new object[1];
            uint     fetchedItem;

            while (itemsSource.Next(1, items, out fetchedItem) == HRESULT.S_OK)
            {
                IUISimplePropertySet uiItem = (IUISimplePropertySet)items[0];
                PropVariant          itemLabel;
                uiItem.GetValue(ref RibbonProperties.Label, out itemLabel);
                MessageBox.Show("Label = " + (string)itemLabel.Value);
            }
        }
Esempio n. 6
0
        private static void PrintChangedProperties(IUISimplePropertySet commandExecutionProperties)
        {
            PropVariant propChangesProperties;

            commandExecutionProperties.GetValue(ref RibbonProperties.FontProperties_ChangedProperties, out propChangesProperties);
            IPropertyStore changedProperties = (IPropertyStore)propChangesProperties.Value;
            uint           changedPropertiesNumber;

            changedProperties.GetCount(out changedPropertiesNumber);

            Debug.WriteLine("");
            Debug.WriteLine("FontControl changed properties:");
            for (uint i = 0; i < changedPropertiesNumber; ++i)
            {
                PropertyKey propertyKey;
                changedProperties.GetAt(i, out propertyKey);
                Debug.WriteLine(RibbonProperties.GetPropertyKeyName(ref propertyKey));
            }
        }
Esempio n. 7
0
        void _buttonDropA_ExecuteEvent(object sender, ExecuteEventArgs e)
        {
            // get selected item index from combo box 1
            uint selectedItemIndex = _comboBox1.SelectedItem;

            if (selectedItemIndex == Constants.UI_Collection_InvalidIndex)
            {
                MessageBox.Show("No item is selected in simple combo");
            }
            else
            {
                object selectedItem;
                _comboBox1.ItemsSource.GetItem(selectedItemIndex, out selectedItem);
                IUISimplePropertySet uiItem = (IUISimplePropertySet)selectedItem;
                PropVariant          itemLabel;
                uiItem.GetValue(ref RibbonProperties.Label, out itemLabel);
                MessageBox.Show("Selected item in simple combo is: " + (string)itemLabel.Value);
            }
        }