RhSolutions-AddIn/Source/Ribbon/RibbonController.cs

58 lines
1.8 KiB
C#
Raw Normal View History

2021-12-05 16:55:36 +03:00
using System.Runtime.InteropServices;
using System.Windows.Forms;
using ExcelDna.Integration.CustomUI;
2021-12-08 14:45:14 +03:00
using RehauSku.DataExport;
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>
<tab id='rau' label='REHAU'>
<group id='priceList' label='Прайс-лист'>
<button id='exportToPrice' label='Экспорт' size='large' imageMso='PivotExportToExcel' onAction='OnExportPressed'/>
</group>
<group id='rausettings' label='Настройки'>
<button id='set' label='Настройки' size='large' imageMso='CurrentViewSettings' onAction='OnSettingsPressed'/>
</group>
2021-12-05 16:55:36 +03:00
</tab>
</tabs>
</ribbon>
</customUI>";
}
public void OnExportPressed(IRibbonControl control)
{
2021-12-08 14:45:14 +03:00
using (Exporter dw = new Exporter())
{
if (!dw.IsRangeValid())
{
MessageBox.Show("Выделен неверный диапазон!",
"Неверный диапазон",
2021-12-10 13:56:28 +03:00
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
else
{
dw.FillSkuAmountDict();
2021-12-09 09:14:19 +03:00
dw.FillPriceList();
}
}
}
public void OnSettingsPressed(IRibbonControl control)
{
Application.Run(new Settings.SettingsForm());
}
2021-12-05 16:55:36 +03:00
}
}