Simple screensaver crashing
C#
1
Posts
1
Posters
0
Views
1
Watching
-
i am rather new to C#, i am switching from java, i followed through with a baisic c# screensaver tutorial, then i tried to add a picture and make it bounce around the screen. i added a picture box set to a picture(LM), i made a loop to make it move, then tried to figure out how to start it, i added it the end of load. this is probably extremely noobish and i am sorry,but if someone would help thatd be great
//Form1.cs--------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace ScreenSaver
{
public partial class Form1 : Form
{private int screenNumber; private Point MouseXY; int curX = 1; int curY = 1; Boolean running = true; public Form1(int screen) { screenNumber = screen; InitializeComponent(); this.run(); } private void form1\_Load(object sender, System.EventArgs e) { this.Bounds = Screen.AllScreens\[screenNumber\].Bounds; Cursor.Hide(); TopMost = true; } private void onMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (!MouseXY.IsEmpty) { if(MouseXY != new Point(e.X,e.Y)) { running = false; } if(e.Clicks >0) { running = false; } } MouseXY = new Point(e.X, e.Y); } public void run() { while (running) { loopMove(); Thread.Sleep(1000); } Close(); } private void LM\_Click(object sender, EventArgs e) { } private void changeLMY(int y) { LM.Left += y; } private void changeLMX(int x) { LM.Top += x; } private void loopMove() { int fX = this.Top; int fY = this.Left; if (LM.Top >= fX - 300) curX = -1; if (LM.Top == 0) curX = 1; if (LM.Left >= fY - 300)