C # A small program that displays images at random positions in full screen mode,
Idea: Use the screen as the background image of the program. In the displayed dialog box, select "OK" and display the scheduled image at random position. (The ESC key can be exited)
- Control to be added: Timer
1 Rectangle bounds = Screen. getBounds (Screen. getBounds (Point. empty); 2 3 public Form1 () 4 {5 this. formBorderStyle = System. windows. forms. formBorderStyle. none; 6 this. backgroundImage = GetNoCursor (); 7 InitializeComponent (); 8} 9 10 private void Form1_Load (object sender, EventArgs e) 11 {12 timer1.Interval = 500; 13 if (MessageBox. show ("message", "title", MessageBoxButtons. yesNo) = DialogResult. yes) 14 {15 Timer1.Enabled = true; 16} 17 else18 {19 this. close (); 20} 21} 22 23 private void Form1_KeyDown (object sender, KeyEventArgs e) 24 {25 if (e. keyData = Keys. escape) 26 {27 timer1.Enabled = false; 28 MessageBox. show ("message", "title", MessageBoxButtons. OK); 29 this. close (); 30} 31} 32 33 private Bitmap GetNoCursor () 34 {35 Bitmap Source = new Bitmap (bounds. width, bounds. height); // create a Bitmap object 36 Graphics g = Based on the screen size Graphics. fromImage (Source); 37g. copyFromScreen (0, 0, 0, 0, Source. size); // obtain the 38 GB screen without a mouse. dispose (); // release resource 39 return Source; 40} 41 42 private void timereffectick (object sender, EventArgs e) 43 {44 Image img = Resource1.Image1; // obtain the resource file for display 45 if (img! = Null) 46 {47 Graphics g = this. createGraphics (); 48 Random rd = new Random (); 49 int picXPoint = rd. next (0, bounds. right-img. width); 50 int picYPoint = rd. next (0, bounds. height-img. height); 51 Point ulCorner = new Point (picXPoint, picYPoint); 52g. drawImageUnscaled (img, ulCorner); 53} 54 else55 {56 timer1.Enabled = false; 57 MessageBox. show ("no image, thank you for using"); 58 this. close (); 59} 60}