Пример #1
0
        /// <summary>
        /// Transpose transpose the table, i.e. exchange columns and rows
        /// this can only work if all columns in the table are of the same type
        /// </summary>
        /// <param name="numberOfDataColumnsChangeToPropertyColumns">Number of data columns that are changed to property columns before transposing the table.</param>
        /// <param name="numberOfPropertyColumnsChangeToDataColumns">Number of property columns that are changed to data columns before transposing the table.</param>
        /// <returns>null if succeeded, error string otherwise</returns>
        public virtual string Transpose(int numberOfDataColumnsChangeToPropertyColumns, int numberOfPropertyColumnsChangeToDataColumns)
        {
            numberOfDataColumnsChangeToPropertyColumns = Math.Max(numberOfDataColumnsChangeToPropertyColumns, 0);
            numberOfDataColumnsChangeToPropertyColumns = Math.Min(numberOfDataColumnsChangeToPropertyColumns, this.DataColumnCount);

            numberOfPropertyColumnsChangeToDataColumns = Math.Max(numberOfPropertyColumnsChangeToDataColumns, 0);
            numberOfPropertyColumnsChangeToDataColumns = Math.Min(numberOfPropertyColumnsChangeToDataColumns, this.PropertyColumnCount);

            // first, save the first data columns that are changed to property columns
            Altaxo.Data.DataColumnCollection savedDataColumns = new DataColumnCollection();
            Altaxo.Data.DataColumnCollection savedPropColumns = new DataColumnCollection();

            Altaxo.Collections.IAscendingIntegerCollection savedDataColIndices = new Altaxo.Collections.IntegerRangeAsCollection(0, numberOfDataColumnsChangeToPropertyColumns);
            Altaxo.Collections.IAscendingIntegerCollection savedPropColIndices = new Altaxo.Collections.IntegerRangeAsCollection(0, numberOfPropertyColumnsChangeToDataColumns);
            // store the columns temporarily in another collection and remove them from the original collections
            DataColumns.MoveColumnsTo(savedDataColumns, 0, savedDataColIndices);
            this.PropertyColumns.MoveColumnsTo(savedPropColumns, 0, savedPropColIndices);

            // now transpose the data columns
            _dataColumns.Transpose();

            savedDataColumns.InsertRows(0, numberOfPropertyColumnsChangeToDataColumns); // take offset caused by newly inserted prop columns->data columns into account
            savedDataColumns.MoveColumnsTo(this.PropertyColumns, 0, savedDataColIndices);

            savedPropColumns.RemoveRows(0, numberOfDataColumnsChangeToPropertyColumns); // take offset caused by data columns changed to property columns into account
            savedPropColumns.MoveColumnsTo(this.DataColumns, 0, savedPropColIndices);

            // now insert both the temporary stored DataColumnCollections at the beginning

            return(null); // no error message
        }
Пример #2
0
            public void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                IntegerRangeAsCollection s = (IntegerRangeAsCollection)obj;

                info.AddValue("Start", s._start);
                info.AddValue("Count", s._count);
            }
Пример #3
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                IntegerRangeAsCollection s = null != o ? (IntegerRangeAsCollection)o : new IntegerRangeAsCollection();

                s._start = info.GetInt32("Start");
                s._count = info.GetInt32("Count");

                return(s);
            }
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="from">Object from which to copy the data.</param>
 public IntegerRangeAsCollection(IntegerRangeAsCollection from)
 {
   this._start = from._start;
   this._count = from._count;
 }
Пример #5
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="from">Object from which to copy the data.</param>
 public IntegerRangeAsCollection(IntegerRangeAsCollection from)
 {
     this._start = from._start;
     this._count = from._count;
 }
Пример #6
0
    /// <summary>
    /// Transpose transpose the table, i.e. exchange columns and rows
    /// this can only work if all columns in the table are of the same type
    /// </summary>
    /// <param name="numberOfDataColumnsChangeToPropertyColumns">Number of data columns that are changed to property columns before transposing the table.</param>
    /// <param name="numberOfPropertyColumnsChangeToDataColumns">Number of property columns that are changed to data columns before transposing the table.</param>
    /// <returns>null if succeeded, error string otherwise</returns>
    public virtual string Transpose(int numberOfDataColumnsChangeToPropertyColumns, int numberOfPropertyColumnsChangeToDataColumns)
    {
    
      numberOfDataColumnsChangeToPropertyColumns = Math.Max(numberOfDataColumnsChangeToPropertyColumns,0);
      numberOfDataColumnsChangeToPropertyColumns = Math.Min(numberOfDataColumnsChangeToPropertyColumns,this.DataColumnCount);

      numberOfPropertyColumnsChangeToDataColumns = Math.Max( numberOfPropertyColumnsChangeToDataColumns, 0);
      numberOfPropertyColumnsChangeToDataColumns = Math.Min(  numberOfPropertyColumnsChangeToDataColumns, this.PropertyColumnCount);

      // first, save the first data columns that are changed to property columns
      Altaxo.Data.DataColumnCollection savedDataColumns = new DataColumnCollection();
      Altaxo.Data.DataColumnCollection savedPropColumns = new DataColumnCollection();

      Altaxo.Collections.IAscendingIntegerCollection savedDataColIndices = new Altaxo.Collections.IntegerRangeAsCollection(0,numberOfDataColumnsChangeToPropertyColumns);
      Altaxo.Collections.IAscendingIntegerCollection savedPropColIndices = new Altaxo.Collections.IntegerRangeAsCollection(0,numberOfPropertyColumnsChangeToDataColumns);
      // store the columns temporarily in another collection and remove them from the original collections
      DataColumns.MoveColumnsTo(savedDataColumns, 0, savedDataColIndices);
      this.PropertyColumns.MoveColumnsTo(savedPropColumns, 0, savedPropColIndices);

      // now transpose the data columns
      _dataColumns.Transpose();

      savedDataColumns.InsertRows(0,numberOfPropertyColumnsChangeToDataColumns); // take offset caused by newly inserted prop columns->data columns into account
      savedDataColumns.MoveColumnsTo(this.PropertyColumns,0, savedDataColIndices);

      savedPropColumns.RemoveRows(0,numberOfDataColumnsChangeToPropertyColumns); // take offset caused by data columns changed to property columns into account
      savedPropColumns.MoveColumnsTo(this.DataColumns,0,savedPropColIndices);

      // now insert both the temporary stored DataColumnCollections at the beginning

      return null; // no error message
    }