當前位置: 首頁>>代碼示例>>C#>>正文


C# AppKit.NSMenuItem類代碼示例

本文整理匯總了C#中MonoMac.AppKit.NSMenuItem的典型用法代碼示例。如果您正苦於以下問題:C# NSMenuItem類的具體用法?C# NSMenuItem怎麽用?C# NSMenuItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NSMenuItem類屬於MonoMac.AppKit命名空間,在下文中一共展示了NSMenuItem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Update

		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			var info = manager.GetCommandInfo (ce.CommandId);

			if (!isArrayItem) {
				SetItemValues (this, info);
				if (!Hidden)
					MDMenu.ShowLastSeparator (ref lastSeparator);
				return;
			}

			Hidden = true;

			if (index < parent.Count - 1) {
				for (int i = index + 1; i < parent.Count; i++) {
					var nextItem = parent.ItemAt (i);
					if (nextItem == null || nextItem.Target != this)
						break;
					parent.RemoveItemAt (i);
					i--;
				}
			}

			PopulateArrayItems (info.ArrayInfo, parent, ref lastSeparator, ref index);
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:25,代碼來源:MDMenuItem.cs

示例2: CreateNsMenu

		private void CreateNsMenu() {

			var menu = new NSMenu ();

			statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
			statusItem.Menu = menu;
			statusItem.Image = NSImage.ImageNamed("statusicon");
			statusItem.HighlightMode = true;

			menu.RemoveAllItems ();

			browseMenuItem = new NSMenuItem ("Browse Media Library", "b", delegate {
				Browse (NSApplication.SharedApplication);
			});
			menu.AddItem (browseMenuItem);

			configureMenuItem = new NSMenuItem ("Configure Media Browser", "c", delegate {
				Configure (NSApplication.SharedApplication);
			});
			menu.AddItem (configureMenuItem);

			communityMenuItem = new NSMenuItem ("Visit Community", "v", delegate {
				Community (NSApplication.SharedApplication);
			});
			menu.AddItem (communityMenuItem);

			quitMenuItem = new NSMenuItem ("Quit", "q", delegate {
				Quit (NSApplication.SharedApplication);
			});
			menu.AddItem (quitMenuItem);
		}
開發者ID:paul-777,項目名稱:Emby,代碼行數:31,代碼來源:MenuBarIcon.cs

示例3: Update

		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			Enabled = true;
			Hidden = Submenu != NSApplication.SharedApplication.ServicesMenu;
			if (!Hidden)
				MDMenu.ShowLastSeparator (ref lastSeparator);
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:7,代碼來源:MDServicesMenuItem.cs

示例4: Run

		public void Run (NSMenuItem sender)
		{
			var a = sender as MDExpandedArrayItem;
			if (a != null) {
				manager.DispatchCommand (ce.CommandId, a.Info.DataItem, CommandSource.MainMenu);
			} else {
				manager.DispatchCommand (ce.CommandId, CommandSource.MainMenu);
			}
		}
開發者ID:IBBoard,項目名稱:monodevelop,代碼行數:9,代碼來源:MDMenuItem.cs

示例5: ValidateMenuItem

		public bool ValidateMenuItem(NSMenuItem item)
		{
			var h = Handler;
			if (h != null)
			{
				h.Widget.OnValidate(EventArgs.Empty);
				return h.Enabled;
			}
			return false;
		}
開發者ID:Exe0,項目名稱:Eto,代碼行數:10,代碼來源:MenuActionHandler.cs

示例6: Update

		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			if (ces.AutoHide) {
				((MDMenu)Submenu).UpdateCommands ();
				Hidden = Submenu.ItemArray ().All (item => item.Hidden);
			}
			if (!Hidden) {
				MDMenu.ShowLastSeparator (ref lastSeparator);
			}
		}
開發者ID:brantwedel,項目名稱:monodevelop,代碼行數:10,代碼來源:MDSubMenuItem.cs

