- Timestamp:
- 04/16/13 13:13:41 (12 years ago)
- Location:
- branches/OaaS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Starter/StarterForm.Designer.cs
r7967 r9363 181 181 this.Name = "StarterForm"; 182 182 this.Text = "HeuristicLab Starter"; 183 this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); 183 this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.StarterForm_FormClosing); 184 this.Load += new System.EventHandler(this.StarterForm_Load); 184 185 this.ResumeLayout(false); 185 186 -
branches/OaaS/HeuristicLab.PluginInfrastructure/3.3/Starter/StarterForm.cs
r7259 r9363 26 26 using System.Linq; 27 27 using System.Threading; 28 using System.Threading.Tasks; 28 29 using System.Windows.Forms; 29 30 using HeuristicLab.PluginInfrastructure.Advanced; 30 31 using HeuristicLab.PluginInfrastructure.Manager; 31 using System.Threading.Tasks;32 32 33 33 namespace HeuristicLab.PluginInfrastructure.Starter { … … 39 39 private const string pluginManagerItemName = "Plugin Manager"; 40 40 private const string updatePluginsItemName = "Updates Available"; 41 41 private const string optimizerItemName = "Optimizer"; 42 43 private readonly ICommandLineArgument[] arguments; 42 44 43 45 private ListViewItem pluginManagerListViewItem; … … 46 48 private SplashScreen splashScreen; 47 49 private bool updatesAvailable = false; 50 48 51 /// <summary> 49 52 /// Initializes an instance of the starter form. … … 63 66 pluginManager = new PluginManager(pluginPath); 64 67 splashScreen = new SplashScreen(pluginManager, 1000); 68 splashScreen.VisibleChanged += new EventHandler(splashScreen_VisibleChanged); 65 69 splashScreen.Show(this, "Loading HeuristicLab..."); 66 70 … … 69 73 70 74 CheckUpdatesAvailableAsync(); 75 } 76 77 /// <summary> 78 /// Creates a new StarterForm and passes the arguments in <paramref name="args"/>. 79 /// </summary> 80 /// <param name="args">The arguments that should be processed</param> 81 public StarterForm(string[] args) 82 : this() { 83 arguments = CommandLineArgumentHandling.GetArguments(args); 84 } 85 86 protected override void SetVisibleCore(bool value) { 87 value &= !(arguments.OfType<HideStarterArgument>().Any() || arguments.OfType<OpenArgument>().Any()); 88 if (!value) HandleArguments(); 89 base.SetVisibleCore(value); 90 } 91 92 #region Events 93 private void StarterForm_Load(object sender, EventArgs e) { 94 HandleArguments(); 95 } 96 97 private void StarterForm_FormClosing(object sender, FormClosingEventArgs e) { 98 splashScreen.Close(); 99 abortRequested = true; 100 } 101 102 private void applicationsListView_SelectedIndexChanged(object sender, EventArgs e) { 103 startButton.Enabled = applicationsListView.SelectedItems.Count > 0; 104 } 105 106 private void applicationsListView_ItemActivate(object sender, EventArgs e) { 107 if (applicationsListView.SelectedItems.Count > 0) { 108 ListViewItem selected = applicationsListView.SelectedItems[0]; 109 if (selected.Text == pluginManagerItemName) { 110 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 111 MessageBox.Show("Installation Manager cannot be started while another HeuristicLab application is active." + Environment.NewLine + 112 "Please stop all active HeuristicLab applications and try again.", "Plugin Manager", 113 MessageBoxButtons.OK, MessageBoxIcon.Information); 114 } else { 115 try { 116 Cursor = Cursors.AppStarting; 117 using (InstallationManagerForm form = new InstallationManagerForm(pluginManager)) { 118 form.ShowDialog(this); 119 } 120 UpdateApplicationsList(); 121 } 122 finally { 123 Cursor = Cursors.Arrow; 124 } 125 } 126 } else if (selected.Text == updatePluginsItemName) { 127 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 128 MessageBox.Show("Updating is not possible while another HeuristicLab application is active." + Environment.NewLine + 129 "Please stop all active HeuristicLab applications and try again.", "Update plugins", 130 MessageBoxButtons.OK, MessageBoxIcon.Information); 131 } else { 132 try { 133 Cursor = Cursors.AppStarting; 134 using (PluginUpdaterForm form = new PluginUpdaterForm(pluginManager)) { 135 form.ShowDialog(this); 136 } 137 updatesAvailable = false; 138 CheckUpdatesAvailableAsync(); 139 UpdateApplicationsList(); 140 } 141 finally { 142 Cursor = Cursors.Arrow; 143 } 144 } 145 } else { 146 ApplicationDescription app = (ApplicationDescription)applicationsListView.SelectedItems[0].Tag; 147 StartApplication(app, arguments); 148 } 149 } 150 } 151 152 private void largeIconsButton_Click(object sender, EventArgs e) { 153 applicationsListView.View = View.LargeIcon; 154 } 155 156 private void detailsButton_Click(object sender, EventArgs e) { 157 applicationsListView.View = View.Details; 158 foreach (ColumnHeader column in applicationsListView.Columns) { 159 if (applicationsListView.Items.Count > 0) 160 column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 161 else column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 162 } 163 } 164 165 private void aboutButton_Click(object sender, EventArgs e) { 166 List<IPluginDescription> plugins = new List<IPluginDescription>(pluginManager.Plugins.OfType<IPluginDescription>()); 167 using (var dialog = new AboutDialog(plugins)) { 168 dialog.ShowDialog(); 169 } 170 } 171 172 private void splashScreen_VisibleChanged(object sender, EventArgs e) { 173 // close hidden starter form 174 if (!splashScreen.Visible && arguments != null && 175 (arguments.OfType<HideStarterArgument>().Any() || arguments.OfType<OpenArgument>().Any())) 176 Close(); 177 } 178 #endregion 179 180 #region Helpers 181 private void UpdateApplicationsList() { 182 if (InvokeRequired) Invoke((Action)UpdateApplicationsList); 183 else { 184 applicationsListView.Items.Clear(); 185 AddPluginManagerItem(); 186 AddUpdatePluginsItem(); 187 188 foreach (ApplicationDescription info in pluginManager.Applications) { 189 ListViewItem item = new ListViewItem(info.Name, 0); 190 item.Tag = info; 191 item.Group = applicationsListView.Groups["Applications"]; 192 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Version.ToString())); 193 item.SubItems.Add(new ListViewItem.ListViewSubItem(item, info.Description)); 194 item.ToolTipText = info.Description; 195 applicationsListView.Items.Add(item); 196 } 197 foreach (ColumnHeader column in applicationsListView.Columns) { 198 if (applicationsListView.Items.Count > 0) 199 column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 200 else column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 201 } 202 } 203 } 204 205 private void AddPluginManagerItem() { 206 FileVersionInfo pluginInfrastructureVersion = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); 207 pluginManagerListViewItem = new ListViewItem(pluginManagerItemName, 0); 208 pluginManagerListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 209 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, pluginInfrastructureVersion.FileVersion)); 210 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, "Install, upgrade or delete plugins")); 211 pluginManagerListViewItem.ToolTipText = "Install, upgrade or delete plugins"; 212 213 applicationsListView.Items.Add(pluginManagerListViewItem); 214 } 215 216 private void AddUpdatePluginsItem() { 217 if (updatesAvailable) { 218 var updateListViewItem = new ListViewItem(updatePluginsItemName, 1); 219 updateListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 220 updateListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(updateListViewItem, "")); 221 updateListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(updateListViewItem, "Download and install updates")); 222 updateListViewItem.ToolTipText = "Download and install updates"; 223 224 applicationsListView.Items.Add(updateListViewItem); 225 } 71 226 } 72 227 … … 108 263 } 109 264 110 /// <summary> 111 /// Creates a new StarterForm and tries to start application with <paramref name="appName"/> immediately. 112 /// </summary> 113 /// <param name="appName">Name of the application</param> 114 public StarterForm(string appName) 115 : this() { 265 private void HandleArguments() { 266 try { 267 if (arguments.OfType<OpenArgument>().Any() && !arguments.OfType<StartArgument>().Any()) { 268 InitiateApplicationStart(optimizerItemName); 269 } 270 foreach (var argument in arguments) { 271 if (argument is StartArgument) { 272 var arg = (StartArgument)argument; 273 InitiateApplicationStart(arg.Value); 274 } 275 } 276 } 277 catch (AggregateException ex) { 278 ErrorHandling.ShowErrorDialog(this, "One or more errors occurred while initializing the application.", ex); 279 } 280 } 281 282 private void InitiateApplicationStart(string appName) { 116 283 var appDesc = (from desc in pluginManager.Applications 117 where desc.Name == appName284 where desc.Name.Equals(appName) 118 285 select desc).SingleOrDefault(); 119 286 if (appDesc != null) { 120 StartApplication(appDesc );287 StartApplication(appDesc, arguments); 121 288 } else { 122 289 MessageBox.Show("Cannot start application " + appName + ".", … … 127 294 } 128 295 129 private void applicationsListView_ItemActivate(object sender, EventArgs e) { 130 if (applicationsListView.SelectedItems.Count > 0) { 131 ListViewItem selected = applicationsListView.SelectedItems[0]; 132 if (selected.Text == pluginManagerItemName) { 133 if (pluginManager.Plugins.Any(x => x.PluginState == PluginState.Loaded)) { 134 MessageBox.Show("Installation Manager cannot be started while another HeuristicLab application is active." + Environment.NewLine + 135 "Please stop all active HeuristicLab applications and try again.", "Plugin Manager", 136 MessageBoxButtons.OK, MessageBoxIcon.Information); 137 } else { 138 try { 139 Cursor = Cursors.AppStarting; 140 using (InstallationManagerForm form = new InstallationManagerForm(pluginManager)) { 141 form.ShowDialog(this); 142 } 143 UpdateApplicationsList(); 144 } 145 finally { 146 Cursor = Cursors.Arrow; 147 } 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 } 168 } else { 169 ApplicationDescription app = (ApplicationDescription)applicationsListView.SelectedItems[0].Tag; 170 StartApplication(app); 171 } 172 } 173 } 174 175 private void UpdateApplicationsList() { 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() { 200 FileVersionInfo pluginInfrastructureVersion = FileVersionInfo.GetVersionInfo(GetType().Assembly.Location); 201 pluginManagerListViewItem = new ListViewItem(pluginManagerItemName, 0); 202 pluginManagerListViewItem.Group = applicationsListView.Groups["Plugin Management"]; 203 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, pluginInfrastructureVersion.FileVersion)); 204 pluginManagerListViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(pluginManagerListViewItem, "Install, upgrade or delete plugins")); 205 pluginManagerListViewItem.ToolTipText = "Install, upgrade or delete plugins"; 206 207 applicationsListView.Items.Add(pluginManagerListViewItem); 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); 219 } 220 } 221 222 private void StartApplication(ApplicationDescription app) { 296 private void StartApplication(ApplicationDescription app, ICommandLineArgument[] args) { 223 297 splashScreen.Show("Loading " + app.Name); 224 298 Thread t = new Thread(delegate() { … … 227 301 try { 228 302 if (!abortRequested) { 229 pluginManager.Run(app );303 pluginManager.Run(app, args); 230 304 } 231 305 stopped = true; … … 241 315 t.Start(); 242 316 } 243 244 private void applicationsListView_SelectedIndexChanged(object sender, EventArgs e) { 245 startButton.Enabled = applicationsListView.SelectedItems.Count > 0; 246 } 247 248 private void largeIconsButton_Click(object sender, EventArgs e) { 249 applicationsListView.View = View.LargeIcon; 250 } 251 252 private void detailsButton_Click(object sender, EventArgs e) { 253 applicationsListView.View = View.Details; 254 foreach (ColumnHeader column in applicationsListView.Columns) { 255 if (applicationsListView.Items.Count > 0) 256 column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 257 else column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 258 } 259 } 260 261 private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { 262 splashScreen.Close(); 263 abortRequested = true; 264 } 265 266 private void aboutButton_Click(object sender, EventArgs e) { 267 List<IPluginDescription> plugins = new List<IPluginDescription>(pluginManager.Plugins.OfType<IPluginDescription>()); 268 using (var dialog = new AboutDialog(plugins)) { 269 dialog.ShowDialog(); 270 } 271 } 317 #endregion 272 318 } 273 319 }
Note: See TracChangeset
for help on using the changeset viewer.