Ensure price list exists on Excel open
This commit is contained in:
parent
5c8c5f5736
commit
9b205a5b3e
@ -1,16 +1,10 @@
|
|||||||
using ExcelDna.Integration.CustomUI;
|
using ExcelDna.Integration.CustomUI;
|
||||||
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
#if! NET472
|
|
||||||
using System.Runtime.Versioning;
|
|
||||||
#endif
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace RhSolutions.Controllers;
|
namespace RhSolutions.Controllers;
|
||||||
|
|
||||||
#if !NET472
|
|
||||||
[SupportedOSPlatform("windows")]
|
|
||||||
#endif
|
|
||||||
[ComVisible(true)]
|
[ComVisible(true)]
|
||||||
public class RibbonController : ExcelRibbon
|
public class RibbonController : ExcelRibbon
|
||||||
{
|
{
|
||||||
@ -114,7 +108,7 @@ public class RibbonController : ExcelRibbon
|
|||||||
public string GetPriceListPathLabel(IRibbonControl control)
|
public string GetPriceListPathLabel(IRibbonControl control)
|
||||||
{
|
{
|
||||||
string name = RhSolutionsAddIn.Configuration.GetPriceListFileName();
|
string name = RhSolutionsAddIn.Configuration.GetPriceListFileName();
|
||||||
return string.IsNullOrEmpty(name) ? "Шаблонный файл" : name;
|
return string.IsNullOrEmpty(name) ? "Указать шаблонный файл" : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateWorkbookValidation()
|
public static void UpdateWorkbookValidation()
|
||||||
@ -128,4 +122,13 @@ public class RibbonController : ExcelRibbon
|
|||||||
_workbookIsValid = worksheet.IsValidSource();
|
_workbookIsValid = worksheet.IsValidSource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void EnsurePriseListExists()
|
||||||
|
{
|
||||||
|
string pricelistPath = RhSolutionsAddIn.Configuration.GetPriceListPath();
|
||||||
|
if (!File.Exists(pricelistPath))
|
||||||
|
{
|
||||||
|
RhSolutionsAddIn.Configuration.SetPriceListPath(string.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
using RhSolutions.Controllers;
|
using RhSolutions.Controllers;
|
||||||
#if !NET472
|
|
||||||
using System.Runtime.Versioning;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace RhSolutions.Tools;
|
namespace RhSolutions.Tools;
|
||||||
|
|
||||||
#if !NET472
|
|
||||||
[SupportedOSPlatform("windows")]
|
|
||||||
#endif
|
|
||||||
internal static class EventsUtil
|
internal static class EventsUtil
|
||||||
{
|
{
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
|
RibbonController.EnsurePriseListExists();
|
||||||
RhSolutionsAddIn.Excel.SheetSelectionChange += RefreshExportButton;
|
RhSolutionsAddIn.Excel.SheetSelectionChange += RefreshExportButton;
|
||||||
RhSolutionsAddIn.Excel.SheetActivate += RefreshButtons;
|
RhSolutionsAddIn.Excel.SheetActivate += RefreshButtons;
|
||||||
RhSolutionsAddIn.Excel.WorkbookActivate += RefreshButtons;
|
RhSolutionsAddIn.Excel.WorkbookActivate += RefreshButtons;
|
||||||
|
Loading…
Reference in New Issue
Block a user