Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/28/17 22:10:45 (7 years ago)
Author:
gkronber
Message:

#2560 merged r13501, r13503, r13511, r13513, r13534, r13535, r13540, r13550, r13552, r13593, r13666 from trunk to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.Designer.cs

    r14186 r15081  
    4949      this.refreshButton = new System.Windows.Forms.Button();
    5050      this.cloneProblemButton = new System.Windows.Forms.Button();
     51      this.tabControl = new System.Windows.Forms.TabControl();
     52      this.parametersTabPage = new System.Windows.Forms.TabPage();
    5153      this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
     54      this.flaAnalysisTabPage = new System.Windows.Forms.TabPage();
     55      this.calculateButton = new System.Windows.Forms.Button();
     56      this.flaSplitContainer = new System.Windows.Forms.SplitContainer();
     57      this.characteristicsMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
     58      this.uploadCharacteristicsButton = new System.Windows.Forms.Button();
     59      this.downloadCharacteristicsButton = new System.Windows.Forms.Button();
    5260      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     61      this.tabControl.SuspendLayout();
     62      this.parametersTabPage.SuspendLayout();
     63      this.flaAnalysisTabPage.SuspendLayout();
     64      ((System.ComponentModel.ISupportInitialize)(this.flaSplitContainer)).BeginInit();
     65      this.flaSplitContainer.Panel1.SuspendLayout();
     66      this.flaSplitContainer.Panel2.SuspendLayout();
     67      this.flaSplitContainer.SuspendLayout();
    5368      this.SuspendLayout();
    5469      //
     
    5873      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    5974      this.nameTextBox.Location = new System.Drawing.Point(72, 27);
    60       this.nameTextBox.Size = new System.Drawing.Size(604, 20);
     75      this.nameTextBox.Size = new System.Drawing.Size(640, 20);
    6176      this.nameTextBox.TabIndex = 5;
    6277      //
     
    6883      // infoLabel
    6984      //
    70       this.infoLabel.Location = new System.Drawing.Point(687, 30);
     85      this.infoLabel.Location = new System.Drawing.Point(723, 30);
    7186      this.infoLabel.TabIndex = 6;
    7287      //
    7388      // problemComboBox
    7489      //
    75       this.problemComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    76                   | System.Windows.Forms.AnchorStyles.Right)));
     90      this.problemComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     91            | System.Windows.Forms.AnchorStyles.Right)));
    7792      this.problemComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    7893      this.problemComboBox.FormattingEnabled = true;
    7994      this.problemComboBox.Location = new System.Drawing.Point(72, 0);
    8095      this.problemComboBox.Name = "problemComboBox";
    81       this.problemComboBox.Size = new System.Drawing.Size(574, 21);
     96      this.problemComboBox.Size = new System.Drawing.Size(610, 21);
    8297      this.problemComboBox.TabIndex = 1;
    8398      this.problemComboBox.SelectedValueChanged += new System.EventHandler(this.problemComboBox_SelectedValueChanged);
     
    95110      //
    96111      this.refreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    97       this.refreshButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh;
    98       this.refreshButton.Location = new System.Drawing.Point(682, -1);
     112      this.refreshButton.Location = new System.Drawing.Point(718, -1);
    99113      this.refreshButton.Name = "refreshButton";
    100114      this.refreshButton.Size = new System.Drawing.Size(24, 24);
     
    107121      //
    108122      this.cloneProblemButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    109       this.cloneProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Clone;
    110       this.cloneProblemButton.Location = new System.Drawing.Point(652, -1);
     123      this.cloneProblemButton.Location = new System.Drawing.Point(688, -1);
    111124      this.cloneProblemButton.Name = "cloneProblemButton";
    112125      this.cloneProblemButton.Size = new System.Drawing.Size(24, 24);
     
    116129      this.cloneProblemButton.Click += new System.EventHandler(this.cloneProblemButton_Click);
    117130      //
     131      // tabControl
     132      //
     133      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     134            | System.Windows.Forms.AnchorStyles.Left)
     135            | System.Windows.Forms.AnchorStyles.Right)));
     136      this.tabControl.Controls.Add(this.parametersTabPage);
     137      this.tabControl.Controls.Add(this.flaAnalysisTabPage);
     138      this.tabControl.Location = new System.Drawing.Point(6, 53);
     139      this.tabControl.Name = "tabControl";
     140      this.tabControl.SelectedIndex = 0;
     141      this.tabControl.Size = new System.Drawing.Size(736, 473);
     142      this.tabControl.TabIndex = 8;
     143      //
     144      // parametersTabPage
     145      //
     146      this.parametersTabPage.Controls.Add(this.parameterCollectionView);
     147      this.parametersTabPage.Location = new System.Drawing.Point(4, 22);
     148      this.parametersTabPage.Name = "parametersTabPage";
     149      this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3);
     150      this.parametersTabPage.Size = new System.Drawing.Size(692, 314);
     151      this.parametersTabPage.TabIndex = 0;
     152      this.parametersTabPage.Text = "Parameters";
     153      this.parametersTabPage.UseVisualStyleBackColor = true;
     154      //
    118155      // parameterCollectionView
    119156      //
    120157      this.parameterCollectionView.AllowEditingOfHiddenParameters = false;
    121       this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    122                   | System.Windows.Forms.AnchorStyles.Left)
    123                   | System.Windows.Forms.AnchorStyles.Right)));
    124158      this.parameterCollectionView.Caption = "ParameterCollection View";
    125159      this.parameterCollectionView.Content = null;
    126       this.parameterCollectionView.Location = new System.Drawing.Point(0, 53);
     160      this.parameterCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;
     161      this.parameterCollectionView.Location = new System.Drawing.Point(3, 3);
    127162      this.parameterCollectionView.Name = "parameterCollectionView";
    128       this.parameterCollectionView.ReadOnly = false;
    129       this.parameterCollectionView.Size = new System.Drawing.Size(706, 340);
    130       this.parameterCollectionView.TabIndex = 7;
     163      this.parameterCollectionView.ReadOnly = true;
     164      this.parameterCollectionView.ShowDetails = true;
     165      this.parameterCollectionView.Size = new System.Drawing.Size(686, 308);
     166      this.parameterCollectionView.TabIndex = 8;
     167      //
     168      // flaAnalysisTabPage
     169      //
     170      this.flaAnalysisTabPage.Controls.Add(this.flaSplitContainer);
     171      this.flaAnalysisTabPage.Location = new System.Drawing.Point(4, 22);
     172      this.flaAnalysisTabPage.Name = "flaAnalysisTabPage";
     173      this.flaAnalysisTabPage.Padding = new System.Windows.Forms.Padding(3);
     174      this.flaAnalysisTabPage.Size = new System.Drawing.Size(728, 447);
     175      this.flaAnalysisTabPage.TabIndex = 2;
     176      this.flaAnalysisTabPage.Text = "Fitness Landscape Analysis";
     177      this.flaAnalysisTabPage.UseVisualStyleBackColor = true;
     178      //
     179      // calculateButton
     180      //
     181      this.calculateButton.Location = new System.Drawing.Point(3, 3);
     182      this.calculateButton.Name = "calculateButton";
     183      this.calculateButton.Size = new System.Drawing.Size(26, 23);
     184      this.calculateButton.TabIndex = 8;
     185      this.calculateButton.Text = "Calculate";
     186      this.calculateButton.UseVisualStyleBackColor = true;
     187      this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click);
     188      //
     189      // flaSplitContainer
     190      //
     191      this.flaSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
     192      this.flaSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
     193      this.flaSplitContainer.Location = new System.Drawing.Point(3, 3);
     194      this.flaSplitContainer.Name = "flaSplitContainer";
     195      //
     196      // flaSplitContainer.Panel1
     197      //
     198      this.flaSplitContainer.Panel1.Controls.Add(this.calculateButton);
     199      //
     200      // flaSplitContainer.Panel2
     201      //
     202      this.flaSplitContainer.Panel2.Controls.Add(this.characteristicsMatrixView);
     203      this.flaSplitContainer.Panel2.Controls.Add(this.uploadCharacteristicsButton);
     204      this.flaSplitContainer.Panel2.Controls.Add(this.downloadCharacteristicsButton);
     205      this.flaSplitContainer.Size = new System.Drawing.Size(722, 441);
     206      this.flaSplitContainer.SplitterDistance = 363;
     207      this.flaSplitContainer.TabIndex = 7;
     208      //
     209      // characteristicsMatrixView
     210      //
     211      this.characteristicsMatrixView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     212            | System.Windows.Forms.AnchorStyles.Left)
     213            | System.Windows.Forms.AnchorStyles.Right)));
     214      this.characteristicsMatrixView.Caption = "StringConvertibleMatrix View";
     215      this.characteristicsMatrixView.Content = null;
     216      this.characteristicsMatrixView.Location = new System.Drawing.Point(3, 32);
     217      this.characteristicsMatrixView.Name = "characteristicsMatrixView";
     218      this.characteristicsMatrixView.ReadOnly = false;
     219      this.characteristicsMatrixView.ShowRowsAndColumnsTextBox = false;
     220      this.characteristicsMatrixView.ShowStatisticalInformation = false;
     221      this.characteristicsMatrixView.Size = new System.Drawing.Size(349, 406);
     222      this.characteristicsMatrixView.TabIndex = 4;
     223      //
     224      // uploadCharacteristicsButton
     225      //
     226      this.uploadCharacteristicsButton.Location = new System.Drawing.Point(35, 3);
     227      this.uploadCharacteristicsButton.Name = "uploadCharacteristicsButton";
     228      this.uploadCharacteristicsButton.Size = new System.Drawing.Size(26, 23);
     229      this.uploadCharacteristicsButton.TabIndex = 5;
     230      this.uploadCharacteristicsButton.Text = "Upload";
     231      this.uploadCharacteristicsButton.UseVisualStyleBackColor = true;
     232      this.uploadCharacteristicsButton.Click += new System.EventHandler(this.uploadCharacteristicsButton_Click);
     233      //
     234      // downloadCharacteristicsButton
     235      //
     236      this.downloadCharacteristicsButton.Location = new System.Drawing.Point(3, 3);
     237      this.downloadCharacteristicsButton.Name = "downloadCharacteristicsButton";
     238      this.downloadCharacteristicsButton.Size = new System.Drawing.Size(26, 23);
     239      this.downloadCharacteristicsButton.TabIndex = 6;
     240      this.downloadCharacteristicsButton.Text = "Download";
     241      this.downloadCharacteristicsButton.UseVisualStyleBackColor = true;
     242      this.downloadCharacteristicsButton.Click += new System.EventHandler(this.downloadCharacteristicsButton_Click);
    131243      //
    132244      // OKBProblemView
     
    134246      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    135247      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     248      this.Controls.Add(this.tabControl);
    136249      this.Controls.Add(this.problemComboBox);
    137       this.Controls.Add(this.parameterCollectionView);
    138250      this.Controls.Add(this.problemLabel);
    139251      this.Controls.Add(this.cloneProblemButton);
    140252      this.Controls.Add(this.refreshButton);
    141253      this.Name = "OKBProblemView";
    142       this.Size = new System.Drawing.Size(706, 393);
     254      this.Size = new System.Drawing.Size(742, 526);
    143255      this.Controls.SetChildIndex(this.refreshButton, 0);
    144256      this.Controls.SetChildIndex(this.cloneProblemButton, 0);
    145257      this.Controls.SetChildIndex(this.problemLabel, 0);
    146       this.Controls.SetChildIndex(this.parameterCollectionView, 0);
     258      this.Controls.SetChildIndex(this.problemComboBox, 0);
     259      this.Controls.SetChildIndex(this.tabControl, 0);
    147260      this.Controls.SetChildIndex(this.nameTextBox, 0);
    148261      this.Controls.SetChildIndex(this.nameLabel, 0);
    149262      this.Controls.SetChildIndex(this.infoLabel, 0);
    150       this.Controls.SetChildIndex(this.problemComboBox, 0);
    151263      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     264      this.tabControl.ResumeLayout(false);
     265      this.parametersTabPage.ResumeLayout(false);
     266      this.flaAnalysisTabPage.ResumeLayout(false);
     267      this.flaSplitContainer.Panel1.ResumeLayout(false);
     268      this.flaSplitContainer.Panel2.ResumeLayout(false);
     269      ((System.ComponentModel.ISupportInitialize)(this.flaSplitContainer)).EndInit();
     270      this.flaSplitContainer.ResumeLayout(false);
    152271      this.ResumeLayout(false);
    153272      this.PerformLayout();
     
    161280    private System.Windows.Forms.Button refreshButton;
    162281    private System.Windows.Forms.Button cloneProblemButton;
    163     private HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView;
     282    private System.Windows.Forms.TabControl tabControl;
     283    private System.Windows.Forms.TabPage parametersTabPage;
     284    private Core.Views.ParameterCollectionView parameterCollectionView;
     285    private System.Windows.Forms.TabPage flaAnalysisTabPage;
     286    private System.Windows.Forms.Button calculateButton;
     287    private System.Windows.Forms.SplitContainer flaSplitContainer;
     288    private Data.Views.StringConvertibleMatrixView characteristicsMatrixView;
     289    private System.Windows.Forms.Button uploadCharacteristicsButton;
     290    private System.Windows.Forms.Button downloadCharacteristicsButton;
    164291
    165292
  • stable/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.cs

    r14186 r15081  
    2020#endregion
    2121
     22using HeuristicLab.Common.Resources;
     23using HeuristicLab.Core;
     24using HeuristicLab.Core.Views;
     25using HeuristicLab.Data;
     26using HeuristicLab.MainForm;
     27using HeuristicLab.Optimization;
     28using HeuristicLab.PluginInfrastructure;
    2229using System;
     30using System.Collections.Generic;
     31using System.Drawing;
    2332using System.Linq;
    2433using System.Windows.Forms;
    25 using HeuristicLab.Core.Views;
    26 using HeuristicLab.MainForm;
    2734
    2835namespace HeuristicLab.Clients.OKB.RunCreation {
     
    3138  [Content(typeof(MultiObjectiveOKBProblem), true)]
    3239  public sealed partial class OKBProblemView : NamedItemView {
     40    private readonly CheckedItemList<ICharacteristicCalculator> calculatorList;
     41
    3342    public new OKBProblem Content {
    3443      get { return (OKBProblem)base.Content; }
     
    3847    public OKBProblemView() {
    3948      InitializeComponent();
     49      var calculatorListView = new CheckedItemListView<ICharacteristicCalculator>() {
     50        Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top,
     51        Location = new Point(flaSplitContainer.Padding.Left, calculateButton.Location.Y + calculateButton.Height + calculateButton.Padding.Bottom + 3),
     52      };
     53      calculatorListView.Size = new Size(flaSplitContainer.Panel1.Size.Width - flaSplitContainer.Panel1.Padding.Horizontal,
     54          flaSplitContainer.Panel1.Height - calculatorListView.Location.Y - flaSplitContainer.Panel1.Padding.Bottom);
     55      calculatorList = new CheckedItemList<ICharacteristicCalculator>();
     56      calculatorList.ItemsAdded += CalculatorListOnChanged;
     57      calculatorList.ItemsRemoved += CalculatorListOnChanged;
     58      calculatorList.ItemsReplaced += CalculatorListOnChanged;
     59      calculatorList.CollectionReset += CalculatorListOnChanged;
     60      calculatorList.CheckedItemsChanged += CalculatorListOnChanged;
     61
     62      calculatorListView.Content = calculatorList.AsReadOnly();
     63
     64      flaSplitContainer.Panel1.Controls.Add(calculatorListView);
     65      calculateButton.Text = string.Empty;
     66      calculateButton.Image = VSImageLibrary.Play;
     67      refreshButton.Text = string.Empty;
     68      refreshButton.Image = VSImageLibrary.Refresh;
     69      cloneProblemButton.Text = string.Empty;
     70      cloneProblemButton.Image = VSImageLibrary.Clone;
     71      downloadCharacteristicsButton.Text = string.Empty;
     72      downloadCharacteristicsButton.Image = VSImageLibrary.Refresh;
     73      uploadCharacteristicsButton.Text = string.Empty;
     74      uploadCharacteristicsButton.Image = VSImageLibrary.PublishToWeb;
     75    }
     76
     77    private void CalculatorListOnChanged(object sender, EventArgs e) {
     78      SetEnabledStateOfControls();
    4079    }
    4180
     
    65104        parameterCollectionView.Content = Content.Parameters;
    66105      }
     106      UpdateCharacteristicCalculators();
    67107    }
    68108
     
    73113      refreshButton.Enabled = (Content != null) && !ReadOnly && !Locked;
    74114      parameterCollectionView.Enabled = Content != null;
     115      characteristicsMatrixView.Enabled = Content != null;
     116      downloadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked;
     117      uploadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly
     118        && characteristicsMatrixView.Content != null && characteristicsMatrixView.Content.Rows > 0;
     119      calculateButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly && calculatorList.CheckedItems.Any();
    75120    }
    76121
     
    79124      RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed);
    80125      base.OnClosed(e);
     126    }
     127
     128    private void UpdateCharacteristicCalculators() {
     129      calculatorList.Clear();
     130      if (Content == null || Content.ProblemId == -1) return;
     131      var problem = Content.CloneProblem();
     132      var calculators = ApplicationManager.Manager.GetInstances<ICharacteristicCalculator>().ToList();
     133      foreach (var calc in calculators) {
     134        calc.Problem = problem;
     135        if (!calc.CanCalculate()) continue;
     136        calculatorList.Add(calc, true);
     137      }
    81138    }
    82139
     
    103160      if (InvokeRequired)
    104161        Invoke(new EventHandler(Content_ProblemChanged), sender, e);
    105       else
     162      else {
    106163        OnContentChanged();
     164        SetEnabledStateOfControls();
     165      }
    107166    }
    108167    #endregion
     
    123182      }
    124183    }
     184    private void downloadCharacteristicsButton_Click(object sender, EventArgs e) {
     185      var values = RunCreationClient.GetCharacteristicValues(Content.ProblemId).ToList();
     186      var content = new StringMatrix(values.Count, 3);
     187      for (var i = 0; i < values.Count; i++) {
     188        content[i, 0] = values[i].Name;
     189        content[i, 1] = values[i].GetValue();
     190        content[i, 2] = values[i].GetType().Name;
     191      }
     192      characteristicsMatrixView.Content = content;
     193      SetEnabledStateOfControls();
     194    }
     195    private void uploadCharacteristicsButton_Click(object sender, EventArgs e) {
     196      var matrix = characteristicsMatrixView.Content as StringMatrix;
     197      if (matrix == null) return;
     198      var values = new List<Value>(matrix.Rows);
     199      for (var i = 0; i < matrix.Rows; i++) {
     200        var name = matrix[i, 0];
     201        var strValue = matrix[i, 1];
     202        var type = matrix[i, 2];
     203        values.Add(Value.Create(name, strValue, type));
     204      }
     205      try {
     206        RunCreationClient.SetCharacteristicValues(Content.ProblemId, values);
     207      } catch (Exception ex) { ErrorHandling.ShowErrorDialog(ex); }
     208    }
     209    private void calculateButton_Click(object sender, EventArgs e) {
     210      var calculators = calculatorList.CheckedItems.Select(x => x.Value).Where(x => x.CanCalculate()).ToList();
     211      if (calculators.Count == 0) return;
     212
     213      var results = new Dictionary<string, Value>();
     214      foreach (var calc in calculators) {
     215        foreach (var result in calc.Calculate())
     216          results[result.Name] = RunCreationClient.Instance.ConvertToValue(result.Value, result.Name);
     217      }
     218      var matrix = (characteristicsMatrixView.Content as StringMatrix) ?? (new StringMatrix(results.Count, 3));
     219      for (var i = 0; i < matrix.Rows; i++) {
     220        Value r;
     221        if (results.TryGetValue(matrix[i, 0], out r)) {
     222          matrix[i, 1] = r.GetValue();
     223          matrix[i, 2] = r.GetType().Name;
     224          results.Remove(matrix[i, 0]);
     225        }
     226      }
     227      if (results.Count == 0) return;
     228      var resultsList = results.ToList();
     229      var counter = resultsList.Count - 1;
     230      for (var i = 0; i < matrix.Rows; i++) {
     231        if (string.IsNullOrEmpty(matrix[i, 0])) {
     232          matrix[i, 0] = resultsList[counter].Key;
     233          matrix[i, 1] = resultsList[counter].Value.GetValue();
     234          matrix[i, 2] = resultsList[counter].Value.GetType().Name;
     235          resultsList.RemoveAt(counter);
     236          counter--;
     237          if (counter < 0) return;
     238        }
     239      }
     240      if (counter >= 0) {
     241        ((IStringConvertibleMatrix)matrix).Rows += counter + 1;
     242        for (var i = matrix.Rows - 1; counter >= 0; i--) {
     243          matrix[i, 0] = resultsList[0].Key;
     244          matrix[i, 1] = resultsList[0].Value.GetValue();
     245          matrix[i, 2] = resultsList[0].Value.GetType().Name;
     246          resultsList.RemoveAt(0);
     247          counter--;
     248        }
     249      }
     250      characteristicsMatrixView.Content = matrix;
     251      SetEnabledStateOfControls();
     252    }
    125253    #endregion
    126254
     
    132260    }
    133261    #endregion
     262
    134263  }
    135264}
Note: See TracChangeset for help on using the changeset viewer.