public TryAgainDelegate ( string project ) : EventHandler | ||
project | string | |
Результат | EventHandler |
public void CreateMenu() { this.context_menu = new ContextMenu(); this.state_item = new SparkleMenuItem { Header = Controller.StateText, IsEnabled = false }; Image folder_image = new Image { Source = UserInterfaceHelpers.GetImageSource("sparkleshare-folder"), Width = 16, Height = 16 }; SparkleMenuItem folder_item = new SparkleMenuItem { Header = "SparkleShare", Icon = folder_image }; SparkleMenuItem add_item = new SparkleMenuItem { Header = "Add hosted project…" }; this.log_item = new SparkleMenuItem { Header = "Recent changes…", IsEnabled = Controller.RecentEventsItemEnabled }; SparkleMenuItem link_code_item = new SparkleMenuItem { Header = "Client ID" }; if (Controller.LinkCodeItemEnabled) { SparkleMenuItem code_item = new SparkleMenuItem { Header = SparkleShare.Controller.UserAuthenticationInfo.PublicKey.Substring(0, 20) + "..." }; SparkleMenuItem copy_item = new SparkleMenuItem { Header = "Copy to Clipboard" }; copy_item.Click += delegate { Controller.CopyToClipboardClicked(); }; link_code_item.Items.Add(code_item); link_code_item.Items.Add(new Separator()); link_code_item.Items.Add(copy_item); } CheckBox notify_check_box = new CheckBox { Margin = new Thickness(6, 0, 0, 0), IsChecked = SparkleShare.Controller.NotificationsEnabled }; SparkleMenuItem notify_item = new SparkleMenuItem { Header = "Notifications", Icon = notify_check_box }; SparkleMenuItem about_item = new SparkleMenuItem { Header = "About SparkleShare" }; this.exit_item = new SparkleMenuItem { Header = "Exit" }; add_item.Click += delegate { Controller.AddHostedProjectClicked(); }; this.log_item.Click += delegate { Controller.RecentEventsClicked(); }; about_item.Click += delegate { Controller.AboutClicked(); }; notify_check_box.Click += delegate { this.context_menu.IsOpen = false; SparkleShare.Controller.ToggleNotifications(); notify_check_box.IsChecked = SparkleShare.Controller.NotificationsEnabled; }; notify_item.Click += delegate { SparkleShare.Controller.ToggleNotifications(); notify_check_box.IsChecked = SparkleShare.Controller.NotificationsEnabled; }; this.exit_item.Click += delegate { this.notify_icon.Dispose(); Controller.QuitClicked(); }; this.context_menu.Items.Add(this.state_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(folder_item); state_menu_items = new SparkleMenuItem[Controller.Projects.Length]; if (Controller.Projects.Length > 0) { int i = 0; foreach (ProjectInfo project in Controller.Projects) { SparkleMenuItem subfolder_item = new SparkleMenuItem { Header = project.Name.Replace("_", "__"), Icon = new Image { Source = UserInterfaceHelpers.GetImageSource("folder"), Width = 16, Height = 16 } }; state_menu_items[i] = new SparkleMenuItem { Header = project.StatusMessage, IsEnabled = false }; subfolder_item.Items.Add(state_menu_items[i]); subfolder_item.Items.Add(new Separator()); SparkleMenuItem open_item = new SparkleMenuItem { Header = "Open folder", Icon = new Image { Source = UserInterfaceHelpers.GetImageSource("folder"), Width = 16, Height = 16 } }; open_item.Click += new RoutedEventHandler(Controller.OpenFolderDelegate(project.Name)); subfolder_item.Items.Add(open_item); subfolder_item.Items.Add(new Separator()); if (project.IsPaused) { SparkleMenuItem resume_item; if (project.UnsyncedChangesInfo.Count > 0) { foreach (KeyValuePair <string, string> pair in project.UnsyncedChangesInfo) { subfolder_item.Items.Add(new SparkleMenuItem { Header = pair.Key, // TODO image IsEnabled = false }); } if (!string.IsNullOrEmpty(project.MoreUnsyncedChanges)) { subfolder_item.Items.Add(new SparkleMenuItem { Header = project.MoreUnsyncedChanges, IsEnabled = false }); } subfolder_item.Items.Add(new Separator()); resume_item = new SparkleMenuItem { Header = "Sync and Resume…" }; } else { resume_item = new SparkleMenuItem { Header = "Resume" }; } resume_item.Click += (sender, e) => Controller.ResumeDelegate(project.Name)(sender, e); subfolder_item.Items.Add(resume_item); } else { if (Controller.Projects[i].HasError) { subfolder_item.Icon = new Image { Source = Imaging.CreateBitmapSourceFromHIcon( Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(16, 16)) }; SparkleMenuItem try_again_item = new SparkleMenuItem { Header = "Retry Sync" }; try_again_item.Click += (sender, e) => Controller.TryAgainDelegate(project.Name)(sender, e); subfolder_item.Items.Add(try_again_item); } else { SparkleMenuItem pause_item = new SparkleMenuItem { Header = "Pause" }; pause_item.Click += (sender, e) => Controller.PauseDelegate(project.Name)(sender, e); subfolder_item.Items.Add(pause_item); } } this.context_menu.Items.Add(subfolder_item); i++; } ; } folder_item.Items.Add(this.log_item); folder_item.Items.Add(add_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(notify_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(link_code_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(about_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(this.exit_item); this.notify_icon.ContextMenu = this.context_menu; }
public void CreateMenu() { this.menu = new Menu(); this.state_item = new MenuItem(Controller.StateText) { Sensitive = false }; ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare"); folder_item.Image = new Image(UserInterfaceHelpers.GetIcon("org.sparkleshare.SparkleShare", 16)); this.menu.Add(this.state_item); this.menu.Add(new SeparatorMenuItem()); this.menu.Add(folder_item); this.state_menu_items = new SparkleMenuItem [Controller.Projects.Length]; if (Controller.Projects.Length > 0) { int i = 0; foreach (ProjectInfo project in Controller.Projects) { SparkleMenuItem item = new SparkleMenuItem(project.Name); Gdk.Pixbuf folder_icon = UserInterfaceHelpers.GetIcon("folder", 16); item.Submenu = new Menu(); this.state_menu_items [i] = new SparkleMenuItem(project.StatusMessage) { Sensitive = false }; (item.Submenu as Menu).Add(this.state_menu_items [i]); (item.Submenu as Menu).Add(new SeparatorMenuItem()); if (project.IsPaused) { MenuItem resume_item; if (project.UnsyncedChangesInfo.Count > 0) { string icons_path = Path.Combine(UserInterface.AssetsPath, "icons", "hicolor", "12x12", "status"); foreach (KeyValuePair <string, string> pair in project.UnsyncedChangesInfo) { string icon_path = Path.Combine(icons_path, pair.Value.Replace("-12", "")); (item.Submenu as Menu).Add(new SparkleMenuItem(pair.Key) { Image = new Image(icon_path), Sensitive = false }); } if (!string.IsNullOrEmpty(project.MoreUnsyncedChanges)) { (item.Submenu as Menu).Add(new MenuItem(project.MoreUnsyncedChanges) { Sensitive = false }); } (item.Submenu as Menu).Add(new SeparatorMenuItem()); resume_item = new MenuItem("Sync and Resume…"); } else { resume_item = new MenuItem("Resume"); } resume_item.Activated += Controller.ResumeDelegate(project.Name); (item.Submenu as Menu).Add(resume_item); } else { if (Controller.Projects [i].HasError) { folder_icon = IconTheme.Default.LoadIcon("dialog-warning", 16, IconLookupFlags.GenericFallback); MenuItem try_again_item = new MenuItem("Retry Sync"); try_again_item.Activated += Controller.TryAgainDelegate(project.Name); (item.Submenu as Menu).Add(try_again_item); } else { MenuItem pause_item = new MenuItem("Pause"); pause_item.Activated += Controller.PauseDelegate(project.Name); (item.Submenu as Menu).Add(pause_item); } } (item.Child as Label).UseUnderline = false; item.Image = new Image(folder_icon); this.menu.Add(item); i++; } ; } this.recent_events_item = new MenuItem("History…"); this.recent_events_item.Sensitive = Controller.RecentEventsItemEnabled; this.quit_item = new MenuItem("Quit") { Sensitive = Controller.QuitItemEnabled }; MenuItem add_item = new MenuItem("Sync Remote Project…"); MenuItem link_code_item = new MenuItem("Computer ID"); if (Controller.LinkCodeItemEnabled) { link_code_item.Submenu = new Menu(); string link_code = SparkleShare.Controller.UserAuthenticationInfo.PublicKey.Substring(0, 20) + "..."; MenuItem code_item = new MenuItem(link_code) { Sensitive = false }; MenuItem copy_item = new MenuItem("Copy to Clipboard"); copy_item.Activated += delegate { Controller.CopyToClipboardClicked(); }; (link_code_item.Submenu as Menu).Add(code_item); (link_code_item.Submenu as Menu).Add(new SeparatorMenuItem()); (link_code_item.Submenu as Menu).Add(copy_item); } MenuItem about_item = new MenuItem("About SparkleShare"); about_item.Activated += delegate { Controller.AboutClicked(); }; add_item.Activated += delegate { Controller.AddHostedProjectClicked(); }; this.recent_events_item.Activated += delegate { Controller.RecentEventsClicked(); }; this.quit_item.Activated += delegate { Controller.QuitClicked(); }; folder_item.Submenu = new Menu(); (folder_item.Submenu as Menu).Add(this.recent_events_item); if (InstallationInfo.OperatingSystem == OS.Ubuntu) { MenuItem notify_item; if (SparkleShare.Controller.NotificationsEnabled) { notify_item = new MenuItem("Turn Notifications Off"); } else { notify_item = new MenuItem("Turn Notifications On"); } notify_item.Activated += delegate { SparkleShare.Controller.ToggleNotifications(); Application.Invoke(delegate { if (SparkleShare.Controller.NotificationsEnabled) { (notify_item.Child as Label).Text = "Turn Notifications Off"; } else { (notify_item.Child as Label).Text = "Turn Notifications On"; } }); }; (folder_item.Submenu as Menu).Add(new SeparatorMenuItem()); (folder_item.Submenu as Menu).Add(notify_item); } (folder_item.Submenu as Menu).Add(new SeparatorMenuItem()); (folder_item.Submenu as Menu).Add(link_code_item); (folder_item.Submenu as Menu).Add(new SeparatorMenuItem()); (folder_item.Submenu as Menu).Add(about_item); this.menu.Add(new SeparatorMenuItem()); this.menu.Add(add_item); this.menu.Add(new SeparatorMenuItem()); this.menu.Add(this.quit_item); this.menu.ShowAll(); if (InstallationInfo.OperatingSystem == OS.Ubuntu) { #if HAVE_APP_INDICATOR indicator.Menu = this.menu; #endif } }