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


C# ContextMenu类代码示例

本文整理汇总了C#中ContextMenu的典型用法代码示例。如果您正苦于以下问题:C# ContextMenu类的具体用法?C# ContextMenu怎么用?C# ContextMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContextMenu类属于命名空间,在下文中一共展示了ContextMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Virtualtray

    private Virtualtray()
    {
        _virtualbox = (IVirtualBox) new VirtualBox.VirtualBox();

        /* the generated VirtualBox.dll COM library doesn't work with the C# event
         * system, so we handle events by registering callbacks
         */
        _virtualbox.RegisterCallback(this);

        _icon = GetIcon("icon/icon-16.ico");
        _idleIcon = GetIcon("icon/icon-gray-16.ico");

        _notifyIcon = new NotifyIcon();
        _notifyIcon.Icon = _idleIcon;
        _notifyIcon.Text = "Virtualtray";
        _notifyIcon.Visible = true;

        _vms = new Hashtable();

        ContextMenu menu = new ContextMenu();
        foreach (IMachine machine in _virtualbox.Machines) {
            MachineMenu mm = new MachineMenu(machine, menu);
            mm.StateChange += new EventHandler(MachineStateChangeEventHandler);
            _vms.Add(machine.Id, mm);
        }
        menu.MenuItems.Add(new MenuItem("-") {Name = "-"});
        menu.MenuItems.Add(new MenuItem("Open VirtualBox...", new EventHandler(
            MenuLaunchVirtualBoxEventHandler)));
        menu.MenuItems.Add(new MenuItem("Exit", new EventHandler(MenuExitEventHandler)));
        _notifyIcon.ContextMenu = menu;

        ToggleIcon();
        _notifyIcon.MouseClick += new MouseEventHandler(IconClickEventHandler);
        Application.ApplicationExit += new EventHandler(ApplicationExitEventHandler);
    }
开发者ID:justinwh,项目名称:virtualtray,代码行数:35,代码来源:Virtualtray.cs

示例2: CreateBaseLink

        Inline CreateBaseLink(string content, string contextHeader, string contextTag, MenuItem customButton = null)
        {
            var link = new HyperlinkButton
            {
                Content = content,
                FontSize = Text.FontSize,
                FontWeight = Text.FontWeight,
                FontStretch = Text.FontStretch,
                FontFamily = Text.FontFamily,
                TargetName = contextTag,
                Margin = new Thickness(-10, -5, -10, -8)
            };

            link.Click += new RoutedEventHandler(link_Click);

            MenuItem item = new MenuItem
            {
                Header = contextHeader,
                Tag = contextTag,
                Foreground = new SolidColorBrush(Colors.Black)
            };
            item.Click += new RoutedEventHandler(CopyLink);

            ContextMenu menu = new ContextMenu();
            menu.Items.Add(item);
            if (customButton != null)
                menu.Items.Add(customButton);

            ContextMenuService.SetContextMenu(link, menu);

            InlineUIContainer container = new InlineUIContainer();
            container.Child = link;
            return container;
        }
开发者ID:rafaelwinter,项目名称:Ocell,代码行数:34,代码来源:DMView.xaml.cs

示例3: PopupMenu

    /// <summary>
    /// Display the popup menu for this row
    /// </summary>
    /// <param name="parent">The parent control</param>
    /// <param name="x">X coordinate of menu</param>
    /// <param name="y">Y coordinate of menu</param>
    public void PopupMenu( System.Windows.Forms.Control parent , int x , int y )
    {
        // Use reflection to get the list of popup menu commands
        MemberInfo[]  members = this.GetType().FindMembers ( MemberTypes.Method ,
          BindingFlags.Public | BindingFlags.Instance ,
          new System.Reflection.MemberFilter ( Filter ) ,
          null ) ;

        if ( members.Length > 0 )
        {
          // Create a context menu
          ContextMenu   menu = new ContextMenu ( ) ;

          // Now loop through those members and generate the popup menu
          // Note the cast to MethodInfo in the foreach
          foreach ( MethodInfo meth in members )
          {
        // Get the caption for the operation from the ContextMenuAttribute
        ContextMenuAttribute[]  ctx = (ContextMenuAttribute[]) meth.GetCustomAttributes ( typeof ( ContextMenuAttribute ) , true ) ;

        MenuCommand  callback = new MenuCommand ( this , meth ) ;
        MenuItem      item = new MenuItem ( ctx[0].Caption , new EventHandler ( callback.Execute ) ) ;

        item.DefaultItem = ctx[0].Default ;

        menu.MenuItems.Add ( item ) ;
          }

          System.Drawing.Point  pt = new System.Drawing.Point ( x , y ) ;
          menu.Show ( parent , pt ) ;
        }
    }
