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); }
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); }
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; }
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; }
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); } }
// 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); if (SparkleUI.EventLog == null) SparkleUI.EventLog = new SparkleEventLog (); SparkleUI.EventLog.OrderFrontRegardless (); SparkleUI.EventLog.MakeKeyAndOrderFront (this); }); }; } Menu.AddItem (RecentEventsMenuItem); NotificationsMenuItem = new NSMenuItem (); if (SparkleShare.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; NotificationsMenuItem.Activated += delegate { SparkleShare.Controller.ToggleNotifications (); InvokeOnMainThread (delegate { if (SparkleShare.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; }); }; Menu.AddItem (NotificationsMenuItem); Menu.AddItem (NSMenuItem.SeparatorItem); AboutMenuItem = new NSMenuItem () { Title = "About SparkleShare" }; AboutMenuItem.Activated += delegate { InvokeOnMainThread (delegate { NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); if (SparkleUI.About == null) SparkleUI.About = new SparkleAbout (); SparkleUI.About.OrderFrontRegardless (); SparkleUI.About.MakeKeyAndOrderFront (this); SparkleUI.About.CheckForNewVersion (); }); }; Menu.AddItem (AboutMenuItem); StatusItem.Menu = Menu; StatusItem.Menu.Update (); }
// 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); }); }; } Menu.AddItem (SyncMenuItem); Menu.AddItem (NSMenuItem.SeparatorItem); NotificationsMenuItem = new NSMenuItem (); if (SparkleShare.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; NotificationsMenuItem.Activated += delegate { SparkleShare.Controller.ToggleNotifications (); InvokeOnMainThread (delegate { if (SparkleShare.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; }); }; Menu.AddItem (NotificationsMenuItem); StatusItem.Menu = Menu; StatusItem.Menu.Update (); }
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 () { Enabled = true }; if (Program.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; NotificationsMenuItem.Activated += delegate { Program.Controller.ToggleNotifications (); InvokeOnMainThread (delegate { if (Program.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; }); }; Menu.AddItem (NotificationsMenuItem); Menu.AddItem (NSMenuItem.SeparatorItem); AboutMenuItem = new NSMenuItem () { Title = "About SparkleShare", Enabled = true }; AboutMenuItem.Activated += delegate { Controller.AboutClicked (); }; Menu.AddItem (AboutMenuItem); Menu.AddItem (NSMenuItem.SeparatorItem); QuitMenuItem = new NSMenuItem () { Title = "Quit", Enabled = Controller.QuitItemEnabled }; QuitMenuItem.Activated += delegate { Controller.QuitClicked (); }; Menu.AddItem (QuitMenuItem); StatusItem.Menu = Menu; StatusItem.Menu.Update (); } }
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; } }); } }; }
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; }
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); }
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(); } if(IsSounding) { sound.Stop(); } }); // clear queue SpeechQueue.Clear(); } SpeechQueue.Enqueue(r); RequestCount++; } var eventdata = new Hashtable(); eventdata.Add("ProcessedRequests", RequestCount); eventdata.Add("QueuedRequests", SpeechQueue.Count); eventdata.Add("IsSpeaking", IsSpeaking); InstrumentationEvent ev = new InstrumentationEvent(); ev.EventName = "status"; ev.Data = eventdata; NotifyGui(ev.EventMessage()); }; // when this timer fires, it will pull off of the speech queue and speak it // the 1000ms delay also adds a little pause between tts requests. speechtimer = new System.Timers.Timer (1000); speechtimer.Elapsed += (object sender, ElapsedEventArgs e) => { if(IsSpeaking.Equals(false)) { if(SpeechQueue.Count > 0) { TTSRequest r = SpeechQueue.Dequeue(); IsSpeaking = true; speechtimer.Enabled = false; var oink = Path.Combine(audiopath, "temp.aiff"); NSApplication.SharedApplication.InvokeOnMainThread( delegate { ConfigureSpeechEngine(r); speech.StartSpeakingStringtoURL(r.Text, new NSUrl(oink, false)); }); synthesis.WaitOne(); NSApplication.SharedApplication.InvokeOnMainThread( delegate { IsSounding = true; sound = new NSSound(Path.Combine(audiopath, "temp.aiff"), false); sound.Delegate = sounddelegate; //if(OutputDeviceUID != "Default") { sound.PlaybackDeviceID = OutputDeviceUID; //} sound.Play(); }); playback.WaitOne(); IsSounding = false; speechtimer.Enabled = true; } } }; queuetimer.Enabled = true; queuetimer.Start (); speechtimer.Enabled = true; speechtimer.Start (); InitHTTPServer (); }
// 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); AboutMenuItem = new NSMenuItem () { Title = "About" }; AboutMenuItem.Activated += delegate { // TODO }; Menu.AddItem (AboutMenuItem); StatusItem.Menu = Menu; StatusItem.Menu.Update (); Console.WriteLine ("MENU UPDATED"); }
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); }
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); RecentEventsMenuItem = new NSMenuItem () { Title = "Open Recent Events", Enabled = (Controller.Folders.Length > 0) }; if (Controller.Folders.Length > 0) { RecentEventsMenuItem.Activated += delegate { InvokeOnMainThread (delegate { NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); if (SparkleUI.EventLog == null) SparkleUI.EventLog = new SparkleEventLog (); SparkleUI.EventLog.OrderFrontRegardless (); SparkleUI.EventLog.MakeKeyAndOrderFront (this); }); }; } Menu.AddItem (RecentEventsMenuItem); NotificationsMenuItem = new NSMenuItem () { Enabled = true }; if (Program.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; NotificationsMenuItem.Activated += delegate { Program.Controller.ToggleNotifications (); InvokeOnMainThread (delegate { if (Program.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; }); }; Menu.AddItem (NotificationsMenuItem); Menu.AddItem (NSMenuItem.SeparatorItem); AboutMenuItem = new NSMenuItem () { Title = "About SparkleShare", Enabled = true }; AboutMenuItem.Activated += delegate { InvokeOnMainThread (delegate { NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); if (SparkleUI.About == null) SparkleUI.About = new SparkleAbout (); else SparkleUI.About.OrderFrontRegardless (); }); }; Menu.AddItem (AboutMenuItem); Menu.AddItem (NSMenuItem.SeparatorItem); QuitMenuItem = new NSMenuItem () { Title = "Quit", Enabled = Controller.QuitItemEnabled }; QuitMenuItem.Activated += delegate { Program.Controller.Quit (); }; Menu.AddItem (QuitMenuItem); StatusItem.Menu = Menu; StatusItem.Menu.Update (); } }
public void CreateMenu () { using (NSAutoreleasePool a = new NSAutoreleasePool ()) { this.menu = new NSMenu (); this.menu.AutoEnablesItems = false; this.FolderItems = new Dictionary<String, NSMenuItem>(); this.state_item = new NSMenuItem () { Title = Controller.StateText, Enabled = false }; this.log_item = new NSMenuItem () { Title = CmisSync.Properties_Resources.ViewLog }; this.log_item.Activated += delegate { Controller.LogClicked(); }; this.add_item = new NSMenuItem () { Title = CmisSync.Properties_Resources.AddARemoteFolder, Enabled = true }; this.add_item.Activated += delegate { Controller.AddRemoteFolderClicked (); }; this.about_item = new NSMenuItem () { Title = CmisSync.Properties_Resources.About, Enabled = true }; this.about_item.Activated += delegate { Controller.AboutClicked (); }; this.quit_item = new NSMenuItem () { Title = CmisSync.Properties_Resources.Exit, Enabled = true }; this.quit_item.Activated += delegate { Controller.QuitClicked (); }; this.menu.AddItem (this.state_item); this.menu.AddItem (NSMenuItem.SeparatorItem); if (Controller.Folders.Length > 0) { foreach (string folder_name in Controller.Folders) { this.menu.AddItem(CreateFolderMenuItem(folder_name)); }; if (Controller.OverflowFolders.Length > 0) { NSMenuItem moreitem = new NSMenuItem(); moreitem.Title = "More Folder"; NSMenu moreitemsmenu = new NSMenu(); foreach (string folder_name in Controller.OverflowFolders) { moreitemsmenu.AddItem(CreateFolderMenuItem(folder_name)); }; moreitem.Submenu = moreitemsmenu; this.menu.AddItem(moreitem); } this.menu.AddItem (NSMenuItem.SeparatorItem); } this.menu.AddItem (this.add_item); this.menu.AddItem (NSMenuItem.SeparatorItem); this.menu.AddItem (this.log_item); this.menu.AddItem (this.about_item); this.menu.AddItem (NSMenuItem.SeparatorItem); this.menu.AddItem (this.quit_item); this.menu.Delegate = new StatusIconMenuDelegate (); this.status_item.Menu = this.menu; } }
public void CreateMenu() { using (NSAutoreleasePool a = new NSAutoreleasePool ()) { StatusItem.Image = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0.png"); StatusItem.AlternateImage = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0-active.png"); StatusItem.Image.Size = new SizeF (16, 16); StatusItem.AlternateImage.Size = new SizeF (16, 16); 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 = NSImage.ImageNamed ("sparkleshare-mac"); FolderMenuItem.Image.Size = new SizeF (16, 16); Menu.AddItem (FolderMenuItem); FolderMenuItems = new NSMenuItem [SparkleShare.Controller.Folders.Count]; if (Controller.Folders.Length > 0) { 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]; i++; }; } else { FolderMenuItems = new NSMenuItem [1]; FolderMenuItems [0] = new NSMenuItem () { Title = "No Remote Folders Yet" }; } foreach (NSMenuItem item in FolderMenuItems) Menu.AddItem (item); 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.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); RecentEventsMenuItem = new NSMenuItem () { Title = "Show Recent Events" }; if (Controller.Folders.Length > 0) { RecentEventsMenuItem.Activated += delegate { InvokeOnMainThread (delegate { NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); if (SparkleUI.EventLog == null) SparkleUI.EventLog = new SparkleEventLog (); SparkleUI.EventLog.OrderFrontRegardless (); SparkleUI.EventLog.MakeKeyAndOrderFront (this); }); }; } Menu.AddItem (RecentEventsMenuItem); NotificationsMenuItem = new NSMenuItem (); if (SparkleShare.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; NotificationsMenuItem.Activated += delegate { SparkleShare.Controller.ToggleNotifications (); InvokeOnMainThread (delegate { if (SparkleShare.Controller.NotificationsEnabled) NotificationsMenuItem.Title = "Turn Notifications Off"; else NotificationsMenuItem.Title = "Turn Notifications On"; }); }; Menu.AddItem (NotificationsMenuItem); Menu.AddItem (NSMenuItem.SeparatorItem); AboutMenuItem = new NSMenuItem () { Title = "About SparkleShare" }; AboutMenuItem.Activated += delegate { InvokeOnMainThread (delegate { NSApplication.SharedApplication.ActivateIgnoringOtherApps (true); if (SparkleUI.About == null) SparkleUI.About = new SparkleAbout (); else SparkleUI.About.OrderFrontRegardless (); }); }; Menu.AddItem (AboutMenuItem); StatusItem.Menu = Menu; StatusItem.Menu.Update (); } }
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; }