Exemple #1
0
 private void Progressing_Tick(object sender, EventArgs e)
 {
     progressBar1.PerformStep();
     if (progressBar1.Value == progressBar1.Maximum)
     {
         countdownlabel.Text = "Time's up!";
         OneSec.Stop();
         Progressing.Stop();     // 計時器停止
     }
 }
    public void DoProgress(int index = -1, string operation = null)
    {
        bool process = true;
        bool refresh = false;

        if (UseQuanta)
        {
            CurrentQuanta++;
            if (CurrentQuanta >= QuantaLevel)
            {
                CurrentQuanta = 0;
            }
            else
            {
                process = false;
            }
        }
        if (!operation.IsNullOrEmpty())
        {
            LabelOperation.Text = operation;
            refresh             = true;
        }
        if (process)
        {
            if (index == -1)
            {
                ProgressBar.PerformStep();
            }
            else
            {
                ProgressBar.Value = index;
            }
            if (LabelCount.Visible)
            {
                LabelCount.Text = $"{ProgressBar.Value}/{ProgressBar.Maximum}";
            }
            refresh = true;
            BringToFront();
        }
        if (refresh)
        {
            Refresh();
        }
        if (Progressing is not null)
        {
            SystemManager.TryCatchManage(() => Progressing.Invoke());
        }
        if (ActionCancel.Visible)
        {
            Application.DoEvents();
        }
    }
Exemple #3
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     OneSec.Stop();
     Progressing.Stop();
     countdowntime = int.Parse(textBox1.Text);
     if (countdowntime != 0)
     {
         progressBar1.Value   = progressBar1.Minimum;
         Progressing.Interval = 10 * countdowntime;
         OneSec.Start();
         Progressing.Start();
     }
 }
Exemple #4
0
        public List <int> GetAllPrimesBelowNumber(int pNumber)
        {
            if (pNumber < 1)
            {
                throw new ArgumentOutOfRangeException();
            }
            Initializing?.Invoke(this, new EventArgs());
            List <int> allPrimes = new List <int>();

            for (int current = 1; current < pNumber; current++)
            {
                bool isPrime = IsPrimeNumber(current);
                if (isPrime)
                {
                    Thread.Sleep(10);
                    allPrimes.Add(current);
                    Progressing?.Invoke(this, new ProgressingEventArgs(pNumber, current));
                }
            }
            Completed?.Invoke(this, new PrimeCompletedEventArgs(pNumber, allPrimes, new TimeSpan(0)));
            return(allPrimes);
        }