开发者ID:alannet,项目名称:example,代码行数:38,代码来源:Data.cs

示例4: Execute

    public void Execute(TabbedExplorerPresenter tabbedExplorerPresenter)
    {
        // Open test.apsimx in a tab
        tabbedExplorerPresenter.OpenApsimXFileInTab(@"..\Tests\Test.apsimx");

        // Get the presenter for this tab.
        ExplorerPresenter presenter = tabbedExplorerPresenter.Presenters[0];

        // Select the field model.
        presenter.SelectNode(".Simulations.Test");

        // Copy the simulation model.
        ContextMenu menu = new ContextMenu(presenter);
        menu.OnCopyClick(null, null);

        // Select the top model
        presenter.SelectNode(".Simulations");

        // Paste the model.
        menu.OnPasteClick(null, null);

        // Make sure the paste has worked by clicking on a child.
        presenter.SelectNode(".Simulations.Test1.Clock");

        // Make sure the parenting of children has worked correctly.
        Clock clock = Apsim.Get(presenter.ApsimXFile, ".Simulations.Test1.Clock") as Clock;
        if (clock.Parent == null)
            throw new Exception("Parenting of models after copy/paste hasn't worked");

        // Close the user interface.
        tabbedExplorerPresenter.Close(false);
    }
开发者ID:hol353,项目名称:ApsimX,代码行数:32,代码来源:CopyPasteTest.cs

示例5: AddContextMenuIfDoesNotExist

 private void AddContextMenuIfDoesNotExist(ContextMenu contextMenu)
 {
     if (!this.menuItems.ContainsKey(contextMenu))
     {
         this.menuItems.Add(contextMenu, new RadContextMenu());
     }
 }
开发者ID:ezimaxtechnologies,项目名称:ASP.Net,代码行数:7,代码来源:Banner.cs

示例6: OldContextMenu

    public OldContextMenu()
    {
        this.Text = "Menu 예제. 닷넷 1.x 형태";

        ContextMenu menu = new ContextMenu();
        this.ContextMenu = menu;

        MenuItem country = new MenuItem("&국가");
        menu.MenuItems.Add(country);

        MenuItem korea = new MenuItem();
        korea.Text = "&대한민국";
        korea.Click += new EventHandler(MenuEvent);
        korea.Shortcut = Shortcut.CtrlK;
        country.MenuItems.Add(korea);

        MenuItem canada = new MenuItem("&캐나다", new EventHandler(MenuEvent), Shortcut.CtrlC);
        country.MenuItems.Add(canada);
        MenuItem france = new MenuItem("&프랑스", new EventHandler(MenuEvent), Shortcut.CtrlF);
        country.MenuItems.Add(france);

        MenuItem sep = new MenuItem("-");
        menu.MenuItems.Add(sep);

        MenuItem coninent = new MenuItem("대륙");
        menu.MenuItems.Add(coninent);

        MenuItem asia = new MenuItem("&아시아", new EventHandler(MenuEvent), Shortcut.Alt1);
        coninent.MenuItems.Add(asia);
        MenuItem euro = new MenuItem("유&럽", new EventHandler(MenuEvent), Shortcut.Alt2);
        coninent.MenuItems.Add(euro);
    }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:32,代码来源:Program.cs

