RhSolutions-AddIn/src/Interface/ProgressBar.cs

35 lines
844 B
C#
Raw Normal View History

2022-02-02 10:23:50 +03:00
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;
2022-02-03 21:56:14 +03:00
private readonly string Message;
2022-02-02 10:23:50 +03:00
2022-02-03 21:56:14 +03:00
public ProgressBar(string message, int weight)
2022-02-02 10:23:50 +03:00
{
2022-02-03 21:56:14 +03:00
Message = message;
2022-02-02 10:23:50 +03:00
TaskWeight = weight;
CurrentProgress = 0;
}
public void DoProgress()
{
double percent = (++CurrentProgress / TaskWeight) * 100;
if (percent < 100)
{
2022-02-03 21:56:14 +03:00
Excel.StatusBar = $"{Message} Выполнено {percent.ToString("#.##")} %";
2022-02-02 10:23:50 +03:00
}
else
{
Excel.StatusBar = false;
}
}
}
}