Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/23/17 00:52:14 (7 years ago)
Author:
abeham
Message:

#2258: merged r13329:14000 from trunk into branch

Location:
branches/Async
Files:
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/Async

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

    r12012 r15280  
    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.solutionsTabPage = new System.Windows.Forms.TabPage();
     55      this.flaAnalysisTabPage = new System.Windows.Forms.TabPage();
     56      this.flaSplitContainer = new System.Windows.Forms.SplitContainer();
     57      this.calculateButton = new System.Windows.Forms.Button();
     58      this.characteristicsMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
     59      this.uploadCharacteristicsButton = new System.Windows.Forms.Button();
     60      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();
    5264      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     65      this.tabControl.SuspendLayout();
     66      this.parametersTabPage.SuspendLayout();
     67      this.solutionsTabPage.SuspendLayout();
     68      this.flaAnalysisTabPage.SuspendLayout();
     69      ((System.ComponentModel.ISupportInitialize)(this.flaSplitContainer)).BeginInit();
     70      this.flaSplitContainer.Panel1.SuspendLayout();
     71      this.flaSplitContainer.Panel2.SuspendLayout();
     72      this.flaSplitContainer.SuspendLayout();
    5373      this.SuspendLayout();
    5474      //
     
    5878      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    5979      this.nameTextBox.Location = new System.Drawing.Point(72, 27);
    60       this.nameTextBox.Size = new System.Drawing.Size(604, 20);
     80      this.nameTextBox.Size = new System.Drawing.Size(640, 20);
    6181      this.nameTextBox.TabIndex = 5;
    6282      //
     
    6888      // infoLabel
    6989      //
    70       this.infoLabel.Location = new System.Drawing.Point(687, 30);
     90      this.infoLabel.Location = new System.Drawing.Point(723, 30);
    7191      this.infoLabel.TabIndex = 6;
    7292      //
    7393      // problemComboBox
    7494      //
    75       this.problemComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    76                   | System.Windows.Forms.AnchorStyles.Right)));
     95      this.problemComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     96            | System.Windows.Forms.AnchorStyles.Right)));
    7797      this.problemComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    7898      this.problemComboBox.FormattingEnabled = true;
    7999      this.problemComboBox.Location = new System.Drawing.Point(72, 0);
    80100      this.problemComboBox.Name = "problemComboBox";
    81       this.problemComboBox.Size = new System.Drawing.Size(574, 21);
     101      this.problemComboBox.Size = new System.Drawing.Size(610, 21);
    82102      this.problemComboBox.TabIndex = 1;
    83103      this.problemComboBox.SelectedValueChanged += new System.EventHandler(this.problemComboBox_SelectedValueChanged);
     
    95115      //
    96116      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);
     117      this.refreshButton.Location = new System.Drawing.Point(718, -1);
    99118      this.refreshButton.Name = "refreshButton";
    100119      this.refreshButton.Size = new System.Drawing.Size(24, 24);
     
    107126      //
    108127      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);
     128      this.cloneProblemButton.Location = new System.Drawing.Point(688, -1);
    111129      this.cloneProblemButton.Name = "cloneProblemButton";
    112130      this.cloneProblemButton.Size = new System.Drawing.Size(24, 24);
     
    116134      this.cloneProblemButton.Click += new System.EventHandler(this.cloneProblemButton_Click);
    117135      //
     136      // tabControl
     137      //
     138      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     139            | System.Windows.Forms.AnchorStyles.Left)
     140            | System.Windows.Forms.AnchorStyles.Right)));
     141      this.tabControl.Controls.Add(this.parametersTabPage);
     142      this.tabControl.Controls.Add(this.solutionsTabPage);
     143      this.tabControl.Controls.Add(this.flaAnalysisTabPage);
     144      this.tabControl.Location = new System.Drawing.Point(6, 53);
     145      this.tabControl.Name = "tabControl";
     146      this.tabControl.SelectedIndex = 0;
     147      this.tabControl.Size = new System.Drawing.Size(736, 473);
     148      this.tabControl.TabIndex = 8;
     149      //
     150      // parametersTabPage
     151      //
     152      this.parametersTabPage.Controls.Add(this.parameterCollectionView);
     153      this.parametersTabPage.Location = new System.Drawing.Point(4, 22);
     154      this.parametersTabPage.Name = "parametersTabPage";
     155      this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3);
     156      this.parametersTabPage.Size = new System.Drawing.Size(728, 447);
     157      this.parametersTabPage.TabIndex = 0;
     158      this.parametersTabPage.Text = "Parameters";
     159      this.parametersTabPage.UseVisualStyleBackColor = true;
     160      //
    118161      // parameterCollectionView
    119162      //
    120163      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)));
    124164      this.parameterCollectionView.Caption = "ParameterCollection View";
    125165      this.parameterCollectionView.Content = null;
    126       this.parameterCollectionView.Location = new System.Drawing.Point(0, 53);
     166      this.parameterCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;
     167      this.parameterCollectionView.Location = new System.Drawing.Point(3, 3);
    127168      this.parameterCollectionView.Name = "parameterCollectionView";
    128       this.parameterCollectionView.ReadOnly = false;
    129       this.parameterCollectionView.Size = new System.Drawing.Size(706, 340);
    130       this.parameterCollectionView.TabIndex = 7;
     169      this.parameterCollectionView.ReadOnly = true;
     170      this.parameterCollectionView.ShowDetails = true;
     171      this.parameterCollectionView.Size = new System.Drawing.Size(722, 441);
     172      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;
     186      //
     187      // flaAnalysisTabPage
     188      //
     189      this.flaAnalysisTabPage.Controls.Add(this.flaSplitContainer);
     190      this.flaAnalysisTabPage.Location = new System.Drawing.Point(4, 22);
     191      this.flaAnalysisTabPage.Name = "flaAnalysisTabPage";
     192      this.flaAnalysisTabPage.Padding = new System.Windows.Forms.Padding(3);
     193      this.flaAnalysisTabPage.Size = new System.Drawing.Size(728, 447);
     194      this.flaAnalysisTabPage.TabIndex = 2;
     195      this.flaAnalysisTabPage.Text = "Fitness Landscape Analysis";
     196      this.flaAnalysisTabPage.UseVisualStyleBackColor = true;
     197      //
     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      //
     218      // calculateButton
     219      //
     220      this.calculateButton.Location = new System.Drawing.Point(3, 3);
     221      this.calculateButton.Name = "calculateButton";
     222      this.calculateButton.Size = new System.Drawing.Size(26, 23);
     223      this.calculateButton.TabIndex = 8;
     224      this.calculateButton.Text = "Calculate";
     225      this.calculateButton.UseVisualStyleBackColor = true;
     226      this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click);
     227      //
     228      // characteristicsMatrixView
     229      //
     230      this.characteristicsMatrixView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     231            | System.Windows.Forms.AnchorStyles.Left)
     232            | System.Windows.Forms.AnchorStyles.Right)));
     233      this.characteristicsMatrixView.Caption = "StringConvertibleMatrix View";
     234      this.characteristicsMatrixView.Content = null;
     235      this.characteristicsMatrixView.Location = new System.Drawing.Point(3, 32);
     236      this.characteristicsMatrixView.Name = "characteristicsMatrixView";
     237      this.characteristicsMatrixView.ReadOnly = false;
     238      this.characteristicsMatrixView.ShowRowsAndColumnsTextBox = false;
     239      this.characteristicsMatrixView.ShowStatisticalInformation = false;
     240      this.characteristicsMatrixView.Size = new System.Drawing.Size(349, 406);
     241      this.characteristicsMatrixView.TabIndex = 4;
     242      //
     243      // uploadCharacteristicsButton
     244      //
     245      this.uploadCharacteristicsButton.Location = new System.Drawing.Point(35, 3);
     246      this.uploadCharacteristicsButton.Name = "uploadCharacteristicsButton";
     247      this.uploadCharacteristicsButton.Size = new System.Drawing.Size(26, 23);
     248      this.uploadCharacteristicsButton.TabIndex = 5;
     249      this.uploadCharacteristicsButton.Text = "Upload";
     250      this.uploadCharacteristicsButton.UseVisualStyleBackColor = true;
     251      this.uploadCharacteristicsButton.Click += new System.EventHandler(this.uploadCharacteristicsButton_Click);
     252      //
     253      // downloadCharacteristicsButton
     254      //
     255      this.downloadCharacteristicsButton.Location = new System.Drawing.Point(3, 3);
     256      this.downloadCharacteristicsButton.Name = "downloadCharacteristicsButton";
     257      this.downloadCharacteristicsButton.Size = new System.Drawing.Size(26, 23);
     258      this.downloadCharacteristicsButton.TabIndex = 6;
     259      this.downloadCharacteristicsButton.Text = "Download";
     260      this.downloadCharacteristicsButton.UseVisualStyleBackColor = true;
     261      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);
    131298      //
    132299      // OKBProblemView
     
    134301      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    135302      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     303      this.Controls.Add(this.tabControl);
    136304      this.Controls.Add(this.problemComboBox);
    137       this.Controls.Add(this.parameterCollectionView);
    138305      this.Controls.Add(this.problemLabel);
    139306      this.Controls.Add(this.cloneProblemButton);
    140307      this.Controls.Add(this.refreshButton);
    141308      this.Name = "OKBProblemView";
    142       this.Size = new System.Drawing.Size(706, 393);
     309      this.Size = new System.Drawing.Size(742, 526);
    143310      this.Controls.SetChildIndex(this.refreshButton, 0);
    144311      this.Controls.SetChildIndex(this.cloneProblemButton, 0);
    145312      this.Controls.SetChildIndex(this.problemLabel, 0);
    146       this.Controls.SetChildIndex(this.parameterCollectionView, 0);
     313      this.Controls.SetChildIndex(this.problemComboBox, 0);
     314      this.Controls.SetChildIndex(this.tabControl, 0);
    147315      this.Controls.SetChildIndex(this.nameTextBox, 0);
    148316      this.Controls.SetChildIndex(this.nameLabel, 0);
    149317      this.Controls.SetChildIndex(this.infoLabel, 0);
    150       this.Controls.SetChildIndex(this.problemComboBox, 0);
    151318      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     319      this.tabControl.ResumeLayout(false);
     320      this.parametersTabPage.ResumeLayout(false);
     321      this.solutionsTabPage.ResumeLayout(false);
     322      this.flaAnalysisTabPage.ResumeLayout(false);
     323      this.flaSplitContainer.Panel1.ResumeLayout(false);
     324      this.flaSplitContainer.Panel2.ResumeLayout(false);
     325      ((System.ComponentModel.ISupportInitialize)(this.flaSplitContainer)).EndInit();
     326      this.flaSplitContainer.ResumeLayout(false);
    152327      this.ResumeLayout(false);
    153328      this.PerformLayout();
     
    161336    private System.Windows.Forms.Button refreshButton;
    162337    private System.Windows.Forms.Button cloneProblemButton;
    163     private HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView;
     338    private System.Windows.Forms.TabControl tabControl;
     339    private System.Windows.Forms.TabPage parametersTabPage;
     340    private Core.Views.ParameterCollectionView parameterCollectionView;
     341    private System.Windows.Forms.TabPage flaAnalysisTabPage;
     342    private System.Windows.Forms.Button calculateButton;
     343    private System.Windows.Forms.SplitContainer flaSplitContainer;
     344    private Data.Views.StringConvertibleMatrixView characteristicsMatrixView;
     345    private System.Windows.Forms.Button uploadCharacteristicsButton;
     346    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;
    164351
    165352
  • branches/Async/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.cs

    r12012 r15280  
    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      refreshSolutionsButton.Text = string.Empty;
     76      refreshSolutionsButton.Image = VSImageLibrary.Refresh;
     77      uploadSolutionsButton.Text = string.Empty;
     78      uploadSolutionsButton.Image = VSImageLibrary.PublishToWeb;
     79    }
     80
     81    private void CalculatorListOnChanged(object sender, EventArgs e) {
     82      SetEnabledStateOfControls();
    4083    }
    4184
     
    5497      base.RegisterContentEvents();
    5598      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      if (InvokeRequired) { Invoke((Action<object, EventArgs>)SolutionsOnChanged, sender, e); return; }
     107      SetEnabledStateOfControls();
    56108    }
    57109
     
    61113        problemComboBox.SelectedIndex = -1;
    62114        parameterCollectionView.Content = null;
     115        solutionsViewHost.Content = null;
    63116      } else {
    64117        problemComboBox.SelectedItem = RunCreationClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
    65118        parameterCollectionView.Content = Content.Parameters;
    66       }
     119        solutionsViewHost.Content = Content.Solutions;
     120      }
     121      UpdateCharacteristicCalculators();
    67122    }
    68123
     
    73128      refreshButton.Enabled = (Content != null) && !ReadOnly && !Locked;
    74129      parameterCollectionView.Enabled = Content != null;
     130      characteristicsMatrixView.Enabled = Content != null;
     131      downloadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked;
     132      uploadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly
     133        && characteristicsMatrixView.Content != null && characteristicsMatrixView.Content.Rows > 0;
     134      calculateButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly && calculatorList.CheckedItems.Any();
     135      refreshSolutionsButton.Enabled = Content != null && !ReadOnly && !Locked && Content.ProblemId != -1;
     136      uploadSolutionsButton.Enabled = Content != null && !ReadOnly && !Locked && Content.ProblemId != -1 && Content.Solutions.Any(x => x.SolutionId == -1);
    75137    }
    76138
     
    79141      RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed);
    80142      base.OnClosed(e);
     143    }
     144
     145    private void UpdateCharacteristicCalculators() {
     146      calculatorList.Clear();
     147      if (Content == null || Content.ProblemId == -1) return;
     148      var problem = Content.CloneProblem();
     149      var calculators = ApplicationManager.Manager.GetInstances<ICharacteristicCalculator>().ToList();
     150      foreach (var calc in calculators) {
     151        calc.Problem = problem;
     152        if (!calc.CanCalculate()) continue;
     153        calculatorList.Add(calc, true);
     154      }
    81155    }
    82156
     
    103177      if (InvokeRequired)
    104178        Invoke(new EventHandler(Content_ProblemChanged), sender, e);
    105       else
     179      else {
    106180        OnContentChanged();
     181        SetEnabledStateOfControls();
     182      }
    107183    }
    108184    #endregion
     
    123199      }
    124200    }
     201    private void downloadCharacteristicsButton_Click(object sender, EventArgs e) {
     202      var values = RunCreationClient.Instance.GetCharacteristicValues(Content.ProblemId).ToList();
     203      var content = new StringMatrix(values.Count, 3);
     204      for (var i = 0; i < values.Count; i++) {
     205        content[i, 0] = values[i].Name;
     206        content[i, 1] = values[i].GetValue();
     207        content[i, 2] = values[i].GetType().Name;
     208      }
     209      characteristicsMatrixView.Content = content;
     210      SetEnabledStateOfControls();
     211    }
     212    private void uploadCharacteristicsButton_Click(object sender, EventArgs e) {
     213      var matrix = characteristicsMatrixView.Content as StringMatrix;
     214      if (matrix == null) return;
     215      var values = new List<Value>(matrix.Rows);
     216      for (var i = 0; i < matrix.Rows; i++) {
     217        var name = matrix[i, 0];
     218        var strValue = matrix[i, 1];
     219        var type = matrix[i, 2];
     220        values.Add(Value.Create(name, strValue, type));
     221      }
     222      try {
     223        RunCreationClient.Instance.SetCharacteristicValues(Content.ProblemId, values);
     224      } catch (Exception ex) { ErrorHandling.ShowErrorDialog(ex); }
     225    }
     226    private void calculateButton_Click(object sender, EventArgs e) {
     227      var calculators = calculatorList.CheckedItems.Select(x => x.Value).Where(x => x.CanCalculate()).ToList();
     228      if (calculators.Count == 0) return;
     229
     230      var results = new Dictionary<string, Value>();
     231      foreach (var calc in calculators) {
     232        foreach (var result in calc.Calculate())
     233          results[result.Name] = RunCreationClient.Instance.ConvertToValue(result.Value, result.Name);
     234      }
     235      var matrix = (characteristicsMatrixView.Content as StringMatrix) ?? (new StringMatrix(results.Count, 3));
     236      try {
     237        for (var i = 0; i < matrix.Rows; i++) {
     238          Value r;
     239          if (results.TryGetValue(matrix[i, 0], out r)) {
     240            matrix[i, 1] = r.GetValue();
     241            matrix[i, 2] = r.GetType().Name;
     242            results.Remove(matrix[i, 0]);
     243          }
     244        }
     245        if (results.Count == 0) return;
     246        var resultsList = results.ToList();
     247        var counter = resultsList.Count - 1;
     248        for (var i = 0; i < matrix.Rows; i++) {
     249          if (string.IsNullOrEmpty(matrix[i, 0])) {
     250            matrix[i, 0] = resultsList[counter].Key;
     251            matrix[i, 1] = resultsList[counter].Value.GetValue();
     252            matrix[i, 2] = resultsList[counter].Value.GetType().Name;
     253            resultsList.RemoveAt(counter);
     254            counter--;
     255            if (counter < 0) return;
     256          }
     257        }
     258        if (counter >= 0) {
     259          ((IStringConvertibleMatrix)matrix).Rows += counter + 1;
     260          for (var i = matrix.Rows - 1; counter >= 0; i--) {
     261            matrix[i, 0] = resultsList[0].Key;
     262            matrix[i, 1] = resultsList[0].Value.GetValue();
     263            matrix[i, 2] = resultsList[0].Value.GetType().Name;
     264            resultsList.RemoveAt(0);
     265            counter--;
     266          }
     267        }
     268      } finally {
     269        characteristicsMatrixView.Content = matrix;
     270        SetEnabledStateOfControls();
     271      }
     272    }
    125273    #endregion
    126274
     
    132280    }
    133281    #endregion
     282
     283    private void refreshSolutionsButton_Click(object sender, EventArgs e) {
     284      Content.RefreshSolutions();
     285    }
     286
     287    private void uploadSolutionsButton_Click(object sender, EventArgs e) {
     288      foreach (var solution in Content.Solutions.Where(x => x.SolutionId == -1))
     289        solution.Upload();
     290      SetEnabledStateOfControls();
     291    }
     292
    134293  }
    135294}
Note: See TracChangeset for help on using the changeset viewer.