当前位置: 首页>>代码示例>>C#>>正文


C# ContextMenu.Add方法代码示例

本文整理汇总了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);
        }
开发者ID:scjunkie,项目名称:Console,代码行数:27,代码来源:ScriptLibraryMenuItemBase.cs

示例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);
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:35,代码来源:EditIseSettingsCombo.cs

示例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);
        }
开发者ID:GuitarRich,项目名称:Console,代码行数:50,代码来源:ScriptLibraryMenuItem.cs

示例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;
      }
开发者ID:borkaborka,项目名称:gmit,代码行数:18,代码来源:MetaModelViewer.xaml.cs

示例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;
      }
开发者ID:borkaborka,项目名称:gmit,代码行数:19,代码来源:SchemaViewer.xaml.cs

示例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; });
		}
开发者ID:pjcollins,项目名称:monodevelop,代码行数:40,代码来源:DockItem.cs


注:本文中的ContextMenu.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。