- Timestamp:
- 09/14/11 13:59:25 (13 years ago)
- Location:
- branches/PersistenceSpeedUp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceSpeedUp
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/PersistenceSpeedUp/HeuristicLab.PluginInfrastructure/3.3/Starter/StarterForm.cs
r5445 r6760 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; 43 47 private bool updatesAvailable = false; 44 48 /// <summary> 45 49 /// Initializes an instance of the starter form. … … 50 54 InitializeComponent(); 51 55 largeImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.HeuristicLab.ToBitmap()); 56 largeImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.UpdateAvailable.ToBitmap()); 52 57 smallImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.HeuristicLab.ToBitmap()); 58 smallImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.UpdateAvailable.ToBitmap()); 53 59 FileVersionInfo pluginInfrastructureVersion = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); 54 60 Text = "HeuristicLab " + pluginInfrastructureVersion.FileVersion; … … 61 67 pluginManager.DiscoverAndCheckPlugins(); 62 68 UpdateApplicationsList(); 69 70 CheckUpdatesAvailableAsync(); 71 } 72 73 private void CheckUpdatesAvailableAsync() { 74 string pluginPath = Path.GetFullPath(Application.StartupPath); 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 try { 93 t.Wait(); 94 updatesAvailable = t.Result; 95 UpdateApplicationsList(); 96 } 97 catch (AggregateException ae) { 98 ae.Handle(ex => { 99 if (ex is InstallationManagerException) { 100 // this is expected when no internet connection is available => do nothing 101 return true; 102 } else { 103 return false; 104 } 105 }); 106 } 107 }); 63 108 } 64 109 … … 85 130 if (applicationsListView.SelectedItems.Count > 0) { 86 131 ListViewItem selected = applicationsListView.SelectedItems[0]; 87 if (selected == pluginManagerListViewItem) {132 if (selected.Text == pluginManagerItemName) { 88 133 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 89 134 MessageBox.Show("Installation Manager cannot be started while another HeuristicLab application is active." + Environment.NewLine + … … 102 147 } 103 148 } 149 } else if (selected.Text == updatePluginsItemName) { 150 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 151 MessageBox.Show("Updating is not possible while another HeuristicLab application is active." + Environment.NewLine + 152 "Please stop all active HeuristicLab applications and try again.", "Update plugins", 153 MessageBoxButtons.OK, MessageBoxIcon.Information); 154 } else { 155 try { 156 Cursor = Cursors.AppStarting; 157 using (PluginUpdaterForm form = new PluginUpdaterForm(pluginManager)) { 158 form.ShowDialog(this); 159 } 160 updatesAvailable = false; 161 CheckUpdatesAvailableAsync(); 162 UpdateApplicationsList(); 163 } 164 finally { 165 Cursor = Cursors.Arrow; 166 } 167 } 104 168 } else { 105 169 ApplicationDescription app = (ApplicationDescription)applicationsListView.SelectedItems[0].Tag; … … 110 174 111 175 private void UpdateApplicationsList() { 112 applicationsListView.Items.Clear(); 176 if (InvokeRequired) Invoke((Action)UpdateApplicationsList); 177 else { 178 applicationsListView.Items.Clear(); 179 AddPluginManagerItem(); 180 AddUpdatePluginsItem(); 181 182 foreach (ApplicationDescription info in pluginManager.Applications) { 183 ListViewItem item = new ListViewItem(info.Name, 0); 184 item.Tag = info; 185 item.Group = applicationsListView.Groups["Applications"]; 186 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Version.ToString())); 187 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Description)); 188 item.ToolTipText = info.Description; 189 applicationsListView.Items.Add(item); 190 } 191 foreach (ColumnHeader column in applicationsListView.Columns) { 192 if (applicationsListView.Items.Count > 0) 193 column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 194 else column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 195 } 196 } 197 } 198 199 private void AddPluginManagerItem() { 113 200 FileVersionInfo pluginInfrastructureVersion = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); 114 pluginManagerListViewItem = new ListViewItem( "Plugin Manager", 0);201 pluginManagerListViewItem = new ListViewItem(pluginManagerItemName, 0); 115 202 pluginManagerListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 116 203 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, pluginInfrastructureVersion.FileVersion)); … … 119 206 120 207 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); 208 } 209 210 private void AddUpdatePluginsItem() { 211 if (updatesAvailable) { 212 var updateListViewItem = new ListViewItem(updatePluginsItemName, 1); 213 updateListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 214 updateListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(updateListViewItem, "")); 215 updateListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(updateListViewItem, "Download and install updates")); 216 updateListViewItem.ToolTipText = "Download and install updates"; 217 218 applicationsListView.Items.Add(updateListViewItem); 135 219 } 136 220 }
Note: See TracChangeset
for help on using the changeset viewer.