- Timestamp:
- 06/14/11 18:59:42 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Starter/StarterForm.cs
r5445 r6413 29 29 using HeuristicLab.PluginInfrastructure.Advanced; 30 30 using HeuristicLab.PluginInfrastructure.Manager; 31 using System.Threading.Tasks; 31 32 32 33 namespace HeuristicLab.PluginInfrastructure.Starter { … … 36 37 /// </summary> 37 38 public partial class StarterForm : Form { 39 private const string pluginManagerItemName = "Plugin Manager"; 40 private const string updatePluginsItemName = "Updates Available"; 41 38 42 39 43 private ListViewItem pluginManagerListViewItem; … … 41 45 private PluginManager pluginManager; 42 46 private SplashScreen splashScreen; 47 private bool updatesAvailable = false; 43 48 44 49 /// <summary> … … 50 55 InitializeComponent(); 51 56 largeImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.HeuristicLab.ToBitmap()); 57 largeImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.UpdateAvailable.ToBitmap()); 52 58 smallImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.HeuristicLab.ToBitmap()); 59 smallImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.UpdateAvailable.ToBitmap()); 53 60 FileVersionInfo pluginInfrastructureVersion = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); 54 61 Text = "HeuristicLab " + pluginInfrastructureVersion.FileVersion; … … 61 68 pluginManager.DiscoverAndCheckPlugins(); 62 69 UpdateApplicationsList(); 70 71 CheckUpdatesAvailableAsync(pluginPath); 72 } 73 74 private void CheckUpdatesAvailableAsync(string pluginPath) { 75 var task = Task.Factory.StartNew<bool>(() => { 76 var installationManager = new InstallationManager(pluginPath); 77 IEnumerable<IPluginDescription> installedPlugins = pluginManager.Plugins.OfType<IPluginDescription>(); 78 var remotePlugins = installationManager.GetRemotePluginList(); 79 // if there is a local plugin with same name and same major and minor version then it's an update 80 var pluginsToUpdate = from remotePlugin in remotePlugins 81 let matchingLocalPlugins = from installedPlugin in installedPlugins 82 where installedPlugin.Name == remotePlugin.Name 83 where installedPlugin.Version.Major == remotePlugin.Version.Major 84 where installedPlugin.Version.Minor == remotePlugin.Version.Minor 85 where Util.IsNewerThan(remotePlugin, installedPlugin) 86 select installedPlugin 87 where matchingLocalPlugins.Count() > 0 88 select remotePlugin; 89 return pluginsToUpdate.Count() > 0; 90 }); 91 task.ContinueWith(t => { 92 updatesAvailable = t.Result; 93 UpdateApplicationsList(); 94 }, TaskContinuationOptions.NotOnFaulted); 63 95 } 64 96 … … 85 117 if (applicationsListView.SelectedItems.Count > 0) { 86 118 ListViewItem selected = applicationsListView.SelectedItems[0]; 87 if (selected == pluginManagerListViewItem) {119 if (selected.Text == pluginManagerItemName) { 88 120 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 89 121 MessageBox.Show("Installation Manager cannot be started while another HeuristicLab application is active." + Environment.NewLine + … … 102 134 } 103 135 } 136 } else if (selected.Text == updatePluginsItemName) { 137 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 138 MessageBox.Show("Updating is not possible while another HeuristicLab application is active." + Environment.NewLine + 139 "Please stop all active HeuristicLab applications and try again.", "Update plugins", 140 MessageBoxButtons.OK, MessageBoxIcon.Information); 141 } else { 142 try { 143 Cursor = Cursors.AppStarting; 144 using (PluginUpdaterForm form = new PluginUpdaterForm(pluginManager)) { 145 form.ShowDialog(this); 146 } 147 UpdateApplicationsList(); 148 } 149 finally { 150 Cursor = Cursors.Arrow; 151 } 152 } 104 153 } else { 105 154 ApplicationDescription app = (ApplicationDescription)applicationsListView.SelectedItems[0].Tag; … … 110 159 111 160 private void UpdateApplicationsList() { 112 applicationsListView.Items.Clear(); 113 FileVersionInfo pluginInfrastructureVersion = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); 114 pluginManagerListViewItem = new ListViewItem("Plugin Manager", 0); 115 pluginManagerListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 116 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, pluginInfrastructureVersion.FileVersion)); 117 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, "Install, upgrade or delete plugins")); 118 pluginManagerListViewItem.ToolTipText = "Install, upgrade or delete plugins"; 119 120 applicationsListView.Items.Add(pluginManagerListViewItem); 121 122 foreach (ApplicationDescription info in pluginManager.Applications) { 123 ListViewItem item = new ListViewItem(info.Name, 0); 124 item.Tag = info; 125 item.Group = applicationsListView.Groups["Applications"]; 126 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Version.ToString())); 127 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Description)); 128 item.ToolTipText = info.Description; 129 applicationsListView.Items.Add(item); 130 } 131 foreach (ColumnHeader column in applicationsListView.Columns) { 132 if (applicationsListView.Items.Count > 0) 133 column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 134 else column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 161 if (InvokeRequired) Invoke((Action)UpdateApplicationsList); 162 else { 163 applicationsListView.Items.Clear(); 164 AddPluginManagerItem(); 165 AddUpdatePluginsItem(); 166 167 foreach (ApplicationDescription info in pluginManager.Applications) { 168 ListViewItem item = new ListViewItem(info.Name, 0); 169 item.Tag = info; 170 item.Group = applicationsListView.Groups["Applications"]; 171 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Version.ToString())); 172 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Description)); 173 item.ToolTipText = info.Description; 174 applicationsListView.Items.Add(item); 175 } 176 foreach (ColumnHeader column in applicationsListView.Columns) { 177 if (applicationsListView.Items.Count > 0) 178 column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 179 else column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 180 } 181 } 182 } 183 184 private void AddPluginManagerItem() { 185 if (HeuristicLab.PluginInfrastructure.Properties.Settings.Default.ShowPluginUploadControls) { 186 FileVersionInfo pluginInfrastructureVersion = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); 187 pluginManagerListViewItem = new ListViewItem(pluginManagerItemName, 0); 188 pluginManagerListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 189 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, pluginInfrastructureVersion.FileVersion)); 190 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, "Install, upgrade or delete plugins")); 191 pluginManagerListViewItem.ToolTipText = "Install, upgrade or delete plugins"; 192 193 applicationsListView.Items.Add(pluginManagerListViewItem); 194 } 195 } 196 197 private void AddUpdatePluginsItem() { 198 if (updatesAvailable) { 199 var updateListViewItem = new ListViewItem(updatePluginsItemName, 1); 200 updateListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 201 updateListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(updateListViewItem, "")); 202 updateListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(updateListViewItem, "Download and install updates")); 203 updateListViewItem.ToolTipText = "Download and install updates"; 204 205 applicationsListView.Items.Add(updateListViewItem); 135 206 } 136 207 }
Note: See TracChangeset
for help on using the changeset viewer.