void uc_MouseDown(object sender, MouseEventArgs e) { try { //Store mouse position so we can check against it at the end of the method Point pntMousePosStart = e.Location; int i = -1; for (i = 0; i < m_dbcDisplayItems.Count(); i++) { if (m_dbcDisplayItems[i] == (UserControl)sender) { break; } } udImage_DragDrop idd = new udImage_DragDrop(); idd.Index = i; idd.BitmapData = (Bitmap)m_bmpThumbnails[i].Clone(); DragDropEffects effects = DoDragDrop(idd, DragDropEffects.Copy); //If button is up at the end of the drag/drop effect, assume that we are letting go. Point pntMousPosEnd = ((UserControl)sender).PointToClient(Control.MousePosition); if (Control.MouseButtons != MouseButtons.Left && pntMousePosStart == pntMousPosEnd) { uc_MouseUp(sender, e); } } catch (Exception ex) { Global.WriteToLog(ex); } }
private void pnlBackgroundImg_DragDrop(object sender, DragEventArgs e) { //Needs reworking to match form1 drag start if (e.Data.GetDataPresent(typeof(udImage_DragDrop))) { try { udImage_DragDrop iddData = (udImage_DragDrop)e.Data.GetData(typeof(udImage_DragDrop)); if (iddData != null && iddData.Indentifier == udImage_DragDrop.IdentifierCheck) { m_bmpBackgroundImage = iddData.BitmapData; m_iSelectedIndex = iddData.Index; pnlBackgroundImg.Invalidate(); if (ApplyClicked != null) { ApplyClicked(); } } } catch (Exception ex) { if (ex.Message != "Identifier is not valid!") { throw ex; } } } }
private void pnlBackgroundImg_DragEnter(object sender, DragEventArgs e) { try { udImage_DragDrop iddData = (udImage_DragDrop)e.Data.GetData(typeof(udImage_DragDrop)); if (iddData != null && iddData.Indentifier == udImage_DragDrop.IdentifierCheck) { e.Effect = DragDropEffects.Copy; if (ValidImageDataDragged != null) { ValidImageDataDragged(sender, e); } } else { e.Effect = DragDropEffects.None; } } catch (Exception ex) { throw ex; } }