Exemplo n.º 1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     CurrentColor = Color.Blue;
     BallDoc      = new BallDoc();
     FileName     = String.Empty;
     timer1.Start();
 }
Exemplo n.º 2
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.White);
            var pen = new Pen(Color.Black, 3);

            e.Graphics.DrawRectangle(pen, _left, _top, _width, _height);
            pen.Dispose();
            BallDoc.Draw(e.Graphics);
        }
Exemplo n.º 3
0
 private void Form1_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Location.X > (_left + Ball.Radius) &&
         e.Location.Y > (_top + Ball.Radius) &&
         e.Location.X < ((_left + _width) - Ball.Radius) &&
         e.Location.Y < ((_top + _height) - Ball.Radius))
     {
         var ball = new Ball(e.Location, CurrentColor);
         BallDoc.AddBall(ball);
         Invalidate();
         BallDoc.ClearRedoStack();
     }
 }
Exemplo n.º 4
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            string message = "Do you want to save the game?";
            string caption = "Save before new game";
            var    res     = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                saveToolStripMenuItem_Click(sender, e);
            }

            FileName = string.Empty;
            BallDoc  = new BallDoc();
            Invalidate();
            timer1.Start();
        }
Exemplo n.º 5
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     BallDoc.Move(_left, _top, _width, _height);
     BallDoc.CheckCollisions();
     Invalidate();
 }
Exemplo n.º 6
0
 private void redoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     BallDoc.Redo();
     Invalidate();
 }