Exemple #1
0
        /// <summary>
        /// Gets control which represents shortcut item.
        /// This item MUST be syncronized with the original
        /// and send command to original one control.
        /// </summary>
        /// <returns>Control which represents shortcut item</returns>
        public virtual FrameworkElement CreateQuickAccessItem()
        {
            RadioButton button = new RadioButton();

            RibbonControl.Bind(this, button, "IsChecked", IsCheckedProperty, BindingMode.TwoWay);
            button.Click += ((sender, e) => RaiseEvent(e));
            RibbonControl.BindQuickAccessItem(this, button);

            return(button);
        }
Exemple #2
0
        /// <summary>
        /// Gets control which represents shortcut item.
        /// This item MUST be syncronized with the original
        /// and send command to original one control.
        /// </summary>
        /// <returns>Control which represents shortcut item</returns>
        public FrameworkElement CreateQuickAccessItem()
        {
            RibbonGroupBox groupBox = new RibbonGroupBox();

            groupBox.DropDownOpened += OnQuickAccessOpened;
            groupBox.DropDownClosed += OnQuickAccessClosed;
            groupBox.State           = RibbonGroupBoxState.QuickAccess;


            //RibbonControl.BindQuickAccessItem(this, groupBox);
            //if (QuickAccessElementStyle != null) RibbonControl.Bind(this, groupBox, "QuickAccessElementStyle", StyleProperty, BindingMode.OneWay);
            //RibbonControl.Bind(this, groupBox, "Icon", RibbonControl.IconProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, groupBox, "LauncherCommandParameter", LauncherCommandParameterProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, groupBox, "LauncherCommand", LauncherCommandProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, groupBox, "LauncherCommandTarget", LauncherCommandTargetProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, groupBox, "LauncherIcon", LauncherIconProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, groupBox, "LauncherText", LauncherTextProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, groupBox, "LauncherToolTip", LauncherToolTipProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, groupBox, "IsLauncherEnabled", IsLauncherEnabledProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, groupBox, "IsLauncherVisible", IsLauncherVisibleProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, groupBox, "DialogLauncherButtonKeyTipKeys", DialogLauncherButtonKeyTipKeysProperty, BindingMode.OneWay);
            groupBox.LauncherClick += this.LauncherClick;
            if (Icon != null)
            {
                Visual iconVisual = Icon as Visual;
                if (iconVisual != null)
                {
                    Rectangle rect = new Rectangle();
                    rect.Width    = 16;
                    rect.Height   = 16;
                    rect.Fill     = new VisualBrush(iconVisual);
                    groupBox.Icon = rect;
                }
                else
                {
                    RibbonControl.Bind(this, groupBox, "Icon", RibbonControl.IconProperty, BindingMode.OneWay);
                }
            }
            if (Header != null)
            {
                RibbonControl.Bind(this, groupBox, "Header", RibbonControl.HeaderProperty, BindingMode.OneWay);
            }

            return(groupBox);
        }
Exemple #3
0
 /// <summary>
 /// This method must be overridden to bind properties to use in quick access creating
 /// </summary>
 /// <param name="element">Toolbar item</param>
 protected override void BindQuickAccessItem(FrameworkElement element)
 {
     RibbonControl.Bind(this, element, "DisplayMemberPath", DisplayMemberPathProperty, BindingMode.OneWay);
     RibbonControl.Bind(this, element, "GroupStyleSelector", GroupStyleSelectorProperty, BindingMode.OneWay);
     RibbonControl.Bind(this, element, "ItemContainerStyle", ItemContainerStyleProperty, BindingMode.OneWay);
     RibbonControl.Bind(this, element, "ItemsPanel", ItemsPanelProperty, BindingMode.OneWay);
     RibbonControl.Bind(this, element, "ItemStringFormat", ItemStringFormatProperty, BindingMode.OneWay);
     RibbonControl.Bind(this, element, "ItemTemplate", ItemTemplateProperty, BindingMode.OneWay);
     RibbonControl.Bind(this, element, "MaxDropDownHeight", MaxDropDownHeightProperty, BindingMode.OneWay);
     RibbonControl.Bind(this, element, "IsChecked", IsCheckedProperty, BindingMode.TwoWay);
     RibbonControl.Bind(this, element, "DropDownToolTip", DropDownToolTipProperty, BindingMode.TwoWay);
     RibbonControl.Bind(this, element, "IsCheckable", IsCheckableProperty, BindingMode.Default);
     RibbonControl.Bind(this, element, "IsButtonEnabled", IsButtonEnabledProperty, BindingMode.Default);
     RibbonControl.Bind(this, element, "ContextMenu", ContextMenuProperty, BindingMode.Default);
     RibbonControl.BindQuickAccessItem(this, element);
     RibbonControl.Bind(this, element, "ResizeMode", ResizeModeProperty, BindingMode.Default);
     RibbonControl.Bind(this, element, "MaxDropDownHeight", MaxDropDownHeightProperty, BindingMode.Default);
     RibbonControl.Bind(this, element, "HasTriangle", HasTriangleProperty, BindingMode.Default);
 }