示例7: FinishedLaunching

        public override void FinishedLaunching(NSObject notification)
        {
            //			mainWindowController = new MainWindowController ();
            //			mainWindowController.Window.MakeKeyAndOrderFront (this);

            // Construct menu that will be displayed when tray icon is clicked
            var notifyMenu = new NSMenu();
            var exitMenuItem = new NSMenuItem("Quit",
                (a,b) => {
                    NSApplication.SharedApplication.Terminate(this);
                    //System.Environment.Exit(0);
                });

            var startMidiModMenuItem = new NSMenuItem("Run",
                (a,b) => { RunMidiMod(); });

            var mappingmodMidiModMenuItem = new NSMenuItem("Mapping Mod",
                (a,b) => { ActivateMappingMod(); });

            statusMenuItem = new NSMenuItem("STATUS",
                (a,b) => {  });
            statusMenuItem.Enabled = false;

            var versionMenuItem = new NSMenuItem("Version 1.0",
                (a,b) => {  });
            versionMenuItem.Enabled = false;

            var seperatorItem = NSMenuItem.SeparatorItem;

            notifyMenu.AutoEnablesItems = false;

            // Just add 'Quit' command
            notifyMenu.AddItem (statusMenuItem);
            notifyMenu.AddItem (versionMenuItem);
            notifyMenu.AddItem (seperatorItem);
            notifyMenu.AddItem (startMidiModMenuItem);
            notifyMenu.AddItem (mappingmodMidiModMenuItem);
            notifyMenu.AddItem(exitMenuItem);

            // Display tray icon in upper-right-hand corner of the screen
            sItem = NSStatusBar.SystemStatusBar.CreateStatusItem(16); //def 16
            sItem.Menu = notifyMenu;
            sItem.Title = "MidiMod";
            sItem.ToolTip = "Midi Mod";
            sItem.Image = NSImage.FromStream(System.IO.File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/9b244f1232672041.icns"));
            sItem.HighlightMode = true;

            UpdateStatus ("Mod not startet");

            // Remove the system tray icon from upper-right hand corner of the screen
             	// (works without adjusting the LSUIElement setting in Info.plist)
            NSApplication.SharedApplication.ActivationPolicy =
                NSApplicationActivationPolicy.Accessory;
        }
開發者ID:cansik,項目名稱:midimodifier,代碼行數:54,代碼來源:AppDelegate.cs

示例8: RepositoryMenuItem

        public RepositoryMenuItem(Repository repo, StatusIconController controller) : base(repo.Name) {
            this.repository = repo;
            this.controller = controller;
            this.Image = this.folderImage;
            this.Image.Size = new SizeF(16, 16);
            this.repository.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.Status)) {
                    this.Status = this.repository.Status;
                }

                if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.LastFinishedSync)) {
                    this.changesFoundAt = this.repository.LastFinishedSync;
                    this.UpdateStatusText();
                }

                if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.NumberOfChanges)) {
                    this.changesFound = this.repository.NumberOfChanges;
                    this.UpdateStatusText();
                }
            };
            this.openLocalFolderItem = new NSMenuItem(Properties_Resources.OpenLocalFolder) {
                Image = this.folderImage
            };
            this.openLocalFolderItem.Image.Size = new SizeF(16, 16);

            this.openLocalFolderItem.Activated += this.OpenFolderDelegate();

            this.editItem = new NSMenuItem(Properties_Resources.Settings);
            this.editItem.Activated += this.EditFolderDelegate();

            this.suspendItem = new NSMenuItem(Properties_Resources.PauseSync);

            this.Status = repo.Status;

            this.suspendItem.Activated += this.SuspendSyncFolderDelegate();
            this.statusItem = new NSMenuItem(Properties_Resources.StatusSearchingForChanges) {
                Enabled = false
            };

            this.removeFolderFromSyncItem = new NSMenuItem(Properties_Resources.RemoveFolderFromSync);
            this.removeFolderFromSyncItem.Activated += this.RemoveFolderFromSyncDelegate();

            var subMenu = new NSMenu();
            subMenu.AddItem(this.statusItem);
            subMenu.AddItem(NSMenuItem.SeparatorItem);
            subMenu.AddItem(this.openLocalFolderItem);
            subMenu.AddItem(this.suspendItem);
            subMenu.AddItem(this.editItem);
            subMenu.AddItem(NSMenuItem.SeparatorItem);
            subMenu.AddItem(this.removeFolderFromSyncItem);
            this.Submenu = subMenu;
        }
開發者ID:OpenDataSpace,項目名稱:CmisSync,代碼行數:52,代碼來源:RepositoryMenuItem.cs

