private void exbarGroups_ContextMenuInitializing(object sender, Infragistics.Win.UltraWinExplorerBar.CancelableContextMenuInitializingEventArgs e) { if(e.ClickArea == ClickArea.GroupHeader) { e.Cancel = true; } var menuTarget = new ContextMenuHelper(); if( e.ClickArea == ClickArea.Item) { menuTarget.Item = e.Item; menuTarget.Group = e.Item.Group; } else { menuTarget.Group = e.Group; } this.exbarGroups.ResetGroupItemAreaContextMenu(); this.exbarGroups.ResetItemContextMenu(); var menuItemAdd = new IGMenuItem("Add", new EventHandler(this.OnMenuItemClicked)); menuItemAdd.Tag = menuTarget; e.ContextMenu.MenuItems.Add(menuItemAdd); if(e.ClickArea == ClickArea.Item) { var menuItemEdit = new IGMenuItem("Edit / Delete", new EventHandler(this.OnMenuItemClicked)); menuItemEdit.Tag = menuTarget; e.ContextMenu.MenuItems.Add(menuItemEdit); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Store the information needed to create context menus. /// </summary> /// <param name="generalFile"></param> /// <param name="specificFile"></param> /// ------------------------------------------------------------------------------------ protected override void InitializeContextMenus(string generalFile, string specificFile) { if (m_cmnuHelper == null) m_cmnuHelper = new ContextMenuHelper(this); m_cmnuHelper.InitializeContextMenus(generalFile, specificFile); }
protected override void AddContextMenu(ContextMenuHelper contextMenu) { // in MomViewVase in OnLoad() (!(this is IChildView)) == false, therefor this method is never called. base.AddContextMenu(contextMenu); }
internal void UpdateExplorerBar(ContextMenuHelper helper, string menuItemText, GroupItem groupItem) { // Note - DB updates have already been done, we're just updating explorer bar if(groupItem.ID == 0) // User cancelled { return; } // We are deleting item if(groupItem.Name == "") { MessageBox.Show("Delete " + helper.Group.Text + ": " + groupItem.ID.ToString()); // delete item helper.Item.ParentCollection.Remove(helper.Item); return; } if(menuItemText == "Add") { // New item was added var nameChar = helper.Group.Text.Substring(0, 1); var stateItem = helper.Group.Items.Add(nameChar + groupItem.ID, groupItem.Name); stateItem.Tag = groupItem.ID; } else { // Update existing item text helper.Item.Text = groupItem.Name; } }
private bool AddColtrols(int addWhat, int[] things, String anothers1) { /* addWhat - 创建什么, another,anothers - 其他数据 * 1 - 普通卡片 * 2 - 普通事件 */ if (addWhat == 1) { Card card = new Card(); StackPanel stackPanel = new StackPanel(); Grid grid = new Grid(); TextBlock textBlock = new TextBlock(); Button button = new Button(); ListView listView = new ListView(); ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem1 = new MenuItem(); MenuItem menuItem2 = new MenuItem(); MenuItem menuItem3 = new MenuItem(); menuItem1.Name = "MenuItem1"; menuItem1.Header = "删除卡片"; menuItem1.Icon = ""; menuItem1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(CD_Del); contextMenu.Items.Add(menuItem1); contextMenu.Width = 150; contextMenu.Background = baseColora.Card; contextMenu.Foreground = baseColora.Fg; ContextMenuHelper.SetShadowColor(contextMenu, baseColora.DBg.Color); ContextMenuHelper.SetItemHeight(contextMenu, 30); textBlock.ContextMenu = contextMenu; card.ContextMenu = contextMenu; card.PreviewMouseRightButtonDown += WhatFuckOpenMeMe; textBlock.Text = things[0] + ". " + anothers1; textBlock.HorizontalAlignment = HorizontalAlignment.Left; textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Margin = new Thickness(34, 25, 34, 10); textBlock.Foreground = baseColora.Fg; textBlock.FontFamily = baseColora.Fonts; textBlock.FontSize = 15; button.Foreground = baseColora.Fg; button.Margin = new Thickness(0, 10, 15, 0); button.Name = "BCDD" + things[0]; button.Width = 30; button.Click += DelCard_Click; button.HorizontalAlignment = HorizontalAlignment.Right; ButtonHelper.SetIcon(button, ""); IconHelper.SetFontSize(button, 16); ButtonHelper.SetButtonStyle(button, ButtonStyle.Link); card.Name = "CDD" + things[0]; card.Margin = new Thickness(5, 15, 20, 5); card.Width = 540; card.Background = baseColora.Card; grid.Children.Add(textBlock); grid.Children.Add(button); stackPanel.Children.Add(grid); card.Content = stackPanel; ScrollViewerHelper.SetScrollBarCornerRadius(listView, new CornerRadius(3)); stackPanel.Children.Add(listView); MainIn.Children.Add(card); RegisterName("CDD" + things[0], card); } else if (addWhat == 2) { Card card = GetChildObjects <Card>(MainIn, "CDD" + things[1].ToString()); if (card == null) { this.RunCard.Visibility = Visibility.Visible; error.ErrorTo("创建控件失败,未找到分类卡片。", Percent, Errorsay); error.logWriter("Tool -7:未找到分类卡片。卡片名称:CDD" + things[1], false); return(false); } List <StackPanel> lstControl = GetChildObjects <StackPanel>(card, typeof(StackPanel)); if (lstControl == null) { this.RunCard.Visibility = Visibility.Visible; error.ErrorTo("创建控件失败,未找到分类卡片中的StackPanel控件。", Percent, Errorsay); error.logWriter("Tool -7:未找到分类卡片中的StackPanel控件。卡片名称:CDD" + things[1], false); return(false); } List <ListView> lstControl1 = GetChildObjects <ListView>(lstControl[0], typeof(ListView)); if (lstControl1 == null) { this.RunCard.Visibility = Visibility.Visible; error.ErrorTo("创建控件失败,未找到分类卡片中的StackPanel控件中的列表控件。", Percent, Errorsay); error.logWriter("Tool -7:未找到分类卡片中的StackPanel控件中的列表控件。卡片名称:CDD" + things[1], false); return(false); } ContextMenu contextMenu = new ContextMenu(); MenuItem menuItem1 = new MenuItem(); MenuItem menuItem2 = new MenuItem(); MenuItem menuItem3 = new MenuItem(); menuItem1.Name = "MenuItem1"; menuItem1.Header = "完成"; menuItem1.Icon = ""; menuItem1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ME_Fin); contextMenu.Items.Add(menuItem1); menuItem2.Name = "MenuItem2"; menuItem2.Header = "删除"; menuItem2.Icon = ""; menuItem2.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ME_Del); if (things[2] == 0) { contextMenu.Items.Add(menuItem2); } contextMenu.Width = 150; contextMenu.Background = baseColora.Card; contextMenu.Foreground = baseColora.Fg; ContextMenuHelper.SetShadowColor(contextMenu, baseColora.DBg.Color); ContextMenuHelper.SetItemHeight(contextMenu, 30); ListViewItem listViewItem = new ListViewItem(); listViewItem.Name = "CDD" + things[1] + "IT" + things[0]; listViewItem.ContextMenu = contextMenu; listViewItem.PreviewMouseRightButtonDown += WhatFuckOpenMe; TextBlock textBlock = new TextBlock(); textBlock.Text = anothers1; textBlock.Background = baseColora.Tran; textBlock.FontFamily = baseColora.Fonts; textBlock.Foreground = baseColora.Font; textBlock.FontSize = 15; textBlock.Margin = new Thickness(38, 5, 38, 5); listViewItem.Content = textBlock; lstControl1[0].Items.Add(listViewItem); } return(true); }
private bool UpdateUI() { IsMaskVisible = false; //初始化颜色 if (!LoadingMain(false)) { Application.Current.Shutdown(); } //版本号 Versionon.Text = "Version - " + stVersion; //刷新工具列表 UpdateList.ItemsSource = listall; //工具列表样式 this.UpdateList.Foreground = baseColor.Fg; this.UpdateList.FontFamily = baseColor.Fonts; this.UpdateList.FontSize = 14; //版本号样式 this.Versionon.Foreground = baseColor.Fg; this.Versionon.FontFamily = baseColor.Fonts; this.Versionon.FontSize = 12; //按钮样式 this.Feedback.Foreground = baseColor.FontM; this.Feedback.FontFamily = baseColor.Fonts; this.Feedback.FontSize = 14; this.OpenButton.Foreground = baseColor.FontM; this.OpenButton.Background = baseColor.Main; this.B1.Foreground = baseColor.Fg; this.B2.Foreground = baseColor.Fg; this.TopIcon.Background = baseColor.Main; this.TopIcon.Foreground = baseColor.FontM; ButtonHelper.SetHoverBrush(TopIcon, baseColor.Main); ButtonHelper.SetClickCoverOpacity(TopIcon, 1); //初始化卡片颜色 WindowXCaption.SetBackground(this, baseColor.Main); WindowXCaption.SetForeground(this, baseColor.FontM); CD1.Background = baseColor.Card; CD2.Background = baseColor.Card; SH1.Background = baseColor.Card; SH1.Foreground = baseColor.Font; UpdateList.Background = baseColor.Tran; Versionon.Foreground = baseColor.Fg; UpdateList.ContextMenu.Background = baseColor.Card; UpdateList.ContextMenu.Foreground = baseColor.Fg; ContextMenuHelper.SetShadowColor(UpdateList.ContextMenu, baseColor.DBg.Color); BorderBut.Background = baseColor.DBg; BorderTop.Background = baseColor.Main; BorderTop1.Background = baseColor.Main; BorderTop2.Background = baseColor.Main; BG.BeginInit(); BG.Source = baseColor.Bgp; BG.EndInit(); SBG.BeginInit(); SBG.Source = baseColor.Bgps; SBG.EndInit(); //加载主页 PageMain main = new PageMain(); Page.Content = new Frame() { Content = main }; return(true); }
/// <summary> /// Return a list context menu entries for a given <see cref="Result"/> (shown at the right side of the result). /// </summary> /// <param name="selectedResult">The <see cref="Result"/> for the list with context menu entries.</param> /// <returns>A list context menu entries.</returns> public List <ContextMenuResult> LoadContextMenus(Result selectedResult) { return(ContextMenuHelper.GetContextMenu(selectedResult, _assemblyName)); }
protected override ContextMenu BuildContextMenu() { return(ContextMenuHelper.CreateContextMenu((ISelectionSet <SceneElement>) this.TimelineItemManager.ViewModel.ElementSelectionSet, this.TimelineItemManager.ViewModel, false)); }
protected void AddContextMenu_InstanceProperties(ContextMenuHelper contextMenu) { Dbg.Log($"Entering {MethodBase.GetCurrentMethod().Name}"); contextMenu.AddContextMenuItem(ViewCommands.Properties, new EventHandler <CommandEventArgs>(OnShowInstanceProperties), new EventHandler <CommandStatusEventArgs>(OnInstancePropertiesStatus)); }
protected void SetupCommands(Func <ExModel[]> getSelectionFunc, Func <DirectoryModel> getCurrentFunc, Func <System.Drawing.Point> getMousePositionFunc) { #region OpenCommand and ContextMenuCommand OpenCommand = new SimpleRoutedCommand(ApplicationCommands.Open) { CanExecuteDelegate = x => { return(getCurrentFunc() != null); }, ExecuteDelegate = x => { Process.Start(getCurrentFunc().EmbeddedDirectoryEntry.FullName); } }; ContextMenuCommand = new SimpleRoutedCommand(ApplicationCommands.ContextMenu) { CanExecuteDelegate = x => { return(getSelectionFunc() != null && getSelectionFunc().Length > 0); }, ExecuteDelegate = x => { ContextMenuWrapper _cmw = new ContextMenuWrapper(); _cmw.OnBeforeInvokeCommand += (InvokeCommandEventHandler) delegate(object sender, InvokeCommandEventArgs args) { if (args.Command == "open") { args.ContinueInvoke = false; } if (args.Command == "openas" && args.SelectedItems != null && args.SelectedItems.Length == 1) { args.ContinueInvoke = false; } }; var selectedItems = (from model in getSelectionFunc() select model.EmbeddedEntry).ToArray(); System.Drawing.Point pt = getMousePositionFunc(); string command = _cmw.Popup(selectedItems, pt); switch (command) { case "open": OpenCommand.Execute(null); break; case "openas": OpenCommand.Execute(null); break; case "rename": RenameCommand.Execute(null); break; case "refresh": RefreshCommand.Execute(null); break; } } }; #endregion #region Delete, Copy and Paste DeleteCommand = new SimpleRoutedCommand(ApplicationCommands.Delete) { CanExecuteDelegate = x => { if (getSelectionFunc() != null && getSelectionFunc().Length > 0) { ; } { var selectedItems = (from model in getSelectionFunc() select model.EmbeddedEntry).ToArray(); foreach (FileSystemInfoEx item in selectedItems) { if ((item.Attributes & FileAttributes.ReadOnly) != 0) { return(false); } } return(true); } //return false; }, ExecuteDelegate = x => { var selectedItems = (from model in getSelectionFunc() select model.EmbeddedEntry).ToArray(); int itemCount = selectedItems.Length; if (System.Windows.Forms.MessageBox.Show(String.Format("Are you sure want to permanently remove these {0} item{1}?", itemCount, itemCount > 1 ? "s" : ""), "Delete", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { foreach (FileSystemInfoEx item in selectedItems) { item.Delete(); } } } }; CopyCommand = new SimpleRoutedCommand(ApplicationCommands.Copy) { CanExecuteDelegate = x => { return(getSelectionFunc() != null && getSelectionFunc().Length > 0); }, ExecuteDelegate = x => { var selectedItems = (from model in getSelectionFunc() select model.EmbeddedEntry).ToArray(); StringCollection fileList = new StringCollection(); foreach (FileSystemInfoEx item in selectedItems) { fileList.Add(item.FullName); } Clipboard.Clear(); Clipboard.SetFileDropList(fileList); } }; PasteCommand = new SimpleRoutedCommand(ApplicationCommands.Paste) { CanExecuteDelegate = x => { return (getCurrentFunc() != null && ((getCurrentFunc().EmbeddedDirectoryEntry.Attributes & FileAttributes.ReadOnly) != 0) && Clipboard.ContainsFileDropList()); }, ExecuteDelegate = x => { DirectoryInfoEx parentDir = getCurrentFunc().EmbeddedDirectoryEntry; List <FileSystemInfoEx> entryList = new List <FileSystemInfoEx>(); foreach (string path in Clipboard.GetFileDropList()) { IOTools.Copy(path, PathEx.Combine(parentDir.FullName, PathEx.GetFileName(path))); } } }; #endregion #region PropertiesCommand PropertiesCommand = new SimpleRoutedCommand(ApplicationCommands.Properties) { CanExecuteDelegate = x => { return(getSelectionFunc() != null && getSelectionFunc().Length > 0); }, ExecuteDelegate = x => { System.Windows.Point position = Mouse.GetPosition(null); var selectedItems = (from model in getSelectionFunc() select model.EmbeddedEntry).ToArray(); ContextMenuHelper.InvokeCommand(getSelectionFunc()[0].EmbeddedEntry.Parent, selectedItems, "properties", new System.Drawing.Point((int)position.X, (int)position.Y)); } }; #endregion }
/// <summary> /// Set up the submenu items for 'Create' and 'Insert' menus. /// </summary> protected void SetupContextMenu(Slice slice, SliceTreeNode sliceTreeNode) { // Get rid of old sub-menu items. m_mnuCreate.MenuItems.Clear(); m_helper = new ContextMenuHelper(sliceTreeNode); m_rgcpiCreateOptions = slice.Object.PropsAndClassesOwnedBy; // Fill in info about which object will be the new owner. for (int index = m_rgcpiCreateOptions.Count; --index >= 0;) { ClassAndPropInfo cpi = m_rgcpiCreateOptions[index]; cpi.hvoOwner = slice.Object.Hvo; } // Drop atomic property options if not empty for (int index = m_rgcpiCreateOptions.Count; --index >= 0;) { ClassAndPropInfo cpi = (ClassAndPropInfo)m_rgcpiCreateOptions[index]; if (cpi.fieldType == (int)FieldType.kcptOwningAtom) { FDO.FdoCache cache = slice.ContainingDataTree.Cache; if (cache.GetObjProperty(cpi.hvoOwner, (int)(cpi.flid)) != 0) { m_rgcpiCreateOptions.RemoveAt(index); } } } int iBefore = m_rgcpiCreateOptions.Count; GetCreateSiblingOptions(slice, m_rgcpiCreateOptions, true); bool fSeq = m_rgcpiCreateOptions.Count > iBefore && m_rgcpiCreateOptions[iBefore].fieldType == (int)FieldType.kcptOwningSequence; int iAfter = m_rgcpiCreateOptions.Count; if (fSeq) { // In a sequence we make another set of options to insert after the current item. GetCreateSiblingOptions(slice, m_rgcpiCreateOptions, false); } for (int index = 0; index < m_rgcpiCreateOptions.Count; index++) { ClassAndPropInfo cpi = (ClassAndPropInfo)m_rgcpiCreateOptions[index]; String format = DetailControlsStrings.ksNewItem; if (index >= iAfter) { format = DetailControlsStrings.ksNewItemAfter; // can't happen if not sequence } else if (index >= iBefore) { if (fSeq) { format = DetailControlsStrings.ksNewItemBefore; } else // sibling collection { format = DetailControlsStrings.ksNewItemWithin; } } m_mnuCreate.MenuItems.Add(new MenuItem( String.Format(format, new object[] { cpi.signatureClassName, cpi.fieldName }), new EventHandler(this.HandleCreateMenuItem))); } m_mnuCreate.Enabled = m_mnuCreate.MenuItems.Count > 0; m_helper.SetupDeleteMenu(m_mnuDelete); }