Exemple #4
0
 /// <summary>
 /// Gets control which represents shortcut item.
 /// This item MUST be synchronized with the original
 /// and send command to original one control.
 /// </summary>
 /// <returns>Control which represents shortcut item</returns>
 public FrameworkElement CreateQuickAccessItem()
 {
     if (HasItems)
     {
         if (IsSplited)
         {
             SplitButton button = new SplitButton();
             RibbonControl.BindQuickAccessItem(this, button);
             RibbonControl.Bind(this, button, "ResizeMode", ResizeModeProperty, BindingMode.Default);
             RibbonControl.Bind(this, button, "MaxDropDownHeight", MaxDropDownHeightProperty, BindingMode.Default);
             RibbonControl.Bind(this, button, "DisplayMemberPath", DisplayMemberPathProperty, BindingMode.OneWay);
             RibbonControl.Bind(this, button, "GroupStyleSelector", GroupStyleSelectorProperty, BindingMode.OneWay);
             RibbonControl.Bind(this, button, "ItemContainerStyle", ItemContainerStyleProperty, BindingMode.OneWay);
             RibbonControl.Bind(this, button, "ItemsPanel", ItemsPanelProperty, BindingMode.OneWay);
             RibbonControl.Bind(this, button, "ItemStringFormat", ItemStringFormatProperty, BindingMode.OneWay);
             RibbonControl.Bind(this, button, "ItemTemplate", ItemTemplateProperty, BindingMode.OneWay);
             button.DropDownOpened += OnQuickAccessOpened;
             return(button);
         }
         else
         {
             DropDownButton button = new DropDownButton();
             RibbonControl.BindQuickAccessItem(this, button);
             RibbonControl.Bind(this, button, "ResizeMode", ResizeModeProperty, BindingMode.Default);
             RibbonControl.Bind(this, button, "MaxDropDownHeight", MaxDropDownHeightProperty, BindingMode.Default);
             RibbonControl.Bind(this, button, "DisplayMemberPath", DisplayMemberPathProperty, BindingMode.OneWay);
             RibbonControl.Bind(this, button, "GroupStyleSelector", GroupStyleSelectorProperty, BindingMode.OneWay);
             RibbonControl.Bind(this, button, "ItemContainerStyle", ItemContainerStyleProperty, BindingMode.OneWay);
             RibbonControl.Bind(this, button, "ItemsPanel", ItemsPanelProperty, BindingMode.OneWay);
             RibbonControl.Bind(this, button, "ItemStringFormat", ItemStringFormatProperty, BindingMode.OneWay);
             RibbonControl.Bind(this, button, "ItemTemplate", ItemTemplateProperty, BindingMode.OneWay);
             button.DropDownOpened += OnQuickAccessOpened;
             return(button);
         }
     }
     else
     {
         Button button = new Button();
         RibbonControl.BindQuickAccessItem(this, button);
         return(button);
     }
 }
