From d9bf61a48aacbd3182b8c1871d72a49e68f63aa9 Mon Sep 17 00:00:00 2001 From: Andrew Vasenev Date: Mon, 23 Sep 2024 03:41:49 +0300 Subject: [PATCH 1/2] Default filename parameter for save file dialog --- Photino.NET/PhotinoDllImports.cs | 4 ++-- Photino.NET/PhotinoWindow.NET.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Photino.NET/PhotinoDllImports.cs b/Photino.NET/PhotinoDllImports.cs index e657462..d1488fa 100644 --- a/Photino.NET/PhotinoDllImports.cs +++ b/Photino.NET/PhotinoDllImports.cs @@ -330,7 +330,7 @@ public partial class PhotinoWindow [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] - public static partial IntPtr Photino_ShowSaveFile(IntPtr inst, string title, string defaultPath, string[] filters, int filtersCount); + public static partial IntPtr Photino_ShowSaveFile(IntPtr inst, string title, string defaultPath, string defaultFileName, string[] filters, int filtersCount); [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)] [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] @@ -343,7 +343,7 @@ public partial class PhotinoWindow public static extern IntPtr Photino_ShowOpenFolder(IntPtr inst, string title, string defaultPath, bool multiSelect, out int resultCount); [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl, SetLastError = true, CharSet = CharSet.Ansi)] - public static extern IntPtr Photino_ShowSaveFile(IntPtr inst, string title, string defaultPath, string[] filters, int filtersCount); + public static extern IntPtr Photino_ShowSaveFile(IntPtr inst, string title, string defaultFileName, string defaultPath, string[] filters, int filtersCount); [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl, SetLastError = true, CharSet = CharSet.Ansi)] public static extern PhotinoDialogResult Photino_ShowMessage(IntPtr inst, string title, string text, PhotinoDialogButtons buttons, PhotinoDialogIcon icon); diff --git a/Photino.NET/PhotinoWindow.NET.cs b/Photino.NET/PhotinoWindow.NET.cs index 94515f2..07f2e16 100644 --- a/Photino.NET/PhotinoWindow.NET.cs +++ b/Photino.NET/PhotinoWindow.NET.cs @@ -2459,7 +2459,7 @@ public void SendNotification(string title, string body) /// Default path. Defaults to /// Array of for filtering. /// - public string ShowSaveFile(string title = "Save file", string defaultPath = null, (string Name, string[] Extensions)[] filters = null) + public string ShowSaveFile(string title = "Save file", string defaultPath = null, string defaultFileName = null, (string Name, string[] Extensions)[] filters = null) { defaultPath ??= Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); filters ??= Array.Empty<(string, string[])>(); @@ -2469,7 +2469,7 @@ public string ShowSaveFile(string title = "Save file", string defaultPath = null Invoke(() => { - var ptrResult = Photino_ShowSaveFile(_nativeInstance, title, defaultPath, nativeFilters, filters.Length); + var ptrResult = Photino_ShowSaveFile(_nativeInstance, title, defaultPath, defaultFileName, nativeFilters, filters.Length); result = Marshal.PtrToStringAuto(ptrResult); }); From 7ce86229de747e687ae311aed94b7e9ddb703496 Mon Sep 17 00:00:00 2001 From: Andrew Vasenev Date: Thu, 10 Oct 2024 21:18:06 +0300 Subject: [PATCH 2/2] ShowSaveFile method overload --- Photino.NET/PhotinoWindow.NET.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Photino.NET/PhotinoWindow.NET.cs b/Photino.NET/PhotinoWindow.NET.cs index 07f2e16..03093a5 100644 --- a/Photino.NET/PhotinoWindow.NET.cs +++ b/Photino.NET/PhotinoWindow.NET.cs @@ -2447,7 +2447,7 @@ public void SendNotification(string title, string body) public string[] ShowOpenFolder(string title = "Select folder", string defaultPath = null, bool multiSelect = false) => ShowOpenDialog(true, title, defaultPath, multiSelect, null); /// - /// Show an save folder dialog native to the OS. + /// Show a save folder dialog native to the OS. /// /// /// Filter names are not used on macOS. @@ -2459,6 +2459,25 @@ public void SendNotification(string title, string body) /// Default path. Defaults to /// Array of for filtering. /// + public string ShowSaveFile(string title = "Save file", string defaultPath = null, (string Name, string[] Extensions)[] filters = null) + { + return ShowSaveFile(title, defaultPath, null, filters); + } + + /// + /// Show a save folder dialog native to the OS. + /// + /// + /// Filter names are not used on macOS. + /// + /// + /// Thrown when the window is not initialized. + /// + /// Title of the dialog + /// Default path. Defaults to + /// Default file name in the text input field. + /// Array of for filtering. + /// public string ShowSaveFile(string title = "Save file", string defaultPath = null, string defaultFileName = null, (string Name, string[] Extensions)[] filters = null) { defaultPath ??= Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);