Inheritance: RibbonControl
Exemple #1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.window = ((Fluent.Sample.Galleries.Window)(target));
                return;

            case 2:
                this.A = ((Fluent.RibbonGroupBox)(target));
                return;

            case 3:
                this.buttonGreen = ((Fluent.DropDownButton)(target));
                return;

            case 4:
                this.B = ((Fluent.RibbonGroupBox)(target));
                return;

            case 5:
                this.inRibbonGallery = ((Fluent.InRibbonGallery)(target));
                return;

            case 6:
                this.galleryFilterAll = ((Fluent.GalleryGroupFilter)(target));
                return;
            }
            this._contentLoaded = true;
        }
Exemple #2
0
    void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
    {
        switch (connectionId)
        {
        case 1:
            this.CancelButton = ((Fluent.Button)(target));
            return;

        case 2:
            this.OKButton = ((Fluent.Button)(target));
            return;

        case 3:
            this.RowsTextBox = ((Fluent.Spinner)(target));
            return;

        case 4:
            this.CellsTextBox = ((Fluent.Spinner)(target));
            return;

        case 5:
            this.BorderColorButton = ((Fluent.DropDownButton)(target));
            return;

        case 6:
            this.BorderColorGallery = ((Fluent.ColorGallery)(target));
            return;

        case 7:
            this.BackgroundColorGallery = ((Fluent.ColorGallery)(target));
            return;

        case 8:
            this.PreviewBox = ((System.Windows.Controls.RichTextBox)(target));
            return;

        case 9:
            this.CellBorderColorButton = ((Fluent.DropDownButton)(target));
            return;

        case 10:
            this.CellBorderColorGallery = ((Fluent.ColorGallery)(target));
            return;

        case 11:
            this.CellBackgroundColorGallery = ((Fluent.ColorGallery)(target));
            return;
        }
        this._contentLoaded = true;
    }
