aboutsummaryrefslogtreecommitdiff
path: root/src/Ribbon/RibbonController.cs
diff options
context:
space:
mode:
authorSerghei Cebotari <51533848+schebotar@users.noreply.github.com>2021-12-26 19:37:46 +0300
committerGitHub <noreply@github.com>2021-12-26 19:37:46 +0300
commitfc870d19555cc77b0e08912b4dab21d496b2321f (patch)
treeac8b9aa1e883a85339a594b2797ab319cca73c4e /src/Ribbon/RibbonController.cs
parent0525ec1b42d5857b740dd0dae7f6d9baeb7088d1 (diff)
parent54fc3320e7d64d7903b4d091fe0d5c15df01fd78 (diff)
Merge pull request #9 from schebotar/dev
Move to /src
Diffstat (limited to 'src/Ribbon/RibbonController.cs')
-rw-r--r--src/Ribbon/RibbonController.cs69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/Ribbon/RibbonController.cs b/src/Ribbon/RibbonController.cs
new file mode 100644
index 0000000..df6f327
--- /dev/null
+++ b/src/Ribbon/RibbonController.cs
@@ -0,0 +1,69 @@
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using ExcelDna.Integration.CustomUI;
+using RehauSku.PriceListTools;
+using RehauSku.Forms;
+
+namespace RehauSku.Ribbon
+{
+ [ComVisible(true)]
+ public class RibbonController : ExcelRibbon
+ {
+ public override string GetCustomUI(string RibbonID)
+ {
+ return @"
+ <customUI xmlns='http://schemas.microsoft.com/office/2006/01/customui'>
+ <ribbon>
+ <tabs>
+ <tab id='rau' label='REHAU'>
+ <group id='priceList' label='Прайс-лист'>
+ <button id='exportToPrice' label='Экспорт в новый файл' size='normal' imageMso='PivotExportToExcel' onAction='OnExportPressed'/>
+ <button id='mergeFiles' label='Объединить' size='normal' imageMso='Copy' onAction='OnMergePressed'/>
+ </group>
+ <group id='rausettings' label='Настройки'>
+ <button id='setPriceList' label='Файл прайс-листа' size='normal' imageMso='CurrentViewSettings' onAction='OnSetPricePressed'/>
+ </group>
+ </tab>
+ </tabs>
+ </ribbon>
+ </customUI>";
+ }
+
+ public void OnMergePressed(IRibbonControl control)
+ {
+ using (MergeTool mergeTool = new MergeTool())
+ {
+ string[] files = Dialog.GetMultiplyFiles();
+ mergeTool.AddSkuAmountToDict(files);
+ string exportFile = PriceListUtil.CreateNewExportFile();
+ mergeTool.ExportToNewFile(exportFile);
+ }
+ }
+
+ public void OnExportPressed(IRibbonControl control)
+ {
+ using (ExportTool exportTool = new ExportTool())
+ {
+ if (!exportTool.IsRangeValid())
+ {
+ MessageBox.Show("Выделен неверный диапазон!",
+ "Неверный диапазон",
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ return;
+ }
+
+ else
+ {
+ exportTool.ExportToNewFile();
+ }
+ }
+ }
+
+ public void OnSetPricePressed(IRibbonControl control)
+ {
+ string path = Dialog.GetFilePath();
+ RegistryUtil.PriceListPath = path;
+ }
+ }
+}