public static GetBitmap ( string name ) : |
||
name | string | |
Résultat |
/// <summary> /// Creates a new menu item, which updates itself on transmission events /// </summary> /// <param name="e">FileTransmissionEvent to listen to</param> /// <param name="parent">Parent control to avoid threading issues</param> public TransmissionMenuItem(FileTransmissionEvent e, Control parent) : base(e.Type.ToString()) { Path = e.Path; Type = e.Type; ParentControl = parent; transmissionEvent = e; switch (Type) { case FileTransmissionType.DOWNLOAD_NEW_FILE: Image = UIHelpers.GetBitmap("Downloading"); break; case FileTransmissionType.UPLOAD_NEW_FILE: Image = UIHelpers.GetBitmap("Uploading"); break; case FileTransmissionType.DOWNLOAD_MODIFIED_FILE: goto case FileTransmissionType.UPLOAD_MODIFIED_FILE; case FileTransmissionType.UPLOAD_MODIFIED_FILE: Image = UIHelpers.GetBitmap("Updating"); break; } Text = TransmissionStatus(transmissionEvent.Status); transmissionEvent.TransmissionStatus += TransmissionEvent; Click += TransmissionEventMenuItem_Click; }
public RepositoryMenuItem( Repository repo, StatusIconController controller, Control parent) : base(repo.Name) { this.repository = repo; this.controller = controller; this.parent = parent; this.Image = UIHelpers.GetBitmap("folder"); this.suspendItem = new ToolStripMenuItem(Properties_Resources.PauseSync, UIHelpers.GetBitmap("media_playback_pause")); this.repository.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => { if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.Status)) { this.Status = this.repository.Status; } if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.LastFinishedSync)) { this.changesFoundAt = this.repository.LastFinishedSync; this.UpdateStatusText(); } if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.NumberOfChanges)) { this.changesFound = this.repository.NumberOfChanges; this.UpdateStatusText(); } }; this.openLocalFolderItem = new ToolStripMenuItem(Properties_Resources.OpenLocalFolder) { Image = UIHelpers.GetBitmap("folder") }; this.openLocalFolderItem.Click += this.OpenFolderDelegate(); this.editItem = new ToolStripMenuItem(Properties_Resources.Settings); this.editItem.Click += this.EditFolderDelegate(); this.Status = repo.Status; this.suspendItem.Click += this.SuspendSyncFolderDelegate(); this.statusItem = new ToolStripMenuItem(Properties_Resources.StatusSearchingForChanges) { Enabled = false }; this.removeFolderFromSyncItem = new ToolStripMenuItem(Properties_Resources.RemoveFolderFromSync); this.removeFolderFromSyncItem.Click += this.RemoveFolderFromSyncDelegate(); this.DropDownItems.Add(this.statusItem); this.DropDownItems.Add(new ToolStripSeparator()); this.DropDownItems.Add(this.openLocalFolderItem); this.DropDownItems.Add(this.suspendItem); this.DropDownItems.Add(this.editItem); this.DropDownItems.Add(new ToolStripSeparator()); this.DropDownItems.Add(this.removeFolderFromSyncItem); }
private void setSyncItemState(ToolStripMenuItem syncitem, SyncStatus status) { switch (status) { case SyncStatus.Idle: syncitem.Text = CmisSync.Properties_Resources.PauseSync; syncitem.Image = UIHelpers.GetBitmap("media_playback_pause"); break; case SyncStatus.Suspend: syncitem.Text = CmisSync.Properties_Resources.ResumeSync; syncitem.Image = UIHelpers.GetBitmap("media_playback_start"); break; } }
private void SetEnabledOrDisabled(ToolStripMenuItem enableDisableItem, ToolStripMenuItem menuItem, bool enabled) { switch (enabled) { case true: enableDisableItem.Text = CmisSync.Properties_Resources.DisableSync; enableDisableItem.Image = UIHelpers.GetBitmap("media_playback_pause"); menuItem.Enabled = true; break; case false: enableDisableItem.Text = CmisSync.Properties_Resources.EnableSync; enableDisableItem.Image = UIHelpers.GetBitmap("media_playback_start"); menuItem.Enabled = false; break; } }
private void CreateInvokeMethod() { Controller.UpdateIconEvent += delegate(int icon_frame) { if (IsHandleCreated) { BeginInvoke((Action) delegate { if (icon_frame > -1) { this.trayicon.Icon = animation_frames[icon_frame]; } else { this.trayicon.Icon = SystemIcons.Error; } }); } }; Controller.UpdateStatusItemEvent += delegate(string state_text) { if (IsHandleCreated) { BeginInvoke((Action) delegate { this.state_item.Text = state_text; this.trayicon.Text = "CmisSync\n" + state_text; }); } }; Controller.UpdateMenuEvent += delegate(IconState state) { if (IsHandleCreated) { BeginInvoke((Action) delegate { CreateMenu(); }); } }; Controller.UpdateQuitItemEvent += delegate(bool item_enabled) { if (IsHandleCreated) { BeginInvoke((Action) delegate { this.exit_item.Enabled = item_enabled; // this.exit_item.UpdateLayout(); }); } }; Controller.UpdateSuspendSyncFolderEvent += delegate(string reponame) { //TODO - Yannick if (IsHandleCreated) { BeginInvoke((Action) delegate { ToolStripMenuItem repoitem = (ToolStripMenuItem)this.traymenu.Items["tsmi" + reponame]; ToolStripMenuItem syncitem = (ToolStripMenuItem)repoitem.DropDownItems[3]; if (syncitem.Tag == "pause") { syncitem.Text = CmisSync.Properties.Resources.ResourceManager.GetString("ResumeSync", CultureInfo.CurrentCulture); syncitem.Tag = "resume"; syncitem.Image = UIHelpers.GetBitmap("media_playback_start"); } else { syncitem.Text = CmisSync.Properties.Resources.ResourceManager.GetString("PauseSync", CultureInfo.CurrentCulture); syncitem.Tag = "pause"; syncitem.Image = UIHelpers.GetBitmap("media_playback_pause"); } }); } }; }
private void CreateMenu() { this.traymenu.Items.Clear(); // State Menu this.state_item = new ToolStripMenuItem() { Text = Controller.StateText, Enabled = false }; this.traymenu.Items.Add(state_item); this.trayicon.Text = "CmisSync\n" + Controller.StateText; // Folders Menu if (Controller.Folders.Length > 0) { foreach (string folder_name in Controller.Folders) { ToolStripMenuItem subfolder_item = new ToolStripMenuItem() { Text = folder_name, Name = "tsmi" + folder_name, Image = UIHelpers.GetBitmap("folder") }; ToolStripMenuItem open_localfolder_item = new ToolStripMenuItem() { Text = CmisSync.Properties.Resources.ResourceManager.GetString("OpenLocalFolder", CultureInfo.CurrentCulture), Image = UIHelpers.GetBitmap("folder") }; open_localfolder_item.Click += OpenFolderDelegate(folder_name); ToolStripMenuItem open_remotefolder_item = new ToolStripMenuItem() { Text = CmisSync.Properties.Resources.ResourceManager.GetString("BrowseRemoteFolder", CultureInfo.CurrentCulture), Image = UIHelpers.GetBitmap("classic_folder_web") }; open_remotefolder_item.Click += OpenRemoteFolderDelegate(folder_name); ToolStripMenuItem suspend_folder_item = new ToolStripMenuItem() { Text = CmisSync.Properties.Resources.ResourceManager.GetString("PauseSync", CultureInfo.CurrentCulture), Tag = "pause", Image = UIHelpers.GetBitmap("media_playback_pause") }; suspend_folder_item.Click += SuspendSyncFolderDelegate(folder_name); subfolder_item.DropDownItems.Add(open_localfolder_item); subfolder_item.DropDownItems.Add(open_remotefolder_item); subfolder_item.DropDownItems.Add(new ToolStripSeparator()); subfolder_item.DropDownItems.Add(suspend_folder_item); this.traymenu.Items.Add(subfolder_item); } } this.traymenu.Items.Add(new ToolStripSeparator()); // Add Menu ToolStripMenuItem add_item = new ToolStripMenuItem() { Text = CmisSync.Properties.Resources.ResourceManager.GetString("AddARemoteFolder", CultureInfo.CurrentCulture) }; add_item.Click += delegate { Controller.AddHostedProjectClicked(); }; this.traymenu.Items.Add(add_item); this.traymenu.Items.Add(new ToolStripSeparator()); // About Menu ToolStripMenuItem about_item = new ToolStripMenuItem() { Text = "About CmisSync" }; about_item.Click += delegate { Controller.AboutClicked(); }; this.traymenu.Items.Add(about_item); // Exit Menu this.exit_item = new ToolStripMenuItem() { Text = CmisSync.Properties.Resources.ResourceManager.GetString("Exit", CultureInfo.CurrentCulture) }; this.exit_item.Click += delegate { this.trayicon.Dispose(); Controller.QuitClicked(); }; this.traymenu.Items.Add(this.exit_item); }
/// <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 = Utils.Ellipsis(Controller.StateText, 32), Enabled = false }; if (Controller.StateText.Length > 32) { this.stateItem.ToolTipText = Utils.WordWrap(Controller.StateText, 63); } this.traymenu.Items.Add(stateItem); this.trayicon.Text = Utils.Ellipsis(Properties_Resources.Oris4Sync + "\n" + Controller.StateText, 63); // 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, Name = "openLocal", Image = UIHelpers.GetBitmap("folder"), }; openLocalFolderItem.Click += OpenLocalFolderDelegate(folderName); // Sub-item: open remotely. ToolStripMenuItem openRemoteFolderItem = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.BrowseRemoteFolder, Name = "openRemote", Image = UIHelpers.GetBitmap("classic_folder_web"), }; openRemoteFolderItem.Click += OpenRemoteFolderDelegate(folderName); // Sub-item: suspend sync. ToolStripMenuItem suspendFolderItem = new ToolStripMenuItem() { Name = "pause", }; suspendFolderItem.Click += SuspendSyncFolderDelegate(folderName); // Sub-item: remove folder from sync ToolStripMenuItem removeFolderFromSyncItem = new ToolStripMenuItem() { Text = Properties_Resources.RemoveFolderFromSync, Name = "remove", Image = UIHelpers.GetBitmap("disconnect"), }; removeFolderFromSyncItem.Click += RemoveFolderFromSyncDelegate(folderName); // Sub-item: manual sync ToolStripMenuItem manualSyncItem = new ToolStripMenuItem() { Text = Properties_Resources.ManualSync, Name = "sync", Image = UIHelpers.GetBitmap("media_playback_refresh"), }; manualSyncItem.Click += ManualSyncDelegate(folderName); // Sub-item: settings dialog ToolStripMenuItem settingsItem = new ToolStripMenuItem() { Text = Properties_Resources.Settings, Name = "settings", }; settingsItem.Click += SettingsDelegate(folderName); setSyncItemState(suspendFolderItem, manualSyncItem, SyncStatus.Idle); foreach (RepoBase aRepo in Program.Controller.Repositories) { if (aRepo.Name.Equals(folderName)) { setSyncItemState(suspendFolderItem, manualSyncItem, aRepo.Status); break; } } // Add the sub-items. subfolderItem.DropDownItems.Add(openLocalFolderItem); subfolderItem.DropDownItems.Add(openRemoteFolderItem); subfolderItem.DropDownItems.Add(new ToolStripSeparator()); subfolderItem.DropDownItems.Add(suspendFolderItem); subfolderItem.DropDownItems.Add(manualSyncItem); subfolderItem.DropDownItems.Add(new ToolStripSeparator()); subfolderItem.DropDownItems.Add(removeFolderFromSyncItem); subfolderItem.DropDownItems.Add(new ToolStripSeparator()); subfolderItem.DropDownItems.Add(settingsItem); // 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, Name = "add", Image = UIHelpers.GetBitmap("connect"), }; if (ConfigManager.CurrentConfig.SingleRepository && ConfigManager.CurrentConfig.Folder.Count > 0) { //Configured for single repository and repository count 1 or more so disable menu item. addFolderItem.Enabled = false; } 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 the log. ToolStripMenuItem log_item = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.ViewLog, Name = "log", }; log_item.Click += delegate { Controller.LogClicked(); }; //Removed for Oris4 //this.traymenu.Items.Add(log_item); // Create the About menu. ToolStripMenuItem about_item = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.About, Name = "about", }; 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, Name = "exit", }; this.exitItem.Click += delegate { this.trayicon.Dispose(); Controller.QuitClicked(); }; this.traymenu.Items.Add(this.exitItem); }
/// <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); }
/// <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 = "CmisSync\n" + Controller.StateText; // 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.ResourceManager.GetString("OpenLocalFolder", CultureInfo.CurrentCulture), Image = UIHelpers.GetBitmap("folder") }; openLocalFolderItem.Click += OpenLocalFolderDelegate(folderName); // Sub-item: open remotely. ToolStripMenuItem openRemoteFolderItem = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.ResourceManager.GetString("BrowseRemoteFolder", CultureInfo.CurrentCulture), Image = UIHelpers.GetBitmap("classic_folder_web") }; openRemoteFolderItem.Click += OpenRemoteFolderDelegate(folderName); // Sub-item: suspend sync. ToolStripMenuItem suspendFolderItem = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.ResourceManager.GetString("PauseSync", CultureInfo.CurrentCulture), Tag = "pause", Image = UIHelpers.GetBitmap("media_playback_pause") }; suspendFolderItem.Click += SuspendSyncFolderDelegate(folderName); // Add the sub-items. subfolderItem.DropDownItems.Add(openLocalFolderItem); subfolderItem.DropDownItems.Add(openRemoteFolderItem); subfolderItem.DropDownItems.Add(new ToolStripSeparator()); subfolderItem.DropDownItems.Add(suspendFolderItem); // 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.ResourceManager.GetString("AddARemoteFolder", CultureInfo.CurrentCulture) }; 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 the log. ToolStripMenuItem log_item = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.ResourceManager.GetString("ViewLog", CultureInfo.CurrentCulture) }; log_item.Click += delegate { Controller.LogClicked(); }; this.traymenu.Items.Add(log_item); // Create the About menu. ToolStripMenuItem about_item = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.ResourceManager.GetString("About", CultureInfo.CurrentCulture) }; about_item.Click += delegate { Controller.AboutClicked(); }; this.traymenu.Items.Add(about_item); // Create the exit menu. this.exitItem = new ToolStripMenuItem() { Text = CmisSync.Properties_Resources.ResourceManager.GetString("Exit", CultureInfo.CurrentCulture) }; this.exitItem.Click += delegate { this.trayicon.Dispose(); Controller.QuitClicked(); }; this.traymenu.Items.Add(this.exitItem); }