using System.Runtime.InteropServices;
using System.Windows.Forms;
using ExcelDna.Integration.CustomUI;
using RehauSku.PriceListTools;
using RehauSku.Forms;
using System;
namespace RehauSku.Ribbon
{
[ComVisible(true)]
public class RibbonController : ExcelRibbon
{
public override string GetCustomUI(string RibbonID)
{
return @"
";
}
//
public void OnMergePressed(IRibbonControl control)
{
using (MergeTool mergeTool = new MergeTool())
{
string[] files = Dialog.GetMultiplyFiles();
mergeTool.GetSource(files);
string exportFile = PriceList.CreateNewFile();
mergeTool.OpenNewPrice(exportFile);
mergeTool.FillPriceList();
}
}
public void OnCombinePressed(IRibbonControl control)
{
using (CombineTool combineTool = new CombineTool())
{
string[] files = Dialog.GetMultiplyFiles();
combineTool.GetSource(files);
string exportFile = PriceList.CreateNewFile();
combineTool.OpenNewPrice(exportFile);
combineTool.FillPriceList();
}
}
public void OnExportPressed(IRibbonControl control)
{
try
{
using (ExportTool exportTool = new ExportTool())
{
exportTool.GetSource(null);
string exportFile = PriceList.CreateNewFile();
exportTool.OpenNewPrice(exportFile);
exportTool.FillPriceList();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
}
public void OnSetPricePressed(IRibbonControl control)
{
string path = Dialog.GetFilePath();
RegistryUtil.PriceListPath = path;
}
}
}