Esempio n. 1
0
		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);
		}
        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),
            };
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
		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);
		}
Esempio n. 6
0
		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;
		}
 public override void MenuWillOpen(NSMenu menu)
 {
     MenuIsOpen = true;
 }
        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;
        }
 public override void MenuDidClose(NSMenu menu)
 {
     MenuIsOpen = false;
 }
Esempio n. 10
0
 public override void MenuWillHighlightItem(NSMenu menu, NSMenuItem item)
 {
 }
Esempio n. 11
0
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 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 ();
            }
        }
Esempio n. 13
0
		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;
		}
Esempio n. 14
0
        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 ();
            }
        }
Esempio n. 15
0
        // 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 ();
        }
Esempio n. 16
0
        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.link_code_item = new NSMenuItem ();
            this.link_code_item.Title = "Client ID";

            if (Controller.LinkCodeItemEnabled) {
                this.link_code_submenu = new NSMenu ();

                this.code_item = new NSMenuItem ();
                this.code_item.Title = Program.Controller.CurrentUser.PublicKey.Substring (0, 20) + "...";

                this.copy_item = new NSMenuItem ();
                this.copy_item.Title = "Copy to Clipboard";
                this.copy_item.Activated += delegate { Controller.CopyToClipboardClicked (); };

                this.link_code_submenu.AddItem (this.code_item);
                this.link_code_submenu.AddItem (NSMenuItem.SeparatorItem);
                this.link_code_submenu.AddItem (this.copy_item);
            
                this.link_code_item.Submenu = this.link_code_submenu;
            }

            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.Projects.Length];
            this.try_again_menu_items = new NSMenuItem [Controller.Projects.Length];
            this.pause_menu_items     = new NSMenuItem [Controller.Projects.Length];
            this.resume_menu_items    = new NSMenuItem [Controller.Projects.Length];
            this.state_menu_items     = new NSMenuItem [Controller.Projects.Length];

            if (Controller.Projects.Length > 0) {
                int i = 0;
                foreach (ProjectInfo project in Controller.Projects) {
                    NSMenuItem item = new NSMenuItem () { Title = project.Name };
                    this.folder_menu_items [i] = item;

                    item.Submenu = new NSMenu ();
                    item.Image   = this.folder_image;

                    this.state_menu_items [i] = new NSMenuItem (project.StatusMessage);

                    item.Submenu.AddItem (this.state_menu_items [i]);
                    item.Submenu.AddItem (NSMenuItem.SeparatorItem);

                    if (project.IsPaused) {
                        if (project.UnsyncedChangesInfo.Count > 0) {
                            foreach (KeyValuePair<string, string> pair in project.UnsyncedChangesInfo)
                                item.Submenu.AddItem (new NSMenuItem (pair.Key) {
                                    Image = NSImage.ImageNamed (pair.Value)
                                });

                            if (!string.IsNullOrEmpty (project.MoreUnsyncedChanges))
                                item.Submenu.AddItem (new NSMenuItem (project.MoreUnsyncedChanges));

                            item.Submenu.AddItem (NSMenuItem.SeparatorItem);
                            this.resume_menu_items [i] = new NSMenuItem ("Sync and Resume…"); 
                        
                        } else {
                            this.resume_menu_items [i] = new NSMenuItem ("Resume");
                        }

                        this.resume_menu_items [i].Activated += Controller.ResumeDelegate (project.Name);
                        item.Submenu.AddItem (this.resume_menu_items [i]);
                    
                    } else {
                        if (Controller.Projects [i].HasError) {
                            item.Image = this.caution_image;
                            
                            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 (project.Name);

                            item.Submenu.AddItem (this.try_again_menu_items [i]);
                            
                        } else {
                            this.pause_menu_items [i] = new NSMenuItem ("Pause"); 
                            this.pause_menu_items [i].Activated += Controller.PauseDelegate (project.Name);

                            item.Submenu.AddItem (this.pause_menu_items [i]);
                        }
                    }

                    if (!Controller.Projects [i].HasError)
                        this.folder_menu_items [i].Activated += Controller.OpenFolderDelegate (project.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 (link_code_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.menu.Delegate    = this.menu_delegate;
            this.status_item.Menu = this.menu;
        }
Esempio n. 17
0
        public override void MenuWillOpen(NSMenu menu)
        {
            Console.WriteLine ("OPENED");

            InvokeOnMainThread (delegate {

                foreach (SparkleLog log in SparkleUI.OpenLogs)
                    log.OrderFrontRegardless ();

            });
        }
Esempio n. 18
0
        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;
                        }
                    });
                }
            };
        }
Esempio n. 19
0
        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;
            }
        }