示例7: MainForm

	public MainForm ()
	{
		// 
		// _contextMenu
		// 
		_contextMenu = new ContextMenu ();
		// 
		// _notifyIcon
		// 
		_notifyIcon = new NotifyIcon ();
		_notifyIcon.ContextMenu = _contextMenu;
		_notifyIcon.Click += new EventHandler (NotifyIcon_Click);
		// 
		// _bringToFrontMenuItem
		// 
		_bringToFrontMenuItem = new MenuItem ();
		_bringToFrontMenuItem.Text = "Bring to front...";
		_bringToFrontMenuItem.Click += new EventHandler (BringToFrontMenuItem_Click);
		_contextMenu.MenuItems.Add (_bringToFrontMenuItem);
		// 
		// _activateMenuItem
		// 
		_activateMenuItem = new MenuItem ();
		_activateMenuItem.Text = "Activate...";
		_activateMenuItem.Click += new EventHandler (ActivateMenuItem_Click);
		_contextMenu.MenuItems.Add (_activateMenuItem);
		// 
		// _tabControl
		// 
		_tabControl = new TabControl ();
		_tabControl.Dock = DockStyle.Fill;
		Controls.Add (_tabControl);
		// 
		// _bugDescriptionText1
		// 
		_bugDescriptionText1 = new TextBox ();
		_bugDescriptionText1.Dock = DockStyle.Fill;
		_bugDescriptionText1.Multiline = true;
		_bugDescriptionText1.Text = string.Format (CultureInfo.InvariantCulture,
			"Steps to execute:{0}{0}" +
			"1. Right-click the notify icon.{0}{0}" +
			"2. Click any of the menu items in the context menu.{0}{0}" +
			"Expected result:{0}{0}" +
			"1. The form is closed after the menu item is clicked.",
			Environment.NewLine);
		// 
		// _tabPage1
		// 
		_tabPage1 = new TabPage ();
		_tabPage1.Text = "#1";
		_tabPage1.Controls.Add (_bugDescriptionText1);
		_tabControl.Controls.Add (_tabPage1);
		// 
		// MainForm
		// 
		ClientSize = new Size (300, 170);
		StartPosition = FormStartPosition.CenterScreen;
		Text = "bug #82162";
		Load += new EventHandler (MainForm_Load);
	}
开发者ID:mono,项目名称:gert,代码行数:60,代码来源:MainForm.cs

示例8: 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

示例9: 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

示例10: btnRecord_Click

        private void btnRecord_Click( object sender, EventArgs e )
        {
            StopwatchListItem item = new StopwatchListItem ();
            item.SetValue ( TiltEffect.IsTiltEnabledProperty, true );
            item.Number = String.Format ( "{0:00}", lstRecord.Items.Count + 1 );
            item.Hour = txtHour.Text;
            item.Minute = txtMinute.Text;
            item.Second = txtSecond.Text;
            item.Millisecond = txtMillisec.Text;

            ContextMenu menu = new ContextMenu ();
            MenuItem menuItem = new MenuItem () { Header = "삭제" };
            menuItem.Tap += ( object s, System.Windows.Input.GestureEventArgs ee ) =>
            {
                if ( MessageBox.Show ( "이 기록을 삭제하시겠습니까?\n이 기록보다 뒤의 순위가 있어도 순위가 변경되지는 않습니다.", "스톱워치", MessageBoxButton.OKCancel )
                    == MessageBoxResult.OK )
                {
                    lstRecord.Items.Remove ( item );
                }
            };
            menu.Items.Add ( menuItem );
            ContextMenuService.SetContextMenu ( item, menu );

            lstRecord.Items.Insert ( 0, item );
        }
开发者ID:Daramkun,项目名称:StopwatchWP,代码行数:25,代码来源:MainPage.xaml.cs

