aboutsummaryrefslogtreecommitdiff
path: root/src/Interface/ProgressBar.cs
blob: 9a0490b0db4e26804251a36c95573a89b9a0b902 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Microsoft.Office.Interop.Excel;

namespace RehauSku.Interface
{
    internal class ProgressBar
    {
        private Application Excel = AddIn.Excel;
        private double CurrentProgress { get; set; }
        private readonly double TaskWeight;
        private readonly string Message;

        public ProgressBar(string message, int weight)
        {
            Message = message;
            TaskWeight = weight;
            CurrentProgress = 0;
        }

        public void DoProgress()
        {
            double percent = (++CurrentProgress / TaskWeight) * 100;

            if (percent < 100)
            {
                Excel.StatusBar = $"{Message} Выполнено {percent.ToString("#.##")} %";
            }

            else
            {
                Excel.StatusBar = false;
            }
        }
    }
}