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();
if (files.Length != 0)
{
mergeTool.GetSourceLists(files);
string exportFile = RegistryUtil.PriceListPath;
mergeTool.OpenNewPrice(exportFile);
mergeTool.FillTarget();
}
}
}
public void OnCombinePressed(IRibbonControl control)
{
using (CombineTool combineTool = new CombineTool())
{
string[] files = Dialog.GetMultiplyFiles();
if (files.Length != 0)
{
combineTool.GetSourceLists(files);
string exportFile = RegistryUtil.PriceListPath;
combineTool.OpenNewPrice(exportFile);
combineTool.FillTarget();
}
}
}
public void OnExportPressed(IRibbonControl control)
{
try
{
using (ExportTool exportTool = new ExportTool())
{
exportTool.GetSource();
string exportFile = RegistryUtil.PriceListPath;
exportTool.OpenNewPrice(exportFile);
exportTool.FillTarget();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,
"Ошибка",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
}
public void OnSetPricePressed(IRibbonControl control)
{
string path = Dialog.GetFilePath();
RegistryUtil.PriceListPath = path;
}
}
}