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 DeskTop
- {
- public partial class Form1 : Form
- {
- Random r = new Random();
- private PictureBox rubish;
- PictureBox[] folderofError;
- public Form1()
- {
- InitializeComponent();
- GenerateBin();
- GeneratePicture();
- GenerateError();
- }
- public void GenerateBin ()
- {
- this.Width = 900;
- this.Height = 600;
- rubish = new PictureBox();
- rubish.Image = Properties.Resources.imageofbin;
- rubish.BackgroundImageLayout = ImageLayout.Center;
- rubish.SizeMode = PictureBoxSizeMode.AutoSize;
- rubish.Size = new Size(90, 100);
- rubish.Location = new Point(800, 400);
- rubish.MouseMove += Rubish_MouseMove;
- rubish.MouseLeave += Rubish_MouseLeave;
- this.Controls.Add(rubish);
- }
- private void Rubish_MouseLeave(object sender, EventArgs e)
- {
- rubish.Image = Properties.Resources.imageofbin;
- }
- private void Rubish_MouseMove(object sender, MouseEventArgs e)
- {
- rubish.Image = Properties.Resources.imageofbin2;
- if (e.Button == MouseButtons.Right)
- rubish.Image = Properties.Resources.imageofbin2;
- {
- for (int i = 0; i < folderofError.Length; i++)
- {
- if(folderofError[i].Location.X>750 && folderofError[i].Location.X<890 && folderofError[i].Location.Y > 350 && folderofError[i].Location.Y < 600)
- {
- this.Controls.Remove(folderofError[i]);
- }
- }
- }
- }
- public void GeneratePicture()
- {
- PictureBox[] folderofPicture = new PictureBox[r.Next(0, 3)];
- for(int i = 0; i< folderofPicture.Length;i++ )
- {
- int PositionOfX = r.Next(0, 800);
- int PositionOfY = r.Next(0, 500);
- folderofPicture[i] = new PictureBox();
- folderofPicture[i].Location = new Point(PositionOfX, PositionOfY);
- folderofPicture[i].Size = new Size(37, 37);
- folderofPicture[i].Image = Properties.Resources.iconfinder_folder_picture_299095;
- folderofPicture[i].SizeMode = PictureBoxSizeMode.Zoom;
- this.Controls.Add(folderofPicture[i]);
- }
- }
- public void GenerateError()
- {
- folderofError = new PictureBox[r.Next(1, 3)];
- for (int i = 0; i < folderofError.Length; i++)
- {
- int PositionOfX = r.Next(0, 800);
- int PositionOfY = r.Next(0, 500);
- folderofError[i] = new PictureBox();
- folderofError[i].Location = new Point(PositionOfX, PositionOfY);
- folderofError[i].Size = new Size(37, 37);
- folderofError[i].Image = Properties.Resources.iconfinder_icon_102_folder_error_314679;
- folderofError[i].SizeMode = PictureBoxSizeMode.Zoom;
- folderofError[i].MouseMove += Error_MouseMove;
- this.Controls.Add(folderofError[i]);
- }
- }
- private void Error_MouseMove(object sender, MouseEventArgs e)
- {
- if(e.Button == MouseButtons.Left)
- {
- PictureBox u = sender as PictureBox;
- u.Location = new Point(Cursor.Position.X-20, Cursor.Position.Y-40);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment