コード例 #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int top    = menuStrip1.Height + toolStrip1.Height;
            int heigth = this.Height - statusStrip1.Height - 25;

            BaloonsDoc.MoveBaloons(top, heigth);
            Invalidate();
        }
コード例 #2
0
 public Form1()
 {
     InitializeComponent();
     BaloonsDoc          = new BaloonsDoc();
     Color               = Color.DarkRed;
     Filename            = string.Empty;
     Random              = new Random();
     this.DoubleBuffered = true;
     timer1.Start();
 }
コード例 #3
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            int x = Random.Next(Baloon.Radius * 2, this.Width - Baloon.Radius * 2);
            int y = Random.Next(Baloon.Radius * 2 + toolStrip1.Height + menuStrip1.Height,
                                this.Height - Baloon.Radius * 2 - statusStrip1.Height - 25);
            Point center = new Point(x, y);

            BaloonsDoc.AddBaloon(center, Color);
            Invalidate(true);
        }
コード例 #4
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            if (MessageBox.Show("Are you sure you want to start a new game", "Start a new game",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                BaloonsDoc = new BaloonsDoc();
                Filename   = string.Empty;
                Invalidate(true);
            }

            timer1.Start();
        }
コード例 #5
0
        private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selectAllToolStripMenuItem.Text == "Select &All")
            {
                BaloonsDoc.SelectAllBaloons(true);
                selectAllToolStripMenuItem.Text = "Unselect &All";
            }
            else
            {
                BaloonsDoc.SelectAllBaloons(false);
                selectAllToolStripMenuItem.Text = "Select &All";
            }

            Invalidate();
        }
コード例 #6
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Color.White);

            BaloonsDoc.DrawBaloons(e.Graphics);

            if (Filename != string.Empty)
            {
                this.Text = $"Moving baloons | {Filename.Substring(Filename.LastIndexOf(@"\") + 1)}";
            }
            else
            {
                this.Text = "Moving baloons";
            }
        }
コード例 #7
0
 private void Form1_MouseClick(object sender, MouseEventArgs e)
 {
     BaloonsDoc.SelectBaloon(e.X, e.Y);
 }
コード例 #8
0
 private void statusStrip1_Paint(object sender, PaintEventArgs e)
 {
     lblBaloni.Text = $"Baloons: {BaloonsDoc.BallonsCount()}";
 }