﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BezeciGumb
{
    public partial class GlOkno_BezeciGumb : Form
    {
        int klikov = 0;
        Random gen = new Random();

        public GlOkno_BezeciGumb()
        {
            InitializeComponent();
        }

        private void gmbBezi_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            klikov += 1;
            gmbBezi.Location = new Point(gen.Next(this.Size.Width - gmbBezi.Size.Width),
                             gen.Next(this.Height - gmbBezi.Size.Height));
            gmbBezi.Text = klikov.ToString();
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            gmbBezi.Location = new Point(gen.Next(this.Size.Width - gmbBezi.Size.Width),
                                         gen.Next(this.Height - gmbBezi.Size.Height));

        }

        private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
        {
            timer1.Interval = 300 + vScrollBar1.Value * 8;
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            progressBar1.Value += 1;
            if (progressBar1.Value == progressBar1.Maximum)
            {                
                timer2.Stop();
                this.Controls.Remove(progressBar1);
                timer1.Stop();
                MessageBox.Show("KONEC");               
            }
            
          
        }

        private void GlOkno_BezeciGumb_Load(object sender, EventArgs e)
        {
            timer2.Start();
            timer1.Start();
            gmbBezi.BackColor = GlOkno_BezeciGumb.DefaultBackColor;
            gmbBezi.FlatStyle = FlatStyle.Flat;
            gmbBezi.FlatAppearance.BorderSize = 0;
            gmbBezi.FlatAppearance.CheckedBackColor = GlOkno_BezeciGumb.DefaultBackColor;
            gmbBezi.FlatAppearance.MouseOverBackColor = GlOkno_BezeciGumb.DefaultBackColor;
            gmbBezi.FlatAppearance.MouseDownBackColor = GlOkno_BezeciGumb.DefaultBackColor; 

        }

        private void progressBar1_Click(object sender, EventArgs e)
        {

        }
    }
}
