本文整理汇总了C#中Altaxo.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Altaxo.Clone方法的具体用法?C# Altaxo.Clone怎么用?C# Altaxo.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Altaxo
的用法示例。
在下文中一共展示了Altaxo.Clone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Executes the script. If no instance of the script object exists, a error message will be stored and the return value is false.
/// If the script object exists, the Execute function of this script object is called.
/// </summary>
/// <param name="myTable">The data table this script is working on.</param>
/// <returns>True if executed without exceptions, otherwise false.</returns>
/// <remarks>If exceptions were thrown during execution, the exception messages are stored
/// inside the column script and can be recalled by the Errors property.</remarks>
public bool Execute(Altaxo.Data.DataTable myTable)
{
if (null == _scriptObject)
{
_errors = new string[1] { "Script Object is null" };
return false;
}
DataTable clonedTable = (DataTable)myTable.Clone();
clonedTable.DataColumns.RemoveRowsAll();
Altaxo.Collections.AscendingIntegerCollection rowsToCopy = new Altaxo.Collections.AscendingIntegerCollection();
int len = myTable.DataRowCount;
try
{
Altaxo.Calc.ExtractTableValuesExeBase scriptObject = (Altaxo.Calc.ExtractTableValuesExeBase)_scriptObject;
for (int i = 0; i < len; i++)
{
if (scriptObject.IsRowIncluded(myTable, i))
rowsToCopy.Add(i);
}
}
catch (Exception ex)
{
_errors = new string[1];
_errors[0] = ex.ToString();
return false;
}
for (int i = myTable.DataColumns.ColumnCount - 1; i >= 0; i--)
{
for (int j = rowsToCopy.Count - 1; j >= 0; j--)
{
clonedTable.DataColumns[i][j] = myTable.DataColumns[i][rowsToCopy[j]];
}
}
Current.Project.DataTableCollection.Add(clonedTable);
Current.ProjectService.OpenOrCreateWorksheetForTable(clonedTable);
return true;
}
示例2: CreateColumnOfSelectedRows
/// <summary>
/// Creates a new column, consisting only of the selected rows of the original column <c>x</c>. If x is null, a new <see cref="Altaxo.Data.DoubleColumn" /> will
/// be returned, consisting of the selected row indices.
/// </summary>
/// <param name="x">The original column (can be null).</param>
/// <param name="selectedRows">Selected row indices (can be null - then the entire column is used).</param>
/// <param name="numrows">Number of rows to create. Must not more than contained in selectedRows.</param>
/// <returns>A freshly created column consisting of x at the selected indices, or of the indices itself if x was null.</returns>
public static DataColumn CreateColumnOfSelectedRows(Altaxo.Data.DataColumn x, Altaxo.Collections.IAscendingIntegerCollection selectedRows, int numrows)
{
Altaxo.Data.DataColumn result;
if(x!=null)
{
result = (Altaxo.Data.DataColumn)x.Clone();
result.Clear();
for(int j=0;j<numrows;j++)
{
int rowidx = selectedRows!=null ? selectedRows[j] : j;
result[j] = x[rowidx];
}
}
else // x is null
{
result = new Altaxo.Data.DoubleColumn();
for(int j=0;j<numrows;j++)
{
int rowidx = selectedRows!=null ? selectedRows[j] : j;
result[j] = (double)rowidx;
}
}
return result;
}
示例3: PutTable
public static void PutTable(this OriginConnection conn, Altaxo.Data.DataTable srcTable, bool appendRows)
{
if (IsColumnReorderingNeccessaryForPuttingTableToOrigin(srcTable))
{
srcTable = (DataTable)srcTable.Clone();
ReorderColumnsInTableForCompatibilityWithOrigin(srcTable);
}
var stb = new System.Text.StringBuilder();
string strWksName = srcTable.ShortName;
strWksName.Trim();
// Validate worksheet name:
if (0 == strWksName.Length)
{
ShowErrorMessage("Please specify a worksheet name first.");
return;
}
int nColumns = srcTable.DataColumnCount;
int nRows = srcTable.DataRowCount;
// Validate the number of columns and the number of rows:
if (nColumns <= 0 || nRows <= 0)
{
ShowErrorMessage("Data table is empty, thus nothing needs to be copyied to Origin!");
return;
}
var app = conn.Application;
var originFolder = GetOrCreateFullFolderPath(app, srcTable.FolderName);
var wbk = GetOrCreateWorksheetPage(originFolder, strWksName);
// for every group in our worksheet, make a separate origin worksheet
Origin.Worksheet wks = wbk.Layers[0] as Origin.Worksheet;
wks.ClearData();
wks.Cols = 0;
wks.set_LabelVisible(Origin.LABELTYPEVALS.LT_LONG_NAME, true);
// Set the column names
for (int i = 0; i < srcTable.DataColumnCount; ++i)
{
var srcCol = srcTable.DataColumns[i];
var srcGroup = srcTable.DataColumns.GetColumnGroup(srcCol);
Origin.Column col = wks.Columns.Add(srcTable.DataColumns.GetColumnName(i));
col.LongName = srcTable.DataColumns.GetColumnName(i);
if (srcCol is DoubleColumn)
{
col.DataFormat = COLDATAFORMAT.DF_DOUBLE;
col.SetData((srcCol as DoubleColumn).Array);
}
else if (srcCol is DateTimeColumn)
{
col.DataFormat = COLDATAFORMAT.DF_DATE;
col.SetData((srcCol as DateTimeColumn).Array);
}
else if (srcCol is TextColumn)
{
col.DataFormat = COLDATAFORMAT.DF_TEXT;
col.SetData((srcCol as TextColumn).Array);
}
else
{
throw new NotImplementedException("Type of column not implemented");
}
col.Type = AltaxoToOriginColumnType(srcTable.DataColumns.GetColumnKind(srcCol));
} // end of loop for all data columns
// now put the property columns to ORIGIN
// note that ORIGIN has only special property columns
// LongName (but this is set already), Units, Comments
// and more generic property columns accessible by Parameter(0), Parameter(1) and so on
var usedPropColIndices = new HashSet<int>();
// Longname
for (int i = 0; i < srcTable.PropCols.ColumnCount; ++i)
{
if (usedPropColIndices.Contains(i))
continue;
if (IsLikeAnyOf(srcTable.PropCols.GetColumnName(i), LongNamePropertyColumnNames))
{
usedPropColIndices.Add(i);
for (int j = 0; j < srcTable.DataColumnCount; ++j)
{
wks.Columns[j].LongName = srcTable.PropCols[i][j].ToString();
}
wks.set_LabelVisible(Origin.LABELTYPEVALS.LT_LONG_NAME, true);
}
}
// Units
for (int i = 0; i < srcTable.PropCols.ColumnCount; ++i)
{
if (usedPropColIndices.Contains(i))
//.........这里部分代码省略.........
示例4: ToRowMatrix
/// <summary>
/// Wrapps a set of <see cref="DataColumn" />s into a writeable matrix so that the matrix rows corresponds to the <see cref="DataColumn" />s.
/// </summary>
/// <param name="collection">DataColumnCollection from which to select the data columns that are part of the matrix by their indices.</param>
/// <param name="selectedColumns">The indices of the data columns in the collection that are part of the matrix. You can subsequently change this parameter without affecting this wrapper.</param>
/// <param name="selectedRows">Selected rows of the data table that participate in the matrix. Remember that this are the columns of the wrapped matrix. This collection will be cloned here, i.e. you can subsequently change it without affecting this wrapper.</param>
public static IMatrix ToRowMatrix(Altaxo.Data.DataColumnCollection collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
{
return new DataColumnToRowMatrixWrapper(collection, selectedColumns, (IAscendingIntegerCollection)selectedRows.Clone());
}
示例5: ToROColumnMatrixWithIntercept
/// <summary>
/// Wraps a set of <see cref="DataColumn" />s into a readonly matrix so that the matrix columns corresponds to the <see cref="DataColumn" />s But the first column consists of elements with a numerical value of 1. The number of columns
/// of the resulting matrix is therefore 1 greater than the number of data columns in the argument.
/// </summary>
/// <param name="collection">Collection of <see cref="DataColumn" />s.</param>
/// <param name="selectedColumns">Set set of indices into the collection that are part of the matrix. You can subsequently change this parameter without affecting this wrapper.</param>
/// <param name="selectedRows">The set of rows that are part of the matrix. This collection will be cloned here, i.e. you can subsequently change it without affecting this wrapper.</param>
/// <returns>The wrapping read only matrix.</returns>
/// <remarks>This type of wrapper is usefull for instance for fitting purposes, where an intercept is needed.</remarks>
public static IROMatrix ToROColumnMatrixWithIntercept(Altaxo.Data.DataColumnCollection collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
{
return new InterceptPlusDataColumnToColumnROMatrixWrapper(collection, selectedColumns, (IAscendingIntegerCollection)selectedRows.Clone());
}
示例6: ToROColumnMatrix
/// <summary>
/// Wraps a set of <see cref="DataColumn" />s into a readonly matrix so that the matrix columns corresponds to the <see cref="DataColumn" />s.
/// </summary>
/// <param name="collection">Collection of <see cref="DataColumn" />s.</param>
/// <param name="selectedColumns">Set set of indices into the collection that are part of the matrix. You can subsequently change this parameter without affecting this wrapper.</param>
/// <param name="selectedRows">The set of rows that are part of the matrix. This collection will be cloned here, i.e. you can subsequently change it without affecting this wrapper.</param>
/// <returns>The wrapping read only matrix.</returns>
public static IROMatrix ToROColumnMatrix(Altaxo.Data.INumericColumn[] collection, Altaxo.Collections.IAscendingIntegerCollection selectedColumns, Altaxo.Collections.IAscendingIntegerCollection selectedRows)
{
return new DataColumnToColumnROMatrixWrapper(collection, selectedColumns, (IAscendingIntegerCollection)selectedRows.Clone());
}