Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/15/11 02:34:08 (13 years ago)
Author:
swagner
Message:

Enabled batch runs to deal with optimizers (#1378)

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  
    3535    private void InitializeComponent() {
    3636      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.openAlgorithmButton = new System.Windows.Forms.Button();
    40       this.newAlgorithmButton = 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();
    4141      this.runsTabPage = new System.Windows.Forms.TabPage();
    4242      this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
     
    5252      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5353      this.tabControl.SuspendLayout();
    54       this.algorithmTabPage.SuspendLayout();
     54      this.optimizerTabPage.SuspendLayout();
    5555      this.runsTabPage.SuspendLayout();
    5656      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
     
    7272                  | System.Windows.Forms.AnchorStyles.Left)
    7373                  | System.Windows.Forms.AnchorStyles.Right)));
    74       this.tabControl.Controls.Add(this.algorithmTabPage);
     74      this.tabControl.Controls.Add(this.optimizerTabPage);
    7575      this.tabControl.Controls.Add(this.runsTabPage);
    7676      this.tabControl.Location = new System.Drawing.Point(0, 78);
     
    8080      this.tabControl.TabIndex = 6;
    8181      //
    82       // algorithmTabPage
    83       //
    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       // algorithmViewHost
    100       //
    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)
    103103                  | System.Windows.Forms.AnchorStyles.Left)
    104104                  | 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       // openAlgorithmButton
    112       //
    113       this.openAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
    114       this.openAlgorithmButton.Location = new System.Drawing.Point(36, 6);
    115       this.openAlgorithmButton.Name = "openAlgorithmButton";
    116       this.openAlgorithmButton.Size = new System.Drawing.Size(24, 24);
    117       this.openAlgorithmButton.TabIndex = 1;
    118       this.toolTip.SetToolTip(this.openAlgorithmButton, "Open Algorithm");
    119       this.openAlgorithmButton.UseVisualStyleBackColor = true;
    120       this.openAlgorithmButton.Click += new System.EventHandler(this.openAlgorithmButton_Click);
    121       //
    122       // newAlgorithmButton
    123       //
    124       this.newAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;
    125       this.newAlgorithmButton.Location = new System.Drawing.Point(6, 6);
    126       this.newAlgorithmButton.Name = "newAlgorithmButton";
    127       this.newAlgorithmButton.Size = new System.Drawing.Size(24, 24);
    128       this.newAlgorithmButton.TabIndex = 0;
    129       this.toolTip.SetToolTip(this.newAlgorithmButton, "New Algorithm");
    130       this.newAlgorithmButton.UseVisualStyleBackColor = true;
    131       this.newAlgorithmButton.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);
    132132      //
    133133      // runsTabPage
     
    211211      //
    212212      this.openFileDialog.DefaultExt = "hl";
    213       this.openFileDialog.FileName = "Algorithm";
     213      this.openFileDialog.FileName = "Optimizer";
    214214      this.openFileDialog.Filter = "HeuristicLab Files|*.hl|All Files|*.*";
    215       this.openFileDialog.Title = "Open Algorithm";
     215      this.openFileDialog.Title = "Open Optimizer";
    216216      //
    217217      // repetitionsLabel
     
    293293      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    294294      this.tabControl.ResumeLayout(false);
    295       this.algorithmTabPage.ResumeLayout(false);
     295      this.optimizerTabPage.ResumeLayout(false);
    296296      this.runsTabPage.ResumeLayout(false);
    297297      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit();
     
    303303
    304304    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 newAlgorithmButton;
    308     private System.Windows.Forms.Button openAlgorithmButton;
     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;
    309309    private System.Windows.Forms.Button startButton;
    310310    private System.Windows.Forms.Button stopButton;
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs

    r5237 r5300  
    3535  [Content(typeof(BatchRun), true)]
    3636  public sealed partial class BatchRunView : NamedItemView {
    37     private TypeSelectorDialog algorithmTypeSelectorDialog;
     37    private TypeSelectorDialog optimizerTypeSelectorDialog;
    3838
    3939    public new BatchRun Content {
     
    5151    protected override void Dispose(bool disposing) {
    5252      if (disposing) {
    53         if (algorithmTypeSelectorDialog != null) algorithmTypeSelectorDialog.Dispose();
     53        if (optimizerTypeSelectorDialog != null) optimizerTypeSelectorDialog.Dispose();
    5454        if (components != null) components.Dispose();
    5555      }
     
    5858
    5959    protected override void DeregisterContentEvents() {
    60       Content.AlgorithmChanged -= new EventHandler(Content_AlgorithmChanged);
     60      Content.OptimizerChanged -= new EventHandler(Content_OptimizerChanged);
    6161      Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    6262      Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
     
    7171    protected override void RegisterContentEvents() {
    7272      base.RegisterContentEvents();
    73       Content.AlgorithmChanged += new EventHandler(Content_AlgorithmChanged);
     73      Content.OptimizerChanged += new EventHandler(Content_OptimizerChanged);
    7474      Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    7575      Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
     
    8686      if (Content == null) {
    8787        repetitionsNumericUpDown.Value = 1;
    88         algorithmViewHost.Content = null;
     88        optimizerViewHost.Content = null;
    8989        runsView.Content = null;
    9090        executionTimeTextBox.Text = "-";
     
    9292        Locked = ReadOnly = Content.ExecutionState == ExecutionState.Started;
    9393        repetitionsNumericUpDown.Value = Content.Repetitions;
    94         algorithmViewHost.Content = Content.Algorithm;
     94        optimizerViewHost.Content = Content.Optimizer;
    9595        runsView.Content = Content.Runs;
    9696        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
     
    100100      base.SetEnabledStateOfControls();
    101101      repetitionsNumericUpDown.Enabled = Content != null && !ReadOnly;
    102       newAlgorithmButton.Enabled = Content != null && !ReadOnly;
    103       openAlgorithmButton.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;
    105105      runsView.Enabled = Content != null;
    106106      executionTimeTextBox.Enabled = Content != null;
     
    164164        ErrorHandling.ShowErrorDialog(this, e.Value);
    165165    }
    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;
    171171      }
    172172    }
     
    188188        Content.Repetitions = (int)repetitionsNumericUpDown.Value;
    189189    }
    190     private void newAlgorithmButton_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) {
    198198        try {
    199           Content.Algorithm = (IAlgorithm)algorithmTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     199          Content.Optimizer = (IOptimizer)optimizerTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    200200        }
    201201        catch (Exception ex) {
     
    204204      }
    205205    }
    206     private void openAlgorithmButton_Click(object sender, EventArgs e) {
    207       openFileDialog.Title = "Open Algorithm";
     206    private void openOptimizerButton_Click(object sender, EventArgs e) {
     207      openFileDialog.Title = "Open Optimizer";
    208208      if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
    209         newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = false;
    210         algorithmViewHost.Enabled = false;
     209        newOptimizerButton.Enabled = openOptimizerButton.Enabled = false;
     210        optimizerViewHost.Enabled = false;
    211211
    212212        ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) {
    213213          try {
    214214            if (error != null) throw error;
    215             IAlgorithm 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);
    218218            else
    219               Content.Algorithm = algorithm;
     219              Content.Optimizer = optimizer;
    220220          }
    221221          catch (Exception ex) {
     
    224224          finally {
    225225            Invoke(new Action(delegate() {
    226               algorithmViewHost.Enabled = true;
    227               newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = true;
     226              optimizerViewHost.Enabled = true;
     227              newOptimizerButton.Enabled = openOptimizerButton.Enabled = true;
    228228            }));
    229229          }
     
    243243      Content.Prepare(false);
    244244    }
    245     private void algorithmTabPage_DragEnterOver(object sender, DragEventArgs e) {
     245    private void optimizerTabPage_DragEnterOver(object sender, DragEventArgs e) {
    246246      e.Effect = DragDropEffects.None;
    247247      if (ReadOnly)
    248248        return;
    249249      Type type = e.Data.GetData("Type") as Type;
    250       if ((type != null) && (typeof(IAlgorithm).IsAssignableFrom(type))) {
     250      if ((type != null) && (typeof(IOptimizer).IsAssignableFrom(type))) {
    251251        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
    252252        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
     
    256256      }
    257257    }
    258     private void algorithmTabPage_DragDrop(object sender, DragEventArgs e) {
     258    private void optimizerTabPage_DragDrop(object sender, DragEventArgs e) {
    259259      if (e.Effect != DragDropEffects.None) {
    260         IAlgorithm 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;
    263263      }
    264264    }
Note: See TracChangeset for help on using the changeset viewer.