Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp1
- {
- public partial class FormG3DataTypeDragDrop : Form
- {
- public static class Globals
- {
- public static string strDragObject ="blank";
- }
- public FormG3DataTypeDragDrop()
- {
- InitializeComponent();
- }
- private void btnReturn_Click(object sender, EventArgs e)
- {
- this.Owner.Show();
- this.Close();
- }
- private void pbDragDate1_MouseDown(object sender, MouseEventArgs e)
- {
- // set the Global Drag Object to indicate a 'Date'
- Globals.strDragObject = "Date";
- //Defines sender as a picturebox so we can use it
- PictureBox codeBlockDate1 = sender as PictureBox;
- //Define a data object and store the image and the tag
- DataObject dragImageDate1 = new DataObject();
- dragImageDate1.SetData(DataFormats.Bitmap, true, codeBlockDate1.Image);
- dragImageDate1.SetData(DataFormats.Text, true, codeBlockDate1.Tag);
- //Copies the data object as we drag
- DoDragDrop(dragImageDate1, DragDropEffects.Copy);
- }
- private void pbDragNumber1_MouseDown(object sender, MouseEventArgs e)
- {
- // set the Global Drag Object to indicate a 'Number'
- Globals.strDragObject = "Number";
- //Defines sender as a picturebox so we can use it
- PictureBox codeBlockNumber1 = sender as PictureBox;
- //Define a data object and store the image and the tag
- DataObject dragImageNumber1 = new DataObject();
- dragImageNumber1.SetData(DataFormats.Bitmap, true, codeBlockNumber1.Image);
- dragImageNumber1.SetData(DataFormats.Text, true, codeBlockNumber1.Tag);
- //Copies the data object as we drag
- DoDragDrop(dragImageNumber1, DragDropEffects.Copy);
- }
- private void pbDragString1_MouseDown(object sender, MouseEventArgs e)
- {
- // set the Global Drag Object to indicate a 'String'
- Globals.strDragObject = "String";
- //Defines sender as a picturebox so we can use it
- PictureBox codeBlockString1 = sender as PictureBox;
- //Define a data object and store the image and the tag
- DataObject dragImageString1 = new DataObject();
- dragImageString1.SetData(DataFormats.Bitmap, true, codeBlockString1.Image);
- dragImageString1.SetData(DataFormats.Text, true, codeBlockString1.Tag);
- //Copies the data object as we drag
- DoDragDrop(dragImageString1, DragDropEffects.Copy);
- }
- private void gbNumberDataType_DragDrop(object sender, DragEventArgs e)
- {
- }
- private void FormG3DataTypeDragDrop_Load(object sender, EventArgs e)
- {
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void lblDragNumberHere_DragEnter(object sender, DragEventArgs e)
- {
- e.Effect = DragDropEffects.Copy;
- }
- private void lblDragNumberHere_DragDrop(object sender, DragEventArgs e)
- {
- // Check if the Global Drag Object is set to 'Number'. If so, allow the image to be dropped. Otherwise - do not drop the image.
- if (Globals.strDragObject == "Number")
- {
- Label picbox = (Label)sender;
- Graphics g = picbox.CreateGraphics();
- g.DrawImage((Image)e.Data.GetData(DataFormats.Bitmap), new Point(0, 0));
- } else
- {
- // find a way of saying "wrong data type!"
- Globals.strDragObject = "Blank";
- }
- }
- private void lblDragNumberHere_Click(object sender, EventArgs e)
- {
- }
- private void lbDragStringHere_DragEnter(object sender, DragEventArgs e)
- {
- e.Effect = DragDropEffects.Copy;
- }
- private void lbDragDateHere_DragEnter(object sender, DragEventArgs e)
- {
- e.Effect = DragDropEffects.Copy;
- }
- private void lbDragStringHere_DragDrop(object sender, DragEventArgs e)
- {
- // Check if the Global Drag Object is set to 'String'. If so, allow the image to be dropped. Otherwise - do not drop the image.
- if (Globals.strDragObject == "String")
- {
- Label picbox = (Label)sender;
- Graphics g = picbox.CreateGraphics();
- g.DrawImage((Image)e.Data.GetData(DataFormats.Bitmap), new Point(0, 0));
- }
- else
- {
- // find a way of saying "wrong data type!"
- Globals.strDragObject = "Blank";
- }
- }
- private void lbDragDateHere_DragDrop(object sender, DragEventArgs e)
- {
- // Check if the Global Drag Object is set to 'Date'. If so, allow the image to be dropped. Otherwise - do not drop the image.
- if (Globals.strDragObject == "Date")
- {
- Label picbox = (Label)sender;
- Graphics g = picbox.CreateGraphics();
- g.DrawImage((Image)e.Data.GetData(DataFormats.Bitmap), new Point(0, 0));
- }
- else
- {
- // find a way of saying "wrong data type!"
- Globals.strDragObject = "Blank";
- }
- }
- private void pbDragDate1_Click(object sender, EventArgs e)
- {
- }
- private void gbStringDataType_Enter(object sender, EventArgs e)
- {
- }
- private void lbDragStringHere_Click(object sender, EventArgs e)
- {
- }
- private void pbDragNumber1_Click(object sender, EventArgs e)
- {
- }
- private void pbDragString1_Click(object sender, EventArgs e)
- {
- }
- private void gbNumberDataType_Enter(object sender, EventArgs e)
- {
- }
- private void gbDateDataType_Enter(object sender, EventArgs e)
- {
- }
- }
- }
Add Comment
Please, Sign In to add comment