예제 #1
0
        private void SetResizeCursor(Point mousePosition)
        {
            if (_resizingColumn != null)
            {
                return;
            }

            // set mouse if we can resize column

            double             distanceFromLeft  = mousePosition.X;
            double             distanceFromRight = this.Width - distanceFromLeft;
            DataGridColumnBase currentColumn     = this.OwningColumn;
            DataGridColumnBase previousColumn    = null;

            if (!(this.OwningColumn is DataGridFillerColumn))
            {
                previousColumn = this.OwningGrid.ColumnsInternal.GetPreviousVisibleColumn(currentColumn);
            }

            if (distanceFromRight <= DATAGRIDCOLUMNHEADER_resizeRegionWidth && currentColumn != null && CanResizeColumn(currentColumn))
            {
                this.Cursor = new Cursor(StandardCursorType.SizeWestEast);
            }
            else if (distanceFromLeft <= DATAGRIDCOLUMNHEADER_resizeRegionWidth && previousColumn != null && CanResizeColumn(previousColumn))
            {
                this.Cursor = new Cursor(StandardCursorType.SizeWestEast);
            }
            else
            {
                this.Cursor = new Cursor(StandardCursorType.Arrow);
            }
        }
예제 #2
0
 public DataGridCellEditingCancelEventArgs(DataGridColumnBase dataGridColumn,
                                           DataGridRow dataGridRow,
                                           Control element,
                                           DataGridEditingTriggerInfo editingTriggerInfo) : base(dataGridColumn, dataGridRow, element)
 {
     this.EditingTriggerInfo = editingTriggerInfo;
 }
예제 #3
0
 private bool TrySetResizeColumn(DataGridColumnBase column)
 {
     // If datagrid.CanUserResizeColumns == false, then the column can still override it
     if (CanResizeColumn(column))
     {
         _resizingColumn = column;
         //
         return(true);
     }
     return(false);
 }
예제 #4
0
        private void DataGridColumnHeader_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            _resizeStart = null;
            ReleaseMouseCapture();

            if (_resizingColumn != null)
            {
                _resizingColumn = null;
                //
                SetResizeCursor(e.GetPosition(this));
                e.Handled = true;
            }
        }
예제 #5
0
 public DataGridCellEventArgs(DataGridColumnBase dataGridColumn,
                              DataGridRow dataGridRow,
                              Control element)
 {
     if (dataGridColumn == null)
     {
         throw new ArgumentNullException("dataGridColumn");
     }
     if (dataGridRow == null)
     {
         throw new ArgumentNullException("dataGridRow");
     }
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     this.Column  = dataGridColumn;
     this.Row     = dataGridRow;
     this.Element = element;
 }
예제 #6
0
        private void DataGridColumnHeader_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!e.Handled && this.OwningGrid != null)
            {
                Point mousePosition = e.GetPosition(this);

                double             distanceFromLeft  = mousePosition.X;
                double             distanceFromRight = this.Width - distanceFromLeft;
                DataGridColumnBase currentColumn     = this.OwningColumn;
                DataGridColumnBase previousColumn    = null;
                if (!(this.OwningColumn is DataGridFillerColumn))
                {
                    previousColumn = this.OwningGrid.ColumnsInternal.GetPreviousVisibleColumn(currentColumn);
                }

                if (_resizingColumn == null && (distanceFromRight <= DATAGRIDCOLUMNHEADER_resizeRegionWidth))
                {
                    e.Handled = TrySetResizeColumn(currentColumn);
                }
                else if (_resizingColumn == null && distanceFromLeft <= DATAGRIDCOLUMNHEADER_resizeRegionWidth && previousColumn != null)
                {
                    e.Handled = TrySetResizeColumn(previousColumn);
                }

                if (_resizingColumn != null)
                {
                    this.CaptureMouse();
                    _resizeStart              = e.GetPosition(this.OwningGrid);
                    _originalWidth            = _resizingColumn.Width;
                    _originalHorizontalOffset = this.OwningGrid.HorizontalOffset;

                    _lastResizeWidth = _originalWidth;
                    e.Handled        = true;
                }
            }
        }
예제 #7
0
 private bool CanResizeColumn(DataGridColumnBase column)
 {
     return(this.OwningGrid.CanUserResizeColumns &&
            !(column is DataGridFillerColumn) &&
            (column.CanUserResize.HasValue && column.CanUserResize.Value || !column.CanUserResize.HasValue));
 }
 public DataGridCellCancelEventArgs(DataGridColumnBase dataGridColumn,
                                    DataGridRow dataGridRow,
                                    Control element) : base(dataGridColumn, dataGridRow, element)
 {
 }
예제 #9
0
 public DataGridValueConverter(DataGridColumnBase dataGridColumn)
 {
     this.Column = dataGridColumn;
 }