aboutsummaryrefslogtreecommitdiff
path: root/src/Interface
diff options
context:
space:
mode:
Diffstat (limited to 'src/Interface')
-rw-r--r--src/Interface/Dialog.cs40
-rw-r--r--src/Interface/ProgressBar.cs22
-rw-r--r--src/Interface/ResultBar.cs45
-rw-r--r--src/Interface/RibbonController.cs137
-rw-r--r--src/Interface/StatusbarBase.cs25
5 files changed, 0 insertions, 269 deletions
diff --git a/src/Interface/Dialog.cs b/src/Interface/Dialog.cs
deleted file mode 100644
index 992368c..0000000
--- a/src/Interface/Dialog.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Microsoft.Office.Interop.Excel;
-using System.Collections.Generic;
-using System.Windows.Forms;
-
-namespace RhSolutions.Interface
-{
- static class Dialog
- {
- public static string GetFilePath()
- {
- using (OpenFileDialog dialog = new OpenFileDialog())
- {
- dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
-
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- return dialog.FileName;
- }
-
- else return string.Empty;
- }
- }
-
- public static string[] GetMultiplyFiles()
- {
- using (OpenFileDialog dialog = new OpenFileDialog())
- {
- dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
- dialog.Multiselect = true;
-
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- return dialog.FileNames;
- }
-
- else return null;
- }
- }
- }
-}
diff --git a/src/Interface/ProgressBar.cs b/src/Interface/ProgressBar.cs
deleted file mode 100644
index 7217d4e..0000000
--- a/src/Interface/ProgressBar.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace RhSolutions.Interface
-{
- internal class ProgressBar : StatusbarBase
- {
- 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 override void Update()
- {
- double percent = (++CurrentProgress / TaskWeight) * 100;
- Excel.StatusBar = $"{Message} Выполнено {percent:#.#} %";
- }
- }
-}
diff --git a/src/Interface/ResultBar.cs b/src/Interface/ResultBar.cs
deleted file mode 100644
index 3652738..0000000
--- a/src/Interface/ResultBar.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System;
-using System.Text;
-
-namespace RhSolutions.Interface
-{
- internal class ResultBar : StatusbarBase
- {
- private int Success { get; set; }
- private int Replaced { get; set; }
- private int NotFound { get; set; }
-
- public ResultBar()
- {
- Success = 0;
- Replaced = 0;
- NotFound = 0;
- }
-
- public void IncrementSuccess() => Success++;
- public void IncrementReplaced() => Replaced++;
- public void IncrementNotFound() => NotFound++;
-
- public override void Update()
- {
- StringBuilder sb = new StringBuilder();
-
- if (Success > 0)
- {
- sb.Append($"Успешно экспортировано {Success} артикулов. ");
- }
-
- if (Replaced > 0)
- {
- sb.Append($"Заменено {Replaced} артикулов. ");
- }
-
- if (NotFound > 0)
- {
- sb.Append($"Не найдено {NotFound} артикулов.");
- }
-
- Excel.StatusBar = sb.ToString();
- }
- }
-}
diff --git a/src/Interface/RibbonController.cs b/src/Interface/RibbonController.cs
deleted file mode 100644
index 6bbba3e..0000000
--- a/src/Interface/RibbonController.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-using ExcelDna.Integration.CustomUI;
-using Microsoft.Office.Interop.Excel;
-using RhSolutions.PriceListTools;
-using System;
-using System.IO;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Windows.Forms;
-
-namespace RhSolutions.Interface
-{
- [ComVisible(true)]
- public class RibbonController : ExcelRibbon
- {
- private static IRibbonUI ribbonUi;
-
- public override string GetCustomUI(string RibbonID)
- {
- return @"
- <customUI onLoad='RibbonLoad' xmlns='http://schemas.microsoft.com/office/2006/01/customui'>
- <ribbon>
- <tabs>
- <tab id='rau' label='RhSolutions'>
- <group id='priceList' label='Прайс-лист'>
- <button id='export' getEnabled='GetExportEnabled' label='Экспорт в новый файл' size='normal' imageMso='PivotExportToExcel' onAction='OnToolPressed'/>
- <button id='convert' getEnabled='GetConvertEnabled' label='Актуализировать' size='normal' imageMso='FileUpdate' onAction='OnToolPressed'/>
- <menu id='conjoinMenu' label='Объединить' imageMso='Copy'>
- <button id='merge' label='Сложить' onAction='OnToolPressed'/>
- <button id='combine' label='По колонкам' onAction='OnToolPressed'/>
- </menu>
- </group>
- <group id='rausettings' getLabel='GetVersionLabel'>
- <button id='setPriceList' getLabel='GetPriceListPathLabel' size='large' imageMso='TableExcelSpreadsheetInsert' onAction='OnSetPricePressed'/>
- </group>
- </tab>
- </tabs>
- </ribbon>
- </customUI>";
- }
-
- public void RibbonLoad(IRibbonUI sender)
- {
- ribbonUi = sender;
- }
-
- public static void RefreshControl(string id)
- {
- if (ribbonUi != null)
- {
- ribbonUi.InvalidateControl(id);
- }
- }
- public void OnSetPricePressed(IRibbonControl control)
- {
- string path = Dialog.GetFilePath();
-
- if (!string.IsNullOrEmpty(path))
- {
- RegistryUtil.PriceListPath = path;
- }
- }
-
- public void OnToolPressed(IRibbonControl control)
- {
- try
- {
- ToolBase tool;
- switch (control.Id)
- {
- case "export":
- tool = new ExportTool();
- break;
- case "convert":
- tool = new ConvertTool();
- break;
- case "merge":
- tool = new MergeTool();
- break;
- case "combine":
- tool = new CombineTool();
- break;
- default:
- throw new Exception("Неизвестный инструмент");
- }
-
- tool.OpenNewPrice();
- tool.FillTarget();
- }
-
- catch (Exception exception)
- {
- MessageBox.Show(exception.Message,
- "Ошибка",
- MessageBoxButtons.OK,
- MessageBoxIcon.Information);
- AddIn.Excel.StatusBar = false;
- return;
- }
- }
-
- public bool GetConvertEnabled(IRibbonControl control)
- {
- if (AddIn.Excel.ActiveWorkbook == null)
- return false;
-
- else
- {
- Worksheet worksheet = AddIn.Excel.ActiveWorkbook.ActiveSheet;
- return worksheet.IsRehauSource();
- }
- }
-
- public bool GetExportEnabled(IRibbonControl control)
- {
- if (AddIn.Excel.ActiveWorkbook == null)
- return false;
-
- else
- {
- Range selection = AddIn.Excel.Selection;
- return selection.Columns.Count == 2;
- }
- }
-
- public string GetVersionLabel(IRibbonControl control)
- {
- string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
- return $"v{version}";
- }
-
- public string GetPriceListPathLabel(IRibbonControl control)
- {
- string name = RegistryUtil.GetPriceListName();
- return string.IsNullOrEmpty(name) ? "Нет файла шаблона!" : name;
- }
- }
-}
diff --git a/src/Interface/StatusbarBase.cs b/src/Interface/StatusbarBase.cs
deleted file mode 100644
index f1af972..0000000
--- a/src/Interface/StatusbarBase.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using ExcelDna.Integration;
-using Microsoft.Office.Interop.Excel;
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace RhSolutions.Interface
-{
- internal abstract class StatusbarBase : IDisposable
- {
- protected Application Excel = AddIn.Excel;
-
- public abstract void Update();
-
- private static void ResetStatusBar()
- {
- AddIn.Excel.StatusBar = false;
- }
-
- public void Dispose()
- {
- Task.Delay(5000).ContinueWith(t => ResetStatusBar());
- }
- }
-}