Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/16 20:06:18 (9 years ago)
Author:
abeham
Message:

#2560:

  • Updated clients (moving of all characteristic service methods to run creation service)
  • Adapted OKB problem view to display characteristic values for the instances
File:
1 edited

Legend:

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

    r12012 r13534  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using System.Windows.Forms;
     26using HeuristicLab.Common.Resources;
    2527using HeuristicLab.Core.Views;
     28using HeuristicLab.Data;
    2629using HeuristicLab.MainForm;
    2730
     
    3841    public OKBProblemView() {
    3942      InitializeComponent();
     43      downloadCharacteristicsButton.Text = string.Empty;
     44      downloadCharacteristicsButton.Image = VSImageLibrary.Refresh;
     45      uploadCharacteristicsButton.Text = string.Empty;
     46      uploadCharacteristicsButton.Image = VSImageLibrary.PublishToWeb;
    4047    }
    4148
     
    7380      refreshButton.Enabled = (Content != null) && !ReadOnly && !Locked;
    7481      parameterCollectionView.Enabled = Content != null;
     82      characteristicsMatrixView.Enabled = Content != null;
     83      downloadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked;
     84      uploadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly
     85        && characteristicsMatrixView.Content != null && characteristicsMatrixView.Content.Rows > 0;
    7586    }
    7687
     
    103114      if (InvokeRequired)
    104115        Invoke(new EventHandler(Content_ProblemChanged), sender, e);
    105       else
     116      else {
    106117        OnContentChanged();
     118        SetEnabledStateOfControls();
     119      }
    107120    }
    108121    #endregion
     
    123136      }
    124137    }
     138    private void downloadCharacteristicsButton_Click(object sender, EventArgs e) {
     139      var values = RunCreationClient.GetCharacteristicValues(Content.ProblemId).ToList();
     140      var content = new StringMatrix(values.Count, 3);
     141      for (var i = 0; i < values.Count; i++) {
     142        content[i, 0] = values[i].Name;
     143        content[i, 1] = values[i].ToString();
     144        content[i, 2] = values[i].GetType().Name;
     145      }
     146      characteristicsMatrixView.Content = content;
     147      SetEnabledStateOfControls();
     148    }
     149    private void uploadCharacteristicsButton_Click(object sender, EventArgs e) {
     150      var matrix = characteristicsMatrixView.Content as StringMatrix;
     151      if (matrix == null) return;
     152      var values = new List<Value>(matrix.Rows);
     153      for (var i = 0; i < matrix.Rows; i++) {
     154        var name = matrix[i, 0];
     155        var strValue = matrix[i, 1];
     156        var type = matrix[i, 2];
     157        values.Add(Value.Create(name, strValue, type));
     158      }
     159      try {
     160        RunCreationClient.SetCharacteristicValues(Content.ProblemId, values);
     161      } catch (Exception ex) { PluginInfrastructure.ErrorHandling.ShowErrorDialog(ex); }
     162    }
    125163    #endregion
    126164
Note: See TracChangeset for help on using the changeset viewer.