Ignore:
Timestamp:
03/11/16 15:29:05 (5 years ago)
Author:
abeham
Message:

#2588: Adapted OKBProblemView to include download/upload of solutions

Location:
trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.Designer.cs

    r13666 r13691  
    5252      this.parametersTabPage = new System.Windows.Forms.TabPage();
    5353      this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
     54      this.solutionsTabPage = new System.Windows.Forms.TabPage();
    5455      this.flaAnalysisTabPage = new System.Windows.Forms.TabPage();
     56      this.flaSplitContainer = new System.Windows.Forms.SplitContainer();
    5557      this.calculateButton = new System.Windows.Forms.Button();
    56       this.flaSplitContainer = new System.Windows.Forms.SplitContainer();
    5758      this.characteristicsMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
    5859      this.uploadCharacteristicsButton = new System.Windows.Forms.Button();
    5960      this.downloadCharacteristicsButton = new System.Windows.Forms.Button();
     61      this.solutionsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     62      this.refreshSolutionsButton = new System.Windows.Forms.Button();
     63      this.uploadSolutionsButton = new System.Windows.Forms.Button();
    6064      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6165      this.tabControl.SuspendLayout();
    6266      this.parametersTabPage.SuspendLayout();
     67      this.solutionsTabPage.SuspendLayout();
    6368      this.flaAnalysisTabPage.SuspendLayout();
    6469      ((System.ComponentModel.ISupportInitialize)(this.flaSplitContainer)).BeginInit();
     
    135140            | System.Windows.Forms.AnchorStyles.Right)));
    136141      this.tabControl.Controls.Add(this.parametersTabPage);
     142      this.tabControl.Controls.Add(this.solutionsTabPage);
    137143      this.tabControl.Controls.Add(this.flaAnalysisTabPage);
    138144      this.tabControl.Location = new System.Drawing.Point(6, 53);
     
    148154      this.parametersTabPage.Name = "parametersTabPage";
    149155      this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3);
    150       this.parametersTabPage.Size = new System.Drawing.Size(692, 314);
     156      this.parametersTabPage.Size = new System.Drawing.Size(728, 447);
    151157      this.parametersTabPage.TabIndex = 0;
    152158      this.parametersTabPage.Text = "Parameters";
     
    163169      this.parameterCollectionView.ReadOnly = true;
    164170      this.parameterCollectionView.ShowDetails = true;
    165       this.parameterCollectionView.Size = new System.Drawing.Size(686, 308);
     171      this.parameterCollectionView.Size = new System.Drawing.Size(722, 441);
    166172      this.parameterCollectionView.TabIndex = 8;
     173      //
     174      // solutionsTabPage
     175      //
     176      this.solutionsTabPage.Controls.Add(this.uploadSolutionsButton);
     177      this.solutionsTabPage.Controls.Add(this.refreshSolutionsButton);
     178      this.solutionsTabPage.Controls.Add(this.solutionsViewHost);
     179      this.solutionsTabPage.Location = new System.Drawing.Point(4, 22);
     180      this.solutionsTabPage.Name = "solutionsTabPage";
     181      this.solutionsTabPage.Padding = new System.Windows.Forms.Padding(3);
     182      this.solutionsTabPage.Size = new System.Drawing.Size(728, 447);
     183      this.solutionsTabPage.TabIndex = 3;
     184      this.solutionsTabPage.Text = "Solutions";
     185      this.solutionsTabPage.UseVisualStyleBackColor = true;
    167186      //
    168187      // flaAnalysisTabPage
     
    177196      this.flaAnalysisTabPage.UseVisualStyleBackColor = true;
    178197      //
     198      // flaSplitContainer
     199      //
     200      this.flaSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
     201      this.flaSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
     202      this.flaSplitContainer.Location = new System.Drawing.Point(3, 3);
     203      this.flaSplitContainer.Name = "flaSplitContainer";
     204      //
     205      // flaSplitContainer.Panel1
     206      //
     207      this.flaSplitContainer.Panel1.Controls.Add(this.calculateButton);
     208      //
     209      // flaSplitContainer.Panel2
     210      //
     211      this.flaSplitContainer.Panel2.Controls.Add(this.characteristicsMatrixView);
     212      this.flaSplitContainer.Panel2.Controls.Add(this.uploadCharacteristicsButton);
     213      this.flaSplitContainer.Panel2.Controls.Add(this.downloadCharacteristicsButton);
     214      this.flaSplitContainer.Size = new System.Drawing.Size(722, 441);
     215      this.flaSplitContainer.SplitterDistance = 363;
     216      this.flaSplitContainer.TabIndex = 7;
     217      //
    179218      // calculateButton
    180219      //
     
    186225      this.calculateButton.UseVisualStyleBackColor = true;
    187226      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;
    208227      //
    209228      // characteristicsMatrixView
     
    241260      this.downloadCharacteristicsButton.UseVisualStyleBackColor = true;
    242261      this.downloadCharacteristicsButton.Click += new System.EventHandler(this.downloadCharacteristicsButton_Click);
     262      //
     263      // solutionsViewHost
     264      //
     265      this.solutionsViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     266            | System.Windows.Forms.AnchorStyles.Left)
     267            | System.Windows.Forms.AnchorStyles.Right)));
     268      this.solutionsViewHost.Caption = "View";
     269      this.solutionsViewHost.Content = null;
     270      this.solutionsViewHost.Enabled = false;
     271      this.solutionsViewHost.Location = new System.Drawing.Point(0, 35);
     272      this.solutionsViewHost.Name = "solutionsViewHost";
     273      this.solutionsViewHost.ReadOnly = false;
     274      this.solutionsViewHost.Size = new System.Drawing.Size(728, 412);
     275      this.solutionsViewHost.TabIndex = 0;
     276      this.solutionsViewHost.ViewsLabelVisible = true;
     277      this.solutionsViewHost.ViewType = null;
     278      //
     279      // refreshSolutionsButton
     280      //
     281      this.refreshSolutionsButton.Location = new System.Drawing.Point(6, 6);
     282      this.refreshSolutionsButton.Name = "refreshSolutionsButton";
     283      this.refreshSolutionsButton.Size = new System.Drawing.Size(26, 23);
     284      this.refreshSolutionsButton.TabIndex = 1;
     285      this.refreshSolutionsButton.Text = "Refresh";
     286      this.refreshSolutionsButton.UseVisualStyleBackColor = true;
     287      this.refreshSolutionsButton.Click += new System.EventHandler(this.refreshSolutionsButton_Click);
     288      //
     289      // uploadSolutionsButton
     290      //
     291      this.uploadSolutionsButton.Location = new System.Drawing.Point(38, 6);
     292      this.uploadSolutionsButton.Name = "uploadSolutionsButton";
     293      this.uploadSolutionsButton.Size = new System.Drawing.Size(26, 23);
     294      this.uploadSolutionsButton.TabIndex = 1;
     295      this.uploadSolutionsButton.Text = "Upload";
     296      this.uploadSolutionsButton.UseVisualStyleBackColor = true;
     297      this.uploadSolutionsButton.Click += new System.EventHandler(this.uploadSolutionsButton_Click);
    243298      //
    244299      // OKBProblemView
     
    264319      this.tabControl.ResumeLayout(false);
    265320      this.parametersTabPage.ResumeLayout(false);
     321      this.solutionsTabPage.ResumeLayout(false);
    266322      this.flaAnalysisTabPage.ResumeLayout(false);
    267323      this.flaSplitContainer.Panel1.ResumeLayout(false);
     
    289345    private System.Windows.Forms.Button uploadCharacteristicsButton;
    290346    private System.Windows.Forms.Button downloadCharacteristicsButton;
     347    private System.Windows.Forms.TabPage solutionsTabPage;
     348    private MainForm.WindowsForms.ViewHost solutionsViewHost;
     349    private System.Windows.Forms.Button uploadSolutionsButton;
     350    private System.Windows.Forms.Button refreshSolutionsButton;
    291351
    292352
  • trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.cs

    r13684 r13691  
    7373      uploadCharacteristicsButton.Text = string.Empty;
    7474      uploadCharacteristicsButton.Image = VSImageLibrary.PublishToWeb;
     75      refreshSolutionsButton.Text = string.Empty;
     76      refreshSolutionsButton.Image = VSImageLibrary.Refresh;
     77      uploadSolutionsButton.Text = string.Empty;
     78      uploadSolutionsButton.Image = VSImageLibrary.PublishToWeb;
    7579    }
    7680
     
    9397      base.RegisterContentEvents();
    9498      Content.ProblemChanged += new EventHandler(Content_ProblemChanged);
     99      Content.Solutions.ItemsAdded += SolutionsOnChanged;
     100      Content.Solutions.ItemsReplaced += SolutionsOnChanged;
     101      Content.Solutions.ItemsRemoved += SolutionsOnChanged;
     102      Content.Solutions.CollectionReset += SolutionsOnChanged;
     103    }
     104
     105    private void SolutionsOnChanged(object sender, EventArgs e) {
     106      SetEnabledStateOfControls();
    95107    }
    96108
     
    100112        problemComboBox.SelectedIndex = -1;
    101113        parameterCollectionView.Content = null;
     114        solutionsViewHost.Content = null;
    102115      } else {
    103116        problemComboBox.SelectedItem = RunCreationClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
    104117        parameterCollectionView.Content = Content.Parameters;
     118        solutionsViewHost.Content = Content.Solutions;
    105119      }
    106120      UpdateCharacteristicCalculators();
     
    118132        && characteristicsMatrixView.Content != null && characteristicsMatrixView.Content.Rows > 0;
    119133      calculateButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly && calculatorList.CheckedItems.Any();
     134      refreshSolutionsButton.Enabled = Content != null && !ReadOnly && !Locked && Content.ProblemId != -1;
     135      uploadSolutionsButton.Enabled = Content != null && !ReadOnly && !Locked && Content.ProblemId != -1 && Content.Solutions.Any(x => x.SolutionId == -1);
    120136    }
    121137
     
    217233      }
    218234      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]);
     235      try {
     236        for (var i = 0; i < matrix.Rows; i++) {
     237          Value r;
     238          if (results.TryGetValue(matrix[i, 0], out r)) {
     239            matrix[i, 1] = r.GetValue();
     240            matrix[i, 2] = r.GetType().Name;
     241            results.Remove(matrix[i, 0]);
     242          }
    225243        }
    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;
     244        if (results.Count == 0) return;
     245        var resultsList = results.ToList();
     246        var counter = resultsList.Count - 1;
     247        for (var i = 0; i < matrix.Rows; i++) {
     248          if (string.IsNullOrEmpty(matrix[i, 0])) {
     249            matrix[i, 0] = resultsList[counter].Key;
     250            matrix[i, 1] = resultsList[counter].Value.GetValue();
     251            matrix[i, 2] = resultsList[counter].Value.GetType().Name;
     252            resultsList.RemoveAt(counter);
     253            counter--;
     254            if (counter < 0) return;
     255          }
    238256        }
    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--;
     257        if (counter >= 0) {
     258          ((IStringConvertibleMatrix)matrix).Rows += counter + 1;
     259          for (var i = matrix.Rows - 1; counter >= 0; i--) {
     260            matrix[i, 0] = resultsList[0].Key;
     261            matrix[i, 1] = resultsList[0].Value.GetValue();
     262            matrix[i, 2] = resultsList[0].Value.GetType().Name;
     263            resultsList.RemoveAt(0);
     264            counter--;
     265          }
    248266        }
    249       }
    250       characteristicsMatrixView.Content = matrix;
    251       SetEnabledStateOfControls();
     267      } finally {
     268        characteristicsMatrixView.Content = matrix;
     269        SetEnabledStateOfControls();
     270      }
    252271    }
    253272    #endregion
     
    261280    #endregion
    262281
     282    private void refreshSolutionsButton_Click(object sender, EventArgs e) {
     283      Content.RefreshSolutions();
     284    }
     285
     286    private void uploadSolutionsButton_Click(object sender, EventArgs e) {
     287      foreach (var solution in Content.Solutions.Where(x => x.SolutionId == -1))
     288        solution.Upload();
     289    }
     290
    263291  }
    264292}
Note: See TracChangeset for help on using the changeset viewer.