diff --git a/Photino.NET/Photino.NET.csproj b/Photino.NET/Photino.NET.csproj
index 555c8ac..7f85038 100644
--- a/Photino.NET/Photino.NET.csproj
+++ b/Photino.NET/Photino.NET.csproj
@@ -24,10 +24,6 @@
true
true
-
-
- OS_WINDOWS
-
@@ -36,7 +32,7 @@
-
+
diff --git a/Photino.NET/PhotinoDllImports.cs b/Photino.NET/PhotinoDllImports.cs
index f5ed2e4..45985f1 100644
--- a/Photino.NET/PhotinoDllImports.cs
+++ b/Photino.NET/PhotinoDllImports.cs
@@ -33,11 +33,7 @@ public partial class PhotinoWindow
#if NET7_0_OR_GREATER
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
static partial void Photino_AddCustomSchemeName(IntPtr instance, string scheme);
@@ -184,19 +180,11 @@ public partial class PhotinoWindow
//NAVIGATE
#if NET7_0_OR_GREATER
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
static partial void Photino_NavigateToString(IntPtr instance, string content);
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
static partial void Photino_NavigateToUrl(IntPtr instance, string url);
#else
@@ -207,11 +195,7 @@ public partial class PhotinoWindow
//SET
#if NET7_0_OR_GREATER
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
static partial void Photino_setWebView2RuntimePath_win32(IntPtr instance, string webView2RuntimePath);
@@ -263,11 +247,7 @@ public partial class PhotinoWindow
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
static partial void Photino_SetSize(IntPtr instance, int width, int height);
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
static partial void Photino_SetTitle(IntPtr instance, string title);
@@ -275,11 +255,7 @@ public partial class PhotinoWindow
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
static partial void Photino_SetTopmost(IntPtr instance, [MarshalAs(UnmanagedType.I1)] bool topmost);
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
static partial void Photino_SetIconFile(IntPtr instance, string filename);
@@ -317,24 +293,17 @@ public partial class PhotinoWindow
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
static partial void Photino_ClearBrowserAutoFill(IntPtr instance);
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
private static partial void Photino_SendWebMessage(IntPtr instance, string message);
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
private static partial void Photino_ShowMessage(IntPtr instance, string title, string body, uint type);
- [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl, SetLastError = true, CharSet = CharSet.Auto)]
- private static extern void Photino_ShowNotification(IntPtr instance, string title, string body);
+ [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
+ [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
+ private static partial void Photino_ShowNotification(IntPtr instance, string title, string body);
[LibraryImport(DLL_NAME, SetLastError = true)]
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
@@ -351,35 +320,19 @@ public partial class PhotinoWindow
//DIALOG
#if NET7_0_OR_GREATER
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr Photino_ShowOpenFile(IntPtr inst, string title, string defaultPath, [MarshalAs(UnmanagedType.I1)] bool multiSelect, string[] filters, int filtersCount, out int resultCount);
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial IntPtr Photino_ShowOpenFolder(IntPtr inst, string title, string defaultPath, [MarshalAs(UnmanagedType.I1)] bool multiSelect, out int resultCount);
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[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);
-#if OS_WINDOWS
- [LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
-#else
[LibraryImport(DLL_NAME, SetLastError = true, StringMarshalling = StringMarshalling.Utf8)]
-#endif
[UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
public static partial PhotinoDialogResult Photino_ShowMessage(IntPtr inst, string title, string text, PhotinoDialogButtons buttons, PhotinoDialogIcon icon);
#else
diff --git a/Photino.NET/PhotinoNativeParameters.cs b/Photino.NET/PhotinoNativeParameters.cs
index 5da197d..7e778ef 100644
--- a/Photino.NET/PhotinoNativeParameters.cs
+++ b/Photino.NET/PhotinoNativeParameters.cs
@@ -5,62 +5,30 @@ namespace Photino.NET;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct PhotinoNativeParameters
{
- ///EITHER StartString or StartUrl Must be specified: Browser control will render this HTML string when initialized. Default is none.
- [MarshalAs(UnmanagedType.LPWStr)]
- internal string StartStringWide;
///EITHER StartString or StartUrl Must be specified: Browser control will render this HTML string when initialized. Default is none.
[MarshalAs(UnmanagedType.LPStr)]
internal string StartString;
- ///EITHER StartString or StartUrl Must be specified: Browser control will navigate to this URL when initialized. Default is none.
- [MarshalAs(UnmanagedType.LPWStr)]
- internal string StartUrlWide;
///EITHER StartString or StartUrl Must be specified: Browser control will navigate to this URL when initialized. Default is none.
[MarshalAs(UnmanagedType.LPStr)]
internal string StartUrl;
- ///OPTIONAL: Appears on the title bar of the native window. Default is none.
- [MarshalAs(UnmanagedType.LPWStr)]
- internal string TitleWide;
///OPTIONAL: Appears on the title bar of the native window. Default is none.
[MarshalAs(UnmanagedType.LPStr)]
internal string Title;
- ///WINDOWS AND LINUX ONLY: OPTIONAL: Path to a local file or a URL. Icon appears on the title bar of the native window (if supported). Default is none.
- [MarshalAs(UnmanagedType.LPWStr)]
- internal string WindowIconFileWide;
///WINDOWS AND LINUX ONLY: OPTIONAL: Path to a local file or a URL. Icon appears on the title bar of the native window (if supported). Default is none.
[MarshalAs(UnmanagedType.LPStr)]
internal string WindowIconFile;
- ///WINDOWS: OPTIONAL: Path to store temp files for browser control. Defaults is user's AppDataLocal folder.
- [MarshalAs(UnmanagedType.LPWStr)]
- internal string TemporaryFilesPathWide;
///WINDOWS: OPTIONAL: Path to store temp files for browser control. Defaults is user's AppDataLocal folder.
[MarshalAs(UnmanagedType.LPStr)]
internal string TemporaryFilesPath;
- ///OPTIONAL: Changes the user agent on the browser control at initialiation.
- [MarshalAs(UnmanagedType.LPWStr)]
- internal string UserAgentWide;
///OPTIONAL: Changes the user agent on the browser control at initialiation.
[MarshalAs(UnmanagedType.LPStr)]
internal string UserAgent;
- ///OPTIONAL:
- ///WINDOWS: WebView2 specific string.
- ///https://peter.sh/experiments/chromium-command-line-switches/
- ///https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2environmentoptions.additionalbrowserarguments?view=webview2-dotnet-1.0.1938.49&viewFallbackFrom=webview2-dotnet-1.0.1901.177view%3Dwebview2-1.0.1901.177
- ///https://www.chromium.org/developers/how-tos/run-chromium-with-flags/
- ///LINUX: Webkit2Gtk specific string.
- ///https://webkitgtk.org/reference/webkit2gtk/2.5.1/WebKitSettings.html
- ///https://lazka.github.io/pgi-docs/WebKit2-4.0/classes/Settings.html
- ///MAC: Webkit specific string.
- ///https://developer.apple.com/documentation/webkit/wkwebviewconfiguration?language=objc
- ///https://developer.apple.com/documentation/webkit/wkpreferences?language=objc
- ///
- [MarshalAs(UnmanagedType.LPWStr)]
- internal string BrowserControlInitParametersWide;
///OPTIONAL:
///WINDOWS: WebView2 specific string.
///https://peter.sh/experiments/chromium-command-line-switches/
@@ -107,9 +75,6 @@ internal struct PhotinoNativeParameters
///SET BY PHOTINIWINDOW CONSTRUCTOR
[MarshalAs(UnmanagedType.FunctionPtr)] internal CppWebMessageReceivedDelegate WebMessageReceivedHandler;
- ///OPTIONAL: Names of custom URL Schemes. e.g. 'app', 'custom'. Array length must be 16. Default is none.
- [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.LPWStr, SizeConst = 16)]
- internal string[] CustomSchemeNamesWide;
///OPTIONAL: Names of custom URL Schemes. e.g. 'app', 'custom'. Array length must be 16. Default is none.
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.LPStr, SizeConst = 16)]
internal string[] CustomSchemeNames;
@@ -204,9 +169,9 @@ internal List GetParamErrors()
{
var response = new List();
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
- var startUrl = isWindows ? StartUrlWide : StartUrl;
- var startString = isWindows ? StartStringWide : StartString;
- var windowIconFile = isWindows ? WindowIconFileWide : WindowIconFile;
+ var startUrl = StartUrl;
+ var startString = StartString;
+ var windowIconFile = WindowIconFile;
if (string.IsNullOrWhiteSpace(startUrl) && string.IsNullOrWhiteSpace(startString))
response.Add("An initial URL or HTML string must be supplied in StartUrl or StartString for the browser control to naviage to.");
diff --git a/Photino.NET/PhotinoWindow.NET.cs b/Photino.NET/PhotinoWindow.NET.cs
index 61205c7..ed7c30c 100644
--- a/Photino.NET/PhotinoWindow.NET.cs
+++ b/Photino.NET/PhotinoWindow.NET.cs
@@ -12,13 +12,10 @@ public partial class PhotinoWindow
///
/// Indicates whether the window is resizable.
/// Specifies whether the context menu is enabled.
- /// An array of strings representing wide custom scheme names.
/// An array of strings representing custom scheme names.
/// Specifies whether developer tools are enabled.
/// Indicates whether browser permissions are granted.
- /// Defines the wide path for temporary files.
/// Defines the path for temporary files.
- /// Sets the wide title of the window.
/// Sets the title of the window.
/// Specifies whether the window should use the OS default location.
/// Indicates whether the window should use the OS default size.
@@ -27,7 +24,6 @@ public partial class PhotinoWindow
{
Resizable = true, //These values can't be initialized within the struct itself. Set required defaults.
ContextMenuEnabled = true,
- CustomSchemeNamesWide = new string[16],
CustomSchemeNames = new string[16],
DevToolsEnabled = true,
GrantBrowserPermissions = true,
@@ -39,10 +35,9 @@ public partial class PhotinoWindow
MediaStreamEnabled = true,
SmoothScrollingEnabled = true,
IgnoreCertificateErrorsEnabled = false,
- TemporaryFilesPathWide = IsWindowsPlatform
+ TemporaryFilesPath = IsWindowsPlatform
? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Photino")
: null,
- TitleWide = "Photino",
Title = "Photino",
UseOsDefaultLocation = true,
UseOsDefaultSize = true,
@@ -375,10 +370,7 @@ public string UserAgent
get
{
if (_nativeInstance == IntPtr.Zero)
- if (IsWindowsPlatform)
- return _startupParameters.UserAgentWide;
- else
- return _startupParameters.UserAgent;
+ return _startupParameters.UserAgent;
var userAgent = string.Empty;
Invoke(() =>
@@ -393,10 +385,7 @@ public string UserAgent
if (UserAgent != value)
{
if (_nativeInstance == IntPtr.Zero)
- if (IsWindowsPlatform)
- _startupParameters.UserAgentWide = value;
- else
- _startupParameters.UserAgent = value;
+ _startupParameters.UserAgent = value;
else
throw new ApplicationException("UserAgent can only be set before the native window is instantiated.");
}
@@ -644,12 +633,8 @@ public string IconFile
_iconFile = value;
-
if (_nativeInstance == IntPtr.Zero)
- if (IsWindowsPlatform)
- _startupParameters.WindowIconFileWide = _iconFile;
- else
- _startupParameters.WindowIconFile = _iconFile;
+ _startupParameters.WindowIconFile = _iconFile;
else
Invoke(() => Photino_SetIconFile(_nativeInstance, _iconFile));
}
@@ -942,21 +927,15 @@ public string BrowserControlInitParameters
{
get
{
- if (IsWindowsPlatform)
- return _startupParameters.BrowserControlInitParametersWide;
- else
- return _startupParameters.BrowserControlInitParameters;
+ return _startupParameters.BrowserControlInitParameters;
}
set
{
- var ss = IsWindowsPlatform ? _startupParameters.BrowserControlInitParametersWide : _startupParameters.BrowserControlInitParameters;
+ var ss = _startupParameters.BrowserControlInitParameters;
if (string.Compare(ss, value, true) != 0)
{
if (_nativeInstance == IntPtr.Zero)
- if (IsWindowsPlatform)
- _startupParameters.BrowserControlInitParametersWide = value;
- else
- _startupParameters.BrowserControlInitParameters = value;
+ _startupParameters.BrowserControlInitParameters = value;
else
throw new ApplicationException($"{nameof(ss)} cannot be changed after Photino Window is initialized");
}
@@ -978,14 +957,11 @@ public string StartString
{
get
{
- if (IsWindowsPlatform)
- return _startupParameters.StartStringWide;
- else
- return _startupParameters.StartString;
+ return _startupParameters.StartString;
}
set
{
- var ss = IsWindowsPlatform ? _startupParameters.StartStringWide : _startupParameters.StartString;
+ var ss = _startupParameters.StartString;
if (string.Compare(ss, value, true) != 0)
{
if (_nativeInstance != IntPtr.Zero)
@@ -1010,14 +986,11 @@ public string StartUrl
{
get
{
- if (IsWindowsPlatform)
- return _startupParameters.StartUrlWide;
- else
- return _startupParameters.StartUrl;
+ return _startupParameters.StartUrl;
}
set
{
- var su = IsWindowsPlatform ? _startupParameters.StartUrlWide : _startupParameters.StartUrl;
+ var su = _startupParameters.StartUrl;
if (string.Compare(su, value, true) != 0)
{
if (_nativeInstance != IntPtr.Zero)
@@ -1041,22 +1014,16 @@ public string TemporaryFilesPath
{
get
{
- if (IsWindowsPlatform)
- return _startupParameters.TemporaryFilesPathWide;
- else
- return _startupParameters.TemporaryFilesPath;
+ return _startupParameters.TemporaryFilesPath;
}
set
{
- var tfp = IsWindowsPlatform ? _startupParameters.TemporaryFilesPathWide : _startupParameters.TemporaryFilesPath;
+ var tfp = _startupParameters.TemporaryFilesPath;
if (tfp != value)
{
if (_nativeInstance != IntPtr.Zero)
throw new ApplicationException($"{nameof(tfp)} cannot be changed after Photino Window is initialized");
- if (IsWindowsPlatform)
- _startupParameters.TemporaryFilesPathWide = value;
- else
- _startupParameters.TemporaryFilesPath = value;
+ _startupParameters.TemporaryFilesPath = value;
}
}
}
@@ -1070,10 +1037,7 @@ public string Title
get
{
if (_nativeInstance == IntPtr.Zero)
- if (IsWindowsPlatform)
- return _startupParameters.TitleWide;
- else
- return _startupParameters.Title;
+ return _startupParameters.Title;
var title = string.Empty;
Invoke(() =>
@@ -1092,10 +1056,7 @@ public string Title
value = value[..31];
if (_nativeInstance == IntPtr.Zero)
- if (IsWindowsPlatform)
- _startupParameters.TitleWide = value;
- else
- _startupParameters.Title = value;
+ _startupParameters.Title = value;
else
Invoke(() => Photino_SetTitle(_nativeInstance, value));
}
@@ -1519,10 +1480,7 @@ public PhotinoWindow Load(Uri uri)
{
Log($".Load({uri})");
if (_nativeInstance == IntPtr.Zero)
- if (IsWindowsPlatform)
- _startupParameters.StartUrlWide = uri.ToString();
- else
- _startupParameters.StartUrl = uri.ToString();
+ _startupParameters.StartUrl = uri.ToString();
else
Invoke(() => Photino_NavigateToUrl(_nativeInstance, uri.ToString()));
return this;
@@ -1585,10 +1543,7 @@ public PhotinoWindow LoadRawString(string content)
var shortContent = content.Length > 50 ? string.Concat(content.AsSpan(0, 50), "...") : content;
Log($".LoadRawString({shortContent})");
if (_nativeInstance == IntPtr.Zero)
- if (IsWindowsPlatform)
- _startupParameters.StartStringWide = content;
- else
- _startupParameters.StartString = content;
+ _startupParameters.StartString = content;
else
Invoke(() => Photino_NavigateToString(_nativeInstance, content));
return this;
@@ -2348,10 +2303,7 @@ public void WaitForClose()
var i = 0;
foreach (var name in CustomSchemes.Take(16))
{
- if (IsWindowsPlatform)
- _startupParameters.CustomSchemeNamesWide[i] = name.Key;
- else
- _startupParameters.CustomSchemeNames[i] = name.Key;
+ _startupParameters.CustomSchemeNames[i] = name.Key;
i++;
}
diff --git a/nuget.config b/nuget.config
new file mode 100644
index 0000000..81b2e08
--- /dev/null
+++ b/nuget.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file