Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue May 18, 2010 10:39 pm Post subject: |
|
|
You would need to create a custom RowWidget (see the section in the help on using widgets) and override the SetDragCursors and DestroyDragCursors methods. Below is the default implementation which paints the selected rows to a bitmap which is then combined with a Copy or Move cursor symbol:
Code: |
protected virtual void SetDragCursors()
{
if (!DrawingUtilities.LargeCursorsSupported) return;
int height = Math.Min(Bounds.Height * Tree.SelectedRows.Count, MaxDragCursorHeight);
int width = Tree.ClientSize.Width;
using (Bitmap bitmap = new Bitmap(width, height))
{
using (Graphics graphics = Graphics.FromImage(bitmap))
{
PanelWidget panelWidget = Tree.CreatePanelWidget();
panelWidget.Bounds = new Rectangle(0, 0, width, height); ;
panelWidget.Printing = true;
Rectangle bounds = new Rectangle(0, 0, width, Bounds.Height);
foreach (Row row in Tree.SelectedRows)
{
RowWidget widget = Tree.CreateRowWidget(panelWidget, row);
widget.Columns = Tree.Columns.GetVisibleColumns();
widget.MainColumn = MainColumn;
widget.Bounds = bounds;
widget.OnPaint(graphics);
bounds.Y += bounds.Height;
if (bounds.Y > height)
break;
}
}
if (_moveCursor == null)
{
_moveCursor = new Cursor(typeof(VirtualTree), "Cursors.Move.cur");
_copyCursor = new Cursor(typeof(VirtualTree), "Cursors.Copy.cur");
}
WidgetControl.DragMoveCursor =
DrawingUtilities.CreateCursor(bitmap, 0.5F, 0, 0, _moveCursor, 16, 16, WidgetControl.RightToLeft);
WidgetControl.DragCopyCursor =
DrawingUtilities.CreateCursor(bitmap, 0.5F, 0, 0, _copyCursor, 16, 16, WidgetControl.RightToLeft);
WidgetControl.DragNoneCursor =
DrawingUtilities.CreateCursor(bitmap, 0.5F, 10, 10, Cursors.No, 16, 16, WidgetControl.RightToLeft);
}
}
protected virtual void DestroyDragCursors()
{
if (WidgetControl.DragNoneCursor != null)
{
DrawingUtilities.DestroyCursor(WidgetControl.DragMoveCursor);
WidgetControl.DragMoveCursor = null;
DrawingUtilities.DestroyCursor(WidgetControl.DragCopyCursor);
WidgetControl.DragCopyCursor = null;
DrawingUtilities.DestroyCursor(WidgetControl.DragNoneCursor);
WidgetControl.DragNoneCursor = null;
}
} |
_________________ Infralution Support |
|