本文整理汇总了C#中ContextMenu.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ContextMenu.Add方法的具体用法?C# ContextMenu.Add怎么用?C# ContextMenu.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContextMenu
的用法示例。
在下文中一共展示了ContextMenu.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override void Execute(CommandContext context)
{
SheerResponse.DisableOutput();
var subMenu = new ContextMenu();
var menuItems = new List<Control>();
string menuItemId = context.Parameters["menuItemId"];
Item contextItem = context.Items.Length == 1
? context.Items[0]
: string.IsNullOrEmpty(context.Parameters["db"]) || string.IsNullOrEmpty(context.Parameters["id"])
? null
: Database.GetDatabase(context.Parameters["db"]).GetItem(new ID(context.Parameters["id"]));
GetLibraryMenuItems(contextItem, menuItems, context.Parameters["scriptDB"], context.Parameters["scriptPath"]);
foreach (Control item in menuItems)
{
var menuItem = item as MenuItem;
if (menuItem != null)
{
var subItem = subMenu.Add(menuItem.ID, menuItem.Header, menuItem.Icon, menuItem.Hotkey, menuItem.Click,
menuItem.Checked, menuItem.Radiogroup, menuItem.Type);
subItem.Disabled = menuItem.Disabled;
}
}
SheerResponse.EnableOutput();
subMenu.Visible = true;
SheerResponse.ShowContextMenu(menuItemId, "right", subMenu);
}
示例2: Execute
public override void Execute(CommandContext context)
{
SheerResponse.DisableOutput();
var subMenu = new ContextMenu();
var menuItems = new List<Control>();
var menuItemId = "iseSettingsDropdown"; //context.Parameters["Id"];
if (string.IsNullOrEmpty(menuItemId))
{
// a bit of a hacky way to determine the caller so we can display the menu
// in proximity to the triggering control
var parameters = new UrlString("?" + Context.Items["SC_FORM"]);
menuItemId = parameters.Parameters["__EVENTTARGET"];
}
var menuRootItem =
Factory.GetDatabase("core")
.GetItem("/sitecore/content/Applications/PowerShell/PowerShellIse/Menus/Settings");
GetMenuItems(menuItems, menuRootItem);
foreach (var item in menuItems)
{
var menuItem = item as MenuItem;
if (menuItem != null)
{
var subItem = subMenu.Add(menuItem.ID, menuItem.Header, menuItem.Icon, menuItem.Hotkey,
menuItem.Click,
menuItem.Checked, menuItem.Radiogroup, menuItem.Type);
subItem.Disabled = menuItem.Disabled;
}
}
SheerResponse.EnableOutput();
subMenu.Visible = true;
SheerResponse.ShowContextMenu(menuItemId, "down", subMenu);
}
示例3: Execute
public override void Execute(CommandContext context)
{
SheerResponse.DisableOutput();
var subMenu = new ContextMenu();
var menuItems = new List<Control>();
var menuItemId = context.Parameters["menuItemId"];
if (string.IsNullOrEmpty(menuItemId))
{
// a bit of a hacky way to determine the caller so we can display the menu
// in proximity to the triggering control
var parameters = new UrlString("?" + Context.Items["SC_FORM"]);
menuItemId = parameters.Parameters["__EVENTTARGET"];
}
SetupIntegrationPoint(context);
var contextItem = context.Items.Length == 1
? context.Items[0]
: string.IsNullOrEmpty(context.Parameters["db"]) || string.IsNullOrEmpty(context.Parameters["id"])
? null
: Database.GetDatabase(context.Parameters["db"]).GetItem(new ID(context.Parameters["id"]));
if (string.IsNullOrEmpty(IntegrationPoint))
{
var submenu =
Factory.GetDatabase(context.Parameters["scriptDB"]).GetItem(context.Parameters["scriptPath"]);
GetLibraryMenuItems(contextItem, menuItems, submenu);
}
else
{
foreach (var root in ModuleManager.GetFeatureRoots(IntegrationPoint))
{
GetLibraryMenuItems(contextItem, menuItems, root);
}
}
foreach (var item in menuItems)
{
var menuItem = item as MenuItem;
if (menuItem != null)
{
var subItem = subMenu.Add(menuItem.ID, menuItem.Header, menuItem.Icon, menuItem.Hotkey,
menuItem.Click,
menuItem.Checked, menuItem.Radiogroup, menuItem.Type);
subItem.Disabled = menuItem.Disabled;
}
}
SheerResponse.EnableOutput();
subMenu.Visible = true;
SheerResponse.ShowContextMenu(menuItemId, "right", subMenu);
}
示例4: _onOptionMenuOpen
private void _onOptionMenuOpen(object sender, RoutedEventArgs e) {
var menu = new ContextMenu();
menu.Placement = PlacementMode.Bottom;
menu.PlacementTarget = OptionsMenu;
Action<string, object, bool, bool> addToggle = (header, tag, isChecked, isEnabled) => {
var menuitem = new MenuItem() { Header = header, Tag = tag, IsChecked = isChecked, IsEnabled = isEnabled };
menuitem.Click += new RoutedEventHandler(_onOptionsMenuClick);
menu.Add(menuitem);
};
addToggle("UML Extensions", INCLUDE_UML_EXT, this.isUmlExtensionIncluded, true);
addToggle("Tool Extensions", INCLUDE_TOOL_EXT, this.isToolExtensionIncluded, true);
addToggle("Profile Definitions", INCLUDE_PROFILE, this.isProfileIncluded, true);
OptionsMenu.ContextMenu = menu;
OptionsMenu.ContextMenu.IsOpen = true;
}
示例5: _onOptionsMenuOpen
private void _onOptionsMenuOpen(object sender, RoutedEventArgs e) {
var menu = new ContextMenu();
menu.Placement = PlacementMode.Bottom;
menu.PlacementTarget = OptionsMenu;
var options = _getOptions();
Action<string, BplSchemaOutputOptions> addToggle = (header, flag) => {
var menuitem = new MenuItem() { Header = header, Tag = flag, IsChecked = (options & flag) != 0 };
menuitem.Click += new RoutedEventHandler(_onOptionsMenuClick);
menu.Add(menuitem);
};
addToggle("Sort members by name", BplSchemaOutputOptions.SortMembers);
addToggle("Expose core types", BplSchemaOutputOptions.ExposeCoreTypes);
addToggle("Externalize local schemas", BplSchemaOutputOptions.ExternalizeLocalSchemas);
OptionsMenu.ContextMenu = menu;
OptionsMenu.ContextMenu.IsOpen = true;
}
示例6: ShowDockPopupMenu
internal void ShowDockPopupMenu (Gtk.Widget parent, Gdk.EventButton evt)
{
var menu = new ContextMenu ();
ContextMenuItem citem;
// Hide menuitem
if ((Behavior & DockItemBehavior.CantClose) == 0) {
citem = new ContextMenuItem (Catalog.GetString ("Hide"));
citem.Clicked += delegate { Visible = false; };
menu.Add (citem);
}
// Auto Hide menuitem
if ((Behavior & DockItemBehavior.CantAutoHide) == 0 && Status != DockItemStatus.AutoHide) {
citem = new ContextMenuItem (Catalog.GetString ("Minimize"));
citem.Clicked += delegate { Status = DockItemStatus.AutoHide; };
menu.Add (citem);
}
if (Status != DockItemStatus.Dockable) {
// Dockable menuitem
citem = new ContextMenuItem (Catalog.GetString ("Dock"));
citem.Clicked += delegate { Status = DockItemStatus.Dockable; };
menu.Add (citem);
}
// Floating menuitem
if ((Behavior & DockItemBehavior.NeverFloating) == 0 && Status != DockItemStatus.Floating) {
citem = new ContextMenuItem (Catalog.GetString ("Undock"));
citem.Clicked += delegate { Status = DockItemStatus.Floating; };
menu.Add (citem);
}
if (menu.Items.Count == 0) {
return;
}
ShowingContextMenu = true;
menu.Show (parent, evt, () => { ShowingContextMenu = true; });
}