Prometheus3439

Untitled

Apr 1st, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace DeskTop
  12. {
  13.  
  14. public partial class Form1 : Form
  15. {
  16. Random r = new Random();
  17. private PictureBox rubish;
  18. PictureBox[] folderofError;
  19. public Form1()
  20. {
  21. InitializeComponent();
  22. GenerateBin();
  23. GeneratePicture();
  24. GenerateError();
  25. }
  26. public void GenerateBin ()
  27. {
  28. this.Width = 900;
  29. this.Height = 600;
  30. rubish = new PictureBox();
  31. rubish.Image = Properties.Resources.imageofbin;
  32. rubish.BackgroundImageLayout = ImageLayout.Center;
  33. rubish.SizeMode = PictureBoxSizeMode.AutoSize;
  34. rubish.Size = new Size(90, 100);
  35. rubish.Location = new Point(800, 400);
  36. rubish.MouseMove += Rubish_MouseMove;
  37. rubish.MouseLeave += Rubish_MouseLeave;
  38. this.Controls.Add(rubish);
  39. }
  40.  
  41. private void Rubish_MouseLeave(object sender, EventArgs e)
  42. {
  43. rubish.Image = Properties.Resources.imageofbin;
  44. }
  45.  
  46. private void Rubish_MouseMove(object sender, MouseEventArgs e)
  47. {
  48. rubish.Image = Properties.Resources.imageofbin2;
  49. if (e.Button == MouseButtons.Right)
  50. rubish.Image = Properties.Resources.imageofbin2;
  51. {
  52. for (int i = 0; i < folderofError.Length; i++)
  53. {
  54. if(folderofError[i].Location.X>750 && folderofError[i].Location.X<890 && folderofError[i].Location.Y > 350 && folderofError[i].Location.Y < 600)
  55. {
  56. this.Controls.Remove(folderofError[i]);
  57. }
  58. }
  59. }
  60. }
  61.  
  62. public void GeneratePicture()
  63. {
  64. PictureBox[] folderofPicture = new PictureBox[r.Next(0, 3)];
  65.  
  66. for(int i = 0; i< folderofPicture.Length;i++ )
  67. {
  68. int PositionOfX = r.Next(0, 800);
  69. int PositionOfY = r.Next(0, 500);
  70. folderofPicture[i] = new PictureBox();
  71. folderofPicture[i].Location = new Point(PositionOfX, PositionOfY);
  72. folderofPicture[i].Size = new Size(37, 37);
  73. folderofPicture[i].Image = Properties.Resources.iconfinder_folder_picture_299095;
  74. folderofPicture[i].SizeMode = PictureBoxSizeMode.Zoom;
  75. this.Controls.Add(folderofPicture[i]);
  76. }
  77. }
  78.  
  79. public void GenerateError()
  80. {
  81. folderofError = new PictureBox[r.Next(1, 3)];
  82.  
  83. for (int i = 0; i < folderofError.Length; i++)
  84. {
  85. int PositionOfX = r.Next(0, 800);
  86. int PositionOfY = r.Next(0, 500);
  87. folderofError[i] = new PictureBox();
  88. folderofError[i].Location = new Point(PositionOfX, PositionOfY);
  89. folderofError[i].Size = new Size(37, 37);
  90. folderofError[i].Image = Properties.Resources.iconfinder_icon_102_folder_error_314679;
  91. folderofError[i].SizeMode = PictureBoxSizeMode.Zoom;
  92.  
  93. folderofError[i].MouseMove += Error_MouseMove;
  94. this.Controls.Add(folderofError[i]);
  95. }
  96. }
  97.  
  98.  
  99. private void Error_MouseMove(object sender, MouseEventArgs e)
  100. {
  101. if(e.Button == MouseButtons.Left)
  102. {
  103. PictureBox u = sender as PictureBox;
  104. u.Location = new Point(Cursor.Position.X-20, Cursor.Position.Y-40);
  105. }
  106. }
  107.  
  108.  
  109. }
  110. }
Add Comment
Please, Sign In to add comment