using System;
using System.Drawing;
using System.Windows.Forms;

namespace uBIMEarthTools
{

    public partial class FilterProgressForm : Form
    {
        string _format;
        public FilterProgressForm(string caption, string format, int max)
        {
            _format = format;
            InitializeComponent();
            Text = caption;
            label1.Text = (null == format) ? caption : string.Format(format, 0);
            progressBar1.Minimum = 0;
            progressBar1.Maximum = max;
            progressBar1.Value = 0;
            progressBar1.Tag = "OK";
            int xWidth = SystemInformation.PrimaryMonitorSize.Width;//获取显示器屏幕宽度
            int yHeight = SystemInformation.PrimaryMonitorSize.Height;//高度
            this.Location=new Point(450,160);
            Show();
            Application.DoEvents();
        }

        public void Increment()
        {
            ++progressBar1.Value;
            if (null != _format)
            {
                label1.Text = string.Format(_format, progressBar1.Value);
            }
            Application.DoEvents();
        }

        public void SetText(string text)
        {
            label1.Text = text;
            System.Windows.Forms.Application.DoEvents();
        }

        public void SetProgressBarMinMax(int min, int max)
        {
            progressBar1.Minimum = min;
            progressBar1.Maximum = max;
            progressBar1.Value = 0;
        }

        public void IncrementProgressBar()
        {
            progressBar1.Value++;
            System.Windows.Forms.Application.DoEvents();
        }

        public void HideProgressBar()
        {
            progressBar1.Visible = false;
            System.Windows.Forms.Application.DoEvents();
        }

        public void ShowProgressBar()
        {
            progressBar1.Visible = true;
            System.Windows.Forms.Application.DoEvents();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            progressBar1.Tag = "Cancel";
            this.Close();
        }
    }
}

