From 9018d7d504dfebbec9a3c75851314d25d1e8197c Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Wed, 2 Feb 2022 18:26:04 +0300 Subject: [PATCH] Edit Open File Dialogs --- src/Interface/Dialog.cs | 17 +++++------------ src/Interface/RibbonController.cs | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Interface/Dialog.cs b/src/Interface/Dialog.cs index f8ab645..806e92d 100644 --- a/src/Interface/Dialog.cs +++ b/src/Interface/Dialog.cs @@ -8,25 +8,21 @@ namespace RehauSku.Interface { public static string GetFilePath() { - string filePath = string.Empty; - using (OpenFileDialog dialog = new OpenFileDialog()) { dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm"; if (dialog.ShowDialog() == DialogResult.OK) { - filePath = dialog.FileName; + return dialog.FileName; } } - return filePath; + return string.Empty; } public static string[] GetMultiplyFiles() { - List fileNames = new List(); - using (OpenFileDialog dialog = new OpenFileDialog()) { dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm"; @@ -34,14 +30,11 @@ namespace RehauSku.Interface if (dialog.ShowDialog() == DialogResult.OK) { - foreach (string file in dialog.FileNames) - { - fileNames.Add(file); - } + return dialog.FileNames; } - } - return fileNames.ToArray(); + else return null; + } } public static void SaveWorkbookAs() diff --git a/src/Interface/RibbonController.cs b/src/Interface/RibbonController.cs index 2b1fd6b..b2e7b28 100644 --- a/src/Interface/RibbonController.cs +++ b/src/Interface/RibbonController.cs @@ -38,7 +38,7 @@ namespace RehauSku.Interface MergeTool mergeTool = new MergeTool(); string[] files = Dialog.GetMultiplyFiles(); - if (files.Length != 0) + if (files != null) { mergeTool.SourceFiles = SourcePriceList.GetSourceLists(files); mergeTool.OpenNewPrice(); @@ -51,7 +51,7 @@ namespace RehauSku.Interface CombineTool combineTool = new CombineTool(); string[] files = Dialog.GetMultiplyFiles(); - if (files.Length != 0) + if (files != null) { combineTool.SourceFiles = SourcePriceList.GetSourceLists(files); combineTool.OpenNewPrice();