Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/23/17 11:17:18 (7 years ago)
Author:
abeham
Message:

#2258: merged r14001:15280 from trunk into branch

Location:
branches/Async
Files:
39 edited

Legend:

Unmodified
Added
Removed
  • branches/Async

  • branches/Async/HeuristicLab.Data.Views

  • branches/Async/HeuristicLab.Data.Views/3.3

  • branches/Async/HeuristicLab.Data.Views/3.3/BoolMatrixView.cs

    r12602 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/BoolValueView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/BoolValueView.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/ComparisonView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/ComparisonView.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/DoubleRangeView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/DoubleRangeView.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/EnhancedStringConvertibleMatrixView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/EnhancedStringConvertibleMatrixView.cs

    r15280 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/EnumValueView.Designer.cs

    r12037 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    4747      this.valueLabel = new System.Windows.Forms.Label();
    4848      this.valueComboBox = new System.Windows.Forms.ComboBox();
     49      this.flagsListView = new System.Windows.Forms.ListView();
     50      this.columnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
    4951      this.SuspendLayout();
    5052      //
     
    5456      this.valueLabel.Location = new System.Drawing.Point(3, 3);
    5557      this.valueLabel.Name = "valueLabel";
    56       this.valueLabel.Size = new System.Drawing.Size(56, 13);
     58      this.valueLabel.Size = new System.Drawing.Size(37, 13);
    5759      this.valueLabel.TabIndex = 0;
    5860      this.valueLabel.Text = "&Value:";
     
    6062      // valueComboBox
    6163      //
    62       this.valueComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     64      this.valueComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    6365            | System.Windows.Forms.AnchorStyles.Right)));
    6466      this.valueComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     
    7173      this.valueComboBox.SelectedIndexChanged += new System.EventHandler(this.valueComboBox_SelectedIndexChanged);
    7274      //
     75      // flagsListView
     76      //
     77      this.flagsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     78            | System.Windows.Forms.AnchorStyles.Left)
     79            | System.Windows.Forms.AnchorStyles.Right)));
     80      this.flagsListView.CheckBoxes = true;
     81      this.flagsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
     82            this.columnHeader});
     83      this.flagsListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
     84      this.flagsListView.Location = new System.Drawing.Point(65, 0);
     85      this.flagsListView.Name = "flagsListView";
     86      this.flagsListView.Size = new System.Drawing.Size(212, 21);
     87      this.flagsListView.TabIndex = 2;
     88      this.flagsListView.UseCompatibleStateImageBehavior = false;
     89      this.flagsListView.View = System.Windows.Forms.View.Details;
     90      this.flagsListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.flagsListView_ItemChecked);
     91      //
     92      // columnHeader
     93      //
     94      this.columnHeader.Width = 100;
     95      //
    7396      // EnumValueView
    7497      //
    75       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    7698      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     99      this.Controls.Add(this.flagsListView);
    77100      this.Controls.Add(this.valueComboBox);
    78101      this.Controls.Add(this.valueLabel);
     
    81104      this.ResumeLayout(false);
    82105      this.PerformLayout();
     106
    83107    }
    84108
     
    87111    private System.Windows.Forms.Label valueLabel;
    88112    private System.Windows.Forms.ComboBox valueComboBox;
     113    private System.Windows.Forms.ListView flagsListView;
     114    private System.Windows.Forms.ColumnHeader columnHeader;
    89115  }
    90116}
  • branches/Async/HeuristicLab.Data.Views/3.3/EnumValueView.cs

    r12037 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
     23using System.Windows.Forms;
    2324using HeuristicLab.Core.Views;
    2425using HeuristicLab.MainForm;
     
    4243    }
    4344
     45    static EnumValueView() {
     46      if (!typeof(T).IsEnum)
     47        throw new InvalidOperationException("Generic type " + typeof(T).Name + " is not an enum.");
     48    }
     49
    4450    public EnumValueView() {
    4551      InitializeComponent();
     52      this.Caption = typeof(T).Name + " View";
     53
    4654      valueComboBox.DataSource = Enum.GetValues(typeof(T));
    47       this.Name = typeof(T).Name + "EnumView";
     55      foreach (T flag in Enum.GetValues(typeof(T)))
     56        flagsListView.Items.Add(new ListViewItem(flag.ToString()) { Tag = flag });
     57      columnHeader.Width = -1;
     58
     59      bool isFlags = Attribute.IsDefined(typeof(T), typeof(FlagsAttribute));
     60      if (isFlags) valueLabel.Text = "Flags:";
     61      valueComboBox.Visible = !isFlags;
     62      flagsListView.Visible = isFlags;
    4863    }
    4964    public EnumValueView(EnumValue<T> content)
     
    6479    protected override void OnContentChanged() {
    6580      base.OnContentChanged();
    66       if (Content == null)
    67         valueComboBox.Enabled = false;
    68       else
     81      if (Content == null) {
     82        valueComboBox.SelectedIndex = -1;
     83        foreach (ListViewItem item in flagsListView.Items)
     84          item.Checked = false;
     85      } else {
    6986        valueComboBox.SelectedItem = Content.Value;
     87        foreach (ListViewItem item in flagsListView.Items) {
     88          var flag = (Enum)item.Tag;
     89          item.Checked = ((Enum)(object)Content.Value).HasFlag(flag);
     90        }
     91      }
    7092    }
    7193
    7294    protected override void SetEnabledStateOfControls() {
    7395      base.SetEnabledStateOfControls();
    74       if (Content == null) valueComboBox.Enabled = false;
    75       else valueComboBox.Enabled = !ReadOnly;
     96      if (Content == null) {
     97        valueComboBox.Enabled = false;
     98        flagsListView.Enabled = false;
     99      } else {
     100        valueComboBox.Enabled = !ReadOnly;
     101        flagsListView.Enabled = !ReadOnly;
     102      }
    76103    }
    77104
     
    79106      if (InvokeRequired)
    80107        Invoke(new EventHandler(Content_ValueChanged), sender, e);
    81       else
     108      else {
    82109        valueComboBox.SelectedItem = Content.Value;
     110        foreach (ListViewItem item in flagsListView.Items) {
     111          var flag = (Enum)item.Tag;
     112          item.Checked = ((Enum)(object)Content.Value).HasFlag(flag);
     113        }
     114      }
    83115    }
    84116
     
    87119        Content.Value = (T)valueComboBox.SelectedItem;
    88120    }
     121
     122    private void flagsListView_ItemChecked(object sender, ItemCheckedEventArgs e) {
     123      var flag = (T)e.Item.Tag;
     124      if ((Content != null) && !Content.ReadOnly)
     125        Content.Value = ((Enum)(object)Content.Value).SetFlag(flag, e.Item.Checked);
     126    }
     127  }
     128
     129  internal static class EnumHelper {
     130    //https://stackoverflow.com/a/21581418
     131    public static T SetFlag<T>(this Enum value, T flag, bool set) {
     132      var baseType = Enum.GetUnderlyingType(value.GetType());
     133      dynamic valueAsBase = Convert.ChangeType(value, baseType);
     134      dynamic flagAsBase = Convert.ChangeType(flag, baseType);
     135      if (set)
     136        valueAsBase |= flagAsBase;
     137      else
     138        valueAsBase &= ~flagAsBase;
     139      return (T)valueAsBase;
     140    }
    89141  }
    90142}
  • branches/Async/HeuristicLab.Data.Views/3.3/HeuristicLab.Data.Views-3.3.csproj

    r15280 r15281  
    105105  </PropertyGroup>
    106106  <ItemGroup>
     107    <Reference Include="Microsoft.CSharp" />
    107108    <Reference Include="System" />
    108109    <Reference Include="System.Core">
  • branches/Async/HeuristicLab.Data.Views/3.3/IntRangeView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/IntRangeView.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/Path Views/DirectoryValueView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/Path Views/DirectoryValueView.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/Path Views/FileValueView.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/Path Views/TextFileView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/Path Views/TextFileView.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/Plugin.cs.frame

    r13321 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2929  /// Plugin class for HeuristicLab.Data.Views plugin.
    3030  /// </summary>
    31   [Plugin("HeuristicLab.Data.Views", "3.3.13.$WCREV$")]
     31  [Plugin("HeuristicLab.Data.Views", "3.3.14.$WCREV$")]
    3232  [PluginFile("HeuristicLab.Data.Views-3.3.dll", PluginFileType.Assembly)]
    3333  [PluginDependency("HeuristicLab.Common", "3.3")]
  • branches/Async/HeuristicLab.Data.Views/3.3/Properties/AssemblyInfo.cs.frame

    r13321 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3232[assembly: AssemblyCompany("")]
    3333[assembly: AssemblyProduct("HeuristicLab")]
    34 [assembly: AssemblyCopyright("(c) 2002-2015 HEAL")]
     34[assembly: AssemblyCopyright("(c) 2002-2016 HEAL")]
    3535[assembly: AssemblyTrademark("")]
    3636[assembly: AssemblyCulture("")]
     
    5454// by using the '*' as shown below:
    5555[assembly: AssemblyVersion("3.3.0.0")]
    56 [assembly: AssemblyFileVersion("3.3.13.$WCREV$")]
     56[assembly: AssemblyFileVersion("3.3.14.$WCREV$")]
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    6565      // lengthTextBox
    6666      //
    67       this.lengthTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    68                   | System.Windows.Forms.AnchorStyles.Right)));
     67      this.lengthTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     68            | System.Windows.Forms.AnchorStyles.Right)));
    6969      this.lengthTextBox.Location = new System.Drawing.Point(52, 0);
    7070      this.lengthTextBox.Name = "lengthTextBox";
     
    7979      this.dataGridView.AllowUserToAddRows = false;
    8080      this.dataGridView.AllowUserToDeleteRows = false;
    81       this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    82                   | System.Windows.Forms.AnchorStyles.Left)
    83                   | System.Windows.Forms.AnchorStyles.Right)));
    84       this.dataGridView.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
     81      this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     82            | System.Windows.Forms.AnchorStyles.Left)
     83            | System.Windows.Forms.AnchorStyles.Right)));
     84      this.dataGridView.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable;
    8585      this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
    8686      this.dataGridView.ColumnHeadersVisible = false;
     
    101101      // StringConvertibleArrayView
    102102      //
    103       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    104103      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    105104      this.Controls.Add(this.dataGridView);
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs

    r15280 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.ComponentModel;
    2425using System.Drawing;
     26using System.Linq;
    2527using System.Text;
    2628using System.Windows.Forms;
     
    199201      }
    200202
     203      var elementNames = Content.ElementNames.ToList();
    201204      for (int i = minRowIndex; i <= maxRowIndex; i++) {
    202205        DataGridViewColumn column = dataGridView.Columns.GetFirstColumn(DataGridViewElementStates.Visible);
    203206        DataGridViewCell cell = dataGridView[column.Index, i];
    204207        if (cell.Selected) {
     208          if (i < elementNames.Count) {
     209            s.Append(elementNames[i]);
     210            s.Append("\t");
     211          } else if (elementNames.Count > 0) {
     212            s.Append("Index " + i);
     213            s.Append("\t");
     214          }
    205215          s.Append(Content.GetValue(i));
    206216          s.Append(Environment.NewLine);
     
    210220    }
    211221    private void PasteValuesToDataGridView() {
    212       string[] values = SplitClipboardString(Clipboard.GetText());
     222      Tuple<string, string>[] values = null;
     223      try {
     224        values = SplitClipboardString(Clipboard.GetText()).ToArray();
     225      } catch (ArgumentException ex) {
     226        MessageBox.Show(this, ex.Message, "Error while parsing clipboard text.", MessageBoxButtons.OK, MessageBoxIcon.Error);
     227        return;
     228      }
    213229      int rowIndex = 0;
    214230      if (dataGridView.CurrentCell != null)
     
    216232
    217233      if (Content.Length < rowIndex + values.Length) Content.Length = rowIndex + values.Length;
    218       for (int row = 0; row < values.Length; row++)
    219         Content.SetValue(values[row], row + rowIndex);
    220     }
    221     private string[] SplitClipboardString(string clipboardText) {
     234      for (int row = 0; row < values.Length; row++) {
     235        Content.SetValue(values[row].Item2, row + rowIndex);
     236      }
     237      if (values.Any(x => !string.IsNullOrEmpty(x.Item1))) {
     238        var elementNames = Content.ElementNames.ToList();
     239        for (int row = 0; row < values.Length; row++) {
     240          if (row + rowIndex < elementNames.Count)
     241            elementNames[row + rowIndex] = values[row].Item1;
     242          else elementNames.Add(values[row].Item1);
     243        }
     244        Content.ElementNames = elementNames;
     245      }
     246    }
     247    private IEnumerable<Tuple<string, string>> SplitClipboardString(string clipboardText) {
    222248      if (clipboardText.EndsWith(Environment.NewLine))
    223249        clipboardText = clipboardText.Remove(clipboardText.Length - Environment.NewLine.Length);  //remove last newline constant
    224       return clipboardText.Split(new string[] { Environment.NewLine, "\t" }, StringSplitOptions.None);
     250
     251      var lines = clipboardText.Split(new [] { Environment.NewLine }, StringSplitOptions.None);
     252      var tabSep = new[] { '\t' };
     253      if (lines.Length > 2) {
     254        // Case 1: Each line contains either "elementName \t value" or just "value" (one or two vertical vectors)
     255        foreach (var l in lines) {
     256          var row = l.Split(tabSep, StringSplitOptions.RemoveEmptyEntries);
     257          if (row.Length > 2) throw new ArgumentException("Clipboard may have either at most two rows or at most two columns.");
     258          if (row.Length == 2) yield return Tuple.Create(row[0], row[1]);
     259          else if (row.Length == 1) yield return Tuple.Create(string.Empty, row[0]);
     260          else yield return Tuple.Create(string.Empty, string.Empty);
     261        }
     262      } else if (lines.Length == 2) {
     263        var firstLine = lines[0].Split(tabSep, StringSplitOptions.None);
     264        var secondLine = lines[1].Split(tabSep, StringSplitOptions.None);
     265        if (firstLine.Length <= 2 && secondLine.Length <= 2) {
     266          // Case 2a: The two lines contain either "elementName \t value" or just "value" (one or two vertical vectors)
     267          yield return firstLine.Length >= 2 ? Tuple.Create(firstLine[0], firstLine[1]) : Tuple.Create(string.Empty, firstLine[0]);
     268          yield return secondLine.Length >= 2 ? Tuple.Create(secondLine[0], secondLine[1]) : Tuple.Create(string.Empty, secondLine[0]);
     269        } else {
     270          // Case 2b: The first line contains the elementNames, the second line contains the values (two horizontal vectors)
     271          var max = Math.Max(firstLine.Length, secondLine.Length);
     272          for (var i = 0; i < max; i++) {
     273            var elemName = i < firstLine.Length ? firstLine[i] : string.Empty;
     274            var value = i < secondLine.Length ? secondLine[i] : string.Empty;
     275            yield return Tuple.Create(elemName, value);
     276          }
     277        }
     278      } else if (lines.Length == 1) {
     279        // Case 3: The line contains the values (one horizontal vector)
     280        var entries = lines[0].Split(tabSep, StringSplitOptions.None);
     281        foreach (var e in entries) {
     282          yield return Tuple.Create(string.Empty, e);
     283        }
     284      }
    225285    }
    226286    #endregion
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixColumnVisibilityDialog.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixColumnVisibilityDialog.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixRowVisibilityDialog.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixRowVisibilityDialog.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs

    r15280 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    131131      virtualRowIndices = Enumerable.Range(0, Content.Rows).ToArray();
    132132
    133       if (Content.Columns == 0 && dataGridView.ColumnCount != Content.Columns && !Content.ReadOnly)
    134         Content.Columns = dataGridView.ColumnCount;
    135       else {
    136         DataGridViewColumn[] columns = new DataGridViewColumn[Content.Columns];
    137         for (int i = 0; i < columns.Length; ++i) {
    138           var column = new DataGridViewTextBoxColumn();
    139           column.FillWeight = 1;
    140           columns[i] = column;
    141         }
    142         dataGridView.Columns.Clear();
     133
     134      dataGridView.RowCount = 0;
     135
     136      DataGridViewColumn[] columns = new DataGridViewColumn[Content.Columns];
     137      for (int i = 0; i < columns.Length; ++i) {
     138        var column = new DataGridViewTextBoxColumn();
     139        column.SortMode = DataGridViewColumnSortMode.Programmatic;
     140        column.FillWeight = 1;
     141        columns[i] = column;
     142      }
     143      dataGridView.Columns.Clear();
     144
     145      if (Content.Columns != 0) {
    143146        dataGridView.Columns.AddRange(columns);
    144       }
    145 
    146       //DataGridViews with rows but no columns are not allowed !
    147       if (Content.Rows == 0 && dataGridView.RowCount != Content.Rows && !Content.ReadOnly)
    148         Content.Rows = dataGridView.RowCount;
    149       else
    150147        dataGridView.RowCount = Content.Rows;
    151 
     148      }
    152149
    153150      ClearSorting();
     
    262259
    263260    #region DataGridView Events
     261
    264262    protected virtual void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) {
    265       if (!dataGridView.ReadOnly) {
    266         string errorMessage;
    267         if (Content != null && !Content.Validate(e.FormattedValue.ToString(), out errorMessage)) {
    268           e.Cancel = true;
    269           dataGridView.Rows[e.RowIndex].ErrorText = errorMessage;
    270         }
    271       }
    272     }
     263      if (dataGridView.ReadOnly) return;
     264      if (Content == null) return;
     265      if (Content.Rows <= e.RowIndex || Content.Columns <= e.ColumnIndex) return;
     266
     267      string errorMessage;
     268      if (!Content.Validate(e.FormattedValue.ToString(), out errorMessage)) {
     269        e.Cancel = true;
     270        dataGridView.Rows[e.RowIndex].ErrorText = errorMessage;
     271      }
     272    }
     273
    273274    protected virtual void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) {
    274275      if (!dataGridView.ReadOnly) {
     
    440441      } else
    441442        if (newSortOrder != SortOrder.None)
    442           sortedColumnIndices.Add(new KeyValuePair<int, SortOrder>(columnIndex, newSortOrder));
     443        sortedColumnIndices.Add(new KeyValuePair<int, SortOrder>(columnIndex, newSortOrder));
    443444      Sort();
    444445    }
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixVisibilityDialog.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixVisibilityDialog.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleValueTupleView.Designer.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleValueTupleView.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.Designer.cs

    r15280 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/Async/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.cs

    r12012 r15281  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
Note: See TracChangeset for help on using the changeset viewer.