From 120eee0231d02e90d9d195ebc38327a58d4564a8 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Wed, 2 Feb 2022 10:23:50 +0300 Subject: Add Excel statusbar progress message --- src/Interface/ProgressBar.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Interface/ProgressBar.cs (limited to 'src/Interface') diff --git a/src/Interface/ProgressBar.cs b/src/Interface/ProgressBar.cs new file mode 100644 index 0000000..474bed7 --- /dev/null +++ b/src/Interface/ProgressBar.cs @@ -0,0 +1,32 @@ +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; + + public ProgressBar(int weight) + { + TaskWeight = weight; + CurrentProgress = 0; + } + + public void DoProgress() + { + double percent = (++CurrentProgress / TaskWeight) * 100; + + if (percent < 100) + { + Excel.StatusBar = $"Выполнено {percent.ToString("#.##")} %"; + } + + else + { + Excel.StatusBar = false; + } + } + } +} -- cgit v1.2.3