示例#1
0
            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);
                }
            }
示例#2
0
        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);
            });
        }
示例#3
0
        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);
        }
示例#4
0
 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]);
     }
 }
        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);
        }