Exemple #5
0
        /// <summary>
        /// Gets control which represents shortcut item.
        /// This item MUST be synchronized with the original
        /// and send command to original one control.
        /// </summary>
        /// <returns>Control which represents shortcut item</returns>
        public virtual FrameworkElement CreateQuickAccessItem()
        {
            var button = new DropDownButton();

            RibbonAttachedProperties.SetRibbonSize(button, RibbonControlSize.Small);

            BindQuickAccessItem(button);
            RibbonControl.Bind(this, button, "DisplayMemberPath", DisplayMemberPathProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, button, "GroupStyleSelector", GroupStyleSelectorProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, button, "ItemContainerStyle", ItemContainerStyleProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, button, "ItemsPanel", ItemsPanelProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, button, "ItemStringFormat", ItemStringFormatProperty, BindingMode.OneWay);
            RibbonControl.Bind(this, button, "ItemTemplate", ItemTemplateProperty, BindingMode.OneWay);

            RibbonControl.Bind(this, button, "MaxDropDownHeight", MaxDropDownHeightProperty, BindingMode.OneWay);

            BindQuickAccessItemDropDownEvents(button);

            button.DropDownOpened += OnQuickAccessOpened;
            return(button);
        }
Exemple #6
0
        void Refresh()
        {
            // Clear currently used group containers
            // and supply with new generated ones
            foreach (GalleryGroupContainer galleryGroupContainer in galleryGroupContainers)
            {
                BindingOperations.ClearAllBindings(galleryGroupContainer);
                //RemoveVisualChild(galleryGroupContainer);
                visualCollection.Remove(galleryGroupContainer);
            }
            galleryGroupContainers.Clear();

            // Gets filters
            string[] filter = Filter == null ? null : Filter.Split(',');

            Dictionary <string, GalleryGroupContainer> dictionary = new Dictionary <string, GalleryGroupContainer>();

            foreach (UIElement item in InternalChildren)
            {
                if (item == null)
                {
                    continue;
                }

                // Resolve group name
                string propertyValue;
                if (GroupByAdvanced == null)
                {
                    propertyValue = (ItemContainerGenerator == null)
                                        ? GetPropertyValueAsString(item)
                                        : GetPropertyValueAsString(ItemContainerGenerator.ItemFromContainer(item));
                }
                else
                {
                    propertyValue = (ItemContainerGenerator == null)
                                        ? GroupByAdvanced(item)
                                        : GroupByAdvanced(ItemContainerGenerator.ItemFromContainer(item));
                }
                if (propertyValue == null)
                {
                    propertyValue = "Undefined";
                }

                // Make invisible if it is not in filter (or is not grouped)
                if ((!IsGrouped) || (filter != null && !filter.Contains(propertyValue)))
                {
                    item.Measure(new Size(0, 0));
                    item.Arrange(new Rect(0, 0, 0, 0));
                }
                // Skip if it is not in filter
                if (filter != null && !filter.Contains(propertyValue))
                {
                    continue;
                }

                // To put all items in one group in case of IsGrouped = False
                if (!IsGrouped)
                {
                    propertyValue = "Undefined";
                }

                if (!dictionary.ContainsKey(propertyValue))
                {
                    GalleryGroupContainer galleryGroupContainer = new GalleryGroupContainer();
                    galleryGroupContainer.Header = propertyValue;
                    RibbonControl.Bind(this, galleryGroupContainer, "GroupStyle", GroupStyleProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "Orientation", GalleryGroupContainer.OrientationProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "ItemWidth", GalleryGroupContainer.ItemWidthProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "ItemHeight", GalleryGroupContainer.ItemHeightProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "MaxItemsInRow", GalleryGroupContainer.MaxItemsInRowProperty, BindingMode.OneWay);
                    RibbonControl.Bind(this, galleryGroupContainer, "MinItemsInRow", GalleryGroupContainer.MinItemsInRowProperty, BindingMode.OneWay);
                    dictionary.Add(propertyValue, galleryGroupContainer);
                    galleryGroupContainers.Add(galleryGroupContainer);

                    visualCollection.Add(galleryGroupContainer);
                }
                dictionary[propertyValue].Items.Add(new GalleryItemPlaceholder(item));
            }

            if (((!IsGrouped) || (GroupBy == null && GroupByAdvanced == null)) && galleryGroupContainers.Count != 0)
            {
                // Make it without headers
                galleryGroupContainers[0].IsHeadered = false;
            }

            InvalidateMeasure();
        }