StatusBar update using directive

This commit is contained in:
Sergey Chebotar 2022-04-01 17:55:36 +03:00
parent 64240ee46c
commit 28ba91e2d6
7 changed files with 59 additions and 55 deletions

View File

@ -1,9 +1,10 @@
using ExcelDna.Integration;
using Microsoft.Office.Interop.Excel;
using System;
namespace RehauSku.Interface
{
internal abstract class AbstractBar
internal abstract class AbstractBar : IDisposable
{
protected Application Excel = AddIn.Excel;
@ -14,5 +15,10 @@ namespace RehauSku.Interface
{
AddIn.Excel.StatusBar = false;
}
public void Dispose()
{
AddIn.Excel.OnTime(DateTime.Now + new TimeSpan(0, 0, 5), "ResetStatusBar");
}
}
}

View File

@ -21,11 +21,6 @@
{
Excel.StatusBar = $"{Message} Выполнено {percent:#.#} %";
}
else
{
Excel.StatusBar = false;
}
}
}
}

View File

@ -40,7 +40,6 @@ namespace RehauSku.Interface
}
Excel.StatusBar = sb.ToString();
AddIn.Excel.OnTime(DateTime.Now + new TimeSpan(0, 0, 5), "ResetStatusBar");
}
}
}

View File

@ -28,9 +28,9 @@ namespace RehauSku.PriceListTools
public override void FillTarget()
{
ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(file => file.PositionAmount.Count));
ResultBar = new ResultBar();
using (ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(file => file.PositionAmount.Count)))
using (ResultBar = new ResultBar())
{
foreach (SourcePriceList source in SourceFiles)
{
TargetFile.Sheet.Columns[TargetFile.AmountCell.Column]
@ -53,3 +53,4 @@ namespace RehauSku.PriceListTools
}
}
}
}

View File

@ -13,9 +13,9 @@ namespace RehauSku.PriceListTools
public override void FillTarget()
{
ProgressBar = new ProgressBar("Заполняю строки...", Current.PositionAmount.Count);
ResultBar = new ResultBar();
using (ProgressBar = new ProgressBar("Заполняю строки...", Current.PositionAmount.Count))
using (ResultBar = new ResultBar())
{
foreach (var kvp in Current.PositionAmount)
{
FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
@ -27,3 +27,4 @@ namespace RehauSku.PriceListTools
}
}
}
}

View File

@ -23,9 +23,9 @@ namespace RehauSku.PriceListTools
public override void FillTarget()
{
ProgressBar = new ProgressBar("Заполняю строки...", PositionAmount.Count);
ResultBar = new ResultBar();
using (ProgressBar = new ProgressBar("Заполняю строки...", PositionAmount.Count))
using (ResultBar = new ResultBar())
{
foreach (var kvp in PositionAmount)
{
FillPositionAmountToColumns(kvp, TargetFile.AmountCell.Column);
@ -35,6 +35,7 @@ namespace RehauSku.PriceListTools
FilterByAmount();
ResultBar.Update();
}
}
private void GetSelected()
{

View File

@ -26,9 +26,9 @@ namespace RehauSku.PriceListTools
public override void FillTarget()
{
ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(x => x.PositionAmount.Count));
ResultBar = new ResultBar();
using (ProgressBar = new ProgressBar("Заполняю строки...", SourceFiles.Sum(x => x.PositionAmount.Count)))
using (ResultBar = new ResultBar())
{
foreach (SourcePriceList source in SourceFiles)
{
foreach (var kvp in source.PositionAmount)
@ -43,3 +43,4 @@ namespace RehauSku.PriceListTools
}
}
}
}