Skip to content

Commit

Permalink
Merge pull request #208 from tryphotino/debug
Browse files Browse the repository at this point in the history
Removed support for UFT16
  • Loading branch information
MikeYeager authored Sep 6, 2024
2 parents 4f45dbb + 8da305f commit bddecc8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 160 deletions.
6 changes: 1 addition & 5 deletions Photino.NET/Photino.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
<IsPackable>true</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<DefineConstants>OS_WINDOWS</DefineConstants>
</PropertyGroup>

<Target Name="SetPackageVersion" DependsOnTargets="Build">
<PropertyGroup>
Expand All @@ -36,7 +32,7 @@
</Target>

<ItemGroup>
<PackageReference Include="Photino.Native" Version="3.1.5" />
<PackageReference Include="Photino.Native" Version="3.1.6" />
</ItemGroup>

</Project>
53 changes: 3 additions & 50 deletions Photino.NET/PhotinoDllImports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand All @@ -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);

Expand Down Expand Up @@ -263,23 +247,15 @@ 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);

[LibraryImport(DLL_NAME, SetLastError = true)]
[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);

Expand Down Expand Up @@ -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) })]
Expand All @@ -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
Expand Down
41 changes: 3 additions & 38 deletions Photino.NET/PhotinoNativeParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,30 @@ namespace Photino.NET;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct PhotinoNativeParameters
{
///<summary>EITHER StartString or StartUrl Must be specified: Browser control will render this HTML string when initialized. Default is none.</summary>
[MarshalAs(UnmanagedType.LPWStr)]
internal string StartStringWide;
///<summary>EITHER StartString or StartUrl Must be specified: Browser control will render this HTML string when initialized. Default is none.</summary>
[MarshalAs(UnmanagedType.LPStr)]
internal string StartString;

///<summary>EITHER StartString or StartUrl Must be specified: Browser control will navigate to this URL when initialized. Default is none.</summary>
[MarshalAs(UnmanagedType.LPWStr)]
internal string StartUrlWide;
///<summary>EITHER StartString or StartUrl Must be specified: Browser control will navigate to this URL when initialized. Default is none.</summary>
[MarshalAs(UnmanagedType.LPStr)]
internal string StartUrl;

///<summary>OPTIONAL: Appears on the title bar of the native window. Default is none.</summary>
[MarshalAs(UnmanagedType.LPWStr)]
internal string TitleWide;
///<summary>OPTIONAL: Appears on the title bar of the native window. Default is none.</summary>
[MarshalAs(UnmanagedType.LPStr)]
internal string Title;

///<summary>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.</summary>
[MarshalAs(UnmanagedType.LPWStr)]
internal string WindowIconFileWide;
///<summary>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.</summary>
[MarshalAs(UnmanagedType.LPStr)]
internal string WindowIconFile;

///<summary>WINDOWS: OPTIONAL: Path to store temp files for browser control. Defaults is user's AppDataLocal folder.</summary>
[MarshalAs(UnmanagedType.LPWStr)]
internal string TemporaryFilesPathWide;
///<summary>WINDOWS: OPTIONAL: Path to store temp files for browser control. Defaults is user's AppDataLocal folder.</summary>
[MarshalAs(UnmanagedType.LPStr)]
internal string TemporaryFilesPath;

///<summary>OPTIONAL: Changes the user agent on the browser control at initialiation.</summary>
[MarshalAs(UnmanagedType.LPWStr)]
internal string UserAgentWide;
///<summary>OPTIONAL: Changes the user agent on the browser control at initialiation.</summary>
[MarshalAs(UnmanagedType.LPStr)]
internal string UserAgent;

///<summary>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
///</summary>
[MarshalAs(UnmanagedType.LPWStr)]
internal string BrowserControlInitParametersWide;
///<summary>OPTIONAL:
///WINDOWS: WebView2 specific string.
///https://peter.sh/experiments/chromium-command-line-switches/
Expand Down Expand Up @@ -107,9 +75,6 @@ internal struct PhotinoNativeParameters
///<summary>SET BY PHOTINIWINDOW CONSTRUCTOR</summary>
[MarshalAs(UnmanagedType.FunctionPtr)] internal CppWebMessageReceivedDelegate WebMessageReceivedHandler;

///<summary>OPTIONAL: Names of custom URL Schemes. e.g. 'app', 'custom'. Array length must be 16. Default is none.</summary>
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.LPWStr, SizeConst = 16)]
internal string[] CustomSchemeNamesWide;
///<summary>OPTIONAL: Names of custom URL Schemes. e.g. 'app', 'custom'. Array length must be 16. Default is none.</summary>
[MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.LPStr, SizeConst = 16)]
internal string[] CustomSchemeNames;
Expand Down Expand Up @@ -204,9 +169,9 @@ internal List<string> GetParamErrors()
{
var response = new List<string>();
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.");
Expand Down
Loading

0 comments on commit bddecc8

Please sign in to comment.