本文整理汇总了C#中MonoMac.AppKit.NSMenu类的典型用法代码示例。如果您正苦于以下问题:C# NSMenu类的具体用法?C# NSMenu怎么用?C# NSMenu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSMenu类属于MonoMac.AppKit命名空间,在下文中一共展示了NSMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: StatusItemBurritoDayView
public StatusItemBurritoDayView(Container container)
{
this.menu = new NSMenu();
this.menu.AddItem(this.refreshMenuItem);
this.menu.AddItem(this.launchMenuItem);
this.menu.AddItem(NSMenuItem.SeparatorItem);
this.menu.AddItem(this.durationMenuItem);
this.menu.AddItem(this.locationMenuItem);
this.menu.AddItem(this.separatorMenuItem);;
this.menu.AddItem(this.dismissMenuitem);
this.menu.AddItem(this.quitMenuItem);
this.launchMenuItem.Activated += delegate {
var handler = this.urlActivated;
if (handler != null)
{
handler(this, "http://isitburritoday.com");
}
};
this.quitMenuItem.Activated += (sender, e) =>
NSApplication.SharedApplication.Terminate(sender as NSObject);
this.presenters = new IDisposable[]
{
container.Resolve<BurritoDayPresenter, IBurritoDayView>(this),
container.Resolve<UrlActivationPresenter, IUrlActivationView>(this),
};
}
示例3: 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;
}
示例4: 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;
}
示例5: 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);
}
示例6: MDServicesMenuItem
public MDServicesMenuItem ()
{
Title = GettextCatalog.GetString ("Services");
var sub = NSApplication.SharedApplication.ServicesMenu;
if (sub == null) {
sub = new NSMenu ();
NSApplication.SharedApplication.ServicesMenu = sub;
} else {
foreach (var m in sub.Supermenu.ItemArray ()) {
if (m.Submenu == sub) {
m.Submenu = new NSMenu ();
break;
}
}
}
Submenu = sub;
}
示例7: MenuWillOpen
public override void MenuWillOpen(NSMenu menu)
{
MenuIsOpen = true;
}
示例8: CreateMenu
public void CreateMenu()
{
this.menu = new NSMenu () { AutoEnablesItems = false };
this.state_item = new NSMenuItem () {
Title = Controller.StateText,
Enabled = false
};
this.folder_item = new NSMenuItem () {
Title = "SparkleShare",
Enabled = true
};
this.folder_item.Image = this.sparkleshare_image;
this.folder_item.Image.Size = new SizeF (16, 16);
this.add_item = new NSMenuItem () {
Title = "Add Hosted Project…",
Enabled = true
};
this.recent_events_item = new NSMenuItem () {
Title = "Recent Changes…",
Enabled = Controller.RecentEventsItemEnabled
};
this.about_item = new NSMenuItem () {
Title = "About SparkleShare",
Enabled = true
};
this.quit_item = new NSMenuItem () {
Title = "Quit",
Enabled = Controller.QuitItemEnabled
};
this.folder_menu_items = new NSMenuItem [Controller.Folders.Length];
this.error_menu_items = new NSMenuItem [Controller.Folders.Length];
this.try_again_menu_items = new NSMenuItem [Controller.Folders.Length];
if (Controller.Folders.Length > 0) {
int i = 0;
foreach (string folder_name in Controller.Folders) {
NSMenuItem item = new NSMenuItem () { Title = folder_name };
this.folder_menu_items [i] = item;
if (!string.IsNullOrEmpty (Controller.FolderErrors [i])) {
item.Image = this.caution_image;
item.Submenu = new NSMenu ();
this.error_menu_items [i] = new NSMenuItem ();
this.error_menu_items [i].Title = Controller.FolderErrors [i];
this.try_again_menu_items [i] = new NSMenuItem ();
this.try_again_menu_items [i].Title = "Try Again";
this.try_again_menu_items [i].Activated += Controller.TryAgainDelegate (folder_name);;
item.Submenu.AddItem (this.error_menu_items [i]);
item.Submenu.AddItem (NSMenuItem.SeparatorItem);
item.Submenu.AddItem (this.try_again_menu_items [i]);
} else {
item.Image = this.folder_image;
this.folder_menu_items [i].Activated += Controller.OpenFolderDelegate (folder_name);
}
item.Image.Size = new SizeF (16, 16);
i++;
};
}
if (Controller.RecentEventsItemEnabled)
this.recent_events_item.Activated += delegate { Controller.RecentEventsClicked (); };
this.add_item.Activated += delegate { Controller.AddHostedProjectClicked (); };
this.about_item.Activated += delegate { Controller.AboutClicked (); };
this.quit_item.Activated += delegate { Controller.QuitClicked (); };
this.menu.AddItem (this.state_item);
this.menu.AddItem (NSMenuItem.SeparatorItem);
this.menu.AddItem (this.folder_item);
this.submenu = new NSMenu ();
this.submenu.AddItem (this.recent_events_item);
this.submenu.AddItem (this.add_item);
this.submenu.AddItem (NSMenuItem.SeparatorItem);
this.submenu.AddItem (this.about_item);
this.folder_item.Submenu = this.submenu;
foreach (NSMenuItem item in this.folder_menu_items)
this.menu.AddItem (item);
this.menu.AddItem (NSMenuItem.SeparatorItem);
this.menu.AddItem (this.quit_item);
this.menu.Delegate = new SparkleMenuDelegate ();
this.status_item.Menu = this.menu;
//.........这里部分代码省略.........
示例9: MenuDidClose
public override void MenuDidClose(NSMenu menu)
{
MenuIsOpen = false;
}
示例10: MenuWillHighlightItem
public override void MenuWillHighlightItem(NSMenu menu, NSMenuItem item)
{
}
示例11: StartSearch
partial void StartSearch(MonoMac.AppKit.NSSearchField sender)
{
var noteResults = AppDelegate.NoteEngine.GetNotes (sender.StringValue, true);
NSMenu noteSearchMenu = new NSMenu ("Search Results");
var action = new MonoMac.ObjCRuntime.Selector ("searchResultSelected");
foreach (var name in noteResults.Values.Select (n => n.Title))
noteSearchMenu.AddItem (name, action, string.Empty);
Console.WriteLine (sender.Frame);
Console.WriteLine (sender.Superview.Frame);
Console.WriteLine (sender.Superview.Superview.Frame);
NSEvent evt = NSEvent.OtherEvent (NSEventType.ApplicationDefined,
new PointF (sender.Frame.Left, sender.Frame.Top),
(NSEventModifierMask)0,
0,
sender.Window.WindowNumber,
sender.Window.GraphicsContext,
(short)NSEventType.ApplicationDefined,
0, 0);
NSMenu.PopUpContextMenu (noteSearchMenu, evt, searchField);
}
示例12: CreateMenu
public void CreateMenu()
{
using (NSAutoreleasePool a = new NSAutoreleasePool ())
{
StatusItem.Image = AnimationFrames [0];
StatusItem.AlternateImage = AnimationFramesActive [0];
StatusItem.Image.Size = new SizeF (16, 16);
StatusItem.AlternateImage.Size = new SizeF (16, 16);
Menu = new NSMenu ();
Menu.AutoEnablesItems = false;
StateMenuItem = new NSMenuItem () {
Title = StateText,
Enabled = false
};
Menu.AddItem (StateMenuItem);
Menu.AddItem (NSMenuItem.SeparatorItem);
FolderMenuItem = new NSMenuItem () {
Title = "SparkleShare"
};
FolderMenuItem.Activated += delegate {
Program.Controller.OpenSparkleShareFolder ();
};
FolderMenuItem.Image = SparkleShareImage;
FolderMenuItem.Image.Size = new SizeF (16, 16);
FolderMenuItem.Enabled = true;
Menu.AddItem (FolderMenuItem);
FolderMenuItems = new NSMenuItem [Program.Controller.Folders.Count];
if (Controller.Folders.Length > 0) {
Tasks = new EventHandler [Program.Controller.Folders.Count];
int i = 0;
foreach (string folder_name in Program.Controller.Folders) {
NSMenuItem item = new NSMenuItem ();
item.Title = folder_name;
if (Program.Controller.UnsyncedFolders.Contains (folder_name))
item.Image = CautionImage;
else
item.Image = FolderImage;
item.Image.Size = new SizeF (16, 16);
Tasks [i] = OpenFolderDelegate (folder_name);
FolderMenuItems [i] = item;
FolderMenuItems [i].Activated += Tasks [i];
FolderMenuItem.Enabled = true;
i++;
};
} else {
FolderMenuItems = new NSMenuItem [1];
FolderMenuItems [0] = new NSMenuItem () {
Title = "No projects yet",
Enabled = false
};
}
foreach (NSMenuItem item in FolderMenuItems)
Menu.AddItem (item);
Menu.AddItem (NSMenuItem.SeparatorItem);
SyncMenuItem = new NSMenuItem () {
Title = "Add Hosted Project…",
Enabled = true
};
if (!Program.Controller.FirstRun) {
SyncMenuItem.Activated += delegate {
InvokeOnMainThread (delegate {
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
if (SparkleUI.Setup == null) {
SparkleUI.Setup = new SparkleSetup ();
SparkleUI.Setup.Controller.ShowAddPage ();
}
if (!SparkleUI.Setup.IsVisible)
SparkleUI.Setup.Controller.ShowAddPage ();
SparkleUI.Setup.OrderFrontRegardless ();
SparkleUI.Setup.MakeKeyAndOrderFront (this);
});
};
}
Menu.AddItem (SyncMenuItem);
Menu.AddItem (NSMenuItem.SeparatorItem);
//.........这里部分代码省略.........
示例13: SetGlobalMenu
public override bool SetGlobalMenu (CommandManager commandManager, string commandMenuAddinPath, string appMenuAddinPath)
{
if (setupFail)
return false;
try {
InitApp (commandManager);
NSApplication.SharedApplication.HelpMenu = null;
var rootMenu = NSApplication.SharedApplication.MainMenu;
if (rootMenu == null) {
rootMenu = new NSMenu ();
NSApplication.SharedApplication.MainMenu = rootMenu;
} else {
rootMenu.RemoveAllItems ();
}
CommandEntrySet appCes = commandManager.CreateCommandEntrySet (appMenuAddinPath);
rootMenu.AddItem (new MDSubMenuItem (commandManager, appCes));
CommandEntrySet ces = commandManager.CreateCommandEntrySet (commandMenuAddinPath);
foreach (CommandEntry ce in ces) {
rootMenu.AddItem (new MDSubMenuItem (commandManager, (CommandEntrySet) ce));
}
} catch (Exception ex) {
try {
var m = NSApplication.SharedApplication.MainMenu;
if (m != null) {
m.Dispose ();
}
NSApplication.SharedApplication.MainMenu = null;
} catch {}
LoggingService.LogError ("Could not install global menu", ex);
setupFail = true;
return false;
}
return true;
}
示例14: CreateMenu
public void CreateMenu()
{
using (NSAutoreleasePool a = new NSAutoreleasePool ())
{
StatusItem.Image = AnimationFrames [0];
StatusItem.AlternateImage = AnimationFramesActive [0];
StatusItem.Image.Size = new SizeF (16, 16);
StatusItem.AlternateImage.Size = new SizeF (16, 16);
Menu = new NSMenu ();
Menu.AutoEnablesItems = false;
StateMenuItem = new NSMenuItem () {
Title = StateText,
Enabled = false
};
Menu.AddItem (StateMenuItem);
Menu.AddItem (NSMenuItem.SeparatorItem);
FolderMenuItem = new NSMenuItem () {
Title = "SparkleShare"
};
FolderMenuItem.Activated += delegate {
Controller.SparkleShareClicked ();
};
FolderMenuItem.Image = SparkleShareImage;
FolderMenuItem.Image.Size = new SizeF (16, 16);
FolderMenuItem.Enabled = true;
Menu.AddItem (FolderMenuItem);
FolderMenuItems = new NSMenuItem [Program.Controller.Folders.Count];
if (Controller.Folders.Length > 0) {
Tasks = new EventHandler [Program.Controller.Folders.Count];
int i = 0;
foreach (string folder_name in Program.Controller.Folders) {
NSMenuItem item = new NSMenuItem ();
item.Title = folder_name;
if (Program.Controller.UnsyncedFolders.Contains (folder_name))
item.Image = CautionImage;
else
item.Image = FolderImage;
item.Image.Size = new SizeF (16, 16);
Tasks [i] = OpenFolderDelegate (folder_name);
FolderMenuItems [i] = item;
FolderMenuItems [i].Activated += Tasks [i];
FolderMenuItem.Enabled = true;
i++;
};
} else {
FolderMenuItems = new NSMenuItem [1];
FolderMenuItems [0] = new NSMenuItem () {
Title = "No projects yet",
Enabled = false
};
}
foreach (NSMenuItem item in FolderMenuItems)
Menu.AddItem (item);
Menu.AddItem (NSMenuItem.SeparatorItem);
SyncMenuItem = new NSMenuItem () {
Title = "Add Hosted Project…",
Enabled = true
};
SyncMenuItem.Activated += delegate {
Controller.AddHostedProjectClicked ();
};
Menu.AddItem (SyncMenuItem);
RecentEventsMenuItem = new NSMenuItem () {
Title = "View Recent Changes…",
Enabled = (Controller.Folders.Length > 0)
};
if (Controller.Folders.Length > 0) {
RecentEventsMenuItem.Activated += delegate {
Controller.OpenRecentEventsClicked ();
};
}
Menu.AddItem (RecentEventsMenuItem);
Menu.AddItem (NSMenuItem.SeparatorItem);
NotificationsMenuItem = new NSMenuItem () {
//.........这里部分代码省略.........
示例15: CreateMenu
// Creates the menu that is popped up when the
// user clicks the status icon
public void CreateMenu()
{
Menu = new NSMenu ();
StateMenuItem = new NSMenuItem () {
Title = StateText
};
Menu.AddItem (StateMenuItem);
Menu.AddItem (NSMenuItem.SeparatorItem);
FolderMenuItem = new NSMenuItem () {
Title = "SparkleShare"
};
FolderMenuItem.Activated += delegate {
SparkleShare.Controller.OpenSparkleShareFolder ();
};
string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
"sparkleshare-mac.icns");
FolderMenuItem.Image = new NSImage (folder_icon_path);
FolderMenuItem.Image.Size = new SizeF (16, 16);
Menu.AddItem (FolderMenuItem);
if (SparkleShare.Controller.Folders.Count > 0) {
FolderMenuItems = new NSMenuItem [SparkleShare.Controller.Folders.Count];
Tasks = new EventHandler [SparkleShare.Controller.Folders.Count];
int i = 0;
foreach (string path in SparkleShare.Controller.Folders) {
// TODO
// if (repo.HasUnsyncedChanges)
// folder_action.IconName = "dialog-error";
NSMenuItem item = new NSMenuItem ();
item.Title = System.IO.Path.GetFileName (path);
item.Image = NSImage.ImageNamed ("NSFolder");
item.Image.Size = new SizeF (16, 16);
Tasks [i] = OpenEventLogDelegate(item.Title);
FolderMenuItems [i] = item;
FolderMenuItems [i].Activated += Tasks [i];
Menu.AddItem (FolderMenuItems [i]);
i++;
};
} else {
FolderMenuItems = new NSMenuItem [1];
FolderMenuItems [0] = new NSMenuItem () {
Title = "No Remote Folders Yet"
};
Menu.AddItem (FolderMenuItems [0]);
}
Menu.AddItem (NSMenuItem.SeparatorItem);
SyncMenuItem = new NSMenuItem () {
Title = "Add Remote Folder…"
};
if (!SparkleShare.Controller.FirstRun) {
SyncMenuItem.Activated += delegate {
InvokeOnMainThread (delegate {
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
if (SparkleUI.Intro == null) {
SparkleUI.Intro = new SparkleIntro ();
SparkleUI.Intro.ShowServerForm (true);
}
if (!SparkleUI.Intro.IsVisible)
SparkleUI.Intro.ShowServerForm (true);
SparkleUI.Intro.OrderFrontRegardless ();
SparkleUI.Intro.MakeKeyAndOrderFront (this);
});
};
//.........这里部分代码省略.........