protected override void HandleDragOver(sw.DragEventArgs e, DragEventArgs args) { var lastRow = LastDragRow; base.HandleDragOver(e, args); var info = LastDragInfo = GetDragInfo(args); if (args.Effects != DragEffects.None) { // show drag indicator! var row = GetDataGridRow(GetItemAtRow(info.Index)); if (row != null) { // same position, just return if (lastRow != null && lastRow.IsEqual(row, info.InsertIndex)) { return; } lastRow?.Revert(); LastDragRow = new GridDragRowState(row, info.InsertIndex); if (info.InsertIndex == -1) { row.Background = sw.SystemColors.HighlightBrush; row.Foreground = sw.SystemColors.HighlightTextBrush; } else { var d = new swm.GeometryDrawing(); var gg = new swm.GeometryGroup(); gg.Children.Add(new swm.LineGeometry(new sw.Point(0, 0), new sw.Point(row.ActualWidth, 0))); d.Geometry = gg; d.Brush = sw.SystemColors.HighlightBrush; d.Pen = new swm.Pen(sw.SystemColors.HighlightBrush, 1); var b = new swm.DrawingBrush { Drawing = d, TileMode = swm.TileMode.None, Stretch = swm.Stretch.None, AlignmentX = swm.AlignmentX.Left }; if (info.InsertIndex == row.GetIndex()) { b.AlignmentY = swm.AlignmentY.Top; row.BorderThickness = new sw.Thickness(0, 1, 0, 0); } else { b.AlignmentY = swm.AlignmentY.Bottom; row.BorderThickness = new sw.Thickness(0, 0, 0, 1); } row.BorderBrush = b; } return; } } ResetDrag(); }
protected override void HandleDragOver(sw.DragEventArgs e, DragEventArgs args) { var lastRow = LastDragRow; base.HandleDragOver(e, args); var info = LastDragInfo = GetDragInfo(args); if (args.Effects != DragEffects.None) { // show drag indicator! var row = GetDataGridRow(info.Item ?? info.Parent); if (row != null) { // same position, just return if (lastRow != null && lastRow.IsEqual(row, info.InsertIndex)) { return; } lastRow?.Revert(); LastDragRow = new GridDragRowState(row, info.InsertIndex); if (info.InsertIndex == -1) { row.Background = sw.SystemColors.HighlightBrush; row.Foreground = sw.SystemColors.HighlightTextBrush; } else { var node = controller.GetNodeAtRow(row.GetIndex()); var level = node.Level + 1; // indicator to the right of the expanders to align with text var i = info.Parent as ITreeGridItem; if (info.Position == GridDragPosition.After && ReferenceEquals(info.Item, null)) { level++; } level *= 16; var d = new swm.GeometryDrawing(); var gg = new swm.GeometryGroup(); gg.Children.Add(new swm.EllipseGeometry(new sw.Point(0, 0), 2, 2)); gg.Children.Add(new swm.LineGeometry(new sw.Point(2, 0), new sw.Point(row.ActualWidth - level - 16, 0))); d.Geometry = gg; d.Brush = sw.SystemColors.HighlightBrush; d.Pen = new swm.Pen(sw.SystemColors.HighlightBrush, 1); var b = new swm.DrawingBrush { Drawing = d, TileMode = swm.TileMode.None, Stretch = swm.Stretch.None, AlignmentX = swm.AlignmentX.Left }; if (info.InsertIndex == node.Index) { b.AlignmentY = swm.AlignmentY.Top; row.BorderThickness = new sw.Thickness(0, 5, 0, 0); } else { b.AlignmentY = swm.AlignmentY.Bottom; row.BorderThickness = new sw.Thickness(0, 0, 0, 5); } b.Transform = new swm.TranslateTransform(level, 0); row.BorderBrush = b; } return; } } ResetDrag(); }