public string GetName(int level) { IReadableColumn col = this.Document; // this may have the side effect that the object is tried to resolve, is this o.k.? if (col is Data.DataColumn) { Altaxo.Data.DataTable table = Altaxo.Data.DataTable.GetParentDataTableOf((DataColumn)col); string tablename = table == null ? string.Empty : table.Name + "\\"; string collectionname = table == null ? string.Empty : (table.PropertyColumns.ContainsColumn((DataColumn)col) ? "PropCols\\" : "DataCols\\"); if (level <= 0) { return(((DataColumn)col).Name); } else if (level == 1) { return(tablename + ((DataColumn)col).Name); } else { return(tablename + collectionname + ((DataColumn)col).Name); } } else if (base._docNodePath != null) { string path = _docNodePath.ToString(); int idx = 0; if (level <= 0) { idx = path.LastIndexOf('/'); if (idx < 0) { idx = 0; } else { idx++; } } return(path.Substring(idx)); } else if (col != null) { return(col.ToString()); } else { return(string.Empty); } }
public string GetName(int level) { return(_column == null ? string.Empty : _column.ToString()); }
/// <summary> /// Updates the information, indicating in <paramref name="hasTableChanged"/> whether the underlying data table has changed. /// </summary> /// <param name="dataTableOfPlotItem">The data table of plot item.</param> /// <param name="groupNumberOfPlotItem">The group number of plot item.</param> /// <param name="hasTableChanged">If set to <c>true</c>, the data table has recently changed.</param> public void Update(DataTable dataTableOfPlotItem, int groupNumberOfPlotItem, bool hasTableChanged) { bool hasChanged = false; if (!object.ReferenceEquals(_supposedDataTable, dataTableOfPlotItem)) { _supposedDataTable = dataTableOfPlotItem; hasChanged = true; } if (!(_supposedGroupNumber == groupNumberOfPlotItem)) { _supposedGroupNumber = groupNumberOfPlotItem; hasChanged = true; } if (null == _underlyingColumn) { if (string.IsNullOrEmpty(_nameOfUnderlyingDataColumn)) { hasChanged |= InternalSet(ref _plotColumnBoxText, string.Empty); hasChanged |= InternalSet(ref _plotColumnBoxState, _plotColumnBoxStateIfColumnIsMissing); switch (_plotColumnBoxState) { case PlotColumnControlState.Normal: hasChanged |= InternalSet(ref _plotColumnToolTip, string.Empty); break; case PlotColumnControlState.Warning: hasChanged |= InternalSet(ref _plotColumnToolTip, "Warning: it is highly recommended to set a column!"); break; case PlotColumnControlState.Error: hasChanged |= InternalSet(ref _plotColumnToolTip, "Error: it is mandatory to set a column!"); break; } } else { hasChanged |= InternalSet(ref _plotColumnBoxText, _nameOfUnderlyingDataColumn); hasChanged |= InternalSet(ref _plotColumnToolTip, string.Format("Column {0} can not be found in this table with this group number", _nameOfUnderlyingDataColumn)); hasChanged |= InternalSet(ref _plotColumnBoxState, PlotColumnControlState.Error); } } else if (_underlyingColumn is DataColumn) { var dcolumn = (DataColumn)_underlyingColumn; var parentTable = DataTable.GetParentDataTableOf(dcolumn); var parentCollection = DataColumnCollection.GetParentDataColumnCollectionOf(dcolumn); if (null == parentTable) { hasChanged |= InternalSet(ref _plotColumnToolTip, string.Format("This column is an orphaned data column without a parent data table", _nameOfUnderlyingDataColumn)); hasChanged |= InternalSet(ref _plotColumnBoxState, PlotColumnControlState.Error); if (parentCollection == null) { hasChanged |= InternalSet(ref _plotColumnBoxText, string.Format("Orphaned {0}", dcolumn.GetType().Name)); } else { string columnName = parentCollection.GetColumnName(dcolumn); hasChanged |= InternalSet(ref _nameOfUnderlyingDataColumn, columnName); hasChanged |= InternalSet(ref _plotColumnBoxText, columnName); } } else // UnderlyingColumn has a parent table { if (!object.ReferenceEquals(parentTable, dataTableOfPlotItem)) { hasChanged |= InternalSet(ref _plotColumnBoxText, parentTable.DataColumns.GetColumnName(dcolumn)); hasChanged |= InternalSet(ref _plotColumnToolTip, string.Format("The column {0} is a data column with another parent data table: {1}", _nameOfUnderlyingDataColumn, parentTable.Name)); hasChanged |= InternalSet(ref _plotColumnBoxState, PlotColumnControlState.Warning); } else if (!(parentTable.DataColumns.GetColumnGroup(dcolumn) == _supposedGroupNumber)) { string columnName = parentTable.DataColumns.GetColumnName(dcolumn); hasChanged |= InternalSet(ref _nameOfUnderlyingDataColumn, columnName); hasChanged |= InternalSet(ref _plotColumnBoxText, columnName); hasChanged |= InternalSet(ref _plotColumnToolTip, string.Format("The column {0} is a data column with another group number: {1}", _nameOfUnderlyingDataColumn, parentTable.DataColumns.GetColumnGroup(dcolumn))); hasChanged |= InternalSet(ref _plotColumnBoxState, PlotColumnControlState.Warning); } else { string columnName = parentTable.DataColumns.GetColumnName(dcolumn); hasChanged |= InternalSet(ref _nameOfUnderlyingDataColumn, columnName); hasChanged |= InternalSet(ref _plotColumnBoxText, columnName); hasChanged |= InternalSet(ref _plotColumnToolTip, string.Format("UnderlyingColumn {0} of data table {1}", _nameOfUnderlyingDataColumn, parentTable.Name)); hasChanged |= InternalSet(ref _plotColumnBoxState, PlotColumnControlState.Normal); } } } else // UnderlyingColumn is not a DataColumn, but is something else { hasChanged |= InternalSet(ref _nameOfUnderlyingDataColumn, null); hasChanged |= InternalSet(ref _plotColumnBoxText, _underlyingColumn.FullName); hasChanged |= InternalSet(ref _plotColumnToolTip, string.Format("Independent data of type {0}: {1}", _underlyingColumn.GetType(), _underlyingColumn.ToString())); hasChanged |= InternalSet(ref _plotColumnBoxState, PlotColumnControlState.Normal); } // now the transformation if (null != _transformation) { hasChanged |= InternalSet(ref _transformationBoxText, _transformation.RepresentationAsOperator ?? _transformation.RepresentationAsFunction); hasChanged |= InternalSet(ref _transformationToolTip, string.Format("Transforms the column data by the function f(x)={0}", _transformation.RepresentationAsFunction)); } else // transformation is null { hasChanged |= InternalSet(ref _transformationBoxText, string.Empty); hasChanged |= InternalSet(ref _transformationToolTip, "No transformation applied."); } _isDirty |= hasChanged; _isDirty |= hasTableChanged; if (_isDirty) { _isDirty = false; OnChanged(); } }