Exemple #3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.window = ((Fluent.Sample.ColorGallery.Window)(target));
                return;

            case 2:
                this.A = ((Fluent.RibbonGroupBox)(target));
                return;

            case 3:
                this.colorPickerStandard = ((Fluent.DropDownButton)(target));
                return;

            case 4:
                this.colorGalleryStandard = ((Fluent.ColorGallery)(target));
                return;

            case 5:
                this.colorPickerThemed = ((Fluent.DropDownButton)(target));
                return;

            case 6:
                this.colorGalleryThemed = ((Fluent.ColorGallery)(target));
                return;

            case 7:
                this.colorPickerHighlight = ((Fluent.DropDownButton)(target));
                return;

            case 8:
                this.colorGalleryHighlight = ((Fluent.ColorGallery)(target));
                return;
            }
            this._contentLoaded = true;
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application 
        /// code or internal processes call ApplyTemplate
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (expandButton != null) expandButton.Click -= OnExpandClick;
            expandButton = GetTemplateChild("PART_ExpandButton") as ToggleButton;
            if (expandButton != null) expandButton.Click += OnExpandClick;

            if (dropDownButton != null) dropDownButton.Click -= OnDropDownClick;
            dropDownButton = GetTemplateChild("PART_DropDownButton") as ToggleButton;
            if (dropDownButton != null) dropDownButton.Click += OnDropDownClick;

            layoutRoot = GetTemplateChild("PART_LayoutRoot") as Panel;

            if (popup != null)
            {
                popup.Opened -= OnDropDownOpened;
                popup.Closed -= OnDropDownClosed;

                popup.PreviewMouseLeftButtonUp -= OnPopupPreviewMouseUp;
                popup.PreviewMouseLeftButtonDown -= OnPopupPreviewMouseDown;
            }

            popup = GetTemplateChild("PART_Popup") as Popup;

            if (popup != null)
            {
                popup.Opened += OnDropDownOpened;
                popup.Closed += OnDropDownClosed;

                popup.PreviewMouseLeftButtonUp += OnPopupPreviewMouseUp;
                popup.PreviewMouseLeftButtonDown += OnPopupPreviewMouseDown;

                KeyboardNavigation.SetControlTabNavigation(popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetDirectionalNavigation(popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetTabNavigation(popup, KeyboardNavigationMode.Cycle);
            }

            if (resizeVerticalThumb != null)
            {
                resizeVerticalThumb.DragDelta -= OnResizeVerticalDelta;
            }
            resizeVerticalThumb = GetTemplateChild("PART_ResizeVerticalThumb") as Thumb;
            if (resizeVerticalThumb != null)
            {
                resizeVerticalThumb.DragDelta += OnResizeVerticalDelta;
            }

            if (resizeBothThumb != null)
            {
                resizeBothThumb.DragDelta -= OnResizeBothDelta;
            }
            resizeBothThumb = GetTemplateChild("PART_ResizeBothThumb") as Thumb;
            if (resizeBothThumb != null)
            {
                resizeBothThumb.DragDelta += OnResizeBothDelta;
            }

            menuPanel = GetTemplateChild("PART_MenuPanel") as Panel;

            if (groupsMenuButton != null) groupsMenuButton.Items.Clear();
            groupsMenuButton = GetTemplateChild("PART_FilterDropDownButton") as DropDownButton;
            if (groupsMenuButton != null)
            {
                for (int i = 0; i < Filters.Count; i++)
                {
                    MenuItem item = new MenuItem();
                    item.Header = Filters[i].Title;
                    item.Tag = Filters[i];
                    item.IsDefinitive = false;
                    if (Filters[i] == SelectedFilter) item.IsChecked = true;
                    item.Click += OnFilterMenuItemClick;
                    groupsMenuButton.Items.Add(item);
                }
            }

            galleryPanel = GetTemplateChild("PART_GalleryPanel") as GalleryPanel;
            if (galleryPanel != null)
            {
                galleryPanel.MinItemsInRow = MaxItemsInRow;
                galleryPanel.MaxItemsInRow = MaxItemsInRow;
            }

            snappedImage = GetTemplateChild("PART_FakeImage") as Image;

            controlPresenter = GetTemplateChild("PART_ContentPresenter") as ContentControl;
            popupControlPresenter = GetTemplateChild("PART_PopupContentPresenter") as ContentControl;

            scrollViewer = GetTemplateChild("PART_ScrollViewer") as ScrollViewer;
        }
 void OnQuickAccessClick(object sender, MouseButtonEventArgs e)
 {
     DropDownButton button = (DropDownButton)sender;
     button.ResizeMode = parentContextMenu.ResizeMode;
     for (int i = 0; i < parentContextMenu.Items.Count; i++)
     {
         UIElement item = parentContextMenu.Items[0];
         parentContextMenu.Items.Remove(item);
         button.Items.Add(item);
         i--;
     }
     button.Closed += OnQuickAccessMenuClosed;
     quickAccessButton = button;
 }
Exemple #6
0
        /// <inheritdoc />
        public override void OnApplyTemplate()
        {
            if (this.showAbove != null)
            {
                this.showAbove.Click -= this.OnShowAboveClick;
            }

            if (this.showBelow != null)
            {
                this.showBelow.Click -= this.OnShowBelowClick;
            }

            this.showAbove = this.GetTemplateChild("PART_ShowAbove") as MenuItem;
            this.showBelow = this.GetTemplateChild("PART_ShowBelow") as MenuItem;

            if (this.showAbove != null)
            {
                this.showAbove.Click += this.OnShowAboveClick;
            }

            if (this.showBelow != null)
            {
                this.showBelow.Click += this.OnShowBelowClick;
            }

            if (this.MenuDownButton != null)
            {
                foreach (var item in this.QuickAccessItems)
                {
                    this.MenuDownButton.Items.Remove(item);
                    item.InvalidateProperty(QuickAccessMenuItem.TargetProperty);
                }
            }
            else if (this.quickAccessItems != null)
            {
                foreach (var item in this.quickAccessItems)
                {
                    this.RemoveLogicalChild(item);
                }
            }

            this.MenuDownButton = this.GetTemplateChild("PART_MenuDownButton") as DropDownButton;

            if (this.MenuDownButton != null &&
                this.quickAccessItems != null)
            {
                for (var i = 0; i < this.quickAccessItems.Count; i++)
                {
                    this.MenuDownButton.Items.Insert(i + 1, this.quickAccessItems[i]);
                    this.quickAccessItems[i].InvalidateProperty(QuickAccessMenuItem.TargetProperty);
                }
            }

            this.toolBarDownButton = this.GetTemplateChild("PART_ToolbarDownButton") as DropDownButton;

            // ToolBar panels
            this.toolBarPanel         = this.GetTemplateChild("PART_ToolBarPanel") as Panel;
            this.toolBarOverflowPanel = this.GetTemplateChild("PART_ToolBarOverflowPanel") as Panel;

            if (this.rootPanel != null)
            {
                this.RemoveLogicalChild(this.rootPanel);
            }

            this.rootPanel = this.GetTemplateChild("PART_RootPanel") as Panel;

            if (this.rootPanel != null)
            {
                this.AddLogicalChild(this.rootPanel);
            }

            // Clears cache
            this.cachedMenuDownButtonWidth     = 0;
            this.cachedOverflowDownButtonWidth = 0;
            this.cachedNonOverflowItemsCount   = this.GetNonOverflowItemsCount(this.ActualWidth);
            this.cachedConstraint = default;
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.btnLoad = ((Fluent.Button)(target));

            #line 30 "..\..\MainWindow.xaml"
                this.btnLoad.Click += new System.Windows.RoutedEventHandler(this.btnLoad_click);

            #line default
            #line hidden
                return;

            case 2:
                this.btnNewInstance = ((Fluent.Button)(target));

            #line 31 "..\..\MainWindow.xaml"
                this.btnNewInstance.Click += new System.Windows.RoutedEventHandler(this.btnNewInstance_click);

            #line default
            #line hidden
                return;

            case 3:
                this.btnSave = ((Fluent.Button)(target));

            #line 34 "..\..\MainWindow.xaml"
                this.btnSave.Click += new System.Windows.RoutedEventHandler(this.btnSave_click);

            #line default
            #line hidden
                return;

            case 4:
                this.btnSaveAs = ((Fluent.Button)(target));

            #line 35 "..\..\MainWindow.xaml"
                this.btnSaveAs.Click += new System.Windows.RoutedEventHandler(this.btnSaveAs_click);

            #line default
            #line hidden
                return;

            case 5:
                this.btnUndo = ((Fluent.Button)(target));

            #line 36 "..\..\MainWindow.xaml"
                this.btnUndo.Click += new System.Windows.RoutedEventHandler(this.btnSaveAs_click);

            #line default
            #line hidden
                return;

            case 6:
                this.btnRedo = ((Fluent.Button)(target));

            #line 37 "..\..\MainWindow.xaml"
                this.btnRedo.Click += new System.Windows.RoutedEventHandler(this.btnSaveAs_click);

            #line default
            #line hidden
                return;

            case 7:
                this.btnDisplay = ((Fluent.Button)(target));

            #line 38 "..\..\MainWindow.xaml"
                this.btnDisplay.Click += new System.Windows.RoutedEventHandler(this.btnDisplay_click);

            #line default
            #line hidden
                return;

            case 8:
                this.btn_bold = ((Fluent.Button)(target));

            #line 44 "..\..\MainWindow.xaml"
                this.btn_bold.Click += new System.Windows.RoutedEventHandler(this.btnBold_click);

            #line default
            #line hidden
                return;

            case 9:
                this.btn_italic = ((Fluent.Button)(target));

            #line 45 "..\..\MainWindow.xaml"
                this.btn_italic.Click += new System.Windows.RoutedEventHandler(this.btnItalic_click);

            #line default
            #line hidden
                return;

            case 10:
                this.btn_mark_code = ((Fluent.Button)(target));

            #line 48 "..\..\MainWindow.xaml"
                this.btn_mark_code.Click += new System.Windows.RoutedEventHandler(this.btnCode_click);

            #line default
            #line hidden
                return;

            case 11:
                this.btn_list = ((Fluent.Button)(target));

            #line 51 "..\..\MainWindow.xaml"
                this.btn_list.Click += new System.Windows.RoutedEventHandler(this.btnList_click);

            #line default
            #line hidden
                return;

            case 12:
                this.btn_numberd_list = ((Fluent.Button)(target));

            #line 52 "..\..\MainWindow.xaml"
                this.btn_numberd_list.Click += new System.Windows.RoutedEventHandler(this.btnNumberedList_click);

            #line default
            #line hidden
                return;

            case 13:
                this.btn_seperator = ((Fluent.Button)(target));

            #line 57 "..\..\MainWindow.xaml"
                this.btn_seperator.Click += new System.Windows.RoutedEventHandler(this.btnSeparator_click);

            #line default
            #line hidden
                return;

            case 14:
                this.btn_linebreak = ((Fluent.Button)(target));

            #line 58 "..\..\MainWindow.xaml"
                this.btn_linebreak.Click += new System.Windows.RoutedEventHandler(this.btnLineBreak_click);

            #line default
            #line hidden
                return;

            case 15:
                this.btn_paragraph = ((Fluent.Button)(target));

            #line 59 "..\..\MainWindow.xaml"
                this.btn_paragraph.Click += new System.Windows.RoutedEventHandler(this.btnParagraph_click);

            #line default
            #line hidden
                return;

            case 16:
                this.ddbtn_Heading = ((Fluent.DropDownButton)(target));
                return;

            case 17:

            #line 64 "..\..\MainWindow.xaml"
                ((Fluent.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnClickHeading1Level);

            #line default
            #line hidden
                return;

            case 18:

            #line 65 "..\..\MainWindow.xaml"
                ((Fluent.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnClickHeading2Level);

            #line default
            #line hidden
                return;

            case 19:

            #line 66 "..\..\MainWindow.xaml"
                ((Fluent.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnClickHeading3Level);

            #line default
            #line hidden
                return;

            case 20:

            #line 67 "..\..\MainWindow.xaml"
                ((Fluent.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnClickHeading4Level);

            #line default
            #line hidden
                return;

            case 21:

            #line 68 "..\..\MainWindow.xaml"
                ((Fluent.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnClickHeading5Level);

            #line default
            #line hidden
                return;

            case 22:

            #line 69 "..\..\MainWindow.xaml"
                ((Fluent.MenuItem)(target)).Click += new System.Windows.RoutedEventHandler(this.OnClickHeading6Level);

            #line default
            #line hidden
                return;

            case 23:
                this.btn_quote = ((Fluent.Button)(target));

            #line 74 "..\..\MainWindow.xaml"
                this.btn_quote.Click += new System.Windows.RoutedEventHandler(this.btnQuote_click);

            #line default
            #line hidden
                return;

            case 24:
                this.btn_unquote = ((Fluent.Button)(target));

            #line 75 "..\..\MainWindow.xaml"
                this.btn_unquote.Click += new System.Windows.RoutedEventHandler(this.btnUnQuote_click);

            #line default
            #line hidden
                return;

            case 25:
                this.btn_insert_photo = ((Fluent.Button)(target));

            #line 80 "..\..\MainWindow.xaml"
                this.btn_insert_photo.Click += new System.Windows.RoutedEventHandler(this.btnInsertPhoto_click);

            #line default
            #line hidden
                return;

            case 26:
                this.btn_insert_hyperlink = ((Fluent.Button)(target));

            #line 83 "..\..\MainWindow.xaml"
                this.btn_insert_hyperlink.Click += new System.Windows.RoutedEventHandler(this.btnInsertHyperlink_click);

            #line default
            #line hidden
                return;

            case 27:
                this.btn_insert_table = ((Fluent.Button)(target));

            #line 84 "..\..\MainWindow.xaml"
                this.btn_insert_table.Click += new System.Windows.RoutedEventHandler(this.btnInsertTable_click);

            #line default
            #line hidden
                return;

            case 28:
                this.rtbMainText = ((System.Windows.Controls.RichTextBox)(target));
                return;

            case 29:
                this.webBrowser = ((System.Windows.Controls.WebBrowser)(target));
                return;
            }
            this._contentLoaded = true;
        }
        /// <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
                {
                    Size = 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;
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application 
        /// code or internal processes call ApplyTemplate
        /// </summary>
        public override void OnApplyTemplate()
        {
            this.layoutRoot = this.GetTemplateChild("PART_LayoutRoot") as FrameworkElement;

            if (this.expandButton != null)
                this.expandButton.Click -= this.OnExpandClick;
            this.expandButton = this.GetTemplateChild("PART_ExpandButton") as ToggleButton;
            if (this.expandButton != null)
                this.expandButton.Click += this.OnExpandClick;

            if (this.dropDownButton != null)
                this.dropDownButton.Click -= this.OnDropDownClick;
            this.dropDownButton = this.GetTemplateChild("PART_DropDownButton") as ToggleButton;
            if (this.dropDownButton != null)
                this.dropDownButton.Click += this.OnDropDownClick;

            if (this.popup != null)
            {
                this.popup.Opened -= this.OnDropDownOpened;
                this.popup.Closed -= this.OnDropDownClosed;

                this.popup.PreviewMouseLeftButtonUp -= this.OnPopupPreviewMouseUp;
                this.popup.PreviewMouseLeftButtonDown -= this.OnPopupPreviewMouseDown;
            }

            this.popup = this.GetTemplateChild("PART_Popup") as Popup;

            if (this.popup != null)
            {
                this.popup.Opened += this.OnDropDownOpened;
                this.popup.Closed += this.OnDropDownClosed;

                this.popup.PreviewMouseLeftButtonUp += this.OnPopupPreviewMouseUp;
                this.popup.PreviewMouseLeftButtonDown += this.OnPopupPreviewMouseDown;

                KeyboardNavigation.SetControlTabNavigation(this.popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetDirectionalNavigation(this.popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetTabNavigation(this.popup, KeyboardNavigationMode.Cycle);
            }

            if (this.resizeVerticalThumb != null)
            {
                this.resizeVerticalThumb.DragDelta -= this.OnResizeVerticalDelta;
            }
            this.resizeVerticalThumb = this.GetTemplateChild("PART_ResizeVerticalThumb") as Thumb;
            if (this.resizeVerticalThumb != null)
            {
                this.resizeVerticalThumb.DragDelta += this.OnResizeVerticalDelta;
            }

            if (this.resizeBothThumb != null)
            {
                this.resizeBothThumb.DragDelta -= this.OnResizeBothDelta;
            }
            this.resizeBothThumb = this.GetTemplateChild("PART_ResizeBothThumb") as Thumb;
            if (this.resizeBothThumb != null)
            {
                this.resizeBothThumb.DragDelta += this.OnResizeBothDelta;
            }

            this.menuPanel = this.GetTemplateChild("PART_MenuPanel") as Panel;

            if (this.groupsMenuButton != null)
                this.groupsMenuButton.Items.Clear();
            this.groupsMenuButton = this.GetTemplateChild("PART_FilterDropDownButton") as DropDownButton;
            if (this.groupsMenuButton != null)
            {
                for (int i = 0; i < this.Filters.Count; i++)
                {
                    MenuItem item = new MenuItem();
                    item.Header = this.Filters[i].Title;
                    item.Tag = this.Filters[i];
                    item.IsDefinitive = false;
                    if (this.Filters[i] == this.SelectedFilter) item.IsChecked = true;
                    item.Click += this.OnFilterMenuItemClick;
                    this.groupsMenuButton.Items.Add(item);
                }
            }

			this.galleryPanel = this.GetTemplateChild("PART_GalleryPanel") as GalleryPanel;

            if (this.galleryPanel != null)
            {
				this.galleryPanel.MinItemsInRow = this.MaxItemsInRow;
				this.galleryPanel.MaxItemsInRow = this.MaxItemsInRow;
            }

            this.snappedImage = this.GetTemplateChild("PART_FakeImage") as Image;

            this.controlPresenter = this.GetTemplateChild("PART_ContentPresenter") as ContentControl;
            this.popupControlPresenter = this.GetTemplateChild("PART_PopupContentPresenter") as ContentControl;

            this.scrollViewer = this.GetTemplateChild("PART_ScrollViewer") as ScrollViewer;
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or 
        /// internal processes call System.Windows.FrameworkElement.ApplyTemplate().
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (showAbove != null) showAbove.Click -= OnShowAboveClick;
            if (showBelow != null) showBelow.Click -= OnShowBelowClick;
            
            showAbove = GetTemplateChild("PART_ShowAbove") as MenuItem;            
            showBelow = GetTemplateChild("PART_ShowBelow") as MenuItem;

            if (showAbove != null) showAbove.Click += OnShowAboveClick;
            if (showBelow != null) showBelow.Click += OnShowBelowClick;

            if (menuDownButton != null)
            {
                for (int i = 0; i < QuickAccessItems.Count; i++)
                {
                    menuDownButton.Items.Remove(QuickAccessItems[i]);
                    QuickAccessItems[i].InvalidateProperty(QuickAccessMenuItem.TargetProperty);
                }
            }
            else if(quickAccessItems!=null)
            {
                for (int i = 0; i < quickAccessItems.Count; i++)
                {
                    RemoveLogicalChild(quickAccessItems[i]);
                }
            }
            menuDownButton = GetTemplateChild("PART_MenuDownButton") as DropDownButton;
            if ((menuDownButton != null) && (quickAccessItems != null))
            {
                for (int i = 0; i < quickAccessItems.Count; i++)
                {
                    menuDownButton.Items.Insert(i + 1, quickAccessItems[i]);
                    quickAccessItems[i].InvalidateProperty(QuickAccessMenuItem.TargetProperty);
                }
            }


            if (toolBarDownButton != null)
            {
                toolBarDownButton.DropDownOpened -= OnToolBarDownOpened;
                toolBarDownButton.DropDownClosed -= OnToolBarDownClosed;
            }
            toolBarDownButton = GetTemplateChild("PART_ToolbarDownButton") as DropDownButton;
            if (toolBarDownButton != null)
            {
                toolBarDownButton.DropDownOpened += OnToolBarDownOpened;
                toolBarDownButton.DropDownClosed += OnToolBarDownClosed;
            }


            //DropDownButton btn = GetTemplateChild("PART_MenuDownButton") as DropDownButton;
            //if (btn != null) btn.ContextMenu = btn.DropDownMenu;
            
            // ToolBar panels
            
            toolBarPanel = GetTemplateChild("PART_ToolBarPanel") as Panel;
            toolBarOverflowPanel = GetTemplateChild("PART_ToolBarOverflowPanel") as Panel;

            if (rootPanel != null) RemoveLogicalChild(rootPanel);
            rootPanel = GetTemplateChild("PART_RootPanel") as Panel;
            if (rootPanel != null) AddLogicalChild(rootPanel);

            // Clears cache
            cachedDeltaWidth = 0;
            cachedCount = GetNonOverflowItemsCount(ActualWidth);
            cachedConstraint = new Size();
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application 
        /// code or internal processes call ApplyTemplate
        /// </summary>
        public override void OnApplyTemplate()
        {
            this.layoutRoot = this.GetTemplateChild("PART_LayoutRoot") as FrameworkElement;

            if (this.expandButton != null)
            {
                this.expandButton.Click -= this.OnExpandClick;
            }

            this.expandButton = this.GetTemplateChild("PART_ExpandButton") as ToggleButton;

            if (this.expandButton != null)
            {
                this.expandButton.Click += this.OnExpandClick;
            }

            if (this.dropDownButton != null)
            {
                this.dropDownButton.Click -= this.OnDropDownClick;
            }

            this.dropDownButton = this.GetTemplateChild("PART_DropDownButton") as ToggleButton;

            if (this.dropDownButton != null)
            {
                this.dropDownButton.Click += this.OnDropDownClick;
            }

            if (this.popup != null)
            {
                this.popup.Opened -= this.OnDropDownOpened;
                this.popup.Closed -= this.OnDropDownClosed;

                this.popup.PreviewMouseLeftButtonUp -= this.OnPopupPreviewMouseUp;
                this.popup.PreviewMouseLeftButtonDown -= this.OnPopupPreviewMouseDown;
            }

            this.popup = this.GetTemplateChild("PART_Popup") as Popup;

            if (this.popup != null)
            {
                this.popup.Opened += this.OnDropDownOpened;
                this.popup.Closed += this.OnDropDownClosed;

                this.popup.PreviewMouseLeftButtonUp += this.OnPopupPreviewMouseUp;
                this.popup.PreviewMouseLeftButtonDown += this.OnPopupPreviewMouseDown;

                KeyboardNavigation.SetControlTabNavigation(this.popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetDirectionalNavigation(this.popup, KeyboardNavigationMode.Cycle);
                KeyboardNavigation.SetTabNavigation(this.popup, KeyboardNavigationMode.Cycle);
            }

            if (this.resizeVerticalThumb != null)
            {
                this.resizeVerticalThumb.DragDelta -= this.OnResizeVerticalDelta;
            }

            this.resizeVerticalThumb = this.GetTemplateChild("PART_ResizeVerticalThumb") as Thumb;

            if (this.resizeVerticalThumb != null)
            {
                this.resizeVerticalThumb.DragDelta += this.OnResizeVerticalDelta;
            }

            if (this.resizeBothThumb != null)
            {
                this.resizeBothThumb.DragDelta -= this.OnResizeBothDelta;
            }

            this.resizeBothThumb = this.GetTemplateChild("PART_ResizeBothThumb") as Thumb;

            if (this.resizeBothThumb != null)
            {
                this.resizeBothThumb.DragDelta += this.OnResizeBothDelta;
            }

            this.menuPanel = this.GetTemplateChild("PART_MenuPanel") as Panel;

            this.groupsMenuButton?.Items.Clear();

            this.groupsMenuButton = this.GetTemplateChild("PART_FilterDropDownButton") as DropDownButton;

            if (this.groupsMenuButton != null)
            {
                foreach (var currentFilter in this.Filters)
                {
                    var item = new MenuItem
                    {
                        Header = currentFilter.Title,
                        Tag = currentFilter,
                        IsDefinitive = false
                    };

                    if (ReferenceEquals(currentFilter, this.SelectedFilter))
                    {
                        item.IsChecked = true;
                    }

                    item.Click += this.OnFilterMenuItemClick;
                    this.groupsMenuButton.Items.Add(item);
                }
            }

            this.galleryPanel = this.GetTemplateChild("PART_GalleryPanel") as GalleryPanel;

            if (this.galleryPanel != null)
            {
                this.galleryPanel.MinItemsInRow = this.MinItemsInRow;
                this.galleryPanel.MaxItemsInRow = this.MaxItemsInRow;
                this.galleryPanel.UpdateMinAndMaxWidth();
            }

            this.snappedImage = this.GetTemplateChild("PART_FakeImage") as Image;

            this.controlPresenter = this.GetTemplateChild("PART_ContentPresenter") as ContentControl;

            this.popupControlPresenter = this.GetTemplateChild("PART_PopupContentPresenter") as ContentControl;

            this.scrollViewer = this.GetTemplateChild("PART_ScrollViewer") as ScrollViewer;

            this.RunInDispatcherAsync(this.ForceContentRefreshToFixLayout, DispatcherPriority.ContextIdle);
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or
        /// internal processes call System.Windows.FrameworkElement.ApplyTemplate().
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (showAbove != null)
            {
                showAbove.Click -= OnShowAboveClick;
            }
            if (showBelow != null)
            {
                showBelow.Click -= OnShowBelowClick;
            }

            showAbove = GetTemplateChild("PART_ShowAbove") as MenuItem;
            showBelow = GetTemplateChild("PART_ShowBelow") as MenuItem;

            if (showAbove != null)
            {
                showAbove.Click += OnShowAboveClick;
            }
            if (showBelow != null)
            {
                showBelow.Click += OnShowBelowClick;
            }

            if (menuPanel != null)
            {
                for (int i = 0; i < QuickAccessItems.Count; i++)
                {
                    menuPanel.Children.Remove(QuickAccessItems[i]);
                    QuickAccessItems[i].InvalidateProperty(QuickAccessMenuItem.TargetProperty);
                }
            }
            else if (quickAccessItems != null)
            {
                for (int i = 0; i < quickAccessItems.Count; i++)
                {
                    RemoveLogicalChild(quickAccessItems[i]);
                }
            }
            menuPanel = GetTemplateChild("PART_MenuPanel") as Panel;
            if ((menuPanel != null) && (quickAccessItems != null))
            {
                for (int i = 0; i < quickAccessItems.Count; i++)
                {
                    menuPanel.Children.Add(quickAccessItems[i]);
                    quickAccessItems[i].InvalidateProperty(QuickAccessMenuItem.TargetProperty);
                }
            }

            if (menuButton != null)
            {
                menuButton.Opened -= OnMenuOpened;
                menuButton.Closed -= OnMenuClosed;
            }
            menuButton = GetTemplateChild("PART_ToolbarDownButton") as DropDownButton;
            if (menuButton != null)
            {
                menuButton.Opened += OnMenuOpened;
                menuButton.Closed += OnMenuClosed;
            }

            DropDownButton btn = GetTemplateChild("PART_MenuDownButton") as DropDownButton;

            if (btn != null)
            {
                btn.ContextMenu = btn.DropDownMenu;
            }

            // ToolBar panels

            toolBarPanel         = GetTemplateChild("PART_ToolBarPanel") as Panel;
            toolBarOverflowPanel = GetTemplateChild("PART_ToolBarOverflowPanel") as Panel;
            rootPanel            = GetTemplateChild("PART_RootPanel") as Panel;

            // Clears cache
            cachedDeltaWidth = 0;
            cachedCount      = GetNonOverflowItemsCount(ActualWidth);
            cachedConstraint = new Size();
        }
Exemple #13
0
 /// <summary>
 /// Binds the DropDownClosed and DropDownOpened events to the created quick access item
 /// </summary>
 /// <param name="button">Toolbar item</param>
 protected void BindQuickAccessItemDropDownEvents(DropDownButton button)
 {
     if (this.DropDownClosed != null) button.DropDownClosed += this.DropDownClosed;
     if (this.DropDownOpened != null) button.DropDownOpened += this.DropDownOpened;
 }
        private void OnQuickAccessMenuOpened(object sender, EventArgs e)
        {
            if (ItemsInRow == 0) gallery.MinWidth = Math.Max(ActualWidth, MenuMinWidth);
            else
            {
                gallery.ItemsInRow = ItemsInRow;
            }
            gallery.MinHeight = ActualHeight;
            DropDownButton button = sender as DropDownButton;
            button.ResizeMode = ResizeMode;
            if (!IsCollapsed) IsSnapped = true;

            object selectedItem = SelectedItem;
            if (listBox!=null)
            {
                selectedItem = listBox.SelectedItem;
                listBox.ItemsSource = null;
            }
            if (ItemsSource == null) gallery.ItemsSource = Items;
            else gallery.ItemsSource = ItemsSource;
            gallery.SelectedItem = selectedItem;
            SelectedItem = selectedItem;
            SelectedIndex = gallery.SelectedIndex;

            if (contextMenu != null)
            {
                for (int i = 0; i < contextMenu.Items.Count; i++)
                {
                    UIElement item = contextMenu.Items[0];
                    contextMenu.Items.Remove(item);
                    button.Items.Add(item);
                    i--;
                }
            }
            else
            {                
                RemoveLogicalChild(gallery);
                RemoveLogicalChild(menuBar);
                button.Items.Add(gallery);
                button.Items.Add(menuBar);
            }
            button.Closed += OnQuickAccessMenuClosed;
            quickAccessButton = button;
        }
 /// <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 override FrameworkElement CreateQuickAccessItem()
 {
     DropDownButton button = new DropDownButton();
     BindQuickAccessItem(button);
     /*if (contextMenu == null)
     {
         CreateMenu();
         IsOpen = false;
     }*/            
     return button;
 }
Exemple #16
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (this.groupsMenuButton != null)
            {
                this.groupsMenuButton.Items.Clear();
            }

            this.groupsMenuButton = this.GetTemplateChild("PART_DropDownButton") as DropDownButton;

            if (this.groupsMenuButton != null)
            {
                for (int i = 0; i < this.Filters.Count; i++)
                {
                    var item = new MenuItem
                        {
                            Header = this.Filters[i].Title,
                            Tag = this.Filters[i],
                            IsDefinitive = false
                        };

                    if (this.Filters[i] == this.SelectedFilter)
                    {
                        item.IsChecked = true;
                    }

                    item.Click += this.OnFilterMenuItemClick;
                    this.groupsMenuButton.Items.Add(item);
                }
            }

            base.OnApplyTemplate();
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or 
        /// internal processes call System.Windows.FrameworkElement.ApplyTemplate().
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (this.showAbove != null)
            {
                this.showAbove.Click -= this.OnShowAboveClick;
            }

            if (this.showBelow != null)
            {
                this.showBelow.Click -= this.OnShowBelowClick;
            }

            this.showAbove = this.GetTemplateChild("PART_ShowAbove") as MenuItem;
            this.showBelow = this.GetTemplateChild("PART_ShowBelow") as MenuItem;

            if (this.showAbove != null)
            {
                this.showAbove.Click += this.OnShowAboveClick;
            }

            if (this.showBelow != null)
            {
                this.showBelow.Click += this.OnShowBelowClick;
            }

            if (this.menuDownButton != null)
            {
                foreach (var item in this.QuickAccessItems)
                {
                    this.menuDownButton.Items.Remove(item);
                    item.InvalidateProperty(QuickAccessMenuItem.TargetProperty);
                }
            }
            else if (this.quickAccessItems != null)
            {
                foreach (var item in this.quickAccessItems)
                {
                    this.RemoveLogicalChild(item);
                }
            }

            this.menuDownButton = this.GetTemplateChild("PART_MenuDownButton") as DropDownButton;

            if (this.menuDownButton != null
                && this.quickAccessItems != null)
            {
                for (var i = 0; i < this.quickAccessItems.Count; i++)
                {
                    this.menuDownButton.Items.Insert(i + 1, this.quickAccessItems[i]);
                    this.quickAccessItems[i].InvalidateProperty(QuickAccessMenuItem.TargetProperty);
                }
            }

            if (this.toolBarDownButton != null)
            {
                this.toolBarDownButton.DropDownOpened -= this.OnToolBarDownOpened;
                this.toolBarDownButton.DropDownClosed -= this.OnToolBarDownClosed;
            }

            this.toolBarDownButton = this.GetTemplateChild("PART_ToolbarDownButton") as DropDownButton;

            if (this.toolBarDownButton != null)
            {
                this.toolBarDownButton.DropDownOpened += this.OnToolBarDownOpened;
                this.toolBarDownButton.DropDownClosed += this.OnToolBarDownClosed;
            }

            // ToolBar panels
            this.toolBarPanel = this.GetTemplateChild("PART_ToolBarPanel") as Panel;
            this.toolBarOverflowPanel = this.GetTemplateChild("PART_ToolBarOverflowPanel") as Panel;

            if (this.rootPanel != null)
            {
                this.RemoveLogicalChild(this.rootPanel);
            }

            this.rootPanel = this.GetTemplateChild("PART_RootPanel") as Panel;

            if (this.rootPanel != null)
            {
                this.AddLogicalChild(this.rootPanel);
            }

            // Clears cache
            this.cachedDeltaWidth = 0;
            this.cachedNonOverflowItemsCount = this.GetNonOverflowItemsCount(this.ActualWidth);
            this.cachedConstraint = new Size();
        }
Exemple #18
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.TestContentControl = ((FluentTest.TestContent)(target));
                return;

            case 3:
                this.ribbon = ((Fluent.Ribbon)(target));
                return;

            case 4:
                this.tabGroup1 = ((Fluent.RibbonContextualTabGroup)(target));
                return;

            case 5:
                this.tabGroup2 = ((Fluent.RibbonContextualTabGroup)(target));
                return;

            case 6:
                this.invisibleTabGroup = ((Fluent.RibbonContextualTabGroup)(target));
                return;

            case 7:
                this.startScreen = ((Fluent.StartScreen)(target));
                return;

            case 8:

            #line 155 "TestContent.xaml"
                ((Fluent.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.HandleSaveAsClick);

            #line default
            #line hidden
                return;

            case 9:

            #line 255 "TestContent.xaml"
                ((Fluent.Spinner)(target)).ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.OnSpinnerValueChanged);

            #line default
            #line hidden
                return;

            case 10:

            #line 284 "TestContent.xaml"
                ((Fluent.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnHelpClick);

            #line default
            #line hidden
                return;

            case 11:
                this.Clipboard = ((Fluent.RibbonGroupBox)(target));

            #line 328 "TestContent.xaml"
                this.Clipboard.LauncherClick += new System.Windows.RoutedEventHandler(this.OnLauncherButtonClick);

            #line default
            #line hidden
                return;

            case 12:
                this.saveButton = ((Fluent.Button)(target));

            #line 337 "TestContent.xaml"
                this.saveButton.Click += new System.Windows.RoutedEventHandler(this.OnSaveButtonClick);

            #line default
            #line hidden
                return;

            case 13:
                this.buttonWatermark = ((Fluent.DropDownButton)(target));
                return;

            case 14:
                this.WatermarkGallery = ((Fluent.Gallery)(target));
                return;

            case 15:

            #line 360 "TestContent.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.New_Suit_Button_Click);

            #line default
            #line hidden
                return;

            case 16:

            #line 374 "TestContent.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.New_Sequence_Button_Click);

            #line default
            #line hidden
                return;

            case 17:

            #line 389 "TestContent.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.New_Step_Button_Click);

            #line default
            #line hidden
                return;

            case 18:
                this.addChildren = ((Fluent.DropDownButton)(target));
                return;

            case 19:
                this.ChildrenGallery = ((Fluent.Gallery)(target));
                return;

            case 20:

            #line 422 "TestContent.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.New_App_Button_Click);

            #line default
            #line hidden
                return;

            case 21:

            #line 434 "TestContent.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.New_DataSource_Button_Click);

            #line default
            #line hidden
                return;

            case 22:

            #line 447 "TestContent.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.New_Variable_Button_Click);

            #line default
            #line hidden
                return;

            case 23:

            #line 460 "TestContent.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.New_Variable_Button_Click);

            #line default
            #line hidden
                return;

            case 24:
                this.cutButton = ((Fluent.Button)(target));
                return;

            case 25:
                this.copyButton = ((Fluent.Button)(target));
                return;

            case 26:
                this.pasteButton = ((Fluent.Button)(target));

            #line 508 "TestContent.xaml"
                this.pasteButton.Click += new System.Windows.RoutedEventHandler(this.OnFormatPainterClick);

            #line default
            #line hidden
                return;

            case 27:
                this.FunctionsGalleryGroup = ((Fluent.RibbonGroupBox)(target));
                return;

            case 28:
                this.galleryFunctionsInRibbonGallery = ((Fluent.InRibbonGallery)(target));
                return;

            case 29:
                this.functionsFilterAll = ((Fluent.GalleryGroupFilter)(target));
                return;

            case 30:
                this.Font = ((Fluent.RibbonGroupBox)(target));

            #line 537 "TestContent.xaml"
                this.Font.LauncherClick += new System.Windows.RoutedEventHandler(this.OnLauncherButtonClick);

            #line default
            #line hidden
                return;

            case 31:
                this.comboBoxFontName = ((Fluent.ComboBox)(target));
                return;

            case 32:
                this.segoeFont = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 33:
                this.comboBoxFontSize = ((Fluent.ComboBox)(target));
                return;

            case 34:
                this.buttonGrowFont = ((Fluent.Button)(target));
                return;

            case 35:
                this.buttonShrinkFont = ((Fluent.Button)(target));
                return;

            case 36:
                this.buttonChangeCase = ((Fluent.DropDownButton)(target));
                return;

            case 37:
                this.buttonClearFormatting = ((Fluent.Button)(target));
                return;

            case 38:
                this.buttonBold = ((Fluent.ToggleButton)(target));
                return;

            case 39:
                this.buttonItalic = ((Fluent.ToggleButton)(target));
                return;

            case 40:
                this.buttonUnderline = ((Fluent.DropDownButton)(target));
                return;

            case 41:
                this.buttonStrikethrough = ((Fluent.Button)(target));
                return;

            case 42:
                this.buttonSubscript = ((Fluent.Button)(target));
                return;

            case 43:
                this.buttonSuperscript = ((Fluent.Button)(target));
                return;

            case 44:
                this.buttonTextEffects = ((Fluent.DropDownButton)(target));
                return;

            case 45:
                this.buttonTextHighlightColor = ((Fluent.DropDownButton)(target));
                return;

            case 46:
                this.buttonFontColor = ((Fluent.DropDownButton)(target));
                return;

            case 47:
                this.Group = ((Fluent.RibbonGroupBox)(target));
                return;

            case 48:
                this.spinner = ((Fluent.Spinner)(target));
                return;

            case 49:
                this.buttonGreen = ((Fluent.Button)(target));
                return;

            case 50:
                this.buttonGray = ((Fluent.Button)(target));
                return;

            case 51:
                this.buttonYellow = ((Fluent.Button)(target));
                return;

            case 52:
                this.buttonBrown = ((Fluent.Button)(target));
                return;

            case 53:
                this.B = ((Fluent.RibbonGroupBox)(target));

            #line 889 "TestContent.xaml"
                this.B.LauncherClick += new System.Windows.RoutedEventHandler(this.OnLauncherButtonClick);

            #line default
            #line hidden
                return;

            case 54:
                this.groupLL = ((Fluent.RibbonGroupBox)(target));
                return;

            case 55:

            #line 951 "TestContent.xaml"
                ((Fluent.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.HandleAddItemToFontsClick);

            #line default
            #line hidden
                return;

            case 56:
                this.InRibbonGallery = ((Fluent.InRibbonGallery)(target));
                return;

            case 57:

            #line 1383 "TestContent.xaml"
                ((Fluent.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnEnlargeClick);

            #line default
            #line hidden
                return;

            case 58:

            #line 1388 "TestContent.xaml"
                ((Fluent.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnReduceClick);

            #line default
            #line hidden
                return;

            case 59:
                this.UndoButton = ((Fluent.SplitButton)(target));
                return;

            case 60:
                this.ShowDetailButton = ((Fluent.ToggleButton)(target));
                return;

            case 61:
                this.ShowMoreButton = ((Fluent.ToggleButton)(target));
                return;

            case 62:
                this.FirstGalleryGroup = ((Fluent.RibbonGroupBox)(target));
                return;

            case 63:
                this.dropDownGreen = ((Fluent.DropDownButton)(target));
                return;

            case 64:
                this.SecondGalleryGroup = ((Fluent.RibbonGroupBox)(target));
                return;

            case 65:
                this.gallerySampleInRibbonGallery = ((Fluent.InRibbonGallery)(target));
                return;

            case 66:
                this.galleryFilterAll = ((Fluent.GalleryGroupFilter)(target));
                return;

            case 67:
                this.A = ((Fluent.RibbonGroupBox)(target));

            #line 1798 "TestContent.xaml"
                this.A.LauncherClick += new System.Windows.RoutedEventHandler(this.OnLauncherButtonClick);

            #line default
            #line hidden
                return;

            case 68:
                this.GalleryFilterAll = ((Fluent.GalleryGroupFilter)(target));
                return;

            case 69:

            #line 1850 "TestContent.xaml"
                ((Fluent.SplitButton)(target)).Click += new System.Windows.RoutedEventHandler(this.OnSplitClick);

            #line default
            #line hidden
                return;

            case 70:
                this.Default = ((Fluent.RibbonGroupBox)(target));
                return;

            case 71:
                this.Large = ((Fluent.RibbonGroupBox)(target));
                return;

            case 72:
                this.Other = ((Fluent.RibbonGroupBox)(target));
                return;

            case 73:
                this.ZC = ((Fluent.RibbonGroupBox)(target));
                return;

            case 74:
                this.xxx = ((Fluent.RibbonGroupBox)(target));

            #line 2317 "TestContent.xaml"
                this.xxx.LauncherClick += new System.Windows.RoutedEventHandler(this.OnLauncherButtonClick);

            #line default
            #line hidden
                return;

            case 75:
                this.zoomSlider = ((System.Windows.Controls.Slider)(target));

            #line 2628 "TestContent.xaml"
                this.zoomSlider.ValueChanged += new System.Windows.RoutedPropertyChangedEventHandler <double>(this.ZoomSlider_OnValueChanged);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
 /// <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 (this.HasItems)
     {
         if (this.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 += this.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 += this.OnQuickAccessOpened;
             return button;
         }
     }
     else
     {
         Button button = new Button();
         RibbonControl.BindQuickAccessItem(this, button);
         return button;
     }
 }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever 
        /// application code or internal processes call ApplyTemplate
        /// </summary>
        public override void OnApplyTemplate()
        {
            groupsMenuButton = GetTemplateChild("PART_DropDownButton") as DropDownButton;
            if (groupsMenuButton != null)
            {
                for (int i = 0; i < Filters.Count; i++)
                {
                    MenuItem item = new MenuItem();
                    item.Text = Filters[i].Title;
                    item.Tag = Filters[i];
                    if (Filters[i] == SelectedFilter) item.IsChecked = true;
                    item.Click += OnFilterMenuItemClick;
                    groupsMenuButton.Items.Add(item);
                }
            }

            if (listBox != null)
            {
                listBox.ItemContainerGenerator.StatusChanged -= OnItemsContainerGeneratorStatusChanged;
            }

            listBox = GetTemplateChild("PART_ListBox") as RibbonListBox;
            if (listBox != null)
            {
                listBox.SelectedIndex = SelectedIndex;
                listBox.SelectedItem = SelectedItem;

                listBox.SelectionChanged += OnListBoxSelectionChanged;

                /*Binding binding = new Binding("SelectedIndex");
                binding.Source = listBox;
                binding.Mode = BindingMode.TwoWay;
                binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                SetBinding(SelectedIndexProperty, binding);

                binding = new Binding("SelectedItem");
                binding.Source = listBox;
                binding.Mode = BindingMode.TwoWay;
                binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                SetBinding(SelectedItemProperty, binding);*/

                Binding binding = new Binding("HasItems");
                binding.Source = listBox;
                binding.Mode = BindingMode.OneWay;
                SetBinding(HasItemsProperty, binding);

                binding = new Binding("IsGrouping");
                binding.Source = listBox;
                binding.Mode = BindingMode.OneWay;
                SetBinding(IsGroupingProperty, binding);

                binding = new Binding("ItemContainerGenerator");
                binding.Source = listBox;
                binding.Mode = BindingMode.OneWay;
                SetBinding(ItemContainerGeneratorProperty, binding);

                listBox.ItemContainerGenerator.StatusChanged += OnItemsContainerGeneratorStatusChanged;

            }
            UpdateGroupBy(GroupBy);
            SetMinWidth();
        }
 /// <summary>
 /// Binds the DropDownClosed and DropDownOpened events to the created quick access item
 /// </summary>
 /// <param name="button">Toolbar item</param>
 protected void BindQuickAccessItemDropDownEvents(DropDownButton button)
 {
     if (this.DropDownClosed != null) button.DropDownClosed += this.DropDownClosed;
     if (this.DropDownOpened != null) button.DropDownOpened += this.DropDownOpened;
 }
        /// <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 override FrameworkElement CreateQuickAccessItem()
        {
            IQuickAccessItemProvider provider = FindParentProvider();
            if (provider != null) return provider.CreateQuickAccessItem();

            DropDownButton button = new DropDownButton();

            button.PreviewMouseLeftButtonDown += OnFirstPreviewClick;

            BindQuickAccessItem(button);
            return button;
        }
Exemple #23
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            if (groupsMenuButton != null) groupsMenuButton.Items.Clear();
            groupsMenuButton = GetTemplateChild("PART_DropDownButton") as DropDownButton;
            if (groupsMenuButton != null)
            {
                for (int i = 0; i < Filters.Count; i++)
                {
                    MenuItem item = new MenuItem();
                    item.Header = Filters[i].Title;
                    item.Tag = Filters[i];
                    if (Filters[i] == SelectedFilter) item.IsChecked = true;
                    item.Click += OnFilterMenuItemClick;
                    groupsMenuButton.Items.Add(item);
                }
            }

            base.OnApplyTemplate();
        }
 /// <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 override FrameworkElement CreateQuickAccessItem()
 {
     DropDownButton button = new DropDownButton();
     button.Size = RibbonControlSize.Small;
     BindQuickAccessItem(button);
     button.PreviewMouseLeftButtonDown += OnQuickAccessClick;
     return button;
 }