Changeset 5300 for trunk/sources/HeuristicLab.Optimization.Views
- Timestamp:
- 01/15/11 02:34:08 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.Designer.cs
r5287 r5300 35 35 private void InitializeComponent() { 36 36 this.tabControl = new System.Windows.Forms.TabControl(); 37 this. algorithmTabPage = new System.Windows.Forms.TabPage();38 this. algorithmViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();39 this.open AlgorithmButton = new System.Windows.Forms.Button();40 this.new AlgorithmButton = new System.Windows.Forms.Button();37 this.optimizerTabPage = new System.Windows.Forms.TabPage(); 38 this.optimizerViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 39 this.openOptimizerButton = new System.Windows.Forms.Button(); 40 this.newOptimizerButton = new System.Windows.Forms.Button(); 41 41 this.runsTabPage = new System.Windows.Forms.TabPage(); 42 42 this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView(); … … 52 52 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 53 53 this.tabControl.SuspendLayout(); 54 this. algorithmTabPage.SuspendLayout();54 this.optimizerTabPage.SuspendLayout(); 55 55 this.runsTabPage.SuspendLayout(); 56 56 ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit(); … … 72 72 | System.Windows.Forms.AnchorStyles.Left) 73 73 | System.Windows.Forms.AnchorStyles.Right))); 74 this.tabControl.Controls.Add(this. algorithmTabPage);74 this.tabControl.Controls.Add(this.optimizerTabPage); 75 75 this.tabControl.Controls.Add(this.runsTabPage); 76 76 this.tabControl.Location = new System.Drawing.Point(0, 78); … … 80 80 this.tabControl.TabIndex = 6; 81 81 // 82 // algorithmTabPage83 // 84 this. algorithmTabPage.AllowDrop = true;85 this. algorithmTabPage.Controls.Add(this.algorithmViewHost);86 this. algorithmTabPage.Controls.Add(this.openAlgorithmButton);87 this. algorithmTabPage.Controls.Add(this.newAlgorithmButton);88 this. algorithmTabPage.Location = new System.Drawing.Point(4, 22);89 this. algorithmTabPage.Name = "algorithmTabPage";90 this. algorithmTabPage.Padding = new System.Windows.Forms.Padding(3);91 this. algorithmTabPage.Size = new System.Drawing.Size(671, 348);92 this. algorithmTabPage.TabIndex = 1;93 this. algorithmTabPage.Text = "Algorithm";94 this. algorithmTabPage.UseVisualStyleBackColor = true;95 this. algorithmTabPage.DragOver += new System.Windows.Forms.DragEventHandler(this.algorithmTabPage_DragEnterOver);96 this. algorithmTabPage.DragDrop += new System.Windows.Forms.DragEventHandler(this.algorithmTabPage_DragDrop);97 this. algorithmTabPage.DragEnter += new System.Windows.Forms.DragEventHandler(this.algorithmTabPage_DragEnterOver);98 // 99 // algorithmViewHost100 // 101 this. algorithmViewHost.Content = null;102 this. algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)82 // optimizerTabPage 83 // 84 this.optimizerTabPage.AllowDrop = true; 85 this.optimizerTabPage.Controls.Add(this.optimizerViewHost); 86 this.optimizerTabPage.Controls.Add(this.openOptimizerButton); 87 this.optimizerTabPage.Controls.Add(this.newOptimizerButton); 88 this.optimizerTabPage.Location = new System.Drawing.Point(4, 22); 89 this.optimizerTabPage.Name = "optimizerTabPage"; 90 this.optimizerTabPage.Padding = new System.Windows.Forms.Padding(3); 91 this.optimizerTabPage.Size = new System.Drawing.Size(671, 348); 92 this.optimizerTabPage.TabIndex = 1; 93 this.optimizerTabPage.Text = "Optimizer"; 94 this.optimizerTabPage.UseVisualStyleBackColor = true; 95 this.optimizerTabPage.DragOver += new System.Windows.Forms.DragEventHandler(this.optimizerTabPage_DragEnterOver); 96 this.optimizerTabPage.DragDrop += new System.Windows.Forms.DragEventHandler(this.optimizerTabPage_DragDrop); 97 this.optimizerTabPage.DragEnter += new System.Windows.Forms.DragEventHandler(this.optimizerTabPage_DragEnterOver); 98 // 99 // optimizerViewHost 100 // 101 this.optimizerViewHost.Content = null; 102 this.optimizerViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 103 103 | System.Windows.Forms.AnchorStyles.Left) 104 104 | System.Windows.Forms.AnchorStyles.Right))); 105 this. algorithmViewHost.Location = new System.Drawing.Point(6, 36);106 this. algorithmViewHost.Name = "algorithmViewHost";107 this. algorithmViewHost.Size = new System.Drawing.Size(659, 306);108 this. algorithmViewHost.TabIndex = 3;109 this. algorithmViewHost.ViewType = null;110 // 111 // open AlgorithmButton112 // 113 this.open AlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;114 this.open AlgorithmButton.Location = new System.Drawing.Point(36, 6);115 this.open AlgorithmButton.Name = "openAlgorithmButton";116 this.open AlgorithmButton.Size = new System.Drawing.Size(24, 24);117 this.open AlgorithmButton.TabIndex = 1;118 this.toolTip.SetToolTip(this.open AlgorithmButton, "Open Algorithm");119 this.open AlgorithmButton.UseVisualStyleBackColor = true;120 this.open AlgorithmButton.Click += new System.EventHandler(this.openAlgorithmButton_Click);121 // 122 // new AlgorithmButton123 // 124 this.new AlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;125 this.new AlgorithmButton.Location = new System.Drawing.Point(6, 6);126 this.new AlgorithmButton.Name = "newAlgorithmButton";127 this.new AlgorithmButton.Size = new System.Drawing.Size(24, 24);128 this.new AlgorithmButton.TabIndex = 0;129 this.toolTip.SetToolTip(this.new AlgorithmButton, "New Algorithm");130 this.new AlgorithmButton.UseVisualStyleBackColor = true;131 this.new AlgorithmButton.Click += new System.EventHandler(this.newAlgorithmButton_Click);105 this.optimizerViewHost.Location = new System.Drawing.Point(6, 36); 106 this.optimizerViewHost.Name = "optimizerViewHost"; 107 this.optimizerViewHost.Size = new System.Drawing.Size(659, 306); 108 this.optimizerViewHost.TabIndex = 3; 109 this.optimizerViewHost.ViewType = null; 110 // 111 // openOptimizerButton 112 // 113 this.openOptimizerButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open; 114 this.openOptimizerButton.Location = new System.Drawing.Point(36, 6); 115 this.openOptimizerButton.Name = "openOptimizerButton"; 116 this.openOptimizerButton.Size = new System.Drawing.Size(24, 24); 117 this.openOptimizerButton.TabIndex = 1; 118 this.toolTip.SetToolTip(this.openOptimizerButton, "Open Optimizer"); 119 this.openOptimizerButton.UseVisualStyleBackColor = true; 120 this.openOptimizerButton.Click += new System.EventHandler(this.openOptimizerButton_Click); 121 // 122 // newOptimizerButton 123 // 124 this.newOptimizerButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument; 125 this.newOptimizerButton.Location = new System.Drawing.Point(6, 6); 126 this.newOptimizerButton.Name = "newOptimizerButton"; 127 this.newOptimizerButton.Size = new System.Drawing.Size(24, 24); 128 this.newOptimizerButton.TabIndex = 0; 129 this.toolTip.SetToolTip(this.newOptimizerButton, "New Optimizer"); 130 this.newOptimizerButton.UseVisualStyleBackColor = true; 131 this.newOptimizerButton.Click += new System.EventHandler(this.newOptimizerButton_Click); 132 132 // 133 133 // runsTabPage … … 211 211 // 212 212 this.openFileDialog.DefaultExt = "hl"; 213 this.openFileDialog.FileName = " Algorithm";213 this.openFileDialog.FileName = "Optimizer"; 214 214 this.openFileDialog.Filter = "HeuristicLab Files|*.hl|All Files|*.*"; 215 this.openFileDialog.Title = "Open Algorithm";215 this.openFileDialog.Title = "Open Optimizer"; 216 216 // 217 217 // repetitionsLabel … … 293 293 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 294 294 this.tabControl.ResumeLayout(false); 295 this. algorithmTabPage.ResumeLayout(false);295 this.optimizerTabPage.ResumeLayout(false); 296 296 this.runsTabPage.ResumeLayout(false); 297 297 ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit(); … … 303 303 304 304 private System.Windows.Forms.TabControl tabControl; 305 private System.Windows.Forms.TabPage algorithmTabPage;306 private HeuristicLab.MainForm.WindowsForms.ViewHost algorithmViewHost;307 private System.Windows.Forms.Button new AlgorithmButton;308 private System.Windows.Forms.Button open AlgorithmButton;305 private System.Windows.Forms.TabPage optimizerTabPage; 306 private HeuristicLab.MainForm.WindowsForms.ViewHost optimizerViewHost; 307 private System.Windows.Forms.Button newOptimizerButton; 308 private System.Windows.Forms.Button openOptimizerButton; 309 309 private System.Windows.Forms.Button startButton; 310 310 private System.Windows.Forms.Button stopButton; -
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs
r5237 r5300 35 35 [Content(typeof(BatchRun), true)] 36 36 public sealed partial class BatchRunView : NamedItemView { 37 private TypeSelectorDialog algorithmTypeSelectorDialog;37 private TypeSelectorDialog optimizerTypeSelectorDialog; 38 38 39 39 public new BatchRun Content { … … 51 51 protected override void Dispose(bool disposing) { 52 52 if (disposing) { 53 if ( algorithmTypeSelectorDialog != null) algorithmTypeSelectorDialog.Dispose();53 if (optimizerTypeSelectorDialog != null) optimizerTypeSelectorDialog.Dispose(); 54 54 if (components != null) components.Dispose(); 55 55 } … … 58 58 59 59 protected override void DeregisterContentEvents() { 60 Content. AlgorithmChanged -= new EventHandler(Content_AlgorithmChanged);60 Content.OptimizerChanged -= new EventHandler(Content_OptimizerChanged); 61 61 Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred); 62 62 Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged); … … 71 71 protected override void RegisterContentEvents() { 72 72 base.RegisterContentEvents(); 73 Content. AlgorithmChanged += new EventHandler(Content_AlgorithmChanged);73 Content.OptimizerChanged += new EventHandler(Content_OptimizerChanged); 74 74 Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred); 75 75 Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged); … … 86 86 if (Content == null) { 87 87 repetitionsNumericUpDown.Value = 1; 88 algorithmViewHost.Content = null;88 optimizerViewHost.Content = null; 89 89 runsView.Content = null; 90 90 executionTimeTextBox.Text = "-"; … … 92 92 Locked = ReadOnly = Content.ExecutionState == ExecutionState.Started; 93 93 repetitionsNumericUpDown.Value = Content.Repetitions; 94 algorithmViewHost.Content = Content.Algorithm;94 optimizerViewHost.Content = Content.Optimizer; 95 95 runsView.Content = Content.Runs; 96 96 executionTimeTextBox.Text = Content.ExecutionTime.ToString(); … … 100 100 base.SetEnabledStateOfControls(); 101 101 repetitionsNumericUpDown.Enabled = Content != null && !ReadOnly; 102 new AlgorithmButton.Enabled = Content != null && !ReadOnly;103 open AlgorithmButton.Enabled = Content != null && !ReadOnly;104 algorithmViewHost.Enabled = Content != null;102 newOptimizerButton.Enabled = Content != null && !ReadOnly; 103 openOptimizerButton.Enabled = Content != null && !ReadOnly; 104 optimizerViewHost.Enabled = Content != null; 105 105 runsView.Enabled = Content != null; 106 106 executionTimeTextBox.Enabled = Content != null; … … 164 164 ErrorHandling.ShowErrorDialog(this, e.Value); 165 165 } 166 private void Content_ AlgorithmChanged(object sender, EventArgs e) {167 if (InvokeRequired) 168 Invoke(new EventHandler(Content_ AlgorithmChanged), sender, e);169 else { 170 algorithmViewHost.Content = Content.Algorithm;166 private void Content_OptimizerChanged(object sender, EventArgs e) { 167 if (InvokeRequired) 168 Invoke(new EventHandler(Content_OptimizerChanged), sender, e); 169 else { 170 optimizerViewHost.Content = Content.Optimizer; 171 171 } 172 172 } … … 188 188 Content.Repetitions = (int)repetitionsNumericUpDown.Value; 189 189 } 190 private void new AlgorithmButton_Click(object sender, EventArgs e) {191 if ( algorithmTypeSelectorDialog == null) {192 algorithmTypeSelectorDialog = new TypeSelectorDialog();193 algorithmTypeSelectorDialog.Caption = "Select Algorithm";194 algorithmTypeSelectorDialog.TypeSelector.Caption = "Available Algorithms";195 algorithmTypeSelectorDialog.TypeSelector.Configure(typeof(IAlgorithm), false, true);196 } 197 if ( algorithmTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {190 private void newOptimizerButton_Click(object sender, EventArgs e) { 191 if (optimizerTypeSelectorDialog == null) { 192 optimizerTypeSelectorDialog = new TypeSelectorDialog(); 193 optimizerTypeSelectorDialog.Caption = "Select Optimizer"; 194 optimizerTypeSelectorDialog.TypeSelector.Caption = "Available Optimizers"; 195 optimizerTypeSelectorDialog.TypeSelector.Configure(typeof(IOptimizer), false, true); 196 } 197 if (optimizerTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) { 198 198 try { 199 Content. Algorithm = (IAlgorithm)algorithmTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();199 Content.Optimizer = (IOptimizer)optimizerTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 200 200 } 201 201 catch (Exception ex) { … … 204 204 } 205 205 } 206 private void open AlgorithmButton_Click(object sender, EventArgs e) {207 openFileDialog.Title = "Open Algorithm";206 private void openOptimizerButton_Click(object sender, EventArgs e) { 207 openFileDialog.Title = "Open Optimizer"; 208 208 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 209 new AlgorithmButton.Enabled = openAlgorithmButton.Enabled = false;210 algorithmViewHost.Enabled = false;209 newOptimizerButton.Enabled = openOptimizerButton.Enabled = false; 210 optimizerViewHost.Enabled = false; 211 211 212 212 ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) { 213 213 try { 214 214 if (error != null) throw error; 215 I Algorithm algorithm = content as IAlgorithm;216 if ( algorithm== null)217 MessageBox.Show(this, "The selected file does not contain an algorithm.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);215 IOptimizer optimizer = content as IOptimizer; 216 if (optimizer == null) 217 MessageBox.Show(this, "The selected file does not contain an optimizer.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error); 218 218 else 219 Content. Algorithm = algorithm;219 Content.Optimizer = optimizer; 220 220 } 221 221 catch (Exception ex) { … … 224 224 finally { 225 225 Invoke(new Action(delegate() { 226 algorithmViewHost.Enabled = true;227 new AlgorithmButton.Enabled = openAlgorithmButton.Enabled = true;226 optimizerViewHost.Enabled = true; 227 newOptimizerButton.Enabled = openOptimizerButton.Enabled = true; 228 228 })); 229 229 } … … 243 243 Content.Prepare(false); 244 244 } 245 private void algorithmTabPage_DragEnterOver(object sender, DragEventArgs e) {245 private void optimizerTabPage_DragEnterOver(object sender, DragEventArgs e) { 246 246 e.Effect = DragDropEffects.None; 247 247 if (ReadOnly) 248 248 return; 249 249 Type type = e.Data.GetData("Type") as Type; 250 if ((type != null) && (typeof(I Algorithm).IsAssignableFrom(type))) {250 if ((type != null) && (typeof(IOptimizer).IsAssignableFrom(type))) { 251 251 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 252 252 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key … … 256 256 } 257 257 } 258 private void algorithmTabPage_DragDrop(object sender, DragEventArgs e) {258 private void optimizerTabPage_DragDrop(object sender, DragEventArgs e) { 259 259 if (e.Effect != DragDropEffects.None) { 260 I Algorithm algorithm = e.Data.GetData("Value") as IAlgorithm;261 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) algorithm = (IAlgorithm)algorithm.Clone();262 Content. Algorithm = algorithm;260 IOptimizer optimizer = e.Data.GetData("Value") as IOptimizer; 261 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) optimizer = (IOptimizer)optimizer.Clone(); 262 Content.Optimizer = optimizer; 263 263 } 264 264 }
Note: See TracChangeset
for help on using the changeset viewer.