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; }
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.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(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; }
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; }
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.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 (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; }