Esempio n. 1
0
        private void RibbonTabItem_GotFocus(object sender, RoutedEventArgs e)
        {
            if (sender.GetType() == typeof(Fluent.RibbonTabItem))
            {
                MainViewModel        mvm  = DataContext as MainViewModel;
                Fluent.RibbonTabItem item = sender as Fluent.RibbonTabItem;
                ViewType             type;

                switch (item.Header)
                {
                case "Hauptmenü": type = ViewType.HomeView; break;

                case "Lager": type = ViewType.MainListView; break;

                case "Produkte": type = ViewType.ProductListView; break;

                case "Suche": type = ViewType.FilterView; break;

                case "Einlagerung": type = ViewType.ProductAdmissionView; break;

                case "Auslagerung": type = ViewType.ProductDeliveryView; break;

                case "Lieferschein": type = ViewType.DeliveryView; break;

                default: type = ViewType.HomeView; break;
                }

                mvm.ChangeView(type);
            }
        }
 void Ribbon_SelectedTabChanged(object sender, EventArgs e)
 {
     if (this.Ribbon.SelectedTabIndex == -1)
     {
         previouslySelectedTab = this.ribbonControl.SelectedTabItem;
     }
 }
        private void SetSelectedTab(Fluent.RibbonTabItem item)
        {
            foreach (Fluent.RibbonTabItem t in Ribbon.Tabs)
            {
                if (t != item)
                {
                    t.IsSelected = false;
                    t.IsOpen     = false;
                }
            }

            item.IsSelected = true;
            item.IsOpen     = true;
        }
Esempio n. 4
0
        protected override void CreateRibbon()
        {
            base.CreateRibbon();

            CreateRibbonBackstage(Ribbon);

            Fluent.RibbonTabItem t = CreateRibbonHomeTab(Ribbon);
            if (t != null)
            {
                Ribbon.Tabs.Add(t);
            }

            Fluent.RibbonTabItem t2 = CreateRibbonEditTab(Ribbon);
            if (t2 != null)
            {
                Ribbon.Tabs.Add(t2);
            }

            Fluent.RibbonTabItem t3 = CreateRibbonViewTab(Ribbon);
            if (t3 != null)
            {
                Ribbon.Tabs.Add(t3);
            }

            Fluent.RibbonTabItem t4 = CreateRibbonPluginsTab(Ribbon);
            if (t4 != null)
            {
                Ribbon.Tabs.Add(t4);
            }

            if (this.tabEdit != null)
            {
                this.tabEdit.IsEnabled = false;
            }

            if (this.tabPlugins != null)
            {
                this.tabPlugins.IsEnabled = false;
            }
        }
 void RibbonTabItem_IsVisibleChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
 {
     Fluent.RibbonTabItem tab = sender as Fluent.RibbonTabItem;
     if (Ribbon.SelectedTabItem == tab && tab.Visibility != System.Windows.Visibility.Visible)
     {
         // selected tab has become invisible, so we need for a different ribbon tab to become selected
         // try to select the previously selected tab if it is visible; if not, just select the first
         // visible ribbon tab in the collection
         if (previouslySelectedTab != null)
         {
             if (previouslySelectedTab.IsVisible)
             {
                 SetSelectedTab(previouslySelectedTab);
                 return;
             }
         }
         if (Ribbon.Tabs.Count > 0)
         {
             foreach (Fluent.RibbonTabItem t in Ribbon.Tabs)
             {
                 if (t.Visibility == System.Windows.Visibility.Visible)
                 {
                     SetSelectedTab(t);
                     return;
                 }
             }
             throw new NotSupportedException("No visible tabs to select in ribbon control!");
         }
         else
         {
             throw new NotSupportedException("No ribbon tabs in ribbon control!");
         }
     }
     else if (Ribbon.SelectedTabItem != tab && tab.Visibility == System.Windows.Visibility.Visible)
     {
         // a previously invisible tab has become visible, so we assume that it supplies necessary actions in
         // respect of the current context --> make this tab the selected tab of the ribbon
         SetSelectedTab(tab);
     }
 }
