Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Customize snapshot of the dragged row

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
rnemchev



Joined: 26 Apr 2010
Posts: 12

PostPosted: Tue May 18, 2010 3:30 pm    Post subject: Customize snapshot of the dragged row Reply with quote

Hello,

Is it possible to customize drawing of dragged row image (displayed next to the drag cursor)?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue May 18, 2010 10:39 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
rnemchev



Joined: 26 Apr 2010
Posts: 12

PostPosted: Wed May 19, 2010 1:42 pm    Post subject: Reply with quote

Thanks! Your support is excellent!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group