当前位置: 首页>>代码示例>>C#>>正文


C# Data.DataTable类代码示例

本文整理汇总了C#中Altaxo.Data.DataTable的典型用法代码示例。如果您正苦于以下问题:C# DataTable类的具体用法?C# DataTable怎么用?C# DataTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DataTable类属于Altaxo.Data命名空间,在下文中一共展示了DataTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePlotItems

		public static List<IGPlotItem> CreatePlotItems(DataTable table, IAscendingIntegerCollection selectedColumns, G3DPlotStyleCollection templatePlotStyle)
		{
			var selColumns = new List<DataColumn>(selectedColumns.Count);
			foreach (int i in selectedColumns)
				selColumns.Add(table[i]);

			return CreatePlotItems(selColumns, templatePlotStyle, table.GetPropertyContext());
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:8,代码来源:PlotCommands3D.cs

示例2: GetCalibrationModel

		public override IMultivariateCalibrationModel GetCalibrationModel(
			DataTable calibTable)
		{
			PLS2CalibrationModel model;
			Export(calibTable, out model);

			return model;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:8,代码来源:PLS2WorksheetAnalysis.cs

示例3: SetContentFromMatrix

		public static void SetContentFromMatrix(DataTable destinationTable, IROMatrix matrix, string columnBaseName, IROVector rowHeaderColumn, string rowHeaderColumnName, IROVector colHeaderColumn, string colHeaderColumnName)
		{
			var c = new MatrixToDataTableConverter(matrix, destinationTable);
			c.ColumnBaseName = columnBaseName;
			c.AddMatrixColumnHeaderData(rowHeaderColumn, rowHeaderColumnName);
			c.AddMatrixColumnHeaderData(colHeaderColumn, colHeaderColumnName);
			c.Execute();
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:8,代码来源:MatrixToDataTableConverter.cs

示例4: Import

    public override void Import(
      IMultivariateCalibrationModel calibrationSet,
      DataTable table)
    {

      PCRCalibrationModel calib = (PCRCalibrationModel)calibrationSet;


      int numFactors = calib.NumberOfFactors;
      int numberOfY = calib.NumberOfY;
      int numberOfPoints = calib.XLoads.Rows;
     


      // store the x-loads - careful - they are horizontal
      for(int i=0;i<numFactors;i++)
      {
        Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();

        for(int j=0;j<calib.XLoads.Columns;j++)
          col[j] = calib.XLoads[i,j];
          
        table.DataColumns.Add(col,GetXLoad_ColumnName(i),Altaxo.Data.ColumnKind.V,0);
      }
     
      // now store the scores - careful - they are vertical in the matrix
      for(int i=0;i<numFactors;i++)
      {
        Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
      
        for(int j=0;j<calib.XScores.Rows;j++)
          col[j] = calib.XScores[j,i];
        
        table.DataColumns.Add(col,GetXScore_ColumnName(i),Altaxo.Data.ColumnKind.V,0);
      }

      // now store the y-loads (this are the preprocessed y in this case
      for(int cn=0;cn<numberOfY;cn++)
      {
        Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
      
        for(int i=0;i<numberOfPoints;i++)
          col[i] = calib.YLoads[i,cn];
        
        table.DataColumns.Add(col,GetYLoad_ColumnName(cn),Altaxo.Data.ColumnKind.V,0);
      }

      // now store the cross product vector - it is a horizontal vector
    {
      Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
      
      for(int j=0;j<numFactors;j++)
        col[j] = calib.CrossProduct[j];
      table.DataColumns.Add(col,GetCrossProduct_ColumnName(),Altaxo.Data.ColumnKind.V,3);
    }

    
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:58,代码来源:PCRWorksheetAnalysis.cs

示例5: TableNode

			public TableNode(DataTable table)
				: base(true)
			{
				_collection = table.DataColumns;
				_firstColumn = 0;
				_columnCount = table.DataColumns.ColumnCount;
				Text = table.ShortName;
				Tag = table;
			}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:9,代码来源:SingleColumnChoiceController.cs

示例6: Import

    public override void Import(
      IMultivariateCalibrationModel calibrationSet,
      DataTable table)
    {
      PLS1CalibrationModel calib = (PLS1CalibrationModel)calibrationSet;

      for(int yn=0;yn<calib.NumberOfY;yn++)
      {
        // store the x-loads - careful - they are horizontal in the matrix
        for(int i=0;i<calib.XLoads[yn].Rows;i++)
        {
          Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();

          for(int j=0;j<calib.XLoads[yn].Columns;j++)
            col[j] = calib.XLoads[yn][i,j];
          
          table.DataColumns.Add(col,GetXLoad_ColumnName(yn,i),Altaxo.Data.ColumnKind.V,0);
        }


        // now store the y-loads - careful - they are horizontal in the matrix
        for(int i=0;i<calib.YLoads[yn].Rows;i++)
        {
          Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
        
          for(int j=0;j<calib.YLoads[yn].Columns;j++)
            col[j] = calib.YLoads[yn][i,j];
        
          table.DataColumns.Add(col,GetYLoad_ColumnName(yn,i),Altaxo.Data.ColumnKind.V,1);
        }

        // now store the weights - careful - they are horizontal in the matrix
        for(int i=0;i<calib.XWeights[yn].Rows;i++)
        {
          Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
      
          for(int j=0;j<calib.XWeights[yn].Columns;j++)
            col[j] = calib.XWeights[yn][i,j];
        
          table.DataColumns.Add(col,GetXWeight_ColumnName(yn,i),Altaxo.Data.ColumnKind.V,0);
        }

        // now store the cross product vector - it is a horizontal vector
      {
        Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
      
        for(int j=0;j<calib.CrossProduct[yn].Columns;j++)
          col[j] = calib.CrossProduct[yn][0,j];
        table.DataColumns.Add(col,GetCrossProduct_ColumnName(yn),Altaxo.Data.ColumnKind.V,3);
      }

      
      } // for all y (constituents)


    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:56,代码来源:PLS1WorksheetAnalysis.cs

示例7: MatrixToDataTableConverter

		public MatrixToDataTableConverter(IROMatrix sourceMatrix, DataTable destinationTable)
		{
			if (null == sourceMatrix)
				throw new ArgumentNullException("sourceMatrix");
			if (null == destinationTable)
				throw new ArgumentNullException("destinationTable");

			_sourceMatrix = sourceMatrix;
			_destinationTable = destinationTable;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:10,代码来源:MatrixToDataTableConverter.cs

示例8: ShowRealFourierTransformation2DDialog

		/// <summary>
		/// Shows the dialog in which the user can select options for the 2D Fourier transformation, and then executes the Fourier transformation
		/// The result is stored in a newly created data table in the same folder as the source data table.
		/// </summary>
		/// <param name="table">The table containing the data to transform.</param>
		/// <param name="selectedDataRows">The selected data rows of the table. (A value of <c>null</c> can be provided here).</param>
		/// <param name="selectedDataColumns">The selected data columns of the table. (A value of <c>null</c> can be provided here).</param>
		/// <param name="selectedPropertyColumns">The selected property columns of the table. (A value of <c>null</c> can be provided here).</param>
		public static void ShowRealFourierTransformation2DDialog(DataTable table, IAscendingIntegerCollection selectedDataRows, IAscendingIntegerCollection selectedDataColumns, IAscendingIntegerCollection selectedPropertyColumns)
		{
			DataTableMatrixProxy proxy = null;
			RealFourierTransformation2DOptions options = null;

			try
			{
				proxy = new DataTableMatrixProxy(table, selectedDataRows, selectedDataColumns, selectedPropertyColumns);

				options = null != _lastUsedOptions ? (RealFourierTransformation2DOptions)_lastUsedOptions.Clone() : new RealFourierTransformation2DOptions();

				double rowIncrementValue; string rowIncrementMessage;
				proxy.TryGetRowHeaderIncrement(out rowIncrementValue, out rowIncrementMessage);
				double columnIncrementValue; string columnIncrementMessage;
				proxy.TryGetColumnHeaderIncrement(out columnIncrementValue, out columnIncrementMessage);

				options.IsUserDefinedRowIncrementValue = false;
				options.RowIncrementValue = rowIncrementValue;
				options.RowIncrementMessage = rowIncrementMessage;

				options.IsUserDefinedColumnIncrementValue = false;
				options.ColumnIncrementValue = columnIncrementValue;
				options.ColumnIncrementMessage = columnIncrementMessage;
			}
			catch (Exception ex)
			{
				Current.Gui.ErrorMessageBox(string.Format("{0}\r\nDetails:\r\n{1}", ex.Message, ex.ToString()), "Error in preparation of Fourier transformation");
				return;
			}

			if (!Current.Gui.ShowDialog(ref options, "Choose fourier transform options", false))
				return;

			_lastUsedOptions = options;

			try
			{
				var resultTable = new DataTable { Name = string.Format("{0}Fourier{1} of {2}", table.Folder, options.OutputKind, table.ShortName) };
				ExecuteFouriertransformation2D(proxy, options, resultTable);

				// Create a DataSource
				Altaxo.Worksheet.Commands.Analysis.FourierTransformation2DDataSource dataSource = new FourierTransformation2DDataSource(proxy, options, new Altaxo.Data.DataSourceImportOptions());
				resultTable.DataSource = dataSource;

				Current.ProjectService.OpenOrCreateWorksheetForTable(resultTable);
			}
			catch (Exception ex)
			{
				Current.Gui.ErrorMessageBox(string.Format("{0}\r\nDetails:\r\n{1}", ex.Message, ex.ToString()), "Error in execution of Fourier transformation");
				return;
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:60,代码来源:FourierCommands.cs

示例9: ToDataTable

		/// <summary>
		/// Imports a Jcamp file into an DataTable. The file must not be a multi spectrum file (an exception is thrown in this case).
		/// </summary>
		/// <param name="table">On return, contains the newly created data table with the spectral data.</param>
		/// <param name="stream">The stream where to import from.</param>
		/// <returns>Null if successful, otherwise an error description.</returns>
		public static string ToDataTable(System.IO.Stream stream, out DataTable table)
		{
			table = null;
			TextReader tr;
			try
			{
				tr = new StreamReader(stream);
				return ToDataTable(tr, out table);
			}
			catch (Exception ex)
			{
				return ex.Message;
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:20,代码来源:ImportJcampFiles.cs

示例10: SDTableScriptController

    public SDTableScriptController(Altaxo.Data.DataTable dataTable, TableScript tableScript)
    {
      this.m_DataTable = dataTable;

      if(null!=tableScript)
      {
        this.m_TableScript = (IScriptText)tableScript.Clone();
      }
      else
      {
        this.m_TableScript = new TableScript();
      }

      SetElements(true);

    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:16,代码来源:SDTableScriptController.cs

示例11: MergeTable

		/// <summary>
		/// Merges two tables by fractional index.
		/// </summary>
		/// <param name="destinationTable">Table to merge into.</param>
		/// <param name="fractionalIndex">Array of fractional indices. Each item points into the slaveTable to the value that should be included in the master column at the item's index.</param>
		/// <param name="slaveTable">The table providing the data for merging into the master table.</param>
		/// <param name="slaveColumnsToMerge">Indices of that columns of the slave table that should be merged into the master table.</param>
		public static void MergeTable(
			this DataTable destinationTable,
			DoubleColumn fractionalIndex,
			DataTable slaveTable,
			IAscendingIntegerCollection slaveColumnsToMerge)
		{
			int destinationTableStartIdx = destinationTable.DataColumnCount;
			destinationTable.AddDataColumnsWithPropertiesFrom(slaveTable, slaveColumnsToMerge);

			for (int i = 0; i < slaveColumnsToMerge.Count; i++)
			{
				int slaveColIdx = slaveColumnsToMerge[i];
				DataColumn newCol = destinationTable[destinationTableStartIdx + i];

				SetColumnFromFractionalIndex(newCol, fractionalIndex, slaveTable[slaveColIdx]);
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:24,代码来源:MergeTables.cs

示例12: GetCommonDataTableAndGroupNumberFromColumns

		/// <summary>
		/// Try to get a common data table and a group number from all columns (here we don't rely on <see cref="DataTable"/> and GroupNumber of this document).
		/// </summary>
		/// <param name="columns">The columns to consider. <see cref="ITransformedReadableColumn"/> will be stripped to get the underlying data column.</param>
		/// <param name="dataTableIsNotUniform">If the columns gives different result for their underlying data table, the result here will be true.</param>
		/// <param name="commonDataTable">If the previous parameter results in false, this is the common data table of all columns. If the previous parameter is true, this is the first underlying data table that could be deduced from the columns. The result is null if no underlying table could be deduced from the columns.</param>
		/// <param name="groupNumberIsNotUniform">If the columns gives different result for their group number, the result here will be true.</param>
		/// <param name="commonGroupNumber">If the previous parameter results in false, this is the common group number of all columns. If the previous parameter results in true, this is the first group number that could be deduced from the columns. The result is null if no group number could be deduced from the columns.</param>
		public static void GetCommonDataTableAndGroupNumberFromColumns(this IEnumerable<IReadableColumn> columns, out bool dataTableIsNotUniform, out DataTable commonDataTable, out bool groupNumberIsNotUniform, out int? commonGroupNumber)
		{
			dataTableIsNotUniform = false;
			groupNumberIsNotUniform = false;
			commonDataTable = null;
			commonGroupNumber = null;

				foreach(var col in columns)
				{
					IReadableColumn underlyingColumn = col;

					while (underlyingColumn is ITransformedReadableColumn)
					{
						underlyingColumn = (underlyingColumn as ITransformedReadableColumn).UnderlyingReadableColumn;
					}

					if (underlyingColumn is DataColumn)
					{
						var colColl = DataColumnCollection.GetParentDataColumnCollectionOf((DataColumn)underlyingColumn);
						var dataTable = DataTable.GetParentDataTableOf(colColl);
						int? groupNumber = colColl?.GetColumnGroup((DataColumn)underlyingColumn);

						if (null != dataTable)
						{
							if (null == commonDataTable)
								commonDataTable = dataTable;
							else if (!object.ReferenceEquals(commonDataTable, dataTable))
								dataTableIsNotUniform = true;
						}

						if (null != groupNumber)
						{
							if (null == commonGroupNumber)
								commonGroupNumber = groupNumber;
							else if (!(commonGroupNumber == groupNumber))
								groupNumberIsNotUniform = true;
						}
					}
				}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:48,代码来源:IReadableColumnExtensions.cs

示例13: Import

    /// <summary>
    /// Imports a Origin OPJ file (tables only) into corresponding new tables in Altaxo.
    /// </summary>
    /// <param name="filename">The file name of the origin OPJ file.</param>
    /// <returns>Null if the import was successfull, or a error message.</returns>
    public static string Import(string filename)
    {
      OpjFile opj = new OpjFile(filename);
      opj.Parse();

      // now create corresponding tables in Altaxo

      for (int nspread = 0; nspread < opj.numSpreads(); nspread++)
      {
        // Create a new table
        string tablename = Current.Project.DataTableCollection.FindNewTableName(opj.spreadName(nspread));
        DataTable table = new DataTable(tablename);

        int numberOfColumns = opj.numCols(nspread);
        for (int ncol = 0; ncol < numberOfColumns; ncol++)
        {
          string colname = opj.colName(nspread, ncol);
          string coltype = opj.colType(nspread, ncol);
          int numberOfRows = opj.numRows(nspread, ncol);
          ColumnKind kind = coltype == "X" ? ColumnKind.X : ColumnKind.V;

          DoubleColumn column = new DoubleColumn(numberOfRows);
          column.CopyDataFrom(opj.Data(nspread, ncol), numberOfRows);


          colname = table.DataColumns.FindUniqueColumnName(colname);
          table.DataColumns.Add(column, colname, kind, 0);
        }


        table.Name = tablename;
        Current.Project.DataTableCollection.Add(table);
        Current.ProjectService.CreateNewWorksheet(table);
      }
      return null;
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:41,代码来源:Import.cs

示例14: PlotPreprocessedSpectra

    /// <summary>
    /// Plots all preprocessed spectra into a newly created graph.
    /// </summary>
    /// <param name="table">The table of PLS output data.</param>
    public static void PlotPreprocessedSpectra(Altaxo.Data.DataTable table)
    {
      DataTable desttable = new DataTable();
      desttable.Name = table.Name+".PS";
      GetAnalysis(table).CalculatePreprocessedSpectra(table, desttable);
      Current.Project.DataTableCollection.Add(desttable);

      Worksheet.Commands.PlotCommands.PlotLine(desttable,new IntegerRangeAsCollection(1,desttable.DataColumnCount-1),true,false);
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:13,代码来源:ChemometricCommands.cs

示例15: GetAnalysis

    public  static WorksheetAnalysis GetAnalysis(DataTable table)
    {
      MultivariateContentMemento plsMemo = table.GetTableProperty("Content") as MultivariateContentMemento;

      if(plsMemo==null)
        throw new ArgumentException("Table does not contain a PLSContentMemento");
  
      return plsMemo.Analysis;
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:9,代码来源:ChemometricCommands.cs


注:本文中的Altaxo.Data.DataTable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。