Esempio n. 20
0
        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;
        }
		//strongly typed window accessor
		public override void AwakeFromNib ()
		{
			// add the searchMenu to this control, allowing recent searches to be added.
			//
			// note that we could build this menu inside our nib, but for clarity we're
			// building the menu in code to illustrate the use of tags:
			//		NSSearchFieldRecentsTitleMenuItemTag, NSSearchFieldNoRecentsMenuItemTag, etc.
			//			
			if (searchField.RespondsToSelector(new Selector("setRecentSearches:")))
			{
				NSMenu searchMenu = new NSMenu("Search Menu") {
					AutoEnablesItems = true
				};
				
				var item = new NSMenuItem("Custom","",(o,e) => actionMenuItem());
				searchMenu.InsertItem(item,0);
				
				var separator = NSMenuItem.SeparatorItem;
				searchMenu.InsertItem(separator,1);
				
				var recentsTitleItem = new NSMenuItem("Recent Searches","");
				// tag this menu item so NSSearchField can use it and respond to it appropriately
				recentsTitleItem.Tag = NSSearchFieldRecentsTitleMenuItemTag;
				searchMenu.InsertItem (recentsTitleItem,2);

				var norecentsTitleItem = new NSMenuItem("No recent searches","");
				// tag this menu item so NSSearchField can use it and respond to it appropriately
				norecentsTitleItem.Tag = NSSearchFieldNoRecentsMenuItemTag;
				searchMenu.InsertItem (norecentsTitleItem,3);
				
				var recentsItem = new NSMenuItem("Recents","");
				// tag this menu item so NSSearchField can use it and respond to it appropriately
				recentsItem.Tag = NSSearchFieldRecentsMenuItemTag;
				searchMenu.InsertItem (recentsItem,4);

				var separatorItem = NSMenuItem.SeparatorItem;
				// tag this menu item so NSSearchField can use it, by hiding/show it appropriately:
				separatorItem.Tag = NSSearchFieldRecentsTitleMenuItemTag;
				searchMenu.InsertItem (separatorItem,5);

				var clearItem = new NSMenuItem ("Clear", "");
				// tag this menu item so NSSearchField can use it
				clearItem.Tag = NSSearchFieldClearRecentsMenuItemTag;
				searchMenu.InsertItem (clearItem, 6);
				
				var searchCell = searchField.Cell;
				searchCell.MaximumRecents = 20;
				searchCell.SearchMenuTemplate = searchMenu;
				
				// with lamda
				//searchField.ControlTextDidChange += (o,e) => controlTextDidChange((NSNotification)o);
				// or delegate
				searchField.Changed += delegate (object sender, EventArgs e) {
					handleTextDidChange ((NSNotification) sender);
				};
				searchField.DoCommandBySelector = handleCommandSelectors;
				searchField.GetCompletions = handleFilterCompletions;
			}
				
			// build the list of keyword strings for our type completion dropdown list in NSSearchField
			builtInKeywords = new List<string>() {"Favorite", "Favorite1", "Favorite11", "Favorite3", "Vacations1", "Vacations2",
					"Hawaii", "Family", "Important", "Important2", "Personal"};
		}
Esempio n. 22
0
        // 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");
        }
