From 06799119fb83cb6b75721c5cf60f4051e50976a7 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Wed, 2 Feb 2022 09:46:47 +0300 Subject: Add Interface namespace --- src/AddIn/RegistryUtil.cs | 2 +- src/Forms/Dialog.cs | 62 ------------------------- src/Interface/Dialog.cs | 62 +++++++++++++++++++++++++ src/Interface/RibbonController.cs | 97 ++++++++++++++++++++++++++++++++++++++ src/PriceListTools/CombineTool.cs | 2 +- src/PriceListTools/ConvertTool.cs | 5 +- src/PriceListTools/ExportTool.cs | 2 +- src/PriceListTools/MergeTool.cs | 5 +- src/RehauSku.Assist.csproj | 4 +- src/Ribbon/RibbonController.cs | 98 --------------------------------------- 10 files changed, 170 insertions(+), 169 deletions(-) delete mode 100644 src/Forms/Dialog.cs create mode 100644 src/Interface/Dialog.cs create mode 100644 src/Interface/RibbonController.cs delete mode 100644 src/Ribbon/RibbonController.cs (limited to 'src') diff --git a/src/AddIn/RegistryUtil.cs b/src/AddIn/RegistryUtil.cs index 3ec6f6a..dabd74d 100644 --- a/src/AddIn/RegistryUtil.cs +++ b/src/AddIn/RegistryUtil.cs @@ -1,5 +1,5 @@ using Microsoft.Win32; -using RehauSku.Forms; +using RehauSku.Interface; using System; using System.IO; using System.Windows.Forms; diff --git a/src/Forms/Dialog.cs b/src/Forms/Dialog.cs deleted file mode 100644 index cc1c29a..0000000 --- a/src/Forms/Dialog.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Microsoft.Office.Interop.Excel; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace RehauSku.Forms -{ - static class Dialog - { - 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 filePath; - } - - public static string[] GetMultiplyFiles() - { - List fileNames = new List(); - - using (OpenFileDialog dialog = new OpenFileDialog()) - { - dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm"; - dialog.Multiselect = true; - - if (dialog.ShowDialog() == DialogResult.OK) - { - foreach (string file in dialog.FileNames) - { - fileNames.Add(file); - } - } - } - - return fileNames.ToArray(); - } - - public static void SaveWorkbookAs() - { - Workbook wb = AddIn.Excel.ActiveWorkbook; - string currentFilename = wb.FullName; - string fileFilter = "Файлы Excel (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm"; - - object fileName = AddIn.Excel.GetSaveAsFilename(currentFilename, fileFilter); - - if (fileName.GetType() == typeof(string)) - wb.SaveAs(fileName); - - else - wb.Close(false); - } - } -} diff --git a/src/Interface/Dialog.cs b/src/Interface/Dialog.cs new file mode 100644 index 0000000..c888703 --- /dev/null +++ b/src/Interface/Dialog.cs @@ -0,0 +1,62 @@ +using Microsoft.Office.Interop.Excel; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace RehauSku.Interface +{ + static class Dialog + { + 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 filePath; + } + + public static string[] GetMultiplyFiles() + { + List fileNames = new List(); + + using (OpenFileDialog dialog = new OpenFileDialog()) + { + dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm"; + dialog.Multiselect = true; + + if (dialog.ShowDialog() == DialogResult.OK) + { + foreach (string file in dialog.FileNames) + { + fileNames.Add(file); + } + } + } + + return fileNames.ToArray(); + } + + public static void SaveWorkbookAs() + { + Workbook wb = AddIn.Excel.ActiveWorkbook; + string currentFilename = wb.FullName; + string fileFilter = "Файлы Excel (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm"; + + object fileName = AddIn.Excel.GetSaveAsFilename(currentFilename, fileFilter); + + if (fileName.GetType() == typeof(string)) + wb.SaveAs(fileName); + + else + wb.Close(false); + } + } +} diff --git a/src/Interface/RibbonController.cs b/src/Interface/RibbonController.cs new file mode 100644 index 0000000..cd7058d --- /dev/null +++ b/src/Interface/RibbonController.cs @@ -0,0 +1,97 @@ +using ExcelDna.Integration.CustomUI; +using RehauSku.PriceListTools; +using System; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace RehauSku.Interface +{ + [ComVisible(true)] + public class RibbonController : ExcelRibbon + { + public override string GetCustomUI(string RibbonID) + { + return @" + + + + + +