/// <summary> /// Create the UI elements of the menu. /// </summary> private void CreateMenu() { // Reset existing items. this.traymenu.Items.Clear(); this.repoItems = new List <RepositoryMenuItem>(); this.trayicon.Text = string.Format("{0}\n{1}", Properties_Resources.ApplicationName, Controller.StateText); // Create a menu item per synchronized folder. if (Controller.Folders.Length > 0) { foreach (var repo in Program.Controller.Repositories) { var repoItem = new RepositoryMenuItem(repo, this.Controller, this); this.repoItems.Add(repoItem); this.traymenu.Items.Add(repoItem); } this.traymenu.Items.Add(new ToolStripSeparator()); } // Create the menu item that lets the user add a new synchronized folder. ToolStripMenuItem addFolderItem = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.AddARemoteFolder }; addFolderItem.Click += delegate { Controller.AddRemoteFolderClicked(); }; this.traymenu.Items.Add(addFolderItem); this.traymenu.Items.Add(new ToolStripSeparator()); // Create the menu item that lets the user view setting. ToolStripMenuItem setting_item = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.Settings }; setting_item.Click += delegate { Controller.SettingClicked(); }; this.traymenu.Items.Add(setting_item); // Create the menu item that lets the uer view transmission. ToolStripMenuItem transmission_item = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.Transmission }; transmission_item.Click += delegate { Controller.TransmissionClicked(); }; this.traymenu.Items.Add(transmission_item); // Create the menu item that lets the user view the log. ToolStripMenuItem log_item = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.ViewLog }; log_item.Click += delegate { Controller.LogClicked(); }; this.traymenu.Items.Add(log_item); // Create the About menu. ToolStripMenuItem about_item = new ToolStripMenuItem() { Text = String.Format(Properties_Resources.About, Properties_Resources.ApplicationName) }; about_item.Click += delegate { Controller.AboutClicked(); }; this.traymenu.Items.Add(about_item); // Create the exit menu. this.exitItem = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.Exit }; this.exitItem.Click += delegate { this.trayicon.Dispose(); Controller.QuitClicked(); }; this.traymenu.Items.Add(this.exitItem); }
public void CreateMenu() { this.menu = new Menu(); // State Menu this.state_item = new MenuItem(Controller.StateText) { Sensitive = false }; this.menu.Add(this.state_item); this.menu.Add(new SeparatorMenuItem()); // Folders Menu if (Controller.Folders.Length > 0) { foreach (string folder_name in Controller.Folders) { Menu submenu = new Menu(); ImageMenuItem subfolder_item = new CmisSyncMenuItem(folder_name) { Image = new Image(UIHelpers.GetIcon("dataspacesync-folder", 16)), Submenu = submenu, RepoName = folder_name }; ImageMenuItem open_localfolder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.OpenLocalFolder) { Image = new Image(UIHelpers.GetIcon("dataspacesync-folder", 16)) }; open_localfolder_item.Activated += OpenFolderDelegate(folder_name); ImageMenuItem edit_folder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.Settings); edit_folder_item.Activated += EditFolderDelegate(folder_name); ImageMenuItem suspend_folder_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.PauseSync) { RepoName = folder_name }; foreach (Repository aRepo in Program.Controller.Repositories) { if (aRepo.Name.Equals(folder_name)) { setSyncItemState(suspend_folder_item, aRepo.Status); break; } } suspend_folder_item.Activated += SuspendSyncFolderDelegate(folder_name); ImageMenuItem remove_folder_from_sync_item = new CmisSyncMenuItem( CmisSync.Properties_Resources.RemoveFolderFromSync) { Image = new Image(UIHelpers.GetIcon("dataspacesync-deleted", 12)) }; remove_folder_from_sync_item.Activated += RemoveFolderFromSyncDelegate(folder_name); submenu.Add(open_localfolder_item); submenu.Add(suspend_folder_item); submenu.Add(edit_folder_item); submenu.Add(new SeparatorMenuItem()); submenu.Add(remove_folder_from_sync_item); this.menu.Add(subfolder_item); } this.menu.Add(new SeparatorMenuItem()); } // Add Menu MenuItem add_item = new MenuItem( CmisSync.Properties_Resources.AddARemoteFolder); add_item.Activated += delegate { Controller.AddRemoteFolderClicked(); }; this.menu.Add(add_item); this.menu.Add(new SeparatorMenuItem()); MenuItem settingsItem = new MenuItem( Properties_Resources.Settings); settingsItem.Activated += delegate { Controller.SettingClicked(); }; this.menu.Add(settingsItem); this.menu.Add(new SeparatorMenuItem()); // Log Menu MenuItem log_item = new MenuItem( CmisSync.Properties_Resources.ViewLog); log_item.Activated += delegate { Controller.LogClicked(); }; this.menu.Add(log_item); // About Menu MenuItem about_item = new MenuItem( String.Format(CmisSync.Properties_Resources.About, Properties_Resources.ApplicationName)); about_item.Activated += delegate { Controller.AboutClicked(); }; this.menu.Add(about_item); this.quit_item = new MenuItem( CmisSync.Properties_Resources.Exit) { Sensitive = true }; this.quit_item.Activated += delegate { Controller.QuitClicked(); }; this.menu.Add(this.quit_item); this.menu.ShowAll(); #if HAVE_APP_INDICATOR this.indicator.Menu = this.menu; #endif this.IsHandleCreated = true; }
/// <summary> /// Create the UI elements of the menu. /// </summary> private void CreateMenu() { // Reset existing items. this.traymenu.Items.Clear(); // Create the state menu item. this.stateItem = new ToolStripMenuItem() { Text = Controller.StateText, Enabled = false }; this.traymenu.Items.Add(stateItem); this.trayicon.Text = String.Format("{0}\n{1}", Properties_Resources.ApplicationName, Controller.StateText); this.traymenu.Items.Add(new ToolStripSeparator()); /*this.transmissionItem = new ToolStripMenuItem() * { * Text = "No active transmissions", * Enabled = false * }; * this.traymenu.Items.Add(transmissionItem); */ // Create a menu item per synchronized folder. if (Controller.Folders.Length > 0) { foreach (string folderName in Controller.Folders) { // Main item. ToolStripMenuItem subfolderItem = new ToolStripMenuItem() { Text = folderName, Name = "tsmi" + folderName, Image = UIHelpers.GetBitmap("folder") }; // Sub-item: open locally. ToolStripMenuItem openLocalFolderItem = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.OpenLocalFolder, Image = UIHelpers.GetBitmap("folder") }; openLocalFolderItem.Click += OpenLocalFolderDelegate(folderName); // Sub-item: edit ignore folder. ToolStripMenuItem editFolderItem = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.Settings }; editFolderItem.Click += EditFolderDelegate(folderName); // Sub-item: suspend sync. ToolStripMenuItem suspendFolderItem = new ToolStripMenuItem(); setSyncItemState(suspendFolderItem, SyncStatus.Idle); foreach (Repository aRepo in Program.Controller.Repositories) { if (aRepo.Name.Equals(folderName)) { setSyncItemState(suspendFolderItem, aRepo.Status); break; } } suspendFolderItem.Click += SuspendSyncFolderDelegate(folderName); // Sub-item: remove folder from sync ToolStripMenuItem removeFolderFromSyncItem = new ToolStripMenuItem() { Text = Properties_Resources.RemoveFolderFromSync, Tag = "remove", }; removeFolderFromSyncItem.Click += RemoveFolderFromSyncDelegate(folderName); // Add the sub-items. subfolderItem.DropDownItems.Add(openLocalFolderItem); //subfolderItem.DropDownItems.Add(openRemoteFolderItem); subfolderItem.DropDownItems.Add(new ToolStripSeparator()); subfolderItem.DropDownItems.Add(suspendFolderItem); subfolderItem.DropDownItems.Add(new ToolStripSeparator()); subfolderItem.DropDownItems.Add(editFolderItem); subfolderItem.DropDownItems.Add(new ToolStripSeparator()); subfolderItem.DropDownItems.Add(removeFolderFromSyncItem); // Add the main item. this.traymenu.Items.Add(subfolderItem); } this.traymenu.Items.Add(new ToolStripSeparator()); } // Create the menu item that lets the user add a new synchronized folder. ToolStripMenuItem addFolderItem = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.AddARemoteFolder }; addFolderItem.Click += delegate { Controller.AddRemoteFolderClicked(); }; this.traymenu.Items.Add(addFolderItem); this.traymenu.Items.Add(new ToolStripSeparator()); // Create the menu item that lets the user view setting. ToolStripMenuItem setting_item = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.Settings }; setting_item.Click += delegate { Controller.SettingClicked(); }; this.traymenu.Items.Add(setting_item); // Create the menu item that lets the user view the log. ToolStripMenuItem log_item = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.ViewLog }; log_item.Click += delegate { Controller.LogClicked(); }; this.traymenu.Items.Add(log_item); // Create the About menu. ToolStripMenuItem about_item = new ToolStripMenuItem() { Text = String.Format(Properties_Resources.About, Properties_Resources.ApplicationName) }; about_item.Click += delegate { Controller.AboutClicked(); }; this.traymenu.Items.Add(about_item); // Create the exit menu. this.exitItem = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.Exit }; this.exitItem.Click += delegate { this.trayicon.Dispose(); Controller.QuitClicked(); }; this.traymenu.Items.Add(this.exitItem); }
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.general_settings_item = new NSMenuItem() { Title = Properties_Resources.EditTitle }; this.general_settings_item.Activated += delegate { Controller.SettingClicked(); }; this.log_item = new NSMenuItem() { Title = Properties_Resources.ViewLog }; this.log_item.Activated += delegate { Controller.LogClicked(); }; this.add_item = new NSMenuItem() { Title = Properties_Resources.AddARemoteFolder, Enabled = true }; this.add_item.Activated += delegate { Controller.AddRemoteFolderClicked(); }; this.about_item = new NSMenuItem() { Title = String.Format(Properties_Resources.About, Properties_Resources.ApplicationName), Enabled = true }; this.about_item.Activated += delegate { Controller.AboutClicked(); }; this.quit_item = new NSMenuItem() { Title = 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.general_settings_item); 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; } }