Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Simple screensaver crashing

Simple screensaver crashing

Scheduled Pinned Locked Moved C#
tutorialcsharpjavagraphicshelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Data_Dragon
    wrote on last edited by
    #1

    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)
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups