本文整理汇总了C#中MonoMac.AppKit.NSMenu.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# NSMenu.AddItem方法的具体用法?C# NSMenu.AddItem怎么用?C# NSMenu.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoMac.AppKit.NSMenu
的用法示例。
在下文中一共展示了NSMenu.AddItem方法的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: 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);
}
示例3: 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;
}
示例4: 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;
}
示例5: CreateContextualMenu
private void CreateContextualMenu()
{
_menuItems = new NSMenu("Song Browser");
var menuItemPlaySong = new NSMenuItem("Play song(s)", PlaySongs);
var menuItemAddToPlaylist = new NSMenuItem("Add to playlist", AddToPlaylist);
_menuItems.AddItem(menuItemPlaySong);
_menuItems.AddItem(menuItemAddToPlaylist);
_menuHeader = new NSMenu();
foreach (var column in _control.Columns)
{
var menuItem = new NSMenuItem(column.FieldName);
_menuHeader.AddItem(menuItem);
}
}
示例6: 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 folder_name in SparkleShare.Controller.Folders) {
NSMenuItem item = new NSMenuItem ();
item.Title = folder_name;
if (SparkleShare.Controller.UnsyncedFolders.Contains (folder_name))
item.Image = NSImage.ImageNamed ("NSCaution");
else
item.Image = NSImage.ImageNamed ("NSFolder");
item.Image.Size = new SizeF (16, 16);
Tasks [i] = OpenFolderDelegate (folder_name);
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);
});
};
}
Menu.AddItem (SyncMenuItem);
Menu.AddItem (NSMenuItem.SeparatorItem);
RecentEventsMenuItem = new NSMenuItem () {
Title = "Show Recent Events"
};
if (SparkleShare.Controller.Folders.Count > 0) {
RecentEventsMenuItem.Activated += delegate {
InvokeOnMainThread (delegate {
NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);
//.........这里部分代码省略.........
示例7: 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);
});
};
//.........这里部分代码省略.........
示例8: 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 () {
//.........这里部分代码省略.........
示例9: StatusIcon
public StatusIcon () : base ()
{
using (var a = new NSAutoreleasePool ())
{
CreateAnimationFrames ();
this.status_item = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
this.status_item.HighlightMode = true;
this.status_item.Image = this.animation_frames [0];
this.status_item.Image = this.animation_frames [0];
this.status_item.Image.Size = new SizeF (16, 16);
CreateMenu ();
}
Controller.UpdateIconEvent += delegate (int icon_frame) {
using (var a = new NSAutoreleasePool ())
{
BeginInvokeOnMainThread (delegate {
if (icon_frame > -1) {
this.status_item.Image = this.animation_frames [icon_frame];
this.status_item.Image.Size = new SizeF (16, 16);
} else {
this.status_item.Image = this.error_image;
this.status_item.Image.Size = new SizeF (16, 16);
}
});
}
};
Controller.UpdateStatusItemEvent += delegate (string state_text) {
using (var a = new NSAutoreleasePool ())
{
InvokeOnMainThread (delegate {
this.state_item.Title = state_text;
});
}
};
Controller.UpdateMenuEvent += delegate {
using (var a = new NSAutoreleasePool ())
{
InvokeOnMainThread (() => CreateMenu ());
}
};
Controller.UpdateSuspendSyncFolderEvent += delegate(string reponame)
{
using (var a = new NSAutoreleasePool()){
InvokeOnMainThread(delegate {
NSMenuItem PauseItem;
if(FolderItems.TryGetValue(reponame,out PauseItem)){
setSyncItemState(PauseItem, getSyncStatus(reponame));
}
});
}
};
// TODO Need to implement this method like the COCOA way to do it
Controller.UpdateTransmissionMenuEvent += delegate
{
using (var a = new NSAutoreleasePool()) {
InvokeOnMainThread(delegate {
List<FileTransmissionEvent> transmissions = Program.Controller.ActiveTransmissions();
NSMenu transmissionmenu = new NSMenu();
foreach(FileTransmissionEvent transmission in transmissions) {
NSMenuItem transmissionItem = new TransmissionMenuItem(transmission);
transmissionmenu.AddItem(transmissionItem);
}
if(transmissions.Count > 0) {
state_item.Submenu = transmissionmenu;
state_item.Enabled = true;
}else{
state_item.Enabled = false;
}
});
}
};
}
示例10: CreateFolderMenuItem
NSMenuItem CreateFolderMenuItem(string folder_name)
{
NSMenuItem folderitem = new NSMenuItem();
folderitem.Image = this.folder_image;
folderitem.Image.Size = new SizeF(16, 16);
folderitem.Title = folder_name;
NSMenu foldersubmenu = new NSMenu();
NSMenuItem openitem = new NSMenuItem();
openitem.Title = Properties_Resources.OpenLocalFolder;
openitem.Activated += OpenFolderDelegate(folder_name);
NSMenuItem openremote = new NSMenuItem();
openremote.Title = Properties_Resources.BrowseRemoteFolder;
openremote.Activated += OpenRemoteFolderDelegate (folder_name);
NSMenuItem pauseitem = new NSMenuItem();
setSyncItemState(pauseitem, getSyncStatus(folder_name));
FolderItems.Add(folder_name, pauseitem);
pauseitem.Activated += PauseFolderDelegate(folder_name);
NSMenuItem manualSyncItem = new NSMenuItem();
manualSyncItem.Title = Properties_Resources.ManualSync;
manualSyncItem.Image = this.sync_image;
manualSyncItem.Image.Size = new SizeF (16, 16);
manualSyncItem.Activated += ManualSyncDelegate(folder_name);
NSMenuItem removeitem = new NSMenuItem();
removeitem.Title = Properties_Resources.RemoveFolderFromSync;
removeitem.Activated += RemoveFolderDelegate(folder_name);
NSMenuItem settingsitem = new NSMenuItem();
settingsitem.Title = Properties_Resources.EditTitle;
settingsitem.Activated += OpenSettingsDialogDelegate(folder_name);
foldersubmenu.AddItem(openitem);
foldersubmenu.AddItem(openremote);
foldersubmenu.AddItem(NSMenuItem.SeparatorItem);
foldersubmenu.AddItem(pauseitem);
foldersubmenu.AddItem(manualSyncItem);
foldersubmenu.AddItem(NSMenuItem.SeparatorItem);
foldersubmenu.AddItem(settingsitem);
foldersubmenu.AddItem(NSMenuItem.SeparatorItem);
foldersubmenu.AddItem(removeitem);
folderitem.Submenu = foldersubmenu;
return folderitem;
}
示例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: FinishedLaunching
public override void FinishedLaunching(NSObject notification)
{
// Configure logger
string path = Path.Combine (Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "log4net.config");
XmlConfigurator.ConfigureAndWatch (new FileInfo(path));
logger.Info ("Ventriliquest 1.0 Starting up...");
// Get list of available audio out devices
xamspeech ham = new xamspeech ();
OutputDevices = ham.GetDevices ();
// Setup UI
statusMenu = new NSMenu ();
statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem (30);
var outputItem = new NSMenuItem ("Output Device",
(a, b) => {
});
var deviceList = new NSMenu ();
outputItem.Submenu = deviceList;
OutputDeviceUID = "Built-in Output";
foreach(var entry in OutputDevices) {
var test = new NSMenuItem (entry.Key.ToString(),
(a, b) => {
foreach(NSMenuItem item in deviceList.ItemArray()) {
item.State = NSCellStateValue.Off;
}
NSMenuItem theItem = (NSMenuItem)a;
theItem.State = NSCellStateValue.On;
config.OutputDevice = theItem.Title;
foreach(var e in OutputDevices) {
if(e.Key.ToString().Equals(theItem.Title)) {
OutputDeviceUID = e.Value.ToString();
}
}
});
if(entry.Key.ToString().Equals(config.OutputDevice)) {
test.State = NSCellStateValue.On;
OutputDeviceUID = entry.Value.ToString ();
}
deviceList.AddItem (test);
}
var daItem = new NSMenuItem ("Local Connections Only",
(a, b) => {
NSMenuItem theItem = (NSMenuItem)a;
if(theItem.State == NSCellStateValue.On) {
config.LocalOnly = false;
theItem.State = NSCellStateValue.Off;
} else {
config.LocalOnly = true;
theItem.State = NSCellStateValue.On;
}
});
if(config.LocalOnly) {
daItem.State = NSCellStateValue.On;
}
var quitItem = new NSMenuItem("Quit",
(a, b) => Shutdown ());
var voiceconfigItem = new NSMenuItem("Voice Configuration",
(a, b) => Process.Start("http://127.0.0.1:7888/config"));
statusMenu.AddItem (outputItem);
statusMenu.AddItem (daItem);
statusMenu.AddItem (voiceconfigItem);
statusMenu.AddItem (quitItem);
statusItem.Menu = statusMenu;
statusItem.Image = NSImage.ImageNamed("tts-1.png");
statusItem.AlternateImage = NSImage.ImageNamed ("tts-2.png");
statusItem.HighlightMode = true;
speechdelegate.DidComplete += delegate {
synthesis.Set();
};
sounddelegate.DidComplete += delegate {
playback.Set ();
IsSounding = false;
IsSpeaking = false;
sound.Dispose();
};
speech.Delegate = speechdelegate;
queuetimer = new System.Timers.Timer (250);
queuetimer.Elapsed += (object sender, ElapsedEventArgs e) => {
TTSRequest r;
if(Queue.TryDequeue(out r)) {
if(r.Interrupt) {
// stop current TTS
NSApplication.SharedApplication.InvokeOnMainThread( delegate {
if(IsSpeaking) {
speech.StopSpeaking();
}
//.........这里部分代码省略.........
示例13: 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 ();
};
//FolderMenuItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/sparkleshare.icns");
FolderMenuItem.Image = NSImage.ImageNamed ("NSFolder");
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) {
// 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 {
// TODO: No Remote Folders Yet
}
Menu.AddItem (NSMenuItem.SeparatorItem);
SyncMenuItem = new NSMenuItem () {
Title = "Add Remote Folder..."
};
if (SparkleShare.Controller.FirstRun)
SyncMenuItem.Enabled = false;
SyncMenuItem.Activated += delegate {
new SparkleWindow ();
};
Menu.AddItem (SyncMenuItem);
Menu.AddItem (NSMenuItem.SeparatorItem);
NotificationsMenuItem = new NSMenuItem () {
Title = "Show Notifications"
};
if (SparkleShare.Controller.NotificationsEnabled)
NotificationsMenuItem.State = NSCellStateValue.On;
NotificationsMenuItem.Activated += delegate {
SparkleShare.Controller.ToggleNotifications ();
if (SparkleShare.Controller.NotificationsEnabled)
NotificationsMenuItem.State = NSCellStateValue.On;
else
NotificationsMenuItem.State = NSCellStateValue.Off;
};
Menu.AddItem (NotificationsMenuItem);
Menu.AddItem (NSMenuItem.SeparatorItem);
//.........这里部分代码省略.........
示例14: CreateContextualMenu
private void CreateContextualMenu()
{
// Need to create member variables or the application will crash
_menu = new NSMenu("Wave Form");
_menuItemSelect = new NSMenuItem("Select", MenuSelect);
_menuItemAutoScroll = new NSMenuItem("Enable automatic scrolling", MenuAutoScroll);
_menuItemSelect.State = NSCellStateValue.On;
_menuItemZoomIn = new NSMenuItem("Zoom in", MenuZoomIn);
_menuItemZoomOut = new NSMenuItem("Zoom out", MenuZoomOut);
_menuItemResetZoom = new NSMenuItem("Reset zoom", MenuResetZoom);
_menuItemDisplayType = new NSMenuItem("Display type");
_menuItemDisplayTypeStereo = new NSMenuItem("Stereo", MenuDisplayType);
_menuItemDisplayTypeStereo.State = NSCellStateValue.On;
_menuItemDisplayTypeMono = new NSMenuItem("Mono (Mix)", MenuDisplayType);
_menuItemDisplayTypeMonoLeft = new NSMenuItem("Mono (Left)", MenuDisplayType);
_menuItemDisplayTypeMonoRight = new NSMenuItem("Mono (Right)", MenuDisplayType);
_menuDisplayType = new NSMenu("Display Type");
_menuDisplayType.AddItem(_menuItemDisplayTypeStereo);
_menuDisplayType.AddItem(_menuItemDisplayTypeMono);
_menuDisplayType.AddItem(_menuItemDisplayTypeMonoLeft);
_menuDisplayType.AddItem(_menuItemDisplayTypeMonoRight);
_menuItemDisplayType.Submenu = _menuDisplayType;
_menu.AddItem(_menuItemSelect);
_menu.AddItem(_menuItemZoomIn);
_menu.AddItem(_menuItemZoomOut);
_menu.AddItem(NSMenuItem.SeparatorItem);
_menu.AddItem(_menuItemResetZoom);
_menu.AddItem(_menuItemAutoScroll);
_menu.AddItem(_menuItemDisplayType);
}
示例15: 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);
//.........这里部分代码省略.........