RhSolutions-AddIn/src/Interface/RibbonController.cs

98 lines
3.3 KiB
C#
Raw Normal View History

using ExcelDna.Integration.CustomUI;
using RehauSku.PriceListTools;
2022-01-09 10:37:25 +03:00
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
2021-12-05 16:55:36 +03:00
2022-02-02 09:46:47 +03:00
namespace RehauSku.Interface
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>
<tab id='rau' label='REHAU'>
<group id='priceList' label='Прайс-лист'>
<button id='exportToPrice' label='Экспорт в новый файл' size='normal' imageMso='PivotExportToExcel' onAction='OnExportPressed'/>
2022-01-28 14:38:05 +03:00
<button id='convertPrice' label='Актуализировать' size='normal' imageMso='FileUpdate' onAction='OnConvertPressed'/>
<menu id='conjoinMenu' label='Объединить' imageMso='Copy'>
<button id='mergeFiles' label='Сложить' onAction='OnMergePressed'/>
<button id='combineFiles' label='По колонкам' onAction='OnCombinePressed'/>
</menu>
</group>
<group id='rausettings' label='Настройки'>
2022-01-28 09:08:35 +03:00
<button id='setPriceList' label='Указать путь к шаблону' size='large' imageMso='CurrentViewSettings' onAction='OnSetPricePressed'/>
</group>
2021-12-05 16:55:36 +03:00
</tab>
</tabs>
</ribbon>
</customUI>";
}
2021-12-24 16:22:03 +03:00
public void OnMergePressed(IRibbonControl control)
{
2022-01-27 17:34:03 +03:00
MergeTool mergeTool = new MergeTool();
string[] files = Dialog.GetMultiplyFiles();
if (files.Length != 0)
2021-12-24 16:22:03 +03:00
{
2022-02-02 18:05:49 +03:00
mergeTool.SourceFiles = SourcePriceList.GetSourceLists(files);
2022-01-27 17:34:03 +03:00
mergeTool.OpenNewPrice();
mergeTool.FillTarget();
}
}
public void OnCombinePressed(IRibbonControl control)
{
2022-01-27 17:34:03 +03:00
CombineTool combineTool = new CombineTool();
string[] files = Dialog.GetMultiplyFiles();
if (files.Length != 0)
{
2022-02-02 18:05:49 +03:00
combineTool.SourceFiles = SourcePriceList.GetSourceLists(files);
2022-01-27 17:34:03 +03:00
combineTool.OpenNewPrice();
combineTool.FillTarget();
2021-12-24 16:22:03 +03:00
}
}
public void OnExportPressed(IRibbonControl control)
{
2022-01-09 10:37:25 +03:00
try
{
2022-01-27 17:34:03 +03:00
ExportTool exportTool = new ExportTool();
exportTool.TryGetSelection();
exportTool.OpenNewPrice();
exportTool.FillTarget();
}
2022-01-27 17:34:03 +03:00
2022-01-09 10:37:25 +03:00
catch (Exception ex)
{
MessageBox.Show(ex.Message,
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
}
2021-12-24 16:22:03 +03:00
2022-01-28 09:08:35 +03:00
public void OnConvertPressed(IRibbonControl control)
{
ConvertTool convertTool = new ConvertTool();
convertTool.GetCurrent();
convertTool.OpenNewPrice();
convertTool.FillTarget();
}
2021-12-24 17:42:20 +03:00
public void OnSetPricePressed(IRibbonControl control)
{
2021-12-24 17:42:20 +03:00
string path = Dialog.GetFilePath();
RegistryUtil.PriceListPath = path;
}
2021-12-05 16:55:36 +03:00
}
}