public void Resize(ColumnBase gridColumn, double diff) { Rows rows = new Rows(this); CorrectColumnsWidth(rows); if (diff == 0d || double.IsNaN(diff)) { return; } int columnIndex = BandedViewBehavior.GetColumn(gridColumn); int rowIndex = BandedViewBehavior.GetRow(gridColumn); Row row = rows[rowIndex]; row.SelectColumn(columnIndex); if (diff > 0) { DecreaseColumnsWidth(row, row.SelectedIndex + 1, ref diff); IncreaseSelectedColumnWidth(row, diff); } if (diff < 0) { diff *= -1; if (Math.Abs(row.SelectedCell.ActualWidth - row.SelectedCell.ColumnMinWidth) <= 0.5) { return; } DecreaseSelectedColumnWidth(row, ref diff); IncreaseColumnsWidth(row, row.SelectedIndex + 1, diff); } row.Foreach(row.SelectedIndex, (rowCell) => { double res = rowCell.NewWidth / row.RowWidth; rowCell.ColumnWidth = new GridLength(res, GridUnitType.Star); }); }
public Row(ResizableGrid owner, int rowIndex) : base(owner) { RowCellList = new List <RowCell>(); foreach (ContentPresenter cp in Owner.Children) { GridColumnData gridColumnData = (GridColumnData)cp.Content; ColumnBase gridColumn = gridColumnData.Column; int row = BandedViewBehavior.GetRow(gridColumn); int rowSpan = BandedViewBehavior.GetRowSpan(gridColumn); if (row <= rowIndex && row + rowSpan > rowIndex) { RowCellList.Add(new RowCell(Owner, gridColumn, cp)); } Comparison <RowCell> sortingMethos = (rowCell1, rowCell2) => { if (rowCell1.Column == rowCell2.Column) { return(0); } return(rowCell1.Column < rowCell2.Column ? -1 : 1); }; RowCellList.Sort(sortingMethos); } }
protected override void UpdateHasLeftRightSibling(IList <ColumnBase> columns) { for (int i = 0; i < columns.Count; i++) { BandedViewBehavior.GetIsRightColumn(columns[i]); columns[i].HasRightSibling = !BandedViewBehavior.GetIsRightColumn(columns[i]); columns[i].HasLeftSibling = !BandedViewBehavior.GetIsLeftColumn(columns[i]); } }
void PrepareChild(ContentPresenter child, ColumnBase column) { int columnCorrectingCoef = BandedViewBehavior.GetIsLeftColumn(column) ? 0 : 1; int columnSpanCorrectingCoef = BandedViewBehavior.GetIsLeftColumn(column) ? 1 : 0; StdGrid.SetRow(child, BandedViewBehavior.GetRow(column)); StdGrid.SetColumn(child, BandedViewBehavior.GetColumn(column) + columnCorrectingCoef); StdGrid.SetRowSpan(child, BandedViewBehavior.GetRowSpan(column)); StdGrid.SetColumnSpan(child, BandedViewBehavior.GetColumnSpan(column) + columnSpanCorrectingCoef); }
void Init(UIElement source) { GridColumnHeader = ((GridColumnHeader)source); ISupportDragDrop iSupportDragDrop = GridColumnHeader; SourceElement = iSupportDragDrop.SourceElement; Column = (GridColumn)GridColumnHeader.GetGridColumn(GridColumnHeader); ColumnsLayoutControl = BandedViewBehavior.GetColumnsLayoutControl(Column); View = (TableView)Column.View; }
protected override FrameworkElement CreateChild(object item) { ContentPresenter child = (ContentPresenter)base.CreateChild(item); ColumnBase column = ((GridColumnData)item).Column; BandBehavior.UpdateColumnHeaderTemplate(column); BandedViewBehavior.SetColumnsLayoutControl(column, this); BandedViewBehavior.UpdateColumnPosition(BandBehavior, column); PrepareChild(child, column); return(child); }
internal static void UpdateColumnPosition(BandedViewBehavior bandBehavior, ColumnBase obj) { int row = GetRow(obj); int column = GetColumn(obj); int rowSpan = GetRowSpan(obj); int columnSpan = GetColumnSpan(obj); SetIsLeftColumn(obj, column <= 0); SetIsTopColumn(obj, row <= 0); SetIsRightColumn(obj, column + columnSpan >= bandBehavior.ColumnDefinitions.Count); SetIsBottomColumn(obj, row + rowSpan >= bandBehavior.RowDefinitions.Count); }
public RowCell(ResizableGrid owner, ColumnBase gridColumn, ContentPresenter contentPresenter) : base(owner) { GridColumnPresenter = contentPresenter; GridColumn = gridColumn; Row = BandedViewBehavior.GetRow(GridColumn); RowSpan = BandedViewBehavior.GetRowSpan(GridColumn); Column = BandedViewBehavior.GetColumn(GridColumn); ColumnSpan = BandedViewBehavior.GetColumnSpan(GridColumn); ColumnDefinitions = new ColumnDefinitions(); for (int i = Column; i < Column + ColumnSpan; i++) { ColumnDefinitions.Add(Owner.BandBehavior.ColumnDefinitions[i]); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (GridColumn == null) { return; } Margin = BandBehavior.GetColumnHeaderMargin(GridColumn); if (BandedViewBehavior.GetIsBand(GridColumn)) { BarManager.SetDXContextMenu(this, null); } else { BarManager.SetDXContextMenu(this, View.DataControlMenu); } }
void UpdateCells() { if (View == null || LayoutPanel == null) { return; } foreach (AutoWidthCellContentPresenter presenter in LayoutPanel.Children) { if (BandedViewBehavior.GetIsBottomColumn(presenter.Column)) { presenter.SetBorderThickness(new Thickness(0, 0, 1, 0)); } else { presenter.SetBorderThickness(new Thickness(0, 0, 1, 1)); presenter.Padding = new Thickness(0, 0, 1, 1); } } }
protected override FrameworkElement CreateChild(object item) { GridCellData cellData = (GridCellData)item; ColumnBase gridColumn = cellData.Column; AutoWidthCellContentPresenter presenter = new AutoWidthCellContentPresenter(); int row = BandedViewBehavior.GetRow(gridColumn); int column = BandedViewBehavior.GetColumn(gridColumn) + 1; int rowSpan = BandedViewBehavior.GetRowSpan(gridColumn); int columnSpan = BandedViewBehavior.GetColumnSpan(gridColumn); StdGrid.SetRow(presenter, row); StdGrid.SetColumn(presenter, column); StdGrid.SetRowSpan(presenter, rowSpan); StdGrid.SetColumnSpan(presenter, columnSpan); if (BandedViewBehavior.GetIsBand(gridColumn)) { presenter.Visibility = Visibility.Collapsed; } else { presenter.Visibility = Visibility.Visible; } return(presenter); }
public override void ApplyResize(ColumnBase resizeColumn, double newWidth, double maxWidth, double indentWidth, bool correctWidths) { ColumnsLayoutControl c = BandedViewBehavior.GetColumnsLayoutControl(resizeColumn); c.Resize(resizeColumn, newWidth); }
public void Initialize(ColumnsLayoutControl owner) { Owner = owner; BandBehavior = Owner.BandBehavior; View = (TableView)Owner.View; }