예제 #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     CurrentColor = Color.Blue;
     BallDoc      = new BallDoc();
     FileName     = String.Empty;
     timer1.Start();
 }
예제 #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);
        }
예제 #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();
     }
 }
예제 #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();
        }
예제 #5
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     BallDoc.Move(_left, _top, _width, _height);
     BallDoc.CheckCollisions();
     Invalidate();
 }
예제 #6
0
 private void redoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     BallDoc.Redo();
     Invalidate();
 }