private void Add2Favorites_Click(object sender, RoutedEventArgs e) { if (_tree == null) { return; } IExplorerObject exObject = _tree.SelectedExplorerObject; if (exObject == null) { return; } gView.Framework.UI.Dialogs.FormAddToFavorites dlg = new gView.Framework.UI.Dialogs.FormAddToFavorites(exObject.FullName, false); if (dlg.ShowDialog() == global::System.Windows.Forms.DialogResult.OK) { MyFavorites favs = new MyFavorites(); favs.AddFavorite(dlg.FavoriteName, exObject.FullName, (exObject.Icon != null) ? exObject.Icon.Image : null); WpfFavoriteMenuItem fItem = new WpfFavoriteMenuItem(new MyFavorites.Favorite(dlg.FavoriteName, dlg.FavoritePath, (exObject.Icon != null) ? exObject.Icon.Image : null)); fItem.Click += new RoutedEventHandler(MenuItem_Favorite_Click); _favDropDownButton.Items.Add(fItem); } }
private void MenuItem_Favorite_Click(object sender, EventArgs e) { if (_tree != null && sender is WpfFavoriteMenuItem) { WpfFavoriteMenuItem item = (WpfFavoriteMenuItem)sender; this.Cursor = System.Windows.Input.Cursors.Wait; try { if (!this.MoveToTreeNode(item.Favorite.Path)) { System.Windows.MessageBox.Show("Can't move to '" + item.Favorite.Path + "'", "Error"); } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message, "Error"); } this.Cursor = System.Windows.Input.Cursors.Arrow; } }
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 }