Example #1
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     if (dragging != null)
     {
         Cursor = Cursors.Cross;
         if (images == null && MouseItem != firstD)
         {
             beginDragged = true;
             if (OnBeginDrag != null)
             {
                 OnBeginDrag.Invoke(dragging);
             }
             RegisterHandling(true);
             isDragging = true;
             var imgs = GetAllImages(SelectedItems);
             //imgs = imgs.SetSizeOfAll(new Size(30,30));
             images = FloatingImageGrid.GetImage(this, imgs, Color.Gray, null);
             images.KeepInMousePos(true, new Point(3, 3), Arithmetics.GetImagesSize(imgs, 10));
             images.Enabled = false;
             images.AddExecutor(mouseCondition, mouseAction);
             this.FindForm().Focus();
             this.FindForm().Select();
         }
     }
     else
     {
         if (MouseItem == null && dragging == null && e.Button == MouseButtons.Left)
         {
             if (panel == null)
             {
                 startPoint              = MousePosition;
                 panel                   = FloatingControl.DisplayFloatingControl <FloatingControl>(this, 1, 1, false, MousePosition);
                 panel.Location          = startPoint;
                 panel.AllowTransparency = true;
                 panel.Enabled           = false;
                 Bitmap bmp = new Bitmap(1, 1);
                 bmp.SetPixel(0, 0, Color.FromArgb(100, Color.Gray));
                 panel.BackgroundImage = bmp;
                 panel.TransparencyKey = Color.FromArgb(100, Color.Gray);
                 this.FindForm().Focus();
                 this.FindForm().Select();
             }
         }
         if (panel != null && e.Button == MouseButtons.Left)
         {
             var size = new Size(MousePosition.X - startPoint.X, MousePosition.Y - startPoint.Y);
             var loc  = panel.Location;
             if (size.Width < 0)
             {
                 size.Width *= -1;
                 loc.X       = startPoint.X - size.Width;
             }
             if (size.Height < 0)
             {
                 size.Height *= -1;
                 loc.Y        = startPoint.Y - size.Height;
             }
             panel.Size     = size;
             panel.Location = loc;
             SelectItemsAt(new Rectangle(loc, size));
         }
         else
         {
             if (panel != null)
             {
                 panel.Close();
                 panel = null;
                 //dontSelect = true;
             }
         }
     }
     base.OnMouseMove(e);
 }