From c11660aa8a72f40f89cfcd4528681990198e332b Mon Sep 17 00:00:00 2001 From: dosymep Date: Mon, 15 Sep 2025 08:44:15 +0300 Subject: [PATCH 1/8] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D0=B4=D0=B8=D0=BB=D0=BE=D0=B3=D0=B8=20=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D1=80=D1=8B=D1=82=D0=B8=D1=8F,=20=D1=81=D0=BE=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B8=20=D0=BF=D0=B0=D0=BF=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WpfOpenFileDialogService.cs | 59 +++++++++++++++++++ .../WpfOpenFolderDialogService.cs | 55 +++++++++++++++++ .../WpfSaveFileDialogService.cs | 54 +++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs create mode 100644 src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs create mode 100644 src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs new file mode 100644 index 0000000..3613f11 --- /dev/null +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs @@ -0,0 +1,59 @@ +using System.IO; +using System.Windows; + +using dosymep.SimpleServices; + +using Microsoft.Win32; + +namespace dosymep.WpfCore.SimpleServices; + +internal sealed class WpfOpenFileDialogService : WpfBaseService, IOpenFileDialogService { + public bool Multiselect { get; set; } + public bool AddExtension { get; set; } + public bool AutoUpgradeEnabled { get; set; } + public bool CheckFileExists { get; set; } + public bool CheckPathExists { get; set; } + public bool ValidateNames { get; set; } + public bool DereferenceLinks { get; set; } + public bool RestoreDirectory { get; set; } + public bool ShowHelp { get; set; } + public bool SupportMultiDottedExtensions { get; set; } + public int FilterIndex { get; set; } + public string? Title { get; set; } + public string? Filter { get; set; } + public string? InitialDirectory { get; set; } + + public FileInfo? File { get; private set; } + public IEnumerable? Files { get; private set; } + + public bool ShowDialog() { + return ShowDialog(InitialDirectory ?? Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); + } + + public bool ShowDialog(string directoryName) { + OpenFileDialog dialog = new() { + Multiselect = Multiselect, + AddExtension = AddExtension, + CheckFileExists = CheckFileExists, + CheckPathExists = CheckPathExists, + ValidateNames = ValidateNames, + DereferenceLinks = DereferenceLinks, + RestoreDirectory = RestoreDirectory, + FilterIndex = FilterIndex, + Title = Title ?? string.Empty, + Filter = Filter ?? string.Empty, + InitialDirectory = directoryName + }; + + bool? result = dialog.ShowDialog(); + + File = new FileInfo(dialog.SafeFileName); + Files = dialog.SafeFileNames.Select(item => new FileInfo(item)).ToArray(); + + return result == true; + } + + public void Reset() { + // nothing to do + } +} \ No newline at end of file diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs new file mode 100644 index 0000000..13f4dbf --- /dev/null +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs @@ -0,0 +1,55 @@ +using System.IO; + +using dosymep.SimpleServices; + +using Microsoft.WindowsAPICodePack.Dialogs; + +namespace dosymep.WpfCore.SimpleServices; + +internal sealed class WpfOpenFolderDialogService:WpfBaseService, IOpenFolderDialogService { + public bool Multiselect { get; set; } + public bool AddExtension { get; set; } + public bool AutoUpgradeEnabled { get; set; } + public bool CheckFileExists { get; set; } + public bool CheckPathExists { get; set; } + public bool ValidateNames { get; set; } + public bool DereferenceLinks { get; set; } + public bool RestoreDirectory { get; set; } + public bool ShowHelp { get; set; } + public bool SupportMultiDottedExtensions { get; set; } + public int FilterIndex { get; set; } + public string? Title { get; set; } + public string? Filter { get; set; } + public string? InitialDirectory { get; set; } + + public DirectoryInfo? Folder { get; private set; } + public IEnumerable? Folders { get; private set; } + + public bool ShowDialog() { + return ShowDialog(InitialDirectory ?? Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); + } + + public bool ShowDialog(string directoryName) { + CommonOpenFileDialog dialog = new(); + dialog.IsFolderPicker = true; + + dialog.Multiselect = Multiselect; + dialog.EnsureFileExists = CheckFileExists; + dialog.EnsurePathExists = CheckPathExists; + dialog.EnsureValidNames = ValidateNames; + dialog.RestoreDirectory = RestoreDirectory; + dialog.Title = Title ?? string.Empty; + dialog.InitialDirectory = directoryName; + + CommonFileDialogResult? result = dialog.ShowDialog(); + + Folder = new DirectoryInfo(dialog.FileName); + Folders = dialog.FileNames.Select(item => new DirectoryInfo(item)).ToArray(); + + return result == CommonFileDialogResult.Ok; + } + + public void Reset() { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs new file mode 100644 index 0000000..2188cf4 --- /dev/null +++ b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs @@ -0,0 +1,54 @@ +using System.IO; + +using dosymep.SimpleServices; + +using Microsoft.Win32; + +namespace dosymep.WpfCore.SimpleServices; + +internal sealed class WpfSaveFileDialogService :WpfBaseService, ISaveFileDialogService{ + public bool AddExtension { get; set; } + public bool AutoUpgradeEnabled { get; set; } + public bool CheckFileExists { get; set; } + public bool CheckPathExists { get; set; } + public bool ValidateNames { get; set; } + public bool DereferenceLinks { get; set; } + public bool RestoreDirectory { get; set; } + public bool ShowHelp { get; set; } + public bool SupportMultiDottedExtensions { get; set; } + public int FilterIndex { get; set; } + public string? Title { get; set; } + public string? Filter { get; set; } + public string? InitialDirectory { get; set; } + public string? DefaultExt { get; set; } + public string? DefaultFileName { get; set; } + + public FileInfo? File { get; private set; } + + public bool ShowDialog(string directoryName, string fileName) { + SaveFileDialog dialog = new() { + AddExtension = AddExtension, + CheckFileExists = CheckFileExists, + CheckPathExists = CheckPathExists, + ValidateNames = ValidateNames, + DereferenceLinks = DereferenceLinks, + RestoreDirectory = RestoreDirectory, + FilterIndex = FilterIndex, + Title = Title ?? string.Empty, + Filter = Filter ?? string.Empty, + InitialDirectory = InitialDirectory ?? Environment.GetFolderPath(Environment.SpecialFolder.Desktop), + DefaultExt = DefaultExt ?? string.Empty, + FileName = DefaultFileName ?? string.Empty + }; + + bool? result = dialog.ShowDialog(); + + File = new FileInfo(dialog.SafeFileName); + + return result == true; + } + + public void Reset() { + // nothing to do + } +} \ No newline at end of file From d6352753cbe2aad5882bd03636656f76875fd091 Mon Sep 17 00:00:00 2001 From: dosymep Date: Mon, 15 Sep 2025 08:56:28 +0300 Subject: [PATCH 2/8] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20XML-=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8E=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=B5=D1=80?= =?UTF-8?q?=D0=B2=D0=B8=D1=81=D0=BE=D0=B2=20=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=D0=B2=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F,=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=B0=D0=BF=D0=BE=D0=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WpfOpenFileDialogService.cs | 38 +++++++++++++++- .../WpfOpenFolderDialogService.cs | 44 +++++++++++++++++-- .../WpfSaveFileDialogService.cs | 43 ++++++++++++++++-- 3 files changed, 116 insertions(+), 9 deletions(-) diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs index 3613f11..66c5ee7 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs @@ -7,29 +7,64 @@ namespace dosymep.WpfCore.SimpleServices; -internal sealed class WpfOpenFileDialogService : WpfBaseService, IOpenFileDialogService { +/// +/// Предоставляет методы для открытия диалога просмотра и открытия файлов. +/// +public sealed class WpfOpenFileDialogService : WpfBaseService, IOpenFileDialogService { + /// public bool Multiselect { get; set; } + + /// public bool AddExtension { get; set; } + + /// public bool AutoUpgradeEnabled { get; set; } + + /// public bool CheckFileExists { get; set; } + + /// public bool CheckPathExists { get; set; } + + /// public bool ValidateNames { get; set; } + + /// public bool DereferenceLinks { get; set; } + + /// public bool RestoreDirectory { get; set; } + + /// public bool ShowHelp { get; set; } + + /// public bool SupportMultiDottedExtensions { get; set; } + + /// public int FilterIndex { get; set; } + + /// public string? Title { get; set; } + + /// public string? Filter { get; set; } + + /// public string? InitialDirectory { get; set; } + /// public FileInfo? File { get; private set; } + + /// public IEnumerable? Files { get; private set; } + /// public bool ShowDialog() { return ShowDialog(InitialDirectory ?? Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); } + /// public bool ShowDialog(string directoryName) { OpenFileDialog dialog = new() { Multiselect = Multiselect, @@ -53,6 +88,7 @@ public bool ShowDialog(string directoryName) { return result == true; } + /// public void Reset() { // nothing to do } diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs index 13f4dbf..333874c 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs @@ -6,29 +6,64 @@ namespace dosymep.WpfCore.SimpleServices; -internal sealed class WpfOpenFolderDialogService:WpfBaseService, IOpenFolderDialogService { +/// +/// Предоставляет методы для открытия диалога выбора папок. +/// +public sealed class WpfOpenFolderDialogService : WpfBaseService, IOpenFolderDialogService { + /// public bool Multiselect { get; set; } + + /// public bool AddExtension { get; set; } + + /// public bool AutoUpgradeEnabled { get; set; } + + /// public bool CheckFileExists { get; set; } + + /// public bool CheckPathExists { get; set; } + + /// public bool ValidateNames { get; set; } + + /// public bool DereferenceLinks { get; set; } + + /// public bool RestoreDirectory { get; set; } + + /// public bool ShowHelp { get; set; } + + /// public bool SupportMultiDottedExtensions { get; set; } + + /// public int FilterIndex { get; set; } + + /// public string? Title { get; set; } + + /// public string? Filter { get; set; } + + /// public string? InitialDirectory { get; set; } + /// public DirectoryInfo? Folder { get; private set; } + + /// public IEnumerable? Folders { get; private set; } - + + /// public bool ShowDialog() { return ShowDialog(InitialDirectory ?? Environment.GetFolderPath(Environment.SpecialFolder.Desktop)); } + /// public bool ShowDialog(string directoryName) { CommonOpenFileDialog dialog = new(); dialog.IsFolderPicker = true; @@ -40,7 +75,7 @@ public bool ShowDialog(string directoryName) { dialog.RestoreDirectory = RestoreDirectory; dialog.Title = Title ?? string.Empty; dialog.InitialDirectory = directoryName; - + CommonFileDialogResult? result = dialog.ShowDialog(); Folder = new DirectoryInfo(dialog.FileName); @@ -48,7 +83,8 @@ public bool ShowDialog(string directoryName) { return result == CommonFileDialogResult.Ok; } - + + /// public void Reset() { throw new NotImplementedException(); } diff --git a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs index 2188cf4..c4eac54 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs @@ -6,25 +6,59 @@ namespace dosymep.WpfCore.SimpleServices; -internal sealed class WpfSaveFileDialogService :WpfBaseService, ISaveFileDialogService{ +/// +/// Предоставляет методы для открытия диалога сохранения файлов. +/// +public sealed class WpfSaveFileDialogService : WpfBaseService, ISaveFileDialogService { + /// public bool AddExtension { get; set; } + + /// public bool AutoUpgradeEnabled { get; set; } + + /// public bool CheckFileExists { get; set; } + + /// public bool CheckPathExists { get; set; } + + /// public bool ValidateNames { get; set; } + + /// public bool DereferenceLinks { get; set; } + + /// public bool RestoreDirectory { get; set; } + + /// public bool ShowHelp { get; set; } + + /// public bool SupportMultiDottedExtensions { get; set; } + + /// public int FilterIndex { get; set; } + + /// public string? Title { get; set; } + + /// public string? Filter { get; set; } + + /// public string? InitialDirectory { get; set; } + + /// public string? DefaultExt { get; set; } + + /// public string? DefaultFileName { get; set; } - + + /// public FileInfo? File { get; private set; } - + + /// public bool ShowDialog(string directoryName, string fileName) { SaveFileDialog dialog = new() { AddExtension = AddExtension, @@ -47,7 +81,8 @@ public bool ShowDialog(string directoryName, string fileName) { return result == true; } - + + /// public void Reset() { // nothing to do } From 8e1f933f6c21e78444bf526afe62fb9ce837afc3 Mon Sep 17 00:00:00 2001 From: dosymep Date: Mon, 15 Sep 2025 08:57:45 +0300 Subject: [PATCH 3/8] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D1=81=D0=B5=D1=80=D0=B2=D0=B8=D1=81=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3=D0=BE=D0=B2=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BE=D0=BA=D0=BE=D0=BD=20(=D0=BE=D1=82=D0=BA=D1=80=D1=8B?= =?UTF-8?q?=D1=82=D0=B8=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2/?= =?UTF-8?q?=D0=BF=D0=B0=D0=BF=D0=BE=D0=BA,=20=D1=81=D0=BE=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2)=20=D0=B2=20Ninject=20=D0=BA=D0=BE=D0=BD=D1=82?= =?UTF-8?q?=D0=B5=D0=B9=D0=BD=D0=B5=D1=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NinjectExtensions.cs | 345 +++++++++++++++++- 1 file changed, 344 insertions(+), 1 deletion(-) diff --git a/src/dosymep.WpfCore.Ninject/NinjectExtensions.cs b/src/dosymep.WpfCore.Ninject/NinjectExtensions.cs index fc842ae..34e04fd 100644 --- a/src/dosymep.WpfCore.Ninject/NinjectExtensions.cs +++ b/src/dosymep.WpfCore.Ninject/NinjectExtensions.cs @@ -111,7 +111,7 @@ public static IKernel UseWpfDispatcher(this IKernel kernel) { /// Ninject контейнер. /// Тип ViewModel к которой будет прикрепление сервиса. /// Возвращает настроенный контейнер Ninject. - /// Обязательно требуется прикрепить к элементу управления через . + /// Обязательно требуется прикрепить к элементу управления через . /// kernel is null. public static IKernel UseWpfDispatcher(this IKernel kernel) { if(kernel is null) { @@ -153,4 +153,347 @@ public static IKernel UseWpfLocalization(this IKernel kernel, return kernel; } + + /// + /// Добавляет в контейнер . + /// + /// Ninject контейнер. + /// Заголовок окна. По умолчанию "Выбрать файл". + /// Применяемый фильтр для файлов. По умолчанию "Все файлы (*.*)|*.*". + /// Применяемый индекс фильтра для файлов. По умолчанию "0". + /// Директория открываемая по умолчанию. + /// True - включает мультивыбор файлов. По умолчанию выключено. + /// True включает автоматическое добавление расширения файла. По умолчанию включено. + /// True - включает автоматическую смену внешнего вида. По умолчанию включено. + /// True - включает проверку расширения файла. По умолчанию включено. + /// True - включает проверку существования пути до файла. По умолчанию включено. + /// True - включает проверку правильности набранного имени файла. По умолчанию включено. + /// True - включает возвращение расположения файла, на который ссылается ярлык. По умолчанию включено. + /// True - запоминает выбранное расположение. По умолчанию выключено. + /// True - включает отображение справки. По умолчанию выключено. + /// True - включает отображение и сохранение файлов с несколькими расширениями. По умолчанию выключено. + /// Возвращает настроенный контейнер Ninject. + /// kernel is null. + public static IKernel UseWpfOpenFileDialog(this IKernel kernel, + string? title = "Выбрать файл", + string? filter = "Все файлы (*.*)|*.*", + int filterIndex = 0, + string? initialDirectory = default, + bool multiSelect = false, + bool addExtension = true, + bool autoUpgradeEnabled = true, + bool checkFileExists = true, + bool checkPathExists = true, + bool validateNames = true, + bool dereferenceLinks = true, + bool restoreDirectory = false, + bool showHelp = false, + bool supportMultiDottedExtensions = false) { + if(kernel == null) { + throw new ArgumentNullException(nameof(kernel)); + } + + kernel.Bind() + .To() + .WithPropertyValue(nameof(IAttachableService.AllowAttach), false) + .WithPropertyValue(nameof(IOpenDialogServiceBase.Multiselect), multiSelect) + .WithPropertyValue(nameof(IFileDialogServiceBase.AddExtension), addExtension) + .WithPropertyValue(nameof(IFileDialogServiceBase.AutoUpgradeEnabled), autoUpgradeEnabled) + .WithPropertyValue(nameof(IFileDialogServiceBase.CheckFileExists), checkFileExists) + .WithPropertyValue(nameof(IFileDialogServiceBase.CheckPathExists), checkPathExists) + .WithPropertyValue(nameof(IFileDialogServiceBase.ValidateNames), validateNames) + .WithPropertyValue(nameof(IFileDialogServiceBase.DereferenceLinks), dereferenceLinks) + .WithPropertyValue(nameof(IFileDialogServiceBase.RestoreDirectory), restoreDirectory) + .WithPropertyValue(nameof(IFileDialogServiceBase.ShowHelp), showHelp) + .WithPropertyValue(nameof(IFileDialogServiceBase.SupportMultiDottedExtensions), + supportMultiDottedExtensions) + .WithPropertyValue(nameof(IFileDialogServiceBase.FilterIndex), filterIndex) + .WithPropertyValue(nameof(IFileDialogServiceBase.Title), title!) + .WithPropertyValue(nameof(IFileDialogServiceBase.Filter), filter!) + .WithPropertyValue(nameof(IFileDialogServiceBase.InitialDirectory), initialDirectory!); + + return kernel; + } + + /// + /// Добавляет в контейнер . + /// + /// Ninject контейнер. + /// Заголовок окна. По умолчанию "Выбрать файл". + /// Применяемый фильтр для файлов. По умолчанию "Все файлы (*.*)|*.*". + /// Применяемый индекс фильтра для файлов. По умолчанию "0". + /// Директория открываемая по умолчанию. + /// True - включает мультивыбор файлов. По умолчанию выключено. + /// True включает автоматическое добавление расширения файла. По умолчанию включено. + /// True - включает автоматическую смену внешнего вида. По умолчанию включено. + /// True - включает проверку расширения файла. По умолчанию включено. + /// True - включает проверку существования пути до файла. По умолчанию включено. + /// True - включает проверку правильности набранного имени файла. По умолчанию включено. + /// True - включает возвращение расположения файла, на который ссылается ярлык. По умолчанию включено. + /// True - запоминает выбранное расположение. По умолчанию выключено. + /// True - включает отображение справки. По умолчанию выключено. + /// True - включает отображение и сохранение файлов с несколькими расширениями. По умолчанию выключено. + /// Тип ViewModel к которой будет прикрепление сервиса. + /// Возвращает настроенный контейнер Ninject. + /// Обязательно требуется прикрепить к элементу управления через . + /// kernel is null. + public static IKernel UseWpfOpenFileDialog(this IKernel kernel, + string? title = "Выбрать файл", + string? filter = "Все файлы (*.*)|*.*", + int filterIndex = 0, + string? initialDirectory = default, + bool multiSelect = false, + bool addExtension = true, + bool autoUpgradeEnabled = true, + bool checkFileExists = true, + bool checkPathExists = true, + bool validateNames = true, + bool dereferenceLinks = true, + bool restoreDirectory = false, + bool showHelp = false, + bool supportMultiDottedExtensions = false) { + if(kernel == null) { + throw new ArgumentNullException(nameof(kernel)); + } + + kernel.Bind() + .To() + .WhenInjectedInto() + .WithPropertyValue(nameof(IAttachableService.AllowAttach), true) + .WithPropertyValue(nameof(IOpenDialogServiceBase.Multiselect), multiSelect) + .WithPropertyValue(nameof(IFileDialogServiceBase.AddExtension), addExtension) + .WithPropertyValue(nameof(IFileDialogServiceBase.AutoUpgradeEnabled), autoUpgradeEnabled) + .WithPropertyValue(nameof(IFileDialogServiceBase.CheckFileExists), checkFileExists) + .WithPropertyValue(nameof(IFileDialogServiceBase.CheckPathExists), checkPathExists) + .WithPropertyValue(nameof(IFileDialogServiceBase.ValidateNames), validateNames) + .WithPropertyValue(nameof(IFileDialogServiceBase.DereferenceLinks), dereferenceLinks) + .WithPropertyValue(nameof(IFileDialogServiceBase.RestoreDirectory), restoreDirectory) + .WithPropertyValue(nameof(IFileDialogServiceBase.ShowHelp), showHelp) + .WithPropertyValue(nameof(IFileDialogServiceBase.SupportMultiDottedExtensions), + supportMultiDottedExtensions) + .WithPropertyValue(nameof(IFileDialogServiceBase.FilterIndex), filterIndex) + .WithPropertyValue(nameof(IFileDialogServiceBase.Title), title!) + .WithPropertyValue(nameof(IFileDialogServiceBase.Filter), filter!) + .WithPropertyValue(nameof(IFileDialogServiceBase.InitialDirectory), initialDirectory!); + + return kernel; + } + + /// + /// Добавляет в контейнер . + /// + /// Ninject контейнер. + /// Заголовок окна. По умолчанию "Сохранить файл". + /// Применяемый фильтр для файлов. По умолчанию "Все файлы (*.*)|*.*". + /// Применяемый индекс фильтра для файлов. По умолчанию "0". + /// Расширение файла по умолчанию. + /// Имя файла по умолчанию. + /// Директория открываемая по умолчанию. + /// True включает автоматическое добавление расширения файла. По умолчанию включено. + /// True - включает автоматическую смену внешнего вида. По умолчанию включено. + /// True - включает проверку расширения файла. По умолчанию включено. + /// True - включает проверку существования пути до файла. По умолчанию включено. + /// True - включает проверку правильности набранного имени файла. По умолчанию включено. + /// True - включает возвращение расположения файла, на который ссылается ярлык. По умолчанию включено. + /// True - запоминает выбранное расположение. По умолчанию выключено. + /// True - включает отображение справки. По умолчанию выключено. + /// True - включает отображение и сохранение файлов с несколькими расширениями. По умолчанию выключено. + /// Возвращает настроенный контейнер Ninject. + /// kernel is null. + public static IKernel UseWpfSaveFileDialog(this IKernel kernel, + string? title = "Сохранить файл", + string? filter = "Все файлы (*.*)|*.*", + int filterIndex = 0, + string? defaultExt = default, + string? defaultFileName = default, + string? initialDirectory = default, + bool addExtension = true, + bool autoUpgradeEnabled = true, + bool checkFileExists = false, + bool checkPathExists = true, + bool validateNames = true, + bool dereferenceLinks = true, + bool restoreDirectory = false, + bool showHelp = false, + bool supportMultiDottedExtensions = false) { + if(kernel == null) { + throw new ArgumentNullException(nameof(kernel)); + } + + kernel.Bind() + .To() + .WithPropertyValue(nameof(IAttachableService.AllowAttach), false) + .WithPropertyValue(nameof(IFileDialogServiceBase.AddExtension), addExtension) + .WithPropertyValue(nameof(IFileDialogServiceBase.AutoUpgradeEnabled), autoUpgradeEnabled) + .WithPropertyValue(nameof(IFileDialogServiceBase.CheckFileExists), checkFileExists) + .WithPropertyValue(nameof(IFileDialogServiceBase.CheckPathExists), checkPathExists) + .WithPropertyValue(nameof(IFileDialogServiceBase.ValidateNames), validateNames) + .WithPropertyValue(nameof(IFileDialogServiceBase.DereferenceLinks), dereferenceLinks) + .WithPropertyValue(nameof(IFileDialogServiceBase.RestoreDirectory), restoreDirectory) + .WithPropertyValue(nameof(IFileDialogServiceBase.ShowHelp), showHelp) + .WithPropertyValue(nameof(IFileDialogServiceBase.SupportMultiDottedExtensions), + supportMultiDottedExtensions) + .WithPropertyValue(nameof(IFileDialogServiceBase.FilterIndex), filterIndex) + .WithPropertyValue(nameof(IFileDialogServiceBase.Title), title!) + .WithPropertyValue(nameof(IFileDialogServiceBase.Filter), filter!) + .WithPropertyValue(nameof(IFileDialogServiceBase.InitialDirectory), initialDirectory!) + .WithPropertyValue(nameof(ISaveFileDialogService.DefaultExt), defaultExt!) + .WithPropertyValue(nameof(ISaveFileDialogService.DefaultFileName), defaultFileName!); + + return kernel; + } + + /// + /// Добавляет в контейнер . + /// + /// Ninject контейнер. + /// Заголовок окна. По умолчанию "Сохранить файл". + /// Применяемый фильтр для файлов. По умолчанию "Все файлы (*.*)|*.*". + /// Применяемый индекс фильтра для файлов. По умолчанию "0". + /// Расширение файла по умолчанию. + /// Имя файла по умолчанию. + /// Директория открываемая по умолчанию. + /// True включает автоматическое добавление расширения файла. По умолчанию включено. + /// True - включает автоматическую смену внешнего вида. По умолчанию включено. + /// True - включает проверку расширения файла. По умолчанию включено. + /// True - включает проверку существования пути до файла. По умолчанию включено. + /// True - включает проверку правильности набранного имени файла. По умолчанию включено. + /// True - включает возвращение расположения файла, на который ссылается ярлык. По умолчанию включено. + /// True - запоминает выбранное расположение. По умолчанию выключено. + /// True - включает отображение справки. По умолчанию выключено. + /// True - включает отображение и сохранение файлов с несколькими расширениями. По умолчанию выключено. + /// Тип ViewModel к которой будет прикрепление сервиса. + /// Возвращает настроенный контейнер Ninject. + /// Обязательно требуется прикрепить к элементу управления через . + /// kernel is null. + public static IKernel UseWpfSaveFileDialog(this IKernel kernel, + string? title = "Сохранить файл", + string? filter = "Все файлы (*.*)|*.*", + int filterIndex = 0, + string? defaultExt = default, + string? defaultFileName = default, + string? initialDirectory = default, + bool addExtension = true, + bool autoUpgradeEnabled = true, + bool checkFileExists = false, + bool checkPathExists = true, + bool validateNames = true, + bool dereferenceLinks = true, + bool restoreDirectory = false, + bool showHelp = false, + bool supportMultiDottedExtensions = false) { + if(kernel == null) { + throw new ArgumentNullException(nameof(kernel)); + } + + kernel.Bind() + .To() + .WhenInjectedInto() + .WithPropertyValue(nameof(IAttachableService.AllowAttach), true) + .WithPropertyValue(nameof(IFileDialogServiceBase.AddExtension), addExtension) + .WithPropertyValue(nameof(IFileDialogServiceBase.AutoUpgradeEnabled), autoUpgradeEnabled) + .WithPropertyValue(nameof(IFileDialogServiceBase.CheckFileExists), checkFileExists) + .WithPropertyValue(nameof(IFileDialogServiceBase.CheckPathExists), checkPathExists) + .WithPropertyValue(nameof(IFileDialogServiceBase.ValidateNames), validateNames) + .WithPropertyValue(nameof(IFileDialogServiceBase.DereferenceLinks), dereferenceLinks) + .WithPropertyValue(nameof(IFileDialogServiceBase.RestoreDirectory), restoreDirectory) + .WithPropertyValue(nameof(IFileDialogServiceBase.ShowHelp), showHelp) + .WithPropertyValue(nameof(IFileDialogServiceBase.SupportMultiDottedExtensions), + supportMultiDottedExtensions) + .WithPropertyValue(nameof(IFileDialogServiceBase.FilterIndex), filterIndex) + .WithPropertyValue(nameof(IFileDialogServiceBase.Title), title!) + .WithPropertyValue(nameof(IFileDialogServiceBase.Filter), filter!) + .WithPropertyValue(nameof(IFileDialogServiceBase.InitialDirectory), initialDirectory!) + .WithPropertyValue(nameof(ISaveFileDialogService.DefaultExt), defaultExt!) + .WithPropertyValue(nameof(ISaveFileDialogService.DefaultFileName), defaultFileName!); + + return kernel; + } + + /// + /// Добавляет в контейнер . + /// + /// Ninject контейнер. + /// Заголовок окна. По умолчанию "Выбрать папку". + /// Директория открываемая по умолчанию. + /// True - разрешает мультивыбор. По умолчанию отключено. + /// True - включает автоматическую смену внешнего вида. По умолчанию включено. + /// True - включает проверку существования пути до файла. По умолчанию включено. + /// True - включает проверку правильности набранного имени файла. По умолчанию включено. + /// True - запоминает выбранное расположение. По умолчанию выключено. + /// True - включает отображение справки. По умолчанию выключено. + /// Возвращает настроенный контейнер Ninject. + /// kernel is null. + public static IKernel UseWpfOpenFolderDialog(this IKernel kernel, + string? title = "Выбрать папку", + string? initialDirectory = default, + bool multiSelect = false, + bool autoUpgradeEnabled = true, + bool checkPathExists = true, + bool validateNames = true, + bool restoreDirectory = false, + bool showHelp = false) { + if(kernel == null) { + throw new ArgumentNullException(nameof(kernel)); + } + + kernel.Bind() + .To() + .WithPropertyValue(nameof(IAttachableService.AllowAttach), false) + .WithPropertyValue(nameof(IOpenDialogServiceBase.Multiselect), multiSelect) + .WithPropertyValue(nameof(IFileDialogServiceBase.AutoUpgradeEnabled), autoUpgradeEnabled) + .WithPropertyValue(nameof(IFileDialogServiceBase.CheckPathExists), checkPathExists) + .WithPropertyValue(nameof(IFileDialogServiceBase.ValidateNames), validateNames) + .WithPropertyValue(nameof(IFileDialogServiceBase.RestoreDirectory), restoreDirectory) + .WithPropertyValue(nameof(IFileDialogServiceBase.ShowHelp), showHelp) + .WithPropertyValue(nameof(IFileDialogServiceBase.Title), title!) + .WithPropertyValue(nameof(IFileDialogServiceBase.InitialDirectory), initialDirectory!); + + return kernel; + } + + /// + /// Добавляет в контейнер . + /// + /// Ninject контейнер. + /// Заголовок окна. По умолчанию "Выбрать папку". + /// Директория открываемая по умолчанию. + /// True - разрешает мультивыбор. По умолчанию отключено. + /// True - включает автоматическую смену внешнего вида. По умолчанию включено. + /// True - включает проверку существования пути до файла. По умолчанию включено. + /// True - включает проверку правильности набранного имени файла. По умолчанию включено. + /// True - запоминает выбранное расположение. По умолчанию выключено. + /// True - включает отображение справки. По умолчанию выключено. + /// Тип ViewModel к которой будет прикрепление сервиса. + /// Возвращает настроенный контейнер Ninject. + /// Обязательно требуется прикрепить к элементу управления через . + /// kernel is null. + public static IKernel UseWpfOpenFolderDialog(this IKernel kernel, + string? title = "Выбрать папку", + string? initialDirectory = default, + bool multiSelect = false, + bool autoUpgradeEnabled = true, + bool checkPathExists = true, + bool validateNames = true, + bool restoreDirectory = false, + bool showHelp = false) { + if(kernel == null) { + throw new ArgumentNullException(nameof(kernel)); + } + + kernel.Bind() + .To() + .WhenInjectedInto() + .WithPropertyValue(nameof(IAttachableService.AllowAttach), true) + .WithPropertyValue(nameof(IOpenDialogServiceBase.Multiselect), multiSelect) + .WithPropertyValue(nameof(IFileDialogServiceBase.AutoUpgradeEnabled), autoUpgradeEnabled) + .WithPropertyValue(nameof(IFileDialogServiceBase.CheckPathExists), checkPathExists) + .WithPropertyValue(nameof(IFileDialogServiceBase.ValidateNames), validateNames) + .WithPropertyValue(nameof(IFileDialogServiceBase.RestoreDirectory), restoreDirectory) + .WithPropertyValue(nameof(IFileDialogServiceBase.ShowHelp), showHelp) + .WithPropertyValue(nameof(IFileDialogServiceBase.Title), title!) + .WithPropertyValue(nameof(IFileDialogServiceBase.InitialDirectory), initialDirectory!); + + return kernel; + } } \ No newline at end of file From 71b643483c3b0e5fb3f1626cd92df95d4490f46b Mon Sep 17 00:00:00 2001 From: dosymep Date: Mon, 15 Sep 2025 09:40:48 +0300 Subject: [PATCH 4/8] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D1=83?= =?UTF-8?q?=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82=D0=B0?= =?UTF-8?q?=20=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3=D0=BE=D0=B2=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B8=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20File/Folder=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SimpleServices/WpfOpenFileDialogService.cs | 12 ++++++++---- .../SimpleServices/WpfOpenFolderDialogService.cs | 9 +++++++-- .../SimpleServices/WpfSaveFileDialogService.cs | 9 ++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs index 66c5ee7..c823751 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs @@ -81,10 +81,14 @@ public bool ShowDialog(string directoryName) { }; bool? result = dialog.ShowDialog(); - - File = new FileInfo(dialog.SafeFileName); - Files = dialog.SafeFileNames.Select(item => new FileInfo(item)).ToArray(); - + if(result==true) { + File = new FileInfo(dialog.SafeFileName); + Files = dialog.SafeFileNames.Select(item => new FileInfo(item)).ToArray(); + } else { + File = null; + Files = null; + } + return result == true; } diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs index 333874c..bc04e1c 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs @@ -78,8 +78,13 @@ public bool ShowDialog(string directoryName) { CommonFileDialogResult? result = dialog.ShowDialog(); - Folder = new DirectoryInfo(dialog.FileName); - Folders = dialog.FileNames.Select(item => new DirectoryInfo(item)).ToArray(); + if(result == CommonFileDialogResult.Ok) { + Folder = new DirectoryInfo(dialog.FileName); + Folders = dialog.FileNames.Select(item => new DirectoryInfo(item)).ToArray(); + } else { + Folder = null; + Folders = null; + } return result == CommonFileDialogResult.Ok; } diff --git a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs index c4eac54..c8712db 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs @@ -76,9 +76,12 @@ public bool ShowDialog(string directoryName, string fileName) { }; bool? result = dialog.ShowDialog(); - - File = new FileInfo(dialog.SafeFileName); - + if(result == true) { + File = new FileInfo(dialog.SafeFileName); + } else { + File = null; + } + return result == true; } From f393bdb84e004084628cec660736de4b21765325 Mon Sep 17 00:00:00 2001 From: dosymep Date: Mon, 15 Sep 2025 09:40:57 +0300 Subject: [PATCH 5/8] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D1=83=20?= =?UTF-8?q?=D0=B4=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3=D0=BE=D0=B2=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D1=8F/=D1=81=D0=BE=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=84=D0=B0=D0=B9=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B8=20=D0=BF=D0=B0=D0=BF=D0=BE=D0=BA,=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8E=20=D0=B8=20=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8E=20=D1=81=D0=B5=D1=80=D0=B2=D0=B8=D1=81?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B2=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9?= =?UTF-8?q?=D0=BD=D0=B5=D1=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WpfDemoLib/ViewModels/MainViewModel.cs | 45 +++++++++++++++- samples/WpfUIDemoApp/App.xaml.cs | 9 ++++ samples/WpfUIDemoApp/MainWindow.xaml | 42 ++++++++++++--- .../Views/Pages/GridViewPage.xaml | 4 +- .../assets/localizations/language.en-US.xaml | 8 +++ .../assets/localizations/language.ru-RU.xaml | 8 +++ samples/XpfDemoApp/App.xaml.cs | 9 ++++ samples/XpfDemoApp/MainWindow.xaml | 52 ++++++++++++++----- .../assets/localizations/language.en-US.xaml | 8 +++ .../assets/localizations/language.ru-RU.xaml | 8 +++ 10 files changed, 168 insertions(+), 25 deletions(-) diff --git a/samples/WpfDemoLib/ViewModels/MainViewModel.cs b/samples/WpfDemoLib/ViewModels/MainViewModel.cs index e640fb6..563e469 100644 --- a/samples/WpfDemoLib/ViewModels/MainViewModel.cs +++ b/samples/WpfDemoLib/ViewModels/MainViewModel.cs @@ -14,6 +14,7 @@ public sealed class MainViewModel : ObservableObject { public const string NotificationWarningIconResourceName = "pack://application:,,,/WpfDemoLib;component/assets/images/icons8-notification-warning-32.png"; + private string? _fileDialogResults; private string? _secondWindowResult; public MainViewModel( @@ -21,31 +22,54 @@ public MainViewModel( ISecondViewService secondViewService, IMessageBoxService messageBoxService, ILocalizationService localizationService, - IProgressDialogFactory progressDialogFactory) { + IProgressDialogFactory progressDialogFactory, + IOpenFileDialogService openFileDialogService, + ISaveFileDialogService saveFileDialogService, + IOpenFolderDialogService openFolderDialogService) { SecondViewService = secondViewService; MessageBoxService = messageBoxService; LocalizationService = localizationService; ProgressDialogFactory = progressDialogFactory; + + OpenFileDialogService = openFileDialogService; + SaveFileDialogService = saveFileDialogService; + OpenFolderDialogService = openFolderDialogService; LoadViewCommand = commandFactory.CreateAsync(LoadAsync); AcceptViewCommand = commandFactory.CreateAsync(AcceptAsync); ShowSecondWindowCommand = commandFactory.CreateAsync(ShowSecondWindowAsync); ShowDialogSecondWindowCommand = commandFactory.CreateAsync(ShowDialogSecondWindowAsync); + + ShowDialogOpenFileCommand = commandFactory.Create(ShowDialogOpenFile); + ShowDialogSaveFileCommand = commandFactory.Create(ShowDialogSaveFile); + ShowDialogOpenFolderCommand = commandFactory.Create(ShowDialogOpenFolder); } - + public ISecondViewService SecondViewService { get; } public IMessageBoxService MessageBoxService { get; } public ILocalizationService LocalizationService { get; } public IProgressDialogFactory ProgressDialogFactory { get; } + public IOpenFileDialogService OpenFileDialogService { get; } + public ISaveFileDialogService SaveFileDialogService { get; } + public IOpenFolderDialogService OpenFolderDialogService { get; } public IAsyncRelayCommand LoadViewCommand { get; set; } public IAsyncRelayCommand AcceptViewCommand { get; set; } public IAsyncRelayCommand ShowSecondWindowCommand { get; set; } public IAsyncRelayCommand ShowDialogSecondWindowCommand { get; set; } + public IRelayCommand ShowDialogOpenFileCommand { get; set; } + public IRelayCommand ShowDialogSaveFileCommand { get; set; } + public IRelayCommand ShowDialogOpenFolderCommand { get; set; } + + public string? FileDialogResults { + get => _fileDialogResults; + set => this.RaiseAndSetIfChanged(ref _fileDialogResults, value); + } + public string? SecondWindowResult { get => _secondWindowResult; set => this.RaiseAndSetIfChanged(ref _secondWindowResult, value); @@ -91,6 +115,23 @@ private async Task ShowDialogSecondWindowAsync() { SecondWindowResult = SecondViewService.Result; } } + + private void ShowDialogOpenFile() { + FileDialogResults = OpenFileDialogService.ShowDialog() + ? OpenFileDialogService.File.Name + : null; + } + + private void ShowDialogSaveFile() { + FileDialogResults = + SaveFileDialogService.ShowDialog(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.txt") + ? SaveFileDialogService.File.Name + : null; + } + + private void ShowDialogOpenFolder() { + FileDialogResults = OpenFolderDialogService.ShowDialog() ? OpenFolderDialogService.Folder.Name : null; + } private async Task AsyncOperation(int maxValue, IProgress? progress, CancellationToken cancellationToken) { for(int i = 0; i < maxValue; i++) { diff --git a/samples/WpfUIDemoApp/App.xaml.cs b/samples/WpfUIDemoApp/App.xaml.cs index 7763f3e..f9c53b6 100644 --- a/samples/WpfUIDemoApp/App.xaml.cs +++ b/samples/WpfUIDemoApp/App.xaml.cs @@ -60,6 +60,15 @@ protected override void OnStartup(StartupEventArgs e) { _kernel.UseWpfUIProgressDialog( displayTitleFormat: localizationService.GetLocalizedString("ProgressDialog.Content")); + + _kernel.UseWpfOpenFileDialog( + title: localizationService.GetLocalizedString("OpenFileDialog.Title")); + + _kernel.UseWpfSaveFileDialog( + title: localizationService.GetLocalizedString("SaveFileDialog.Title")); + + _kernel.UseWpfOpenFolderDialog( + title: localizationService.GetLocalizedString("OpenFolderDialog.Title")); _kernel.Bind().To(); _kernel.Bind() diff --git a/samples/WpfUIDemoApp/MainWindow.xaml b/samples/WpfUIDemoApp/MainWindow.xaml index 399419f..19f4cda 100644 --- a/samples/WpfUIDemoApp/MainWindow.xaml +++ b/samples/WpfUIDemoApp/MainWindow.xaml @@ -34,6 +34,9 @@ + + + @@ -46,6 +49,7 @@ + @@ -82,31 +86,53 @@ - + LastChildFill="True"> - + + + + + + + + + + + + @@ -128,7 +154,7 @@ diff --git a/samples/WpfUIDemoApp/Views/Pages/GridViewPage.xaml b/samples/WpfUIDemoApp/Views/Pages/GridViewPage.xaml index c7e38e2..9f512e6 100644 --- a/samples/WpfUIDemoApp/Views/Pages/GridViewPage.xaml +++ b/samples/WpfUIDemoApp/Views/Pages/GridViewPage.xaml @@ -66,8 +66,8 @@ + Text="{Binding Name}"> + diff --git a/samples/WpfUIDemoApp/assets/localizations/language.en-US.xaml b/samples/WpfUIDemoApp/assets/localizations/language.en-US.xaml index 71e4db4..09717da 100644 --- a/samples/WpfUIDemoApp/assets/localizations/language.en-US.xaml +++ b/samples/WpfUIDemoApp/assets/localizations/language.en-US.xaml @@ -33,6 +33,14 @@ Hello world! Please wait [{0}/{1}]... + Choose file + Save file + Choose folder + + Choose file + Save file + Choose folder + Dark Light \ No newline at end of file diff --git a/samples/WpfUIDemoApp/assets/localizations/language.ru-RU.xaml b/samples/WpfUIDemoApp/assets/localizations/language.ru-RU.xaml index 5d118d1..2041d31 100644 --- a/samples/WpfUIDemoApp/assets/localizations/language.ru-RU.xaml +++ b/samples/WpfUIDemoApp/assets/localizations/language.ru-RU.xaml @@ -38,6 +38,14 @@ Привет мир! Пожалуйста подождите [{0}/{1}]... + Выбрать файл + Сохранить файл + Выбрать папку + + Выбрать файл + Сохранить файл + Выбрать папку + Темная Светлая \ No newline at end of file diff --git a/samples/XpfDemoApp/App.xaml.cs b/samples/XpfDemoApp/App.xaml.cs index 7c22c2d..56b265e 100644 --- a/samples/XpfDemoApp/App.xaml.cs +++ b/samples/XpfDemoApp/App.xaml.cs @@ -65,6 +65,15 @@ protected override void OnStartup(StartupEventArgs e) { _kernel.UseXtraProgressDialog( displayTitleFormat: localizationService.GetLocalizedString("ProgressDialog.Content")); + + _kernel.UseXtraOpenFileDialog( + title: localizationService.GetLocalizedString("OpenFileDialog.Title")); + + _kernel.UseXtraSaveFileDialog( + title: localizationService.GetLocalizedString("SaveFileDialog.Title")); + + _kernel.UseXtraOpenFolderDialog( + title: localizationService.GetLocalizedString("OpenFolderDialog.Title")); _kernel.Bind().To(); _kernel.Bind() diff --git a/samples/XpfDemoApp/MainWindow.xaml b/samples/XpfDemoApp/MainWindow.xaml index b4a1f81..1839341 100644 --- a/samples/XpfDemoApp/MainWindow.xaml +++ b/samples/XpfDemoApp/MainWindow.xaml @@ -22,7 +22,7 @@ x:Name="_this" mc:Ignorable="d" - + Icon="{me:QualifiedImage assets/images/icons8-google-photos-144.png}" WindowStartupLocation="CenterScreen" @@ -35,6 +35,9 @@ + + + @@ -47,42 +50,65 @@ + - - + LastChildFill="True"> - + - + + + + + + + + + + + - + @@ -123,7 +149,7 @@ Height="18" Margin="10 0" Source="{me:QualifiedImage /dosymep.WpfCore;component/assets/images/icons8-no-image-96.png}" /> - + diff --git a/samples/XpfDemoApp/assets/localizations/language.en-US.xaml b/samples/XpfDemoApp/assets/localizations/language.en-US.xaml index d219d89..f3ddb50 100644 --- a/samples/XpfDemoApp/assets/localizations/language.en-US.xaml +++ b/samples/XpfDemoApp/assets/localizations/language.en-US.xaml @@ -28,6 +28,14 @@ Hello world! Please wait [{0}/{1}]... + Choose file + Save file + Choose folder + + Choose file + Save file + Choose folder + Dark Light \ No newline at end of file diff --git a/samples/XpfDemoApp/assets/localizations/language.ru-RU.xaml b/samples/XpfDemoApp/assets/localizations/language.ru-RU.xaml index 7907fbf..81888bb 100644 --- a/samples/XpfDemoApp/assets/localizations/language.ru-RU.xaml +++ b/samples/XpfDemoApp/assets/localizations/language.ru-RU.xaml @@ -33,6 +33,14 @@ Привет мир! Пожалуйста подождите [{0}/{1}]... + Выбрать файл + Сохранить файл + Выбрать папку + + Выбрать файл + Сохранить файл + Выбрать папку + Темная Светлая \ No newline at end of file From c36e9ce81204d855350a5c143227eaba8ee9870b Mon Sep 17 00:00:00 2001 From: dosymep Date: Mon, 15 Sep 2025 15:31:41 +0300 Subject: [PATCH 6/8] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D0=BF=D0=B5=D1=87=D0=B0=D1=82=D0=BA=D1=83=20?= =?UTF-8?q?=D0=B2=20XML-=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=B4=D0=B0=20`UseWpfDispatcher`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dosymep.WpfCore.Ninject/NinjectExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dosymep.WpfCore.Ninject/NinjectExtensions.cs b/src/dosymep.WpfCore.Ninject/NinjectExtensions.cs index 34e04fd..f9a6b1a 100644 --- a/src/dosymep.WpfCore.Ninject/NinjectExtensions.cs +++ b/src/dosymep.WpfCore.Ninject/NinjectExtensions.cs @@ -111,7 +111,7 @@ public static IKernel UseWpfDispatcher(this IKernel kernel) { /// Ninject контейнер. /// Тип ViewModel к которой будет прикрепление сервиса. /// Возвращает настроенный контейнер Ninject. - /// Обязательно требуется прикрепить к элементу управления через . + /// Обязательно требуется прикрепить к элементу управления через . /// kernel is null. public static IKernel UseWpfDispatcher(this IKernel kernel) { if(kernel is null) { From 8aaef80d0d9763d69b33da97967d1a46c1d9f582 Mon Sep 17 00:00:00 2001 From: dosymep Date: Mon, 15 Sep 2025 15:34:08 +0300 Subject: [PATCH 7/8] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20`ShowDialog`=20=D0=B2=20`Wp?= =?UTF-8?q?fSaveFileDialogService`=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D0=B8=20nullable=20=D0=BF?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE=D0=B2=20`direc?= =?UTF-8?q?toryName`=20=D0=B8=20`fileName`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SimpleServices/WpfSaveFileDialogService.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs index c8712db..41217e3 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs @@ -59,7 +59,7 @@ public sealed class WpfSaveFileDialogService : WpfBaseService, ISaveFileDialogSe public FileInfo? File { get; private set; } /// - public bool ShowDialog(string directoryName, string fileName) { + public bool ShowDialog(string? directoryName, string? fileName) { SaveFileDialog dialog = new() { AddExtension = AddExtension, CheckFileExists = CheckFileExists, @@ -70,9 +70,10 @@ public bool ShowDialog(string directoryName, string fileName) { FilterIndex = FilterIndex, Title = Title ?? string.Empty, Filter = Filter ?? string.Empty, - InitialDirectory = InitialDirectory ?? Environment.GetFolderPath(Environment.SpecialFolder.Desktop), + InitialDirectory = + directoryName ?? InitialDirectory ?? Environment.GetFolderPath(Environment.SpecialFolder.Desktop), DefaultExt = DefaultExt ?? string.Empty, - FileName = DefaultFileName ?? string.Empty + FileName = fileName ?? DefaultFileName ?? string.Empty }; bool? result = dialog.ShowDialog(); @@ -81,7 +82,7 @@ public bool ShowDialog(string directoryName, string fileName) { } else { File = null; } - + return result == true; } From 834410964b8ec5c196b58758c23b4939d5c1be8a Mon Sep 17 00:00:00 2001 From: dosymep Date: Mon, 15 Sep 2025 15:35:42 +0300 Subject: [PATCH 8/8] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20`Reset`=20=D0=B2=20?= =?UTF-8?q?=D1=81=D0=B5=D1=80=D0=B2=D0=B8=D1=81=D0=B0=D1=85=20=D0=B4=D0=B8?= =?UTF-8?q?=D0=B0=D0=BB=D0=BE=D0=B3=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE=D0=B9=20?= =?UTF-8?q?=D0=B8=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D0=BF=D0=BE=D0=BB=D0=B5=D0=B9=20`File`,?= =?UTF-8?q?=20`Files`,=20`Folder`=20=D0=B8=20`Folders`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SimpleServices/WpfOpenFileDialogService.cs | 3 ++- .../SimpleServices/WpfOpenFolderDialogService.cs | 5 +++-- .../SimpleServices/WpfSaveFileDialogService.cs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs index c823751..e184896 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFileDialogService.cs @@ -94,6 +94,7 @@ public bool ShowDialog(string directoryName) { /// public void Reset() { - // nothing to do + File = null; + Files = []; } } \ No newline at end of file diff --git a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs index bc04e1c..ec3ac66 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfOpenFolderDialogService.cs @@ -83,7 +83,7 @@ public bool ShowDialog(string directoryName) { Folders = dialog.FileNames.Select(item => new DirectoryInfo(item)).ToArray(); } else { Folder = null; - Folders = null; + Folders = []; } return result == CommonFileDialogResult.Ok; @@ -91,6 +91,7 @@ public bool ShowDialog(string directoryName) { /// public void Reset() { - throw new NotImplementedException(); + Folder = null; + Folders = []; } } \ No newline at end of file diff --git a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs index 41217e3..c2ac462 100644 --- a/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs +++ b/src/dosymep.WpfCore/SimpleServices/WpfSaveFileDialogService.cs @@ -88,6 +88,6 @@ public bool ShowDialog(string? directoryName, string? fileName) { /// public void Reset() { - // nothing to do + File = null; } } \ No newline at end of file