From 5001219695090d4a6ead73b2d17434b0805516a3 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Wed, 2 Feb 2022 18:34:32 +0300 Subject: [PATCH] Do not delete template path on registry key if cancel pick template dialog --- src/AddIn/RegistryUtil.cs | 6 ++++++ src/Interface/Dialog.cs | 4 ++-- src/Interface/RibbonController.cs | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/AddIn/RegistryUtil.cs b/src/AddIn/RegistryUtil.cs index dabd74d..5fe2eea 100644 --- a/src/AddIn/RegistryUtil.cs +++ b/src/AddIn/RegistryUtil.cs @@ -38,6 +38,12 @@ namespace RehauSku if (result == DialogResult.OK) { string fileName = Dialog.GetFilePath(); + + if (string.IsNullOrEmpty(fileName)) + { + throw new Exception("Нет файла шаблона"); + } + priceListPath = fileName; RootKey.SetValue("PriceListPath", fileName); return priceListPath; diff --git a/src/Interface/Dialog.cs b/src/Interface/Dialog.cs index 806e92d..23f65d7 100644 --- a/src/Interface/Dialog.cs +++ b/src/Interface/Dialog.cs @@ -16,9 +16,9 @@ namespace RehauSku.Interface { return dialog.FileName; } - } - return string.Empty; + else return string.Empty; + } } public static string[] GetMultiplyFiles() diff --git a/src/Interface/RibbonController.cs b/src/Interface/RibbonController.cs index b2e7b28..822fe98 100644 --- a/src/Interface/RibbonController.cs +++ b/src/Interface/RibbonController.cs @@ -91,7 +91,11 @@ namespace RehauSku.Interface public void OnSetPricePressed(IRibbonControl control) { string path = Dialog.GetFilePath(); - RegistryUtil.PriceListPath = path; + + if (!string.IsNullOrEmpty(path)) + { + RegistryUtil.PriceListPath = path; + } } } }