//禁止菜单ToolWindow ToolTabStrip的上下文菜单 隐藏Mdi窗体标题部分右键菜单 /// <summary> /// 禁止菜单ToolWindow ToolTabStrip的上下文菜单 隐藏Mdi窗体标题部分右键菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void MenuServiceContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e) { //判断是不是DockWindow if (e.MenuType != ContextMenuType.DockWindow) { return; } //判断是不是DockWindow的ToolTabStrip if (e.DockWindow.DockTabStrip is ToolTabStrip) { //移除所有菜单 e.Cancel = true; return; } //判断是不是DockWindow的DocumentTabStrip if (!(e.DockWindow.DockTabStrip is DocumentTabStrip)) { return; } //移除“新建水平选项卡组”“新建垂直选项卡组” for (var i = 0; i < e.MenuItems.Count; i++) { var menuItem = e.MenuItems[i]; if (menuItem.Name != "CloseWindow" && menuItem.Name != "CloseAllButThis" && menuItem.Name != "CloseAll") { menuItem.Visibility = ElementVisibility.Collapsed; } } }
/* * public void UpdateDataManager() * { * try * { * List<SymbolGroup> newPortfolio = new List<SymbolGroup>(); * * foreach (DocumentWindow dw in radDock1.GetWindows<DocumentWindow>()) * { * SymbolGroup nPortfolio = new SymbolGroup(); * * if (dw == documentWindow1) * continue; * * nPortfolio.Name = dw.Text; * List<string> Symbols = new List<string>(); * * foreach (string s in from DataManagerExtends dm in dw.Controls from s in dm.AssetList select s) * { * Symbols.Add(s); * } * nPortfolio.Symbols = Symbols.ToArray(); * newPortfolio.Add(nPortfolio); * } * * //ListPortfolios.Instance().UpdatePortfolios(newPortfolio); * DBSymbolShared.Connect(); * DBSymbolShared.SaveGroups(newPortfolio); * DBSymbolShared.Disconnect(); * * MFrmMain.ReloadSelectTools(); * } * catch (Exception ex) * { * MessageBox.Show(ex.Message); * } * } */ private void MenuServiceContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e) { if (e.MenuType != ContextMenuType.ActiveWindowList) { e.Cancel = true; } }
private void menuService_ContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e) { //the menu request is associated with a valid DockWindow instance, which resides within a DocumentTabStrip if (e.MenuType == ContextMenuType.DockWindow && e.DockWindow.DockTabStrip is DocumentTabStrip) { //remove the "Close" menu items foreach (RadMenuItemBase menuItem in e.MenuItems) { if (menuItem.Name == "CloseWindow" || menuItem.Name == "CloseAllButThis" || menuItem.Name == "CloseAll" || menuItem is RadMenuSeparatorItem) { // In case you just want to disable to option you can set Enabled false // menuItem.Enabled = false; menuItem.Text = "سلام"; // menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; } } } }
/// <summary> /// Modify Dock Context Menu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void menuService_ContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e) { //the menu request is associated with a valid DockWindow instance, which resides within a DocumentTabStrip if (e.MenuType == ContextMenuType.DockWindow && e.DockWindow.DockTabStrip is DocumentTabStrip) { //remove the "Close" menu items for (int i = 0; i < e.MenuItems.Count; i++) { RadMenuItemBase menuItem = e.MenuItems[i]; if (menuItem.Name == "CloseWindow" || menuItem.Name == "CloseAllButThis" || menuItem.Name == "CloseAll" || menuItem is RadMenuSeparatorItem) { // In case you just want to disable to option you can set Enabled false //menuItem.Enabled = false; menuItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; } } } // MENU ITEM'S NAMES //Text Name //--------------------------------------------------- //Close CloseWindow //Close All But This CloseAllButThis //Close All CloseAll //New Horizontal Tab Group NewHTabGroup //New Vertical Tab Group NewVTabGroup //Floating Floating //Dockable Docked //Tabbed Document TabbedDocument //Auto Hide AutoHide //Hide Hidden //Document Name ActivateWindow }
//禁止菜单ToolWindow ToolTabStrip的上下文菜单 隐藏Mdi窗体标题部分右键菜单 /// <summary> /// 禁止菜单ToolWindow ToolTabStrip的上下文菜单 隐藏Mdi窗体标题部分右键菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void MenuServiceContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e) { //判断是不是DockWindow if (e.MenuType != ContextMenuType.DockWindow) return; //判断是不是DockWindow的ToolTabStrip if (e.DockWindow.DockTabStrip is ToolTabStrip) { //移除所有菜单 e.Cancel = true; return; } //判断是不是DockWindow的DocumentTabStrip if (!(e.DockWindow.DockTabStrip is DocumentTabStrip)) return; //移除“新建水平选项卡组”“新建垂直选项卡组” for (var i = 0; i < e.MenuItems.Count; i++) { var menuItem = e.MenuItems[i]; if (menuItem.Name != "CloseWindow" && menuItem.Name != "CloseAllButThis" && menuItem.Name != "CloseAll") { menuItem.Visibility = ElementVisibility.Collapsed; } } }