2021-12-05 16:55:36 +03:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using ExcelDna.Integration.CustomUI;
|
2021-12-24 16:22:03 +03:00
|
|
|
|
using RehauSku.PriceListTools;
|
|
|
|
|
using RehauSku.Forms;
|
2022-01-09 10:37:25 +03:00
|
|
|
|
using System;
|
2021-12-05 16:55:36 +03:00
|
|
|
|
|
2021-12-08 14:45:14 +03:00
|
|
|
|
namespace RehauSku.Ribbon
|
2021-12-05 16:55:36 +03:00
|
|
|
|
{
|
|
|
|
|
[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>
|
2021-12-09 14:08:26 +03:00
|
|
|
|
<tab id='rau' label='REHAU'>
|
|
|
|
|
<group id='priceList' label='Прайс-лист'>
|
2022-01-07 19:04:07 +03:00
|
|
|
|
<button id='exportToPrice' label='Экспорт в новый файл' size='normal' imageMso='PivotExportToExcel' onAction='OnExportPressed'/>
|
|
|
|
|
<menu id='conjoinMenu' label='Объединить' imageMso='Copy'>
|
|
|
|
|
<button id='mergeFiles' label='Сложить' onAction='OnMergePressed'/>
|
|
|
|
|
<button id='combineFiles' label='По колонкам' onAction='OnCombinePressed'/>
|
|
|
|
|
</menu>
|
2021-12-09 14:08:26 +03:00
|
|
|
|
</group>
|
|
|
|
|
<group id='rausettings' label='Настройки'>
|
2022-01-09 10:37:25 +03:00
|
|
|
|
<button id='setPriceList' label='Файл прайс-листа' size='large' imageMso='CurrentViewSettings' onAction='OnSetPricePressed'/>
|
2021-12-09 14:08:26 +03:00
|
|
|
|
</group>
|
2021-12-05 16:55:36 +03:00
|
|
|
|
</tab>
|
|
|
|
|
</tabs>
|
|
|
|
|
</ribbon>
|
|
|
|
|
</customUI>";
|
|
|
|
|
}
|
2021-12-07 08:28:21 +03:00
|
|
|
|
|
2022-01-07 19:04:07 +03:00
|
|
|
|
// <dropDown id = 'dd1' label = 'Drop dynamic' getItemCount = 'fncGetItemCountDrop' getItemLabel = 'fncGetItemLabelDrop' onAction = 'fncOnActionDrop'/>
|
|
|
|
|
|
2021-12-24 16:22:03 +03:00
|
|
|
|
public void OnMergePressed(IRibbonControl control)
|
|
|
|
|
{
|
|
|
|
|
using (MergeTool mergeTool = new MergeTool())
|
|
|
|
|
{
|
|
|
|
|
string[] files = Dialog.GetMultiplyFiles();
|
2022-01-09 10:37:25 +03:00
|
|
|
|
mergeTool.GetSource(files);
|
|
|
|
|
string exportFile = PriceList.CreateNewFile();
|
|
|
|
|
mergeTool.OpenNewPrice(exportFile);
|
|
|
|
|
mergeTool.FillPriceList();
|
2022-01-07 19:04:07 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnCombinePressed(IRibbonControl control)
|
|
|
|
|
{
|
|
|
|
|
using (CombineTool combineTool = new CombineTool())
|
|
|
|
|
{
|
|
|
|
|
string[] files = Dialog.GetMultiplyFiles();
|
2022-01-09 10:37:25 +03:00
|
|
|
|
combineTool.GetSource(files);
|
|
|
|
|
string exportFile = PriceList.CreateNewFile();
|
|
|
|
|
combineTool.OpenNewPrice(exportFile);
|
|
|
|
|
combineTool.FillPriceList();
|
2021-12-24 16:22:03 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-17 09:07:34 +03:00
|
|
|
|
public void OnExportPressed(IRibbonControl control)
|
2021-12-07 08:28:21 +03:00
|
|
|
|
{
|
2022-01-09 10:37:25 +03:00
|
|
|
|
try
|
2021-12-07 08:28:21 +03:00
|
|
|
|
{
|
2022-01-09 10:37:25 +03:00
|
|
|
|
using (ExportTool exportTool = new ExportTool())
|
2021-12-07 08:28:21 +03:00
|
|
|
|
{
|
2022-01-09 10:49:41 +03:00
|
|
|
|
exportTool.GetSource();
|
2022-01-09 10:37:25 +03:00
|
|
|
|
string exportFile = PriceList.CreateNewFile();
|
|
|
|
|
exportTool.OpenNewPrice(exportFile);
|
|
|
|
|
exportTool.FillPriceList();
|
2021-12-07 08:28:21 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-09 10:37:25 +03:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message,
|
|
|
|
|
"Ошибка",
|
|
|
|
|
MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Information);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 08:28:21 +03:00
|
|
|
|
}
|
2021-12-24 16:22:03 +03:00
|
|
|
|
|
2021-12-24 17:42:20 +03:00
|
|
|
|
public void OnSetPricePressed(IRibbonControl control)
|
2021-12-17 09:07:34 +03:00
|
|
|
|
{
|
2021-12-24 17:42:20 +03:00
|
|
|
|
string path = Dialog.GetFilePath();
|
|
|
|
|
RegistryUtil.PriceListPath = path;
|
2021-12-17 09:07:34 +03:00
|
|
|
|
}
|
2021-12-05 16:55:36 +03:00
|
|
|
|
}
|
|
|
|
|
}
|