private static void DataGridContextChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e) { DataGridContext dataGridContext = e.NewValue as DataGridContext; GroupByControl panel = ( GroupByControl )sender; if (dataGridContext != null) { panel.RegisterParentDataGridContext(dataGridContext); } }
private static void ParentGridControlChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e) { DataGridControl grid = e.NewValue as DataGridControl; GroupByControl panel = ( GroupByControl )sender; if (grid != null) { panel.PrepareDefaultStyleKey(grid.GetView()); } }
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) { bool isMouseCaptured = this.IsMouseCaptured; bool isPressed = this.IsPressed; if (m_dragSourceManager != null) { m_dragSourceManager.Drop(e); } if (isMouseCaptured) { this.ReleaseMouseCapture(); bool click = isPressed; if (click) { bool allowSort = true; GroupByControl parentGBC = this.GetParentGroupByControl(); if (parentGBC != null) { allowSort = parentGBC.AllowSort; } if (allowSort) { DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); GroupLevelDescription groupInfo = this.Content as GroupLevelDescription; Debug.Assert((dataGridContext != null) && (groupInfo != null)); if ((dataGridContext != null) && (groupInfo != null)) { ColumnBase column = dataGridContext.Columns[groupInfo.FieldName]; if ((column != null) && (column.AllowSort)) { bool shiftUnpressed = ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift); var toggleColumnSort = dataGridContext.ToggleColumnSortCommand; if (toggleColumnSort.CanExecute(column, shiftUnpressed)) { toggleColumnSort.Execute(column, shiftUnpressed); } e.Handled = true; } } } } } base.OnMouseLeftButtonUp(e); }
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) { bool isMouseCaptured = this.IsMouseCaptured; bool isPressed = this.IsPressed; if (m_dragSourceManager != null) { m_dragSourceManager.ProcessMouseLeftButtonUp(e); } if (isMouseCaptured) { bool click = isPressed; if (click) { bool allowSort = true; GroupByControl parentGBC = this.GetParentGroupByControl(); if (parentGBC != null) { allowSort = parentGBC.AllowSort; } if (allowSort) { DataGridContext gridContext = DataGridControl.GetDataGridContext(this); GroupLevelDescription groupInfo = this.Content as GroupLevelDescription; Debug.Assert((gridContext != null) && (groupInfo != null)); if ((gridContext != null) && (groupInfo != null)) { ColumnBase column = gridContext.Columns[groupInfo.FieldName]; if ((column != null) && (column.AllowSort)) { DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); SortDescriptionCollection sortDescriptions = dataGridContext.Items.SortDescriptions; ColumnCollection columns = dataGridContext.Columns; SortingHelper.ToggleColumnSort( dataGridContext, sortDescriptions, columns, column, ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift)); e.Handled = true; } } } } } base.OnMouseLeftButtonUp(e); }
bool IDropTarget.CanDropElement(UIElement draggedElement) { bool allowGroupingModification = true; GroupByControl parentGBC = this.GetParentGroupByControl(); if (parentGBC != null) { allowGroupingModification = parentGBC.IsGroupingModificationAllowed; } // We don't accept any ColumnManagerCell from Details DataGridContext context = DataGridControl.GetDataGridContext(draggedElement); ColumnManagerCell cell = draggedElement as ColumnManagerCell; bool isAlreadyGroupedBy = false; if (cell != null) { isAlreadyGroupedBy = GroupingHelper.IsAlreadyGroupedBy(cell); ColumnBase parentColumn = cell.ParentColumn; if ((parentColumn == null) || (!parentColumn.AllowGroup)) { return(false); } } DataGridContext sourceDetailContext = DataGridControl.GetDataGridContext(this); Debug.Assert(sourceDetailContext != null); DetailConfiguration sourceDetailConfig = (sourceDetailContext != null) ? sourceDetailContext.SourceDetailConfiguration : null; DataGridContext draggedDetailContext = DataGridControl.GetDataGridContext(draggedElement); Debug.Assert(draggedDetailContext != null); DetailConfiguration draggedDetailConfig = (draggedDetailContext != null) ? draggedDetailContext.SourceDetailConfiguration : null; bool canDrop = (sourceDetailConfig == draggedDetailConfig) && (allowGroupingModification) && ((draggedElement is ColumnManagerCell) || (draggedElement is GroupByItem)) && (draggedElement != this) && (isAlreadyGroupedBy == false); if (canDrop && (cell != null)) { canDrop = GroupingHelper.ValidateMaxGroupDescriptions(draggedDetailContext); } return(canDrop); }
private void m_dragSourceManager_DragOutsideQueryCursor(object sender, QueryCursorEventArgs e) { GroupByControl parentGBC = this.GetParentGroupByControl(); if ((parentGBC == null) || !parentGBC.IsGroupingModificationAllowed) { return; } DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); if ((dataGridContext != null) && (dataGridContext.DataGridControl != null)) { UIViewBase uiViewBase = dataGridContext.DataGridControl.GetView() as UIViewBase; e.Cursor = (uiViewBase != null) ? uiViewBase.RemovingGroupCursor : UIViewBase.DefaultGroupDraggedOutsideCursor; } else { e.Cursor = UIViewBase.DefaultGroupDraggedOutsideCursor; } }
void m_dragSourceManager_DroppedOutside(object sender, EventArgs e) { bool allowGroupingModification = true; GroupByControl parentGBC = this.GetParentGroupByControl(); if (parentGBC != null) { allowGroupingModification = parentGBC.IsGroupingModificationAllowed; } if (allowGroupingModification) { DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); Debug.Assert(dataGridContext != null); if (dataGridContext != null) { GroupingHelper.RemoveGroupDescription( dataGridContext.Items.GroupDescriptions, this.Content as GroupLevelDescription, dataGridContext.DataGridControl); } } }