Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2669


Ignore:
Timestamp:
01/22/10 03:29:02 (15 years ago)
Author:
swagner
Message:

Continued work on adapting and refactoring HeuristicLab.Data according to the changes in HeuristicLab.Core (#95)

Location:
trunk/sources
Files:
4 added
13 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Collections/3.3/IndexedItem.cs

    r2623 r2669  
    4444    public override string ToString() {
    4545      StringBuilder sb = new StringBuilder();
    46       sb.Append("[").Append(index).Append(", ");
     46      sb.Append("[").Append(index).Append(": ");
    4747      if (value != null) sb.Append(value.ToString());
    4848      sb.Append("]");
  • trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemView.cs

    r2664 r2669  
    100100
    101101        // check if variable name was set successfully
    102         e.Cancel = !NamedItemBase.Name.Equals(nameTextBox.Text);
     102        e.Cancel = e.Cancel || !NamedItemBase.Name.Equals(nameTextBox.Text);
    103103        if (e.Cancel) {
    104104          MessageBox.Show(this, "\"" + nameTextBox.Text + "\" is not a valid name.", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
  • trunk/sources/HeuristicLab.Core/3.3/NamedItemCollection.cs

    r2664 r2669  
    114114
    115115    private void Item_NameChanging(object sender, CancelEventArgs<string> e) {
    116       e.Cancel = this.ContainsKey(e.Value);
     116      e.Cancel = e.Cancel || this.ContainsKey(e.Value);
    117117    }
    118118    private void Item_NameChanged(object sender, EventArgs e) {
  • trunk/sources/HeuristicLab.Core/3.3/Parameter.cs

    r2664 r2669  
    6363      return clone;
    6464    }
     65
     66    public override string ToString() {
     67      return string.Format("{0} ({1})", Name, DataType.Name);
     68    }
    6569  }
    6670}
  • trunk/sources/HeuristicLab.Data.Views/3.3/BoolDataView.cs

    r2665 r2669  
    2727using System.Text;
    2828using System.Windows.Forms;
     29using HeuristicLab.Core;
    2930using HeuristicLab.Core.Views;
    3031using HeuristicLab.MainForm;
     
    4849
    4950    protected override void DeregisterObjectEvents() {
    50       BoolData.ValueChanged -= new EventHandler(BoolData_ValueChanged);
     51      BoolData.Changed -= new ChangedEventHandler(BoolData_Changed);
    5152      base.DeregisterObjectEvents();
    5253    }
     
    5455    protected override void RegisterObjectEvents() {
    5556      base.RegisterObjectEvents();
    56       BoolData.ValueChanged += new EventHandler(BoolData_ValueChanged);
     57      BoolData.Changed += new ChangedEventHandler(BoolData_Changed);
    5758    }
    5859
     
    7071    }
    7172
    72     private void BoolData_ValueChanged(object sender, EventArgs e) {
     73    private void BoolData_Changed(object sender, ChangedEventArgs e) {
    7374      if (InvokeRequired)
    74         Invoke(new EventHandler(BoolData_ValueChanged), sender, e);
     75        Invoke(new ChangedEventHandler(BoolData_Changed), sender, e);
    7576      else
    7677        valueCheckBox.Checked = BoolData.Value;
  • trunk/sources/HeuristicLab.Data.Views/3.3/HeuristicLab.Data.Views-3.3.csproj

    r2665 r2669  
    5757      <DependentUpon>BoolDataView.cs</DependentUpon>
    5858    </Compile>
     59    <Compile Include="StringConvertibleArrayDataView.cs">
     60      <SubType>UserControl</SubType>
     61    </Compile>
     62    <Compile Include="StringConvertibleArrayDataView.Designer.cs">
     63      <DependentUpon>StringConvertibleArrayDataView.cs</DependentUpon>
     64    </Compile>
    5965    <Compile Include="StringConvertibleDataView.cs">
    6066      <SubType>UserControl</SubType>
     
    7177  </ItemGroup>
    7278  <ItemGroup>
     79    <ProjectReference Include="..\..\HeuristicLab.Common\3.2\HeuristicLab.Common-3.2.csproj">
     80      <Project>{1FC004FC-59AF-4249-B1B6-FF25873A20E4}</Project>
     81      <Name>HeuristicLab.Common-3.2</Name>
     82    </ProjectReference>
    7383    <ProjectReference Include="..\..\HeuristicLab.Core.Views\3.3\HeuristicLab.Core.Views-3.3.csproj">
    7484      <Project>{E226881D-315F-423D-B419-A766FE0D8685}</Project>
  • trunk/sources/HeuristicLab.Data.Views/3.3/HeuristicLabDataViewsPlugin.cs

    r2663 r2669  
    3131  [Plugin("HeuristicLab.Data.Views-3.3", "")]
    3232  [PluginFile("HeuristicLab.Data.Views-3.3.dll", PluginFileType.Assembly)]
     33  [PluginDependency("HeuristicLab.Common-3.2")]
    3334  [PluginDependency("HeuristicLab.Core-3.3")]
    3435  [PluginDependency("HeuristicLab.Core.Views-3.3")]
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleDataView.cs

    r2665 r2669  
    2727using System.Text;
    2828using System.Windows.Forms;
     29using HeuristicLab.Core;
    2930using HeuristicLab.Core.Views;
    3031using HeuristicLab.MainForm;
     
    4849
    4950    protected override void DeregisterObjectEvents() {
    50       StringConvertibleData.ValueChanged -= new EventHandler(StringConvertibleData_ValueChanged);
     51      StringConvertibleData.Changed -= new ChangedEventHandler(StringConvertibleData_Changed);
    5152      base.DeregisterObjectEvents();
    5253    }
     
    5455    protected override void RegisterObjectEvents() {
    5556      base.RegisterObjectEvents();
    56       StringConvertibleData.ValueChanged += new EventHandler(StringConvertibleData_ValueChanged);
     57      StringConvertibleData.Changed += new ChangedEventHandler(StringConvertibleData_Changed);
    5758    }
    5859
     
    6162      if (StringConvertibleData == null) {
    6263        Caption = "StringConvertibleData View";
    63         valueTextBox.Text = "-";
     64        valueTextBox.Text = string.Empty;
    6465        valueTextBox.Enabled = false;
    6566      } else {
     
    7071    }
    7172
    72     private void StringConvertibleData_ValueChanged(object sender, EventArgs e) {
     73    private void StringConvertibleData_Changed(object sender, ChangedEventArgs e) {
    7374      if (InvokeRequired)
    74         Invoke(new EventHandler(StringConvertibleData_ValueChanged), sender, e);
     75        Invoke(new ChangedEventHandler(StringConvertibleData_Changed), sender, e);
    7576      else
    7677        valueTextBox.Text = StringConvertibleData.GetValue();
     
    7879
    7980    private void valueTextBox_Validating(object sender, CancelEventArgs e) {
    80       e.Cancel = !StringConvertibleData.SetValue(valueTextBox.Text);
     81      e.Cancel = e.Cancel || !StringConvertibleData.SetValue(valueTextBox.Text);
    8182      if (e.Cancel) {
    8283        MessageBox.Show(this, "\"" + valueTextBox.Text + "\" is not a valid value.", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
  • trunk/sources/HeuristicLab.Data/3.3/BoolData.cs

    r2665 r2669  
    3333  public sealed class BoolData : ValueTypeData<bool>, IStringConvertibleData {
    3434    public BoolData() : base() { }
    35     public BoolData(bool value)
    36       : base() {
    37       Value = value;
    38     }
     35    public BoolData(bool value) : base(value) { }
    3936
    4037    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Data/3.3/DateTimeData.cs

    r2665 r2669  
    3333  public sealed class DateTimeData : ValueTypeData<DateTime>, IStringConvertibleData {
    3434    public DateTimeData() : base() { }
    35     public DateTimeData(DateTime value)
    36       : base() {
    37       Value = value;
    38     }
     35    public DateTimeData(DateTime value) : base(value) { }
    3936
    4037    public override IDeepCloneable Clone(Cloner cloner) {
     
    4441    }
    4542
     43    public override string ToString() {
     44      return Value.ToString("o");  // round-trip format
     45    }
     46
    4647    string IStringConvertibleData.GetValue() {
    47       return Value.ToString();
     48      return Value.ToString("o");  // round-trip format
    4849    }
    4950    bool IStringConvertibleData.SetValue(string value) {
  • trunk/sources/HeuristicLab.Data/3.3/DoubleData.cs

    r2665 r2669  
    3333  public sealed class DoubleData : ValueTypeData<double>, IStringConvertibleData {
    3434    public DoubleData() : base() { }
    35     public DoubleData(double value)
    36       : base() {
    37       Value = value;
    38     }
     35    public DoubleData(double value) : base(value) { }
    3936
    4037    public override IDeepCloneable Clone(Cloner cloner) {
     
    4441    }
    4542
     43    public override string ToString() {
     44      return Value.ToString("r");  // round-trip format
     45    }
     46
    4647    string IStringConvertibleData.GetValue() {
    47       return Value.ToString();
     48      return Value.ToString("r");  // round-trip format
    4849    }
    4950    bool IStringConvertibleData.SetValue(string value) {
  • trunk/sources/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj

    r2665 r2669  
    103103      <SubType>Code</SubType>
    104104    </Compile>
    105     <Compile Include="ReferenceTypeData.cs" />
     105    <Compile Include="IStringConvertibleArrayData.cs" />
     106    <Compile Include="ValueTypeArrayData.cs" />
     107    <Compile Include="IntArrayData.cs" />
    106108    <Compile Include="StringData.cs">
    107109      <SubType>Code</SubType>
     
    126128      <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
    127129      <Name>HeuristicLab.Common.Resources-3.2</Name>
     130    </ProjectReference>
     131    <ProjectReference Include="..\..\HeuristicLab.Common\3.2\HeuristicLab.Common-3.2.csproj">
     132      <Project>{1FC004FC-59AF-4249-B1B6-FF25873A20E4}</Project>
     133      <Name>HeuristicLab.Common-3.2</Name>
    128134    </ProjectReference>
    129135    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
  • trunk/sources/HeuristicLab.Data/3.3/HeuristicLabDataPlugin.cs

    r2663 r2669  
    3131  [Plugin("HeuristicLab.Data-3.3", "")]
    3232  [PluginFile("HeuristicLab.Data-3.3.dll", PluginFileType.Assembly)]
     33  [PluginDependency("HeuristicLab.Common-3.2")]
    3334  [PluginDependency("HeuristicLab.Common.Resources-3.2")]
    3435  [PluginDependency("HeuristicLab.Core-3.3")]
  • trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleData.cs

    r2665 r2669  
    2424using System.Text;
    2525using System.Xml;
     26using HeuristicLab.Core;
    2627
    2728namespace HeuristicLab.Data {
     
    3031    bool SetValue(string value);
    3132
    32     event EventHandler ValueChanged;
     33    event ChangedEventHandler Changed;
    3334  }
    3435}
  • trunk/sources/HeuristicLab.Data/3.3/IntArrayData.cs

    r2520 r2669  
    2525using System.Xml;
    2626using HeuristicLab.Core;
    27 using System.Globalization;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2928
    3029namespace HeuristicLab.Data {
    31   /// <summary>
    32   /// The representation of an array of integer values.
    33   /// </summary>
    3430  [EmptyStorableClass]
    35   public class IntArrayData : ArrayDataBase {
    36     /// <summary>
    37     /// Gets or sets the int elements of the array.
    38     /// </summary>
    39     /// <remarks>Uses property <see cref="ArrayDataBase.Data"/> of base class <see cref="ArrayDataBase"/>.
    40     /// No own data storage present.</remarks>
    41     public new int[] Data {
    42       get { return (int[])base.Data; }
    43       set { base.Data = value; }
     31  [Item("IntArrayData", "Represents an array of integer values.")]
     32  [Creatable("Test")]
     33  public sealed class IntArrayData : ValueTypeArrayData<int>, IStringConvertibleArrayData {
     34    public IntArrayData() : base() { }
     35    public IntArrayData(int length) : base(length) { }
     36    public IntArrayData(IntArrayData elements) : base(elements) { }
     37    public IntArrayData(int[] elements) : base(elements) { }
     38
     39    public override IDeepCloneable Clone(Cloner cloner) {
     40      IntArrayData clone = new IntArrayData(this);
     41      cloner.RegisterClonedObject(this, clone);
     42      return clone;
    4443    }
    4544
    46     /// <summary>
    47     /// Initializes a new instance of <see cref="IntArrayData"/>.
    48     /// </summary>
    49     public IntArrayData() {
    50       Data = new int[0];
     45    int IStringConvertibleArrayData.Length {
     46      get { return Length; }
     47      set { Length = value; }
    5148    }
    52     /// <summary>
    53     /// Initializes a new instance of <see cref="IntArrayData"/>.
    54     /// <note type="caution"> No CopyConstructor! <paramref name="data"/> is not copied!</note>
    55     /// </summary>
    56     /// <param name="data">The array of integers to represent.</param>
    57     public IntArrayData(int[] data) {
    58       Data = data;
     49    string IStringConvertibleArrayData.GetValue(int index) {
     50      return this[index].ToString();
    5951    }
    60 
    61     /// <summary>
    62     /// The string representation of the array, formatted according to the given <paramref name="format"/>.
    63     /// </summary>
    64     /// <param name="format">The <see cref="NumberFormatInfo"></see> the single int values
    65     /// should be formatted accordingly.</param>
    66     /// <returns>The elements of the array as string, each element separated by a semicolon
    67     /// and formatted according to the parameter <paramref name="format"/>.</returns>
    68     private string ToString(NumberFormatInfo format) {
    69       StringBuilder builder = new StringBuilder();
    70       for (int i = 0; i < Data.Length; i++) {
    71         builder.Append(";");
    72         builder.Append(Data[i].ToString(format));
     52    bool IStringConvertibleArrayData.SetValue(string value, int index) {
     53      int i;
     54      if (int.TryParse(value, out i)) {
     55        this[index] = i;
     56        return true;
     57      } else {
     58        return false;
    7359      }
    74       if (builder.Length > 0) builder.Remove(0, 1);
    75       return builder.ToString();
    7660    }
    7761  }
  • trunk/sources/HeuristicLab.Data/3.3/IntData.cs

    r2665 r2669  
    3333  public sealed class IntData : ValueTypeData<int>, IStringConvertibleData {
    3434    public IntData() : base() { }
    35     public IntData(int value)
    36       : base() {
    37       Value = value;
    38     }
     35    public IntData(int value) : base(value) { }
    3936
    4037    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Data/3.3/StringData.cs

    r2665 r2669  
    3131  [Item("String", "Represents a string.")]
    3232  [Creatable("Test")]
    33   public sealed class StringData : ReferenceTypeData<string>, IStringConvertibleData {
    34     public StringData() : base() {
    35       Value = string.Empty;
     33  public sealed class StringData : Item, IStringConvertibleData {
     34    [Storable]
     35    private string value;
     36    public string Value {
     37      get { return value; }
     38      set {
     39        if (value != this.value) {
     40          if ((value != null) || (this.value != string.Empty)) {
     41            this.value = value != null ? value : string.Empty;
     42            OnChanged();
     43          }
     44        }
     45      }
    3646    }
    37     public StringData(string value)
    38       : base() {
    39       Value = value;
     47
     48    public StringData() {
     49      this.value = string.Empty;
     50    }
     51    public StringData(string value) {
     52      this.value = value != null ? value : string.Empty;
    4053    }
    4154
     
    4457      cloner.RegisterClonedObject(this, clone);
    4558      return clone;
     59    }
     60
     61    public override string ToString() {
     62      return value;
    4663    }
    4764
  • trunk/sources/HeuristicLab.Data/3.3/TimeSpanData.cs

    r2665 r2669  
    3333  public sealed class TimeSpanData : ValueTypeData<TimeSpan>, IStringConvertibleData {
    3434    public TimeSpanData() : base() { }
    35     public TimeSpanData(TimeSpan value)
    36       : base() {
    37       Value = value;
    38     }
     35    public TimeSpanData(TimeSpan value) : base(value) { }
    3936
    4037    public override IDeepCloneable Clone(Cloner cloner) {
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeData.cs

    r2664 r2669  
    3737        if (!value.Equals(this.value)) {
    3838          this.value = value;
    39           OnValueChanged();
     39          OnChanged();
    4040        }
    4141      }
     
    4343
    4444    public ValueTypeData() {
    45       value = default(T);
     45      this.value = default(T);
     46    }
     47    public ValueTypeData(T value) {
     48      this.value = value;
    4649    }
    4750
     
    5558      return value.ToString();
    5659    }
    57 
    58     public event EventHandler ValueChanged;
    59     protected virtual void OnValueChanged() {
    60       if (ValueChanged != null)
    61         ValueChanged(this, EventArgs.Empty);
    62       OnChanged();
    63     }
    6460  }
    6561}
Note: See TracChangeset for help on using the changeset viewer.