示例11: MainWindow

    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        oXbmc = new XBMC_Communicator();
        oXbmc.SetIp("10.0.0.5");
        oXbmc.SetConnectionTimeout(4000);
        oXbmc.SetCredentials("", "");
        oXbmc.Status.StartHeartBeat();

        Build ();

        this.AllowStaticAccess();

        //Create objects used
        oPlaylist 		= new Playlist(this);
        oControls		= new Controls(this);
        oMenuItems		= new MenuItems(this);
        oContextMenu 	= new ContextMenu(this);
        oShareBrowser 	= new ShareBrowser(this);
        oTrayicon 		= new SysTrayIcon(this);
        oStatusUpdate	= new StatusUpdate(this);
        oMediaInfo		= new MediaInfo(this);
        oNowPlaying		= new NowPlaying(this);
        oGuiConfig		= new GuiConfig(this);

        nbDataContainer.CurrentPage = 0;
    }
开发者ID:Bram77,项目名称:xbmcontrol-evo,代码行数:27,代码来源:MainWindow.cs

示例12: InitializeComponent

	public void InitializeComponent()
	{
	//text
	text = new TextBox();
	text.Name = "textBox1";
	text.Location = new Point(0, 50);
	text.Size = new Size(120, 30);
   
   //text
	text1 = new TextBox();
	text1.Name = "text1Box1";
	text1.Location = new Point(0, 80);
	text1.Size = new Size(120, 30);
   
  //context menu
   ContextMenu textcon = new ContextMenu();
   text.ContextMenu = textcon;
   text1.ContextMenu = textcon;
   
   MenuItem item1 = new MenuItem();
   MenuItem item2 = new MenuItem();
   MenuItem item3 = new MenuItem();
   
   item1.Text = "&Copy";
   item2.Text = "&Paste";
   item3.Text = "&Delete";
   item1.Click += new EventHandler(CopyMenuItem1_Clicked);
   item2.Click += new EventHandler(CopyMenuItem2_Clicked);
   item3.Click += new EventHandler(CopyMenuItem3_Clicked);
   
   textcon.MenuItems.Add(item1);
   textcon.MenuItems.Add(item2);
   textcon.MenuItems.Add(item3);
   

		ContextMenu con = new ContextMenu();
		this.ContextMenu = con;
//  con += new EventHandler(contextMenuClicked);
		MenuItem menu1 = new MenuItem();
		MenuItem menu2 = new MenuItem();
		MenuItem close = new MenuItem();
		menu1.Click += new EventHandler(menu1ItemClicked);
		menu2.Click += new EventHandler(menu2ItemClicked);
		close.Click += new EventHandler(menu3ItemClicked);
		
		menu1.Text = "&Add";
		menu2.Text = "&Delete";
		close.Text = "&Close";
		
		con.MenuItems.Add(menu1);
		con.MenuItems.Add(menu2);
		con.MenuItems.Add(close);

 this.Text = "This is Clip box example";
 this.Name = "Form1";

    this.Controls.Add(text);
    this.Controls.Add(text1);
	}
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:59,代码来源:example1.cs

示例13: SetContextMenu

        /// <summary>
        /// Sets the value of the ContextMenu property of the specified object.
        /// </summary>
        /// <param name="element">Object to set the property on.</param>
        /// <param name="value">Value to set.</param>
        public static void SetContextMenu(DependencyObject element, ContextMenu value)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            element.SetValue(ContextMenuProperty, value);
        }
开发者ID:joseph-zhong,项目名称:WPtoolkit,代码行数:14,代码来源:ContextMenuService.cs

示例14: GTrello

        public GTrello(ContextMenu menustrip, NotifyIcon icon)
        {
            menu = menustrip;
            app = icon;
            isUpdating = false;

            InitMenu();
            InitIcon();
            Initialized = InitServices();
        }
开发者ID:czoper,项目名称:GTrello,代码行数:10,代码来源:Program.cs

示例15: MainForm_Load

	void MainForm_Load (object sender, EventArgs e)
	{
		InstructionsForm instructionsForm = new InstructionsForm ();
		instructionsForm.Show ();

		ContextMenu context = new ContextMenu ();
		context.MenuItems.Add (new MenuItem ("&Close"));

		_propertyGrid.ContextMenu = context;
		_propertyGrid.SelectedObject = new Config ();
	}
开发者ID:mono,项目名称:gert,代码行数:11,代码来源:MainForm.cs


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