/// <summary> /// Delegate called when a mouse is mouving on a thumb. /// </summary> /// <param name="pSender">The event sender.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnThumbPreviewMouseMove(object pSender, MouseEventArgs pEventArgs) { Thumb lThumb = pSender as Thumb; if (lThumb == null) { return; } GridViewColumn lColumn = this.FindParentColumn(lThumb); if (lColumn == null) { return; } // Suppress column resizing for fixed and range fill columns. if (FixedColumn.IsFixedColumn(lColumn) || this.IsFillColumn(lColumn)) { // Cursor is hidden. lThumb.Cursor = null; return; } // Check range column bounds. if (lThumb.IsMouseCaptured && RangeColumn.IsRangeColumn(lColumn)) { double?lMinWidth = RangeColumn.GetRangeMinWidth(lColumn); double?lMaxWidth = RangeColumn.GetRangeMaxWidth(lColumn); if ((lMinWidth.HasValue && lMaxWidth.HasValue) && (lMinWidth > lMaxWidth)) { // Invalid case. return; } if (this.mBackCursor == null) { // First time = save the resize cursor. this.mBackCursor = lThumb.Cursor; } // Updating the cursor. if (lMinWidth.HasValue && lColumn.Width <= lMinWidth.Value) { lThumb.Cursor = Cursors.No; } else if (lMaxWidth.HasValue && lColumn.Width >= lMaxWidth.Value) { lThumb.Cursor = Cursors.No; } else { lThumb.Cursor = this.mBackCursor; } } }
/// <summary> /// Initialize the columns by applying there properties. /// </summary> private void InitColumns() { if (this.mListView.View == null) { return; } foreach (GridViewColumn lColumn in this.mListView.View.Columns) { if (RangeColumn.IsRangeColumn(lColumn) == false) { continue; } double?lMinWidth = RangeColumn.GetRangeMinWidth(lColumn); double?lMaxWidth = RangeColumn.GetRangeMaxWidth(lColumn); if (lMinWidth.HasValue == false && lMaxWidth.HasValue == false) { continue; } GridViewColumnHeader lColumnHeader = this.FindColumnHeader(this.mListView, lColumn); if (lColumnHeader == null) { continue; } double lActualWidth = lColumnHeader.ActualWidth; if (lMinWidth.HasValue) { lColumnHeader.MinWidth = lMinWidth.Value; if (!double.IsInfinity(lActualWidth) && lActualWidth < lColumnHeader.MinWidth) { lColumn.Width = lColumnHeader.MinWidth; } } if (lMaxWidth.HasValue) { lColumnHeader.MaxWidth = lMaxWidth.Value; if (double.IsInfinity(lActualWidth) == false && lActualWidth > lColumnHeader.MaxWidth) { lColumn.Width = lColumnHeader.MaxWidth; } } } }
/// <summary> /// Delegate called when a column width change. /// </summary> /// <param name="pSender">The event sender.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnGridColumnWidthChanged(object pSender, EventArgs pEventArgs) { if (this.mLoaded == false) { return; } GridViewColumn lColumn = pSender as GridViewColumn; if (lColumn == null) { return; } // Suppress column resizing for fixed columns. if (FixedColumn.IsFixedColumn(lColumn)) { return; } // Ensure range column within the bounds. if (RangeColumn.IsRangeColumn(lColumn)) { // Special case: auto column width - maybe conflicts with min/max range. if (lColumn != null && lColumn.Width.Equals(double.NaN)) { // Resize is handled by the change header size event. this.mAutoSizedColumn = lColumn; return; } // ensure column bounds if (Math.Abs(this.SetRangeColumnToBounds(lColumn) - 0) > ZERO_WIDTH_RANGE) { return; } } // Force resize. this.DoResizeColumns(this.mListView.View.Columns.IndexOf(lColumn)); }