Esempio n. 23
0
        public void CreateMenu()
        {
            using (NSAutoreleasePool a = new NSAutoreleasePool ())
            {
                this.menu                  = new NSMenu ();
                this.menu.AutoEnablesItems = false;

                this.state_item = new NSMenuItem () {
                    Title   = Controller.StateText,
                    Enabled = false
                };

                this.folder_item = new NSMenuItem () {
                    Title = "SparkleShare"
                };

                this.folder_item.Activated += delegate {
                    Controller.SparkleShareClicked ();
                };

                this.folder_item.Image      = this.sparkleshare_image;
                this.folder_item.Image.Size = new SizeF (16, 16);
                this.folder_item.Enabled    = true;

                this.add_item = new NSMenuItem () {
                    Title   = "Add Hosted Project…",
                    Enabled = true
                };

                this.add_item.Activated += delegate {
                    Controller.AddHostedProjectClicked ();
                };

                this.recent_events_item = new NSMenuItem () {
                    Title   = "Recent Changes…",
                    Enabled = Controller.RecentEventsItemEnabled
                };

                if (Controller.Folders.Length > 0) {
                    this.recent_events_item.Activated += delegate {
                        Controller.RecentEventsClicked ();
                    };
                }

                this.notify_item = new NSMenuItem () {
                    Enabled = (Controller.Folders.Length > 0)
                };

                if (Program.Controller.NotificationsEnabled)
                    this.notify_item.Title = "Turn Notifications Off";
                else
                    this.notify_item.Title = "Turn Notifications On";

                this.notify_item.Activated += delegate {
                    Program.Controller.ToggleNotifications ();

                    InvokeOnMainThread (delegate {
                        if (Program.Controller.NotificationsEnabled)
                            this.notify_item.Title = "Turn Notifications Off";
                        else
                            this.notify_item.Title = "Turn Notifications On";
                    });
                };

                this.about_item = new NSMenuItem () {
                    Title   = "About SparkleShare",
                    Enabled = true
                };

                this.about_item.Activated += delegate {
                    Controller.AboutClicked ();
                };

                this.quit_item = new NSMenuItem () {
                    Title   = "Quit",
                    Enabled = Controller.QuitItemEnabled
                };

                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.folder_menu_items = new NSMenuItem [Controller.Folders.Length];
                this.submenu_items     = new NSMenuItem [Controller.OverflowFolders.Length];

                if (Controller.Folders.Length > 0) {
                    this.folder_tasks   = new EventHandler [Controller.Folders.Length];
                    this.overflow_tasks = new EventHandler [Controller.OverflowFolders.Length];

                    int i = 0;
                    foreach (string folder_name in Controller.Folders) {
                        NSMenuItem item = new NSMenuItem ();
                        item.Title      = folder_name;

                        if (!string.IsNullOrEmpty (Controller.FolderErrors [i])) {
                            item.Image   = this.caution_image;
                            item.Submenu = new NSMenu ();

                            NSMenuItem error_item = new NSMenuItem () {
                                Title = Controller.FolderErrors [i]
                            };

                            item.Submenu.AddItem (error_item);

                        } else {
                            item.Image = this.folder_image;
                        }

                        item.Image.Size = new SizeF (16, 16);
                        this.folder_tasks [i] = OpenFolderDelegate (folder_name);

                        this.folder_menu_items [i] = item;
                        this.folder_menu_items [i].Activated += this.folder_tasks [i];

                        i++;
                    };

                    i = 0;
                    foreach (string folder_name in Controller.OverflowFolders) {
                        NSMenuItem item = new NSMenuItem ();
                        item.Title      = folder_name;

                        if (!string.IsNullOrEmpty (Controller.OverflowFolderErrors [i])) {
                            item.Image   = this.caution_image;
                            item.Submenu = new NSMenu ();

                            NSMenuItem error_item = new NSMenuItem () {
                                Title = Controller.OverflowFolderErrors [i]
                            };

                            item.Submenu.AddItem (error_item);

                        } else {
                            item.Image = this.folder_image;
                        }

                        item.Image.Size   = new SizeF (16, 16);
                        this.overflow_tasks [i] = OpenFolderDelegate (folder_name);

                        this.submenu_items [i] = item;
                        this.submenu_items [i].Activated += this.overflow_tasks [i];

                        i++;
                    };

                }

                foreach (NSMenuItem item in this.folder_menu_items)
                    this.menu.AddItem (item);

                if (this.submenu_items.Length > 0) {
                    this.submenu = new NSMenu ();

                    foreach (NSMenuItem item in this.submenu_items)
                        this.submenu.AddItem (item);

                    this.more_item = new NSMenuItem () {
                        Title = "More Projects",
                        Submenu = this.submenu
                    };

                    this.menu.AddItem (NSMenuItem.SeparatorItem);
                    this.menu.AddItem (this.more_item);
                }

                this.menu.AddItem (NSMenuItem.SeparatorItem);
                this.menu.AddItem (this.add_item);
                this.menu.AddItem (this.recent_events_item);
                this.menu.AddItem (NSMenuItem.SeparatorItem);
                this.menu.AddItem (this.notify_item);
                this.menu.AddItem (NSMenuItem.SeparatorItem);
                this.menu.AddItem (this.about_item);
                this.menu.AddItem (NSMenuItem.SeparatorItem);
                this.menu.AddItem (this.quit_item);

                this.menu.Delegate    = new SparkleStatusIconMenuDelegate ();
                this.status_item.Menu = this.menu;
            }
        }
Esempio n. 24
0
		void MenuNeedsUpdate (NSMenu menu)
		{
			Debug.Assert (menu == this);
			UpdateCommands ();
		}
Esempio n. 25
0
		void PopulateArrayItems (CommandArrayInfo infos, NSMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			foreach (CommandInfo ci in infos) {
				if (ci.IsArraySeparator) {
					var n = NSMenuItem.SeparatorItem;
					n.Hidden = true;
					n.Target = this;
					lastSeparator = n;
					parent.InsertItem (n, index++);
					continue;
				}

				var item = new MDExpandedArrayItem {
					Info = ci,
					Target = this,
					Action = ActionSel,
				};

				if (ci is CommandInfoSet) {
					item.Submenu = new NSMenu ();
					int i = 0;
					NSMenuItem sep = null;
					PopulateArrayItems (((CommandInfoSet)ci).CommandInfos, item.Submenu, ref sep, ref i);
				}
				SetItemValues (item, ci);

				if (!item.Hidden)
					MDMenu.ShowLastSeparator (ref lastSeparator);
				parent.InsertItem (item, index++);
			}
		}
Esempio n. 26
0
        // 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 ();
        }
Esempio n. 27
0
        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 ();
            }
        }
Esempio n. 28
0
        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);
            }
        }
Esempio n. 29
0
 public override void MenuWillOpen(NSMenu menu)
 {
     InvokeOnMainThread (delegate {
         NSApplication.SharedApplication.DockTile.BadgeLabel = null;
     });
 }
Esempio n. 30
0
        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 ();
        }