Beispiel #1
0
        void BuildBmpSource(object data, Rectangle sourceRange, GenerateImageCallBack dragImageCreator)
        {
            if (BmpSource != null)
            {
                BmpSource.Dispose();
                BmpSource = null;
            }

            if (dragImageCreator != null)
            {
                BmpSource = dragImageCreator(data);
            }
            else
            {
                if (Owner == null || !Owner.Created || sourceRange.Width <= 0 || sourceRange.Height <= 0)
                {
                    return;
                }

                BmpSource = new Bitmap(sourceRange.Width, sourceRange.Height);
                Owner.DrawToBitmap(BmpSource, sourceRange, 0, 0);
            }
        }
Beispiel #2
0
        public void BeginDrag(object data, Rectangle sourceRange, Rectangle moveRange, Point mousePos, GenerateImageCallBack dragImageCreator)
        {
            SourceRange = sourceRange;
            MoveRange   = moveRange;
            DragObject  = data;
            IsDraging   = false;

            if (Owner == null)
            {
                return;
            }

            RelativeMousePos = new Point(sourceRange.X - mousePos.X, sourceRange.Y - mousePos.Y);
            IsDraging        = true;

            if (DraggingFeedback != DragFeedbackType.None)
            {
                if (DragginBox == null)
                {
                    DragginBox = new DragBmpWin(this, DraggingFeedback == DragFeedbackType.SubControl ? Owner : null);
                }
                BuildBmpSource(data, sourceRange, dragImageCreator);
                DragginBox.Show(BmpSource, new Point(sourceRange.X, sourceRange.Y));
            }
        }