本文整理匯總了C#中PropertyTools.Wpf.CellRef類的典型用法代碼示例。如果您正苦於以下問題:C# CellRef類的具體用法?C# CellRef怎麽用?C# CellRef使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CellRef類屬於PropertyTools.Wpf命名空間,在下文中一共展示了CellRef類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ApplyProperties
protected override void ApplyProperties(CellDefinition cd, DataGrid owner, CellRef cell, PropertyDefinition pd, object item)
{
base.ApplyProperties(cd, owner, cell, pd, item);
cd.IsEnabledBindingSource = this.isItemEnabledSource;
cd.IsEnabledBindingParameter = "yes";
cd.IsEnabledBindingPath = owner.Operator.GetBindingPath(owner, cell);
}
示例2: CreateCellDefinition
/// <summary>
/// Creates the cell definition for the specified cell.
/// </summary>
/// <param name="owner">The owner.</param>
/// <param name="cell">The cell.</param>
/// <returns>
/// The cell definition
/// </returns>
public virtual CellDefinition CreateCellDefinition(
DataGrid owner,
CellRef cell)
{
var pd = owner.GetPropertyDefinition(cell);
var item = owner.Operator.GetItem(owner, cell);
var cd = this.CreateCellDefinitionOverride(owner, cell, pd, item);
this.ApplyProperties(cd, owner, cell, pd, item);
return cd;
}
示例3: TryExtrapolate
public bool TryExtrapolate(CellRef cell, CellRef currentCell, CellRef selectionCell, CellRef autoFillRef, out object result)
{
int selMinRow = Math.Min(currentCell.Row, selectionCell.Row);
int selMaxRow = Math.Max(currentCell.Row, selectionCell.Row);
int selMinCol = Math.Min(currentCell.Column, selectionCell.Column);
int selMaxCol = Math.Max(currentCell.Column, selectionCell.Column);
int i = cell.Row;
int j = cell.Column;
// skip cells inside selection area
if (i >= selMinRow && i <= selMaxRow && j >= selMinCol && j <= selMaxCol)
{
result = null;
return false;
}
object value = null;
if (i < selMinRow)
{
TryExtrapolate(cell, new CellRef(selMinRow, j), new CellRef(selMaxRow, j), out value);
}
if (i > selMaxRow)
{
TryExtrapolate(cell, new CellRef(selMinRow, j), new CellRef(selMaxRow, j), out value);
}
if (j < selMinCol)
{
TryExtrapolate(cell, new CellRef(i, selMinCol), new CellRef(i, selMaxCol), out value);
}
if (j > selMaxCol)
{
TryExtrapolate(cell, new CellRef(i, selMinCol), new CellRef(i, selMaxCol), out value);
}
if (value == null)
{
var source = new CellRef(PeriodicClamp(i, selMinRow, selMaxRow),
PeriodicClamp(j, selMinCol, selMaxCol));
value = GetCellValue(source);
}
if (value != null)
{
result = value;
return true;
}
result = null;
return false;
}
示例4: CreateCellDefinitionOverride
/// <summary>
/// Creates the cell definition object.
/// </summary>
/// <param name="owner">The owner.</param>
/// <param name="cell">The cell.</param>
/// <param name="pd">The property definition.</param>
/// <param name="item">The item.</param>
/// <returns>A cell definition.</returns>
protected virtual CellDefinition CreateCellDefinitionOverride(DataGrid owner, CellRef cell, PropertyDefinition pd, object item)
{
var propertyType = owner.Operator.GetPropertyType(pd, cell, item);
var tcd = pd as TemplateColumnDefinition;
if (tcd != null)
{
return new TemplateCellDefinition
{
DisplayTemplate = tcd.CellTemplate,
EditTemplate = tcd.CellEditingTemplate
};
}
if (propertyType.Is(typeof(bool)))
{
return new CheckCellDefinition();
}
if (propertyType.Is(typeof(Color)))
{
return new ColorCellDefinition();
}
if (propertyType.Is(typeof(Enum)))
{
var enumType = Nullable.GetUnderlyingType(propertyType) ?? propertyType;
var values = Enum.GetValues(enumType).Cast<object>().ToList();
if (Nullable.GetUnderlyingType(propertyType) != null)
{
values.Insert(0, null);
}
return new SelectCellDefinition
{
ItemsSource = values
};
}
if (pd.ItemsSourceProperty != null || pd.ItemsSource != null)
{
return new SelectCellDefinition
{
ItemsSource = pd.ItemsSource,
ItemsSourceProperty = pd.ItemsSourceProperty
};
}
return new TextCellDefinition();
}
示例5: GetItem
/// <summary>
/// Gets the item in cell.
/// </summary>
/// <param name="owner">The owner.</param>
/// <param name="cell">The cell reference.</param>
/// <returns>
/// The item <see cref="object" />.
/// </returns>
public override object GetItem(DataGrid owner, CellRef cell)
{
var list = owner.ItemsSource;
if (list == null)
{
return null;
}
var index = this.GetItemIndex(owner, cell);
if (index >= 0 && index < list.Count)
{
return list[index];
}
return null;
}
示例6: AutoFill
public void AutoFill(CellRef currentCell, CellRef selectionCell, CellRef autoFillRef)
{
for (int i = Math.Min(currentCell.Row, autoFillRef.Row);
i <= Math.Max(currentCell.Row, autoFillRef.Row);
i++)
{
for (int j = Math.Min(currentCell.Column, autoFillRef.Column);
j <= Math.Max(currentCell.Column, autoFillRef.Column);
j++)
{
object value;
var cell = new CellRef(i, j);
if (TryExtrapolate(cell, currentCell, selectionCell, autoFillRef, out value))
{
TrySetCellValue(cell, value);
// UpdateCellContent(cell);
}
}
}
}
示例7: GetItem
/// <summary>
/// Gets the item in cell.
/// </summary>
/// <param name="owner">The owner.</param>
/// <param name="cell">The cell reference.</param>
/// <returns>
/// The <see cref="object" />.
/// </returns>
public override object GetItem(DataGrid owner, CellRef cell)
{
var list = owner.ItemsSource;
var rowIndex = cell.Row;
var columnIndex = cell.Column;
if (list == null || rowIndex < 0 || columnIndex < 0)
{
return null;
}
if (rowIndex >= list.Count)
{
return null;
}
var row = list[rowIndex] as IList;
if (row == null || columnIndex >= row.Count)
{
return null;
}
return ((IList)list[rowIndex])[columnIndex];
}
示例8: ApplyProperties
/// <summary>
/// Applies the properties to the specified cell definition.
/// </summary>
/// <param name="cd">The cell definition.</param>
/// <param name="owner">The owner.</param>
/// <param name="cell">The cell.</param>
/// <param name="pd">The row/column definition.</param>
/// <param name="item">The current value of the cell.</param>
protected virtual void ApplyProperties(CellDefinition cd, DataGrid owner, CellRef cell, PropertyDefinition pd, object item)
{
cd.HorizontalAlignment = pd.HorizontalAlignment;
cd.BindingPath = pd.PropertyName ?? owner.Operator.GetBindingPath(owner, cell);
cd.IsReadOnly = pd.IsReadOnly;
cd.FormatString = pd.FormatString;
if (pd.Converter != null)
{
cd.Converter = pd.Converter;
}
cd.ConverterParameter = pd.ConverterParameter;
cd.ConverterCulture = pd.ConverterCulture;
cd.IsEnabledBindingParameter = pd.IsEnabledByValue;
cd.IsEnabledBindingPath = pd.IsEnabledByProperty;
cd.BackgroundBindingPath = pd.BackgroundProperty;
if (pd.Background != null)
{
cd.BackgroundBindingSource = pd.Background;
cd.BackgroundBindingPath = string.Empty;
}
}
示例9: GetCellElement
/// <summary>
/// Gets the element at the specified cell.
/// </summary>
/// <param name="cellRef">The cell reference.</param>
/// <returns>
/// The element, or <c>null</c> if the cell was not found.
/// </returns>
public UIElement GetCellElement(CellRef cellRef)
{
UIElement e;
return this.cellMap.TryGetValue(cellRef.GetHashCode(), out e) ? e : null;
}
示例10: ToString
/// <summary>
/// Exports the specified cell range to a string.
/// </summary>
/// <param name="cell1">The cell 1.</param>
/// <param name="cell2">The cell 2.</param>
/// <param name="separator">The separator.</param>
/// <param name="encode">Determines whether to encode the elements.</param>
/// <returns>
/// The to string.
/// </returns>
private string ToString(CellRef cell1, CellRef cell2, string separator, bool encode = false)
{
int rowMin = Math.Min(cell1.Row, cell2.Row);
int columnMin = Math.Min(cell1.Column, cell2.Column);
int rowMax = Math.Max(cell1.Row, cell2.Row);
int columnMax = Math.Max(cell1.Column, cell2.Column);
var sb = new StringBuilder();
for (int i = rowMin; i <= rowMax; i++)
{
if (i > rowMin)
{
sb.AppendLine();
}
for (int j = columnMin; j <= columnMax; j++)
{
string cell = this.GetCellString(new CellRef(i, j));
if (encode)
{
cell = CsvEncodeString(cell);
}
if (j > columnMin)
{
sb.Append(separator);
}
if (cell != null)
{
sb.Append(cell);
}
}
}
return sb.ToString();
}
示例11: GetCell
/// <summary>
/// Gets the cell reference for the specified position.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="isInAutoFillMode">if set to <c>true</c> [is in auto fill mode].</param>
/// <param name="relativeTo">The relative to.</param>
/// <returns>
/// The cell reference.
/// </returns>
public CellRef GetCell(Point position, bool isInAutoFillMode = false, CellRef relativeTo = default(CellRef))
{
double w = 0;
int column = -1;
int row = -1;
for (int j = 0; j < this.sheetGrid.ColumnDefinitions.Count; j++)
{
double aw0 = j - 1 >= 0 ? this.sheetGrid.ColumnDefinitions[j - 1].ActualWidth : 0;
double aw1 = this.sheetGrid.ColumnDefinitions[j].ActualWidth;
double aw2 = j + 1 < this.sheetGrid.ColumnDefinitions.Count
? this.sheetGrid.ColumnDefinitions[j + 1].ActualWidth
: 0;
if (isInAutoFillMode)
{
if (relativeTo.Column <= j)
{
aw0 = 0;
aw2 *= 0.5;
}
else
{
aw0 *= 0.5;
aw2 = 0;
}
}
else
{
aw0 = 0;
aw2 = 0;
}
if (position.X > w - aw0 && position.X < w + aw1 + aw2)
{
column = j;
break;
}
w += aw1;
}
if (w > 0 && column == -1)
{
column = this.sheetGrid.ColumnDefinitions.Count - 1;
}
double h = 0;
for (int i = 0; i < this.sheetGrid.RowDefinitions.Count; i++)
{
double ah = this.sheetGrid.RowDefinitions[i].ActualHeight;
if (position.Y < h + ah)
{
row = i;
break;
}
h += ah;
}
if (h > 0 && row == -1)
{
row = this.sheetGrid.RowDefinitions.Count - 1;
}
if (column == -1 || row == -1)
{
return new CellRef(-1, -1);
}
return new CellRef(row, column);
}
示例12: SetValue
/// <summary>
/// Sets value to items in cell.
/// </summary>
/// <param name="cell">The cell reference.</param>
/// <param name="value">The value to be set.</param>
private void SetValue(CellRef cell, object value)
{
if (this.ItemsSource == null)
{
return;
}
this.Operator.SetValue(cell, value);
}
示例13: ToArray
/// <summary>
/// Converts the specified cell range to an array.
/// </summary>
/// <param name="cell1">The cell1.</param>
/// <param name="cell2">The cell2.</param>
/// <returns>
/// An array.
/// </returns>
private object[,] ToArray(CellRef cell1, CellRef cell2)
{
int rowMin = Math.Min(cell1.Row, cell2.Row);
int columnMin = Math.Min(cell1.Column, cell2.Column);
int rowMax = Math.Max(cell1.Row, cell2.Row);
int columnMax = Math.Max(cell1.Column, cell2.Column);
int m = rowMax - rowMin + 1;
int n = columnMax - columnMin + 1;
var result = new object[m, n];
for (int i = rowMin; i <= rowMax; i++)
{
for (int j = columnMin; j <= columnMax; j++)
{
result[i - rowMin, j - columnMin] = this.GetCellValue(new CellRef(i, j));
}
}
return result;
}
示例14: SetElementPosition
/// <summary>
/// The set element position.
/// </summary>
/// <param name="element">The element.</param>
/// <param name="cell">The cell.</param>
private static void SetElementPosition(UIElement element, CellRef cell)
{
Grid.SetColumn(element, cell.Column);
Grid.SetRow(element, cell.Row);
}
示例15: InsertDisplayControl
/// <summary>
/// Inserts the display control for the specified cell.
/// </summary>
/// <param name="cellRef">The cell reference.</param>
private void InsertDisplayControl(CellRef cellRef)
{
var e = this.CreateDisplayControl(cellRef, null, null);
SetElementPosition(e, cellRef);
this.sheetGrid.Children.Insert(this.cellInsertionIndex, e);
this.cellInsertionIndex++;
this.cellMap.Add(cellRef.GetHashCode(), e);
}