示例9: Run

		public void Run (NSMenuItem sender)
		{
			var a = sender as MDExpandedArrayItem;
			//if the command opens a modal subloop, give cocoa a chance to unhighlight the menu item
			GLib.Timeout.Add (1, () => {
				if (a != null) {
					manager.DispatchCommand (ce.CommandId, a.Info.DataItem, CommandSource.MainMenu);
				} else {
					manager.DispatchCommand (ce.CommandId, CommandSource.MainMenu);
				}
				return false;
			});
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:13,代碼來源:MDMenuItem.cs

示例10: ValidateMenuItem

		public bool ValidateMenuItem(NSMenuItem menuItem)
		{
            switch ((MenuTag) (int)menuItem.Tag)
			{
				case MenuTag.AlwaysEnable:
					return true;
				case MenuTag.RequiresFile:
					return mediaListController.Count > 0;
			}

			logger.Info("ValidateMenuItem: unexpected tag {0} for menu item '{1}'", menuItem.Tag, menuItem.Title);
			return false;
		}
開發者ID:kevintavog,項目名稱:Radish.net,代碼行數:13,代碼來源:MenuHandlers.cs

示例11: DidFinishLaunching

        public override void DidFinishLaunching(NSNotification notification)
        {
            var menu = new NSMenu ();

            var menuItem = new NSMenuItem ();
            menu.AddItem (menuItem);

            var appMenu = new NSMenu ();
            var quitItem = new NSMenuItem ("Quit " + NSProcessInfo.ProcessInfo.ProcessName, "q", (s, e) => NSApplication.SharedApplication.Terminate (menu));
            appMenu.AddItem (quitItem);

            var window = new NSWindow ();

            menuItem.Submenu = appMenu;
            NSApplication.SharedApplication.MainMenu = menu;
        }
開發者ID:Sracinas,項目名稱:XamarinTest,代碼行數:16,代碼來源:AppDelegate.cs

示例12: CreateNsMenu

		private void CreateNsMenu() {

			var menu = new NSMenu ();

			statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
			statusItem.Menu = menu;
			statusItem.Image = NSImage.ImageNamed("statusicon");
			statusItem.HighlightMode = true;

			menu.RemoveAllItems ();

			browseMenuItem = new NSMenuItem ("Browse Media Library", "b", delegate {
				Browse (NSApplication.SharedApplication);
			});
			menu.AddItem (browseMenuItem);

			configureMenuItem = new NSMenuItem ("Configure Media Browser", "c", delegate {
				Configure (NSApplication.SharedApplication);
			});
			menu.AddItem (configureMenuItem);

			developerMenuItem = new NSMenuItem ("Developer Resources");
			menu.AddItem (developerMenuItem);

			var developerMenu = new NSMenu ();
			developerMenuItem.Submenu = developerMenu;

			apiMenuItem = new NSMenuItem ("Api Documentation", "a", delegate {
				ApiDocs (NSApplication.SharedApplication);
			});
			developerMenu.AddItem (apiMenuItem);

			githubMenuItem = new NSMenuItem ("Github", "g", delegate {
				Github (NSApplication.SharedApplication);
			});
			developerMenu.AddItem (githubMenuItem);

			communityMenuItem = new NSMenuItem ("Visit Community", "v", delegate {
				Community (NSApplication.SharedApplication);
			});
			menu.AddItem (communityMenuItem);

			quitMenuItem = new NSMenuItem ("Quit", "q", delegate {
				Quit (NSApplication.SharedApplication);
			});
			menu.AddItem (quitMenuItem);
		}
開發者ID:jabbera,項目名稱:MediaBrowser,代碼行數:47,代碼來源:MenuBarIcon.cs

示例13: MenuItemWrapper

 public MenuItemWrapper(string text, Duplicati.GUI.TrayIcon.MenuIcons icon, Action callback, IList<Duplicati.GUI.TrayIcon.IMenuItem> subitems)
 {
     if (text == "-")
         m_item = NSMenuItem.SeparatorItem;
     else
     {
         m_item = new NSMenuItem(text, ClickHandler);
         m_callback = callback;
         
         if (subitems != null && subitems.Count > 0)
         {
             m_item.Submenu = new NSMenu();
             foreach(var itm in subitems)
                 m_item.Submenu.AddItem(((MenuItemWrapper)itm).MenuItem);
         }
     }
 }
開發者ID:admz,項目名稱:duplicati,代碼行數:17,代碼來源:CocoaRunner.cs

示例14: SelectEncodingPopUpButton

		public SelectEncodingPopUpButton (bool showAutoDetected)
		{
			Cell.UsesItemFromMenu = false;
			
			if (showAutoDetected) {
				autoDetectedItem = new NSMenuItem () {
					Title = GettextCatalog.GetString ("Auto Detected"),
					Tag = -1,
					Target = this,
					Action = itemActivationSel,
				};
			}
			
			addRemoveItem = new NSMenuItem () {
				Title = GettextCatalog.GetString ("Add or Remove..."),
				Tag = -20,
				Target = this,
				Action = addRemoveActivationSel,
			};
			
			Populate (false);
			SelectedEncodingId = 0;
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:23,代碼來源:SelectEncodingPopUpButton.cs

示例15: AwakeFromNib

		public override void AwakeFromNib ()
		{
			base.AwakeFromNib ();
			
			#region first two buttons 
			
			// add the image menu item back to the first menu item
			NSMenuItem menuItem = new NSMenuItem ("", new Selector (""), "");
			
			menuItem.Image = NSImage.ImageNamed ("moof.png");
			buttonMenu.InsertItematIndex (menuItem, 0);
			
			nibBasedPopUpDown.Menu = buttonMenu;
			nibBasedPopUpRight.Menu = buttonMenu;
		
			// create the pull down button pointing DOWN
			RectangleF buttonFrame = placeHolder1.Frame;
			codeBasedPopUpDown = new NSPopUpButton (buttonFrame, true);
			
			((NSPopUpButtonCell)codeBasedPopUpDown.Cell).ArrowPosition = NSPopUpArrowPosition.Bottom;
			((NSPopUpButtonCell)codeBasedPopUpDown.Cell).BezelStyle = NSBezelStyle.ThickSquare;
			codeBasedPopUpDown.Menu = buttonMenu;
			popupBox.AddSubview (codeBasedPopUpDown);
			placeHolder1.RemoveFromSuperview ();
		
			// create the pull down button pointing RIGHT
			buttonFrame = placeHolder2.Frame;
			codeBasedPopUpRight = new NSPopUpButton (buttonFrame, true);
			
			((NSPopUpButtonCell)codeBasedPopUpRight.Cell).ArrowPosition = NSPopUpArrowPosition.Bottom;
			((NSPopUpButtonCell)codeBasedPopUpRight.Cell).PreferredEdge = NSRectEdge.MaxXEdge;
			((NSPopUpButtonCell)codeBasedPopUpRight.Cell).BezelStyle = NSBezelStyle.Circular;
			codeBasedPopUpRight.Menu = buttonMenu;
			((NSPopUpButtonCell)codeBasedPopUpRight.Cell).HighlightsBy = (int)NSCellMask.ChangeGrayCell;
			popupBox.AddSubview (codeBasedPopUpRight);
			placeHolder2.RemoveFromSuperview ();
			
			#endregion
			
			#region second two buttons
			
			// create the rounded button
			buttonFrame = placeHolder3.Frame;
			// note: this button we want alternate title and image, so we need to call this:
			codeBasedButtonRound = new NSButton (buttonFrame) {
				Title = "NSButton",
				AlternateTitle = "(pressed)",
				Image = NSImage.ImageNamed ("moof.png"),
				AlternateImage = NSImage.ImageNamed ("moof2.png"),
				BezelStyle = NSBezelStyle.RegularSquare,
				ImagePosition = NSCellImagePosition.ImageLeft,
				Font = NSFont.SystemFontOfSize (NSFont.SmallSystemFontSize),
				Sound = NSSound.FromName ("Pop"),
			};
			// Two choices, either use the .NET event system:
			//    foo.Activated += delegate {..} or += SomeMethod
			//
			// Or you can use the Target = this Action = new Selector ("buttonAction:")
			// pattern
			codeBasedButtonRound.Activated += delegate {
				buttonAction (null);
			};
			codeBasedButtonRound.SetButtonType (NSButtonType.MomentaryChange);
			codeBasedButtonRound.Cell.Alignment = NSTextAlignment.Left;
			buttonBox.AddSubview (codeBasedButtonRound);
			placeHolder3.RemoveFromSuperview (); 			// we are done with the place holder, remove it from the window
			
			// create the square button
			buttonFrame = placeHolder4.Frame;
			codeBasedButtonSquare = new NSButton (buttonFrame){
				Title = "NSButton",
				BezelStyle = NSBezelStyle.ShadowlessSquare,
				ImagePosition = NSCellImagePosition.ImageLeft,
				Image = NSImage.ImageNamed ("moof.png"),
				Font = NSFont.SystemFontOfSize (NSFont.SmallSystemFontSize),
				Sound = NSSound.FromName ("Pop"),
			};
			codeBasedButtonSquare.Activated += delegate { buttonAction (null); };
			codeBasedButtonSquare.Cell.Alignment = NSTextAlignment.Left;
			buttonBox.AddSubview (codeBasedButtonSquare);
			placeHolder4.RemoveFromSuperview (); 			// we are done with the place holder, remove it from the window
			
			#endregion
			
			#region segmented control
			
			buttonFrame = placeHolder5.Frame;
			codeBasedSegmentControl = new NSSegmentedControl(buttonFrame) {
				SegmentCount = 3,
				Target = this,
				Action = new Selector("segmentAction:")
			};
					
			codeBasedSegmentControl.SetWidth (nibBasedSegControl.GetWidth(0), 0);
			codeBasedSegmentControl.SetWidth (nibBasedSegControl.GetWidth (1), 1);
			codeBasedSegmentControl.SetWidth (nibBasedSegControl.GetWidth (2), 2);
			codeBasedSegmentControl.SetLabel ("One", 0);
			codeBasedSegmentControl.SetLabel ("Two", 1);
			codeBasedSegmentControl.SetLabel ("Three", 2);
			segmentBox.AddSubview (codeBasedSegmentControl);
//.........這裏部分代碼省略.........
開發者ID:Anomalous-Software,項目名稱:monomac,代碼行數:101,代碼來源:TestWindowController.cs


注:本文中的MonoMac.AppKit.NSMenuItem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。