Esempio n. 6
0
        public void MakeRibbon()
        {
            PlugInManager pm = new PlugInManager();

            foreach (IExplorerRibbonTab exRibbonTab in OrderedPluginList<IExplorerRibbonTab>.Sort(pm.GetPluginNodes(Plugins.Type.IExplorerRibbonTab)))
            {
                Fluent.RibbonTabItem tabItem = new Fluent.RibbonTabItem();
                tabItem.Header = exRibbonTab.Header;
                ribbon.Tabs.Add(tabItem);
                tabItem.DataContext = exRibbonTab;

                foreach (RibbonGroupBox exGroupBox in exRibbonTab.Groups)
                {
                    Fluent.RibbonGroupBox groupBox = new Fluent.RibbonGroupBox();
                    groupBox.Header = exGroupBox.Header;
                    tabItem.Groups.Add(groupBox);

                    foreach (RibbonItem cartoRibbonItem in exGroupBox.Items)
                    {
                        Guid toolGUID = cartoRibbonItem.Guid;
                        if (toolGUID == new Guid("00000000-0000-0000-0000-000000000000"))
                        {
                            groupBox.Items.Add(new Separator());
                            continue;
                        }

                        object tool = pm.CreateInstance(toolGUID);
                        if (tool == null) continue;

                        #region IToolItem
                        if (tool is IToolItem)
                        {
                            if (((IToolItem)tool).ToolItem != null)
                            {
                                if (((IToolItem)tool).ToolItem is System.Windows.Forms.ToolStripItem)
                                {
                                    StackPanel panel = new StackPanel();
                                    panel.Margin = new Thickness(0, 32, 0, 0);

                                    System.Windows.Forms.ToolStripItem stripItem = (System.Windows.Forms.ToolStripItem)((IToolItem)tool).ToolItem;

                                    System.Windows.Forms.MenuStrip bar = new System.Windows.Forms.MenuStrip();
                                    bar.BackColor = System.Drawing.Color.Transparent; //.FromArgb(223, 234, 246);

                                    bar.Items.Add(stripItem);

                                    WindowsFormsHost host = new WindowsFormsHost();
                                    host.Background = new SolidColorBrush(Color.FromRgb(223, 234, 246));
                                    host.Child = bar;

                                    if (tool is IToolItemLabel)
                                    {
                                        IToolItemLabel label = (IToolItemLabel)tool;
                                        panel.Orientation = label.LabelPosition == ToolItemLabelPosition.top ||
                                                            label.LabelPosition == ToolItemLabelPosition.bottom ? Orientation.Vertical : Orientation.Horizontal;

                                        if (panel.Orientation == Orientation.Vertical)
                                            panel.Margin = new Thickness(0, 13, 0, 0);
                                        TextBlock text = new TextBlock();
                                        text.Text = label.Label;
                                        text.Padding = new Thickness(3);

                                        if (label.LabelPosition == ToolItemLabelPosition.top || label.LabelPosition == ToolItemLabelPosition.left)
                                            panel.Children.Insert(0, text);
                                        else
                                            panel.Children.Add(text);
                                    }

                                    panel.Children.Add(host);

                                    groupBox.Items.Add(panel);
                                }
                            }
                        }
                        #endregion

                        #region IToolMenu
                        else if (tool is IExToolMenu)
                        {
                            DropDownToolButton button = new DropDownToolButton(tool as IExToolMenu);
                            button.Click += new RoutedEventHandler(ToolButton_Click);
                            groupBox.Items.Add(button);
                        }
                        #endregion

                        #region ITool
                        else if (tool is IExTool)
                        {
                            ((IExTool)tool).OnCreate(_application);
                            ToolButton button = new ToolButton(tool as IExTool);
                            button.SizeDefinition = cartoRibbonItem.SizeDefinition;

                            groupBox.Items.Add(button);
                            button.Click += new RoutedEventHandler(ToolButton_Click);
                            
                        }
                        #endregion
                    }
                }

                if (ribbon.Tabs.Count == 1)
                {
                    #region Favorites
                    Fluent.RibbonGroupBox favBox = new Fluent.RibbonGroupBox();
                    favBox.Header = String.Empty;
                    _favDropDownButton = new Fluent.DropDownButton();
                    _favDropDownButton.Header = "Favorites";
                    _favDropDownButton.Icon = _favDropDownButton.LargeIcon = ImageFactory.FromBitmap(global::gView.Desktop.Wpf.DataExplorer.Properties.Resources.folder_heart);

                    Fluent.MenuItem add2fav = new Fluent.MenuItem();
                    add2fav.Header = "Add to favorites...";
                    add2fav.Icon = ImageFactory.FromBitmap(global::gView.Desktop.Wpf.DataExplorer.Properties.Resources.folder_heart);
                    add2fav.Click += new RoutedEventHandler(Add2Favorites_Click);
                    _favDropDownButton.Items.Add(add2fav);

                    bool first = true;
                    foreach (MyFavorites.Favorite fav in (new MyFavorites().Favorites))
                    {
                        if (fav == null) continue;
                        WpfFavoriteMenuItem fItem = new WpfFavoriteMenuItem(fav);
                        fItem.Click += new RoutedEventHandler(MenuItem_Favorite_Click);

                        if (first)
                        {
                            first = false;
                            _favDropDownButton.Items.Add(new Separator());
                        }
                        _favDropDownButton.Items.Add(fItem);
                    }

                    favBox.Items.Add(_favDropDownButton);
                    ribbon.Tabs[0].Groups.Add(favBox);
                    #endregion

                    _createNewRibbonGroupBox = new Fluent.RibbonGroupBox();
                    _createNewRibbonGroupBox.Header = "Create New";
                    _createNewRibbonGroupBox.Visibility = Visibility.Visible;
                    _createNewRibbonGroupBox.Background = new SolidColorBrush(Colors.GreenYellow);
                    
                    ribbon.Tabs[0].Groups.Add(_createNewRibbonGroupBox);
                }
            }

            #region Options
            Fluent.RibbonTabItem optionsTab = new Fluent.RibbonTabItem() { Header = "Options" };
            Fluent.RibbonGroupBox optionsBox = new Fluent.RibbonGroupBox() { Header = String.Empty };
            optionsTab.Groups.Add(optionsBox);

            foreach (XmlNode pageNode in pm.GetPluginNodes(Plugins.Type.IExplorerOptionPage))
            {
                IExplorerOptionPage page = pm.CreateInstance(pageNode) as IExplorerOptionPage;
                if (page == null) continue;

                OptionsButton button = new OptionsButton(page);
                button.Click += new RoutedEventHandler(OptoinButton_Click);
                optionsBox.Items.Add(button);
            }
            ribbon.Tabs.Add(optionsTab);
            #endregion
        }
 void Ribbon_SelectedTabChanged(object sender, EventArgs e)
 {
     if (this.Ribbon.SelectedTabIndex == -1)
         previouslySelectedTab = this.ribbonControl.SelectedTabItem;
 }