コード例 #1
0
 public Form1()
 {
     InitializeComponent();
     this.DoubleBuffered = true;
     BallDoc             = new BallDoc();
     Random = new Random();
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Bojmaliev/finkiVezbi
 public Form1()
 {
     InitializeComponent();
     ballDoc = new BallDoc(this.Width, this.Height);
     timer1.Start();
     this.DoubleBuffered = true;
 }
コード例 #3
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool stopped = false;

            if (timer1.Enabled)
            {
                timer1.Stop();
                stopped = true;
            }

            if (MessageBox.Show("Are you sure you want to start a new game?", "Start a new game",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                BallDoc  = new BallDoc();
                Filename = string.Empty;
                stopped  = false;
                timer1.Stop();
                Invalidate(true);
            }

            if (stopped)
            {
                timer1.Start();
            }
        }
コード例 #4
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (BallDoc.Move(this.Width, this.Height - statusStrip1.Height))
     {
         timer1.Stop();
     }
     Invalidate(true);
 }
コード例 #5
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.White);

            BallDoc.DrawBalls(e.Graphics);

            if (Filename != string.Empty)
            {
                this.Text = $"Sliding Balls | {Filename.Substring(Filename.LastIndexOf(@"\") + 1)}";
            }
            else
            {
                this.Text = "Sliding Balls";
            }
        }
コード例 #6
0
        private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var choice = Random.Next(2);

            if (choice == 0) // add a blue ball
            {
                BallDoc.AddBall(e.Location, Color.Blue);
            }
            else if (choice == 1)
            {
                BallDoc.AddBall(e.Location, Color.Green);
            }

            Invalidate(true);
        }
コード例 #7
0
 private void Form1_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left) // start moving a red ball, if clicked
     {
         if (BallDoc.SelectBall(e.Location))
         {
             timer1.Start();
         }
     }
     else if (e.Button == MouseButtons.Right) // add a red ball
     {
         BallDoc.AddBall(e.Location, Color.Red);
         Invalidate(true);
     }
 }