diff --git a/README.md b/README.md index d2cb1ed..182fc16 100644 --- a/README.md +++ b/README.md @@ -70,3 +70,4 @@ You can also support this project with Liberapay. * [WebView4Delphi](https://github.com/salvadordf/WebView4Delphi) * [WebUI4Delphi](https://github.com/salvadordf/WebUI4Delphi) * [Doxygen](https://github.com/doxygen/doxygen) +* [WebUI.NET](https://github.com/Juff-Ma/WebUI.NET) diff --git a/WebUI4CSharp/WebUI.cs b/WebUI4CSharp/WebUI.cs index f3eda3c..bd47e01 100644 --- a/WebUI4CSharp/WebUI.cs +++ b/WebUI4CSharp/WebUI.cs @@ -11,7 +11,7 @@ public static class WebUI /// /// WebUI library version. /// - public const string WEBUI_VERSION = "2.4.2"; + public const string WEBUI_VERSION = "2.5.0-beta.1"; /// /// Max windows, servers and threads @@ -54,7 +54,7 @@ public static bool SetDefaultRootFolder(string path) } /// - /// Timeout in seconds before the browser starts. 0 means wait forever. + /// Set the maximum time in seconds to wait for the window to connect. This affects `show()` and `wait()`. /// public static void SetTimeout(UIntPtr second) { @@ -211,5 +211,15 @@ public static void CommonBindCallback(ref webui_event_t e) lWindow.DoBindEvent(ref e); } } + + /// + /// Control the WebUI behaviour. It's better to call at the beginning. + /// + /// The desired option from `webui_config` enum. + /// The status of the option, `true` or `false`. + public static void SetConfig(webui_config option, bool status) + { + WebUILibFunctions.webui_set_config((UIntPtr) option, status); + } } } diff --git a/WebUI4CSharp/WebUIBase64.cs b/WebUI4CSharp/WebUIBase64.cs index dfffe47..5b24b4a 100644 --- a/WebUI4CSharp/WebUIBase64.cs +++ b/WebUI4CSharp/WebUIBase64.cs @@ -6,17 +6,17 @@ public static class WebUIBase64 { /// - /// Base64 encoding. Use this to safely send text based data to the UI. If it fails it will return an empty string. + /// Encode text to Base64. /// /// The string to encode. - /// Returns a encoded string. + /// Returns the base64 encoded string. public static string Encode(string str) { return WebUILibFunctions.webui_encode(str); } /// - /// Base64 decoding. Use this to safely decode received Base64 text from the UI. If it fails it will return an empty string. + /// Decode a Base64 encoded text. /// /// The string to decode. - /// Returns a decoded string. + /// Returns the base64 decoded string. public static string Decode(string str) { return WebUILibFunctions.webui_decode(str); } } } diff --git a/WebUI4CSharp/WebUIEvent.cs b/WebUI4CSharp/WebUIEvent.cs index 89f24a8..dd8ae48 100644 --- a/WebUI4CSharp/WebUIEvent.cs +++ b/WebUI4CSharp/WebUIEvent.cs @@ -51,7 +51,7 @@ public WebUIEvent(UIntPtr window, UIntPtr event_type, IntPtr element, UIntPtr ev /// /// Event type. /// - public webui_events EventType { get => (webui_events)_event.event_type; } + public webui_event EventType { get => (webui_event)_event.event_type; } /// /// HTML element ID. @@ -101,6 +101,39 @@ public long GetIntAt(UIntPtr index) } } + /// + /// Get the first argument as float. + /// + /// Returns argument as float. + public double GetFloat() + { + if (Initialized) + { + return WebUILibFunctions.webui_get_float(ref _event); + } + else + { + return 0; + } + } + + /// + /// Get an argument as float at a specific index. + /// + /// The argument position starting from 0. + /// Returns argument as float. + public double GetFloatAt(UIntPtr index) + { + if (Initialized) + { + return WebUILibFunctions.webui_get_float_at(ref _event, index); + } + else + { + return 0; + } + } + /// /// Get the first argument as string. /// @@ -235,6 +268,22 @@ public UIntPtr GetSizeAt(UIntPtr index) } } + /// + /// Get how many arguments there are in an event. + /// + /// Returns the arguments count. + public UIntPtr GetCount() + { + if (Initialized) + { + return WebUILibFunctions.webui_get_count(ref _event); + } + else + { + return 0; + } + } + /// /// Return the response to JavaScript as integer. /// @@ -247,6 +296,18 @@ public void ReturnInt(long value) } } + /// + /// Return the response to JavaScript as float. + /// + /// The float number to be send to JavaScript. + public void ReturnFloat(double value) + { + if (Initialized) + { + WebUILibFunctions.webui_return_float(ref _event, value); + } + } + /// /// Return the response to JavaScript as string. /// diff --git a/WebUI4CSharp/WebUILibFunctions.cs b/WebUI4CSharp/WebUILibFunctions.cs index 2309a9e..2d47d52 100644 --- a/WebUI4CSharp/WebUILibFunctions.cs +++ b/WebUI4CSharp/WebUILibFunctions.cs @@ -12,10 +12,10 @@ public static class WebUILibFunctions // The demos define the WEBUIDEMO conditional for convenience // Enable the right library depending on the selected platform target in each demo private const string _LibName = "..\\..\\..\\..\\..\\WebUI_binaries\\64bits\\webui-2.dll"; // Any CPU - //private const string _LibName = "..\\..\\..\\..\\..\\..\\WebUI_binaries\\64bits\\webui-2.dll"; // x64 - //private const string _LibName = "..\\..\\..\\..\\..\\..\\WebUI_binaries\\64bits\\webui-2_debug.dll"; // x64 (verbose logging) - //private const string _LibName = "..\\..\\..\\..\\..\\..\\WebUI_binaries\\32bits\\webui-2.dll"; // x32 - //private const string _LibName = "..\\..\\..\\..\\..\\..\\WebUI_binaries\\32bits\\webui-2_debug.dll"; // x32 (verbose logging) + //private const string _LibName = "..\\..\\..\\..\\..\\..\\WebUI_binaries\\64bits\\webui-2.dll"; // x64 + //private const string _LibName = "..\\..\\..\\..\\..\\..\\WebUI_binaries\\64bits\\webui-2_debug.dll"; // x64 (verbose logging) + //private const string _LibName = "..\\..\\..\\..\\..\\..\\WebUI_binaries\\32bits\\webui-2.dll"; // x32 + //private const string _LibName = "..\\..\\..\\..\\..\\..\\WebUI_binaries\\32bits\\webui-2_debug.dll"; // x32 (verbose logging) #else private const string _LibName = "webui-2"; #endif @@ -34,7 +34,7 @@ public static class WebUILibFunctions /// Create a new webui window object using a specified window number. /// /// The window number (should be > 0, and < WEBUI_MAX_IDS). - /// Returns the window number. + /// Returns the same window number if success. /// /// WebUI source file: /include/webui.h (webui_new_window_id) /// @@ -64,6 +64,18 @@ public static class WebUILibFunctions [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] public static extern UIntPtr webui_bind(UIntPtr window, [MarshalAs(UnmanagedType.LPUTF8Str)] string element, BindCallback func); + /// + /// Get the recommended web browser ID to use. If you are already using one, + /// this function will return the same ID. + /// + /// The window number. + /// Returns a web browser ID. + /// + /// WebUI source file: /include/webui.h (webui_get_best_browser) + /// + [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UIntPtr webui_get_best_browser(UIntPtr window); + /// /// Show a window using embedded HTML, or a file. If the window is already open, it will be refreshed. /// @@ -91,6 +103,20 @@ public static class WebUILibFunctions [return: MarshalAs(UnmanagedType.I1)] public static extern bool webui_show_browser(UIntPtr window, [MarshalAs(UnmanagedType.LPUTF8Str)] string content, UIntPtr browser); + /// + /// Show a WebView window using embedded HTML, or a file. If the window is already + /// open, it will be refreshed. Note: Win32 need `WebView2Loader.dll`. + /// + /// The window number. + /// The HTML, URL, Or a local file. + /// Returns True if showing the window is successed. + /// + /// WebUI source file: /include/webui.h (webui_show_wv) + /// + [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + public static extern bool webui_show_wv(UIntPtr window, [MarshalAs(UnmanagedType.LPUTF8Str)] string content); + /// /// Set the window in Kiosk mode (Full screen). /// @@ -189,7 +215,7 @@ public static class WebUILibFunctions public static extern bool webui_is_shown(UIntPtr window); /// - /// Set the maximum time in seconds to wait for the browser to start. + /// Set the maximum time in seconds to wait for the window to connect. This affects `show()` and `wait()`. /// /// The timeout in seconds. /// @@ -211,10 +237,10 @@ public static class WebUILibFunctions public static extern void webui_set_icon(UIntPtr window, [MarshalAs(UnmanagedType.LPUTF8Str)] string icon, [MarshalAs(UnmanagedType.LPUTF8Str)] string icon_type); /// - /// Base64 encoding. Use this to safely send text based data to the UI. If it fails it will return NULL. + /// Encode text to Base64. The returned buffer need to be freed. /// /// The string to encode (Should be null terminated). - /// Returns a encoded string. + /// Returns the base64 encoded string. /// /// WebUI source file: /include/webui.h (webui_encode) /// @@ -223,10 +249,10 @@ public static class WebUILibFunctions public static extern string webui_encode([MarshalAs(UnmanagedType.LPUTF8Str)] string str); /// - /// Base64 decoding. Use this to safely decode received Base64 text from the UI. If it fails it will return NULL. + /// Decode a Base64 encoded text. The returned buffer need to be freed. /// /// The string to decode (Should be null terminated). - /// Returns a decoded string. + /// Returns the base64 decoded string. /// /// WebUI source file: /include/webui.h (webui_decode) /// @@ -316,10 +342,10 @@ public static class WebUILibFunctions public static extern void webui_set_profile(UIntPtr window, [MarshalAs(UnmanagedType.LPUTF8Str)] string name, [MarshalAs(UnmanagedType.LPUTF8Str)] string path); /// - /// Set the web browser proxy_server to use. Need to be called before 'webui_show()'. + /// Set the web browser proxy server to use. Need to be called before `webui_show()`. /// /// The window number. - /// The web browser proxy_server. For example 'http://127.0.0.1:8888' + /// The web browser proxy_server. /// /// WebUI source file: /include/webui.h (webui_set_proxy) /// @@ -412,7 +438,7 @@ public static class WebUILibFunctions public static extern UIntPtr webui_get_child_process_id(UIntPtr window); /// - /// Set a custom web-server network port to be used by WebUI. + /// Set a custom web-server/websocket network port to be used by WebUI. /// This can be useful to determine the HTTP link of `webui.js` in case /// you are trying to use WebUI with an external web-server like NGNIX /// @@ -426,6 +452,31 @@ public static class WebUILibFunctions [return: MarshalAs(UnmanagedType.I1)] public static extern bool webui_set_port(UIntPtr window, UIntPtr port); + /// + /// Control the WebUI behaviour. It's better to call at the beginning. + /// + /// The desired option from `webui_config` enum. + /// The status of the option, `true` or `false`. + /// + /// WebUI source file: /include/webui.h (webui_set_config) + /// + [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void webui_set_config(UIntPtr option, [MarshalAs(UnmanagedType.I1)] bool status); + + /// + /// Control if UI events comming from this window should be processed + /// one a time in a single blocking thread `True`, or process every event in + /// a new non-blocking thread `False`. This update single window. You can use + /// `webui_set_config(ui_event_blocking, ...)` to update all windows. + /// + /// The window number. + /// The blocking status `true` or `false`. + /// + /// WebUI source file: /include/webui.h (webui_set_event_blocking) + /// + [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void webui_set_event_blocking(UIntPtr window, [MarshalAs(UnmanagedType.I1)] bool status); + /// /// Set the SSL/TLS certificate and the private key content, both in PEM /// format. This works only with `webui-2-secure` library. If set empty WebUI @@ -473,13 +524,24 @@ public static class WebUILibFunctions /// Chose between Deno and Nodejs as runtime for .js and .ts files. /// /// The window number. - /// Deno or Nodejs. + /// Deno, Nodejs or None. /// /// WebUI source file: /include/webui.h (webui_set_runtime) /// [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] public static extern void webui_set_runtime(UIntPtr window, UIntPtr runtime); + /// + /// Get how many arguments there are in an event. + /// + /// The event struct. + /// Returns the arguments count. + /// + /// WebUI source file: /include/webui.h (webui_get_count) + /// + [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] + public static extern UIntPtr webui_get_count(ref webui_event_t e); + /// /// Get an argument as integer at a specific index. /// @@ -503,6 +565,29 @@ public static class WebUILibFunctions [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] public static extern long webui_get_int(ref webui_event_t e); + /// + /// Get an argument as float at a specific index. + /// + /// The event struct. + /// The argument position starting from 0. + /// Returns argument as float. + /// + /// WebUI source file: /include/webui.h (webui_get_float_at) + /// + [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] + public static extern double webui_get_float_at(ref webui_event_t e, UIntPtr index); + + /// + /// Get the first argument as float. + /// + /// The event struct. + /// Returns argument as float. + /// + /// WebUI source file: /include/webui.h (webui_get_float) + /// + [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] + public static extern double webui_get_float(ref webui_event_t e); + /// /// Get an argument as string at a specific index. /// @@ -585,6 +670,17 @@ public static class WebUILibFunctions [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] public static extern void webui_return_int(ref webui_event_t e, long n); + /// + /// Return the response to JavaScript as float. + /// + /// The event struct. + /// The float number to be send to JavaScript. + /// + /// WebUI source file: /include/webui.h (webui_return_float) + /// + [DllImport(_LibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void webui_return_float(ref webui_event_t e, double f); + /// /// Return the response to JavaScript as string. /// diff --git a/WebUI4CSharp/WebUITypes.cs b/WebUI4CSharp/WebUITypes.cs index 6d9b4ff..229dccb 100644 --- a/WebUI4CSharp/WebUITypes.cs +++ b/WebUI4CSharp/WebUITypes.cs @@ -5,7 +5,7 @@ namespace WebUI4CSharp /// /// Supported web browsers /// - public enum webui_browsers + public enum webui_browser { NoBrowser = 0, // 0. No web browser AnyBrowser = 1, // 1. Default recommended web browser @@ -25,7 +25,7 @@ public enum webui_browsers /// /// Supported runtimes /// - public enum webui_runtimes + public enum webui_runtime { /// /// Prevent WebUI from using any runtime for .js and .ts files. @@ -44,7 +44,7 @@ public enum webui_runtimes /// /// WebUI event types /// - public enum webui_events + public enum webui_event { /// /// Window disconnection event. @@ -68,6 +68,27 @@ public enum webui_events WEBUI_EVENT_CALLBACK, }; + /// + /// WebUI configuration. + /// + public enum webui_config + { + /// + /// Control if `webui_show()`, `webui_show_browser()` and + /// `webui_show_wv()` should wait for the window to connect + /// before returns or not. Default: True. + /// + show_wait_connection = 0, + /// + /// Control if WebUI should block and process the UI events + /// one a time in a single thread `True`, or process every + /// event in a new non-blocking thread `False`. This updates + /// all windows. You can use `webui_set_event_blocking()` for + /// a specific single window update. Default: False. + /// + ui_event_blocking, + } + /// /// Structure with event information /// diff --git a/WebUI4CSharp/WebUIWindow.cs b/WebUI4CSharp/WebUIWindow.cs index c8411a2..76a6884 100644 --- a/WebUI4CSharp/WebUIWindow.cs +++ b/WebUI4CSharp/WebUIWindow.cs @@ -132,6 +132,25 @@ public UIntPtr ChildProcessId } } + /// + /// Get the recommended web browser ID to use. If you are already using one, + /// this function will return the same ID. + /// + public webui_browser BestBrowser + { + get + { + if (Initialized) + { + return (webui_browser)WebUILibFunctions.webui_get_best_browser(_id); + } + else + { + return webui_browser.NoBrowser; + } + } + } + /// /// Event triggered after binding a webui event. /// @@ -234,11 +253,22 @@ public bool Show(string content) /// The HTML, URL, Or a local file. /// The web browser to be used. /// Returns True if showing the window is successed. - public bool ShowBrowser(string content, webui_browsers browser) + public bool ShowBrowser(string content, webui_browser browser) { return Initialized && WebUILibFunctions.webui_show_browser(_id, content, (UIntPtr)browser); } + /// + /// Show a WebView window using embedded HTML, or a file. If the window is already + /// open, it will be refreshed. Note: Win32 need `WebView2Loader.dll`. + /// + /// The HTML, URL, Or a local file. + /// Returns True if showing the window is successed. + public bool ShowWV(string content) + { + return Initialized && WebUILibFunctions.webui_show_wv(_id, content); + } + /// /// Bind a specific html element click event with a callback function. Empty element means all events. /// @@ -476,7 +506,7 @@ public void SetProfile(string name, string path) } /// - /// Set the web browser proxy_server to use. Need to be called before 'webui_show()'. + /// Set the web browser proxy server to use. Need to be called before `webui_show()`. /// /// The web browser proxy_server. For example 'http://127.0.0.1:8888' public void SetProxy(string proxy_server) @@ -523,7 +553,7 @@ public void DeleteProfile() } /// - /// Set a custom web-server network port to be used by WebUI. + /// Set a custom web-server/websocket network port to be used by WebUI. /// This can be useful to determine the HTTP link of `webui.js` in case /// you are trying to use WebUI with an external web-server like NGNIX /// @@ -534,6 +564,21 @@ public bool SetPort(UIntPtr port) return Initialized && WebUILibFunctions.webui_set_port(_id, port); } + /// + /// Control if UI events comming from this window should be processed + /// one a time in a single blocking thread `True`, or process every event in + /// a new non-blocking thread `False`. This update single window. You can use + /// WebUI.SetConfig(ui_event_blocking, ...)` to update all windows. + /// + /// The blocking status `true` or `false`. + public void SetEventBlocking(bool status) + { + if (Initialized) + { + WebUILibFunctions.webui_set_event_blocking(_id, status); + } + } + /// /// Run JavaScript without waiting for the response. /// @@ -582,8 +627,8 @@ public bool Script(string script_, UIntPtr timeout, out string response, UIntPtr /// /// Chose between Deno and Nodejs as runtime for .js and .ts files. /// - /// Deno or Nodejs. - public void SetRuntime(webui_runtimes runtime) + /// Deno, Nodejs or None. + public void SetRuntime(webui_runtime runtime) { if (Initialized) { diff --git a/WebUI_binaries/32bits/webui-2.dll b/WebUI_binaries/32bits/webui-2.dll index 13eeac8..f3e5d9a 100644 Binary files a/WebUI_binaries/32bits/webui-2.dll and b/WebUI_binaries/32bits/webui-2.dll differ diff --git a/WebUI_binaries/32bits/webui-2_debug.dll b/WebUI_binaries/32bits/webui-2_debug.dll index a2139bb..09935da 100644 Binary files a/WebUI_binaries/32bits/webui-2_debug.dll and b/WebUI_binaries/32bits/webui-2_debug.dll differ diff --git a/WebUI_binaries/64bits/webui-2.dll b/WebUI_binaries/64bits/webui-2.dll index f5cfc58..ffd9a4c 100644 Binary files a/WebUI_binaries/64bits/webui-2.dll and b/WebUI_binaries/64bits/webui-2.dll differ diff --git a/WebUI_binaries/64bits/webui-2_debug.dll b/WebUI_binaries/64bits/webui-2_debug.dll index c8ef368..30df621 100644 Binary files a/WebUI_binaries/64bits/webui-2_debug.dll and b/WebUI_binaries/64bits/webui-2_debug.dll differ diff --git a/assets/serve_a_folder/index.html b/assets/serve_a_folder/index.html index 4b16b23..54d406b 100644 --- a/assets/serve_a_folder/index.html +++ b/assets/serve_a_folder/index.html @@ -79,12 +79,9 @@

Static file example (Embedded)

Dynamic file example (Embedded)

Unicode Test:

- مرحبًا
- - 你好
- - こんにちは - + مرحبًا
+ 你好
+ こんにちは

@@ -94,8 +91,8 @@

Dynamic file example (Embedded)

diff --git a/assets/text_editor/css/all.min.css b/assets/text_editor/css/all.min.css index 1f367c1..164a7f9 100644 --- a/assets/text_editor/css/all.min.css +++ b/assets/text_editor/css/all.min.css @@ -1,7 +1,7 @@ /*! * Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) - * Copyright 2023 Fonticons, Inc. + * Copyright 2024 Fonticons, Inc. */ .fa{font-family:var(--fa-style-family,"Font Awesome 6 Free");font-weight:var(--fa-style,900)}.fa,.fa-brands,.fa-classic,.fa-regular,.fa-sharp,.fa-solid,.fab,.far,.fas{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:var(--fa-display,inline-block);font-style:normal;font-variant:normal;line-height:1;text-rendering:auto}.fa-classic,.fa-regular,.fa-solid,.far,.fas{font-family:"Font Awesome 6 Free"}.fa-brands,.fab{font-family:"Font Awesome 6 Brands"}.fa-1x{font-size:1em}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-6x{font-size:6em}.fa-7x{font-size:7em}.fa-8x{font-size:8em}.fa-9x{font-size:9em}.fa-10x{font-size:10em}.fa-2xs{font-size:.625em;line-height:.1em;vertical-align:.225em}.fa-xs{font-size:.75em;line-height:.08333em;vertical-align:.125em}.fa-sm{font-size:.875em;line-height:.07143em;vertical-align:.05357em}.fa-lg{font-size:1.25em;line-height:.05em;vertical-align:-.075em}.fa-xl{font-size:1.5em;line-height:.04167em;vertical-align:-.125em}.fa-2xl{font-size:2em;line-height:.03125em;vertical-align:-.1875em}.fa-fw{text-align:center;width:1.25em}.fa-ul{list-style-type:none;margin-left:var(--fa-li-margin,2.5em);padding-left:0}.fa-ul>li{position:relative}.fa-li{left:calc(var(--fa-li-width, 2em)*-1);position:absolute;text-align:center;width:var(--fa-li-width,2em);line-height:inherit}.fa-border{border-radius:var(--fa-border-radius,.1em);border:var(--fa-border-width,.08em) var(--fa-border-style,solid) var(--fa-border-color,#eee);padding:var(--fa-border-padding,.2em .25em .15em)}.fa-pull-left{float:left;margin-right:var(--fa-pull-margin,.3em)}.fa-pull-right{float:right;margin-left:var(--fa-pull-margin,.3em)}.fa-beat{-webkit-animation-name:fa-beat;animation-name:fa-beat;-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,ease-in-out);animation-timing-function:var(--fa-animation-timing,ease-in-out)}.fa-bounce{-webkit-animation-name:fa-bounce;animation-name:fa-bounce;-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,cubic-bezier(.28,.84,.42,1));animation-timing-function:var(--fa-animation-timing,cubic-bezier(.28,.84,.42,1))}.fa-fade{-webkit-animation-name:fa-fade;animation-name:fa-fade;-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1));animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1))}.fa-beat-fade,.fa-fade{-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s)}.fa-beat-fade{-webkit-animation-name:fa-beat-fade;animation-name:fa-beat-fade;-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1));animation-timing-function:var(--fa-animation-timing,cubic-bezier(.4,0,.6,1))}.fa-flip{-webkit-animation-name:fa-flip;animation-name:fa-flip;-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,ease-in-out);animation-timing-function:var(--fa-animation-timing,ease-in-out)}.fa-shake{-webkit-animation-name:fa-shake;animation-name:fa-shake;-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,linear);animation-timing-function:var(--fa-animation-timing,linear)}.fa-shake,.fa-spin{-webkit-animation-delay:var(--fa-animation-delay,0s);animation-delay:var(--fa-animation-delay,0s);-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal)}.fa-spin{-webkit-animation-name:fa-spin;animation-name:fa-spin;-webkit-animation-duration:var(--fa-animation-duration,2s);animation-duration:var(--fa-animation-duration,2s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,linear);animation-timing-function:var(--fa-animation-timing,linear)}.fa-spin-reverse{--fa-animation-direction:reverse}.fa-pulse,.fa-spin-pulse{-webkit-animation-name:fa-spin;animation-name:fa-spin;-webkit-animation-direction:var(--fa-animation-direction,normal);animation-direction:var(--fa-animation-direction,normal);-webkit-animation-duration:var(--fa-animation-duration,1s);animation-duration:var(--fa-animation-duration,1s);-webkit-animation-iteration-count:var(--fa-animation-iteration-count,infinite);animation-iteration-count:var(--fa-animation-iteration-count,infinite);-webkit-animation-timing-function:var(--fa-animation-timing,steps(8));animation-timing-function:var(--fa-animation-timing,steps(8))}@media (prefers-reduced-motion:reduce){.fa-beat,.fa-beat-fade,.fa-bounce,.fa-fade,.fa-flip,.fa-pulse,.fa-shake,.fa-spin,.fa-spin-pulse{-webkit-animation-delay:-1ms;animation-delay:-1ms;-webkit-animation-duration:1ms;animation-duration:1ms;-webkit-animation-iteration-count:1;animation-iteration-count:1;-webkit-transition-delay:0s;transition-delay:0s;-webkit-transition-duration:0s;transition-duration:0s}}@-webkit-keyframes fa-beat{0%,90%{-webkit-transform:scale(1);transform:scale(1)}45%{-webkit-transform:scale(var(--fa-beat-scale,1.25));transform:scale(var(--fa-beat-scale,1.25))}}@keyframes fa-beat{0%,90%{-webkit-transform:scale(1);transform:scale(1)}45%{-webkit-transform:scale(var(--fa-beat-scale,1.25));transform:scale(var(--fa-beat-scale,1.25))}}@-webkit-keyframes fa-bounce{0%{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}10%{-webkit-transform:scale(var(--fa-bounce-start-scale-x,1.1),var(--fa-bounce-start-scale-y,.9)) translateY(0);transform:scale(var(--fa-bounce-start-scale-x,1.1),var(--fa-bounce-start-scale-y,.9)) translateY(0)}30%{-webkit-transform:scale(var(--fa-bounce-jump-scale-x,.9),var(--fa-bounce-jump-scale-y,1.1)) translateY(var(--fa-bounce-height,-.5em));transform:scale(var(--fa-bounce-jump-scale-x,.9),var(--fa-bounce-jump-scale-y,1.1)) translateY(var(--fa-bounce-height,-.5em))}50%{-webkit-transform:scale(var(--fa-bounce-land-scale-x,1.05),var(--fa-bounce-land-scale-y,.95)) translateY(0);transform:scale(var(--fa-bounce-land-scale-x,1.05),var(--fa-bounce-land-scale-y,.95)) translateY(0)}57%{-webkit-transform:scale(1) translateY(var(--fa-bounce-rebound,-.125em));transform:scale(1) translateY(var(--fa-bounce-rebound,-.125em))}64%{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}to{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}}@keyframes fa-bounce{0%{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}10%{-webkit-transform:scale(var(--fa-bounce-start-scale-x,1.1),var(--fa-bounce-start-scale-y,.9)) translateY(0);transform:scale(var(--fa-bounce-start-scale-x,1.1),var(--fa-bounce-start-scale-y,.9)) translateY(0)}30%{-webkit-transform:scale(var(--fa-bounce-jump-scale-x,.9),var(--fa-bounce-jump-scale-y,1.1)) translateY(var(--fa-bounce-height,-.5em));transform:scale(var(--fa-bounce-jump-scale-x,.9),var(--fa-bounce-jump-scale-y,1.1)) translateY(var(--fa-bounce-height,-.5em))}50%{-webkit-transform:scale(var(--fa-bounce-land-scale-x,1.05),var(--fa-bounce-land-scale-y,.95)) translateY(0);transform:scale(var(--fa-bounce-land-scale-x,1.05),var(--fa-bounce-land-scale-y,.95)) translateY(0)}57%{-webkit-transform:scale(1) translateY(var(--fa-bounce-rebound,-.125em));transform:scale(1) translateY(var(--fa-bounce-rebound,-.125em))}64%{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}to{-webkit-transform:scale(1) translateY(0);transform:scale(1) translateY(0)}}@-webkit-keyframes fa-fade{50%{opacity:var(--fa-fade-opacity,.4)}}@keyframes fa-fade{50%{opacity:var(--fa-fade-opacity,.4)}}@-webkit-keyframes fa-beat-fade{0%,to{opacity:var(--fa-beat-fade-opacity,.4);-webkit-transform:scale(1);transform:scale(1)}50%{opacity:1;-webkit-transform:scale(var(--fa-beat-fade-scale,1.125));transform:scale(var(--fa-beat-fade-scale,1.125))}}@keyframes fa-beat-fade{0%,to{opacity:var(--fa-beat-fade-opacity,.4);-webkit-transform:scale(1);transform:scale(1)}50%{opacity:1;-webkit-transform:scale(var(--fa-beat-fade-scale,1.125));transform:scale(var(--fa-beat-fade-scale,1.125))}}@-webkit-keyframes fa-flip{50%{-webkit-transform:rotate3d(var(--fa-flip-x,0),var(--fa-flip-y,1),var(--fa-flip-z,0),var(--fa-flip-angle,-180deg));transform:rotate3d(var(--fa-flip-x,0),var(--fa-flip-y,1),var(--fa-flip-z,0),var(--fa-flip-angle,-180deg))}}@keyframes fa-flip{50%{-webkit-transform:rotate3d(var(--fa-flip-x,0),var(--fa-flip-y,1),var(--fa-flip-z,0),var(--fa-flip-angle,-180deg));transform:rotate3d(var(--fa-flip-x,0),var(--fa-flip-y,1),var(--fa-flip-z,0),var(--fa-flip-angle,-180deg))}}@-webkit-keyframes fa-shake{0%{-webkit-transform:rotate(-15deg);transform:rotate(-15deg)}4%{-webkit-transform:rotate(15deg);transform:rotate(15deg)}8%,24%{-webkit-transform:rotate(-18deg);transform:rotate(-18deg)}12%,28%{-webkit-transform:rotate(18deg);transform:rotate(18deg)}16%{-webkit-transform:rotate(-22deg);transform:rotate(-22deg)}20%{-webkit-transform:rotate(22deg);transform:rotate(22deg)}32%{-webkit-transform:rotate(-12deg);transform:rotate(-12deg)}36%{-webkit-transform:rotate(12deg);transform:rotate(12deg)}40%,to{-webkit-transform:rotate(0deg);transform:rotate(0deg)}}@keyframes fa-shake{0%{-webkit-transform:rotate(-15deg);transform:rotate(-15deg)}4%{-webkit-transform:rotate(15deg);transform:rotate(15deg)}8%,24%{-webkit-transform:rotate(-18deg);transform:rotate(-18deg)}12%,28%{-webkit-transform:rotate(18deg);transform:rotate(18deg)}16%{-webkit-transform:rotate(-22deg);transform:rotate(-22deg)}20%{-webkit-transform:rotate(22deg);transform:rotate(22deg)}32%{-webkit-transform:rotate(-12deg);transform:rotate(-12deg)}36%{-webkit-transform:rotate(12deg);transform:rotate(12deg)}40%,to{-webkit-transform:rotate(0deg);transform:rotate(0deg)}}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}.fa-rotate-90{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-webkit-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-webkit-transform:scaleX(-1);transform:scaleX(-1)}.fa-flip-vertical{-webkit-transform:scaleY(-1);transform:scaleY(-1)}.fa-flip-both,.fa-flip-horizontal.fa-flip-vertical{-webkit-transform:scale(-1);transform:scale(-1)}.fa-rotate-by{-webkit-transform:rotate(var(--fa-rotate-angle,none));transform:rotate(var(--fa-rotate-angle,none))}.fa-stack{display:inline-block;height:2em;line-height:2em;position:relative;vertical-align:middle;width:2.5em}.fa-stack-1x,.fa-stack-2x{left:0;position:absolute;text-align:center;width:100%;z-index:var(--fa-stack-z-index,auto)}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:var(--fa-inverse,#fff)} diff --git a/assets/text_editor/index.html b/assets/text_editor/index.html index 5ea4167..ee547d4 100644 --- a/assets/text_editor/index.html +++ b/assets/text_editor/index.html @@ -16,7 +16,7 @@
@@ -27,7 +27,7 @@

WebUI Text Editor

v1.1

Example of a text editor software in C using WebUI library.

-

webui.me | (C)2023 Hassan Draga

+

webui.me | (C)2024 Hassan Draga

diff --git a/demos/console_call_csharp_from_js/console_call_csharp_from_js.cs b/demos/console_call_csharp_from_js/console_call_csharp_from_js.cs index d7fc3aa..e465559 100644 --- a/demos/console_call_csharp_from_js/console_call_csharp_from_js.cs +++ b/demos/console_call_csharp_from_js/console_call_csharp_from_js.cs @@ -38,13 +38,13 @@ " " + "

WebUI - Call C from JavaScript

" + "

Call C functions with arguments (See the logs in your terminal)

" + - " " + + " " + "
" + - " " + + " " + "
" + - " " + + " " + "
" + - " " + "
" + "

Call a C function that returns a response

" + @@ -58,7 +58,7 @@ " function MyJS() {" + " const MyInput = document.getElementById('MyInputID');" + " const number = MyInput.value;" + - " webui.call('MyID_Four', number, 2).then((response) => {" + + " my_function_with_response(number, 2).then((response) => {" + " MyInput.value = response;" + " });" + " }" + @@ -67,11 +67,11 @@ ""; WebUIWindow window = new WebUIWindow(); -window.Bind("MyID_One", WebUI_Events.my_function_string); -window.Bind("MyID_Two", WebUI_Events.my_function_integer); -window.Bind("MyID_Three", WebUI_Events.my_function_boolean); -window.Bind("MyID_Four", WebUI_Events.my_function_with_response); -window.Bind("MyID_RawBinary", WebUI_Events.my_function_raw_binary); +window.Bind("my_function_string", WebUI_Events.my_function_string); +window.Bind("my_function_integer", WebUI_Events.my_function_integer); +window.Bind("my_function_boolean", WebUI_Events.my_function_boolean); +window.Bind("my_function_with_response", WebUI_Events.my_function_with_response); +window.Bind("my_function_raw_binary", WebUI_Events.my_function_raw_binary); window.Show(my_html); WebUI.Wait(); WebUI.Clean(); diff --git a/demos/console_call_csharp_from_js/console_call_csharp_from_js_events.cs b/demos/console_call_csharp_from_js/console_call_csharp_from_js_events.cs index 467faa4..b593c4d 100644 --- a/demos/console_call_csharp_from_js/console_call_csharp_from_js_events.cs +++ b/demos/console_call_csharp_from_js/console_call_csharp_from_js_events.cs @@ -7,7 +7,7 @@ public static class WebUI_Events public static void my_function_string(ref webui_event_t e) { // JavaScript: - // webui.call('MyID_One', 'Hello', 'World`); + // my_function_string('Hello', 'World`); WebUIEvent lEvent = new WebUIEvent(e); string? str_1 = lEvent.GetString(); @@ -20,25 +20,29 @@ public static void my_function_string(ref webui_event_t e) public static void my_function_integer(ref webui_event_t e) { - // JavaScript: - // webui.call('MyID_Two', 123, 456, 789); + // my_function_integer(123, 456, 789, 12345.6789); WebUIEvent lEvent = new WebUIEvent(e); + + UIntPtr count = lEvent.GetCount(); + Console.WriteLine("my_function_integer: There are {0} arguments in this event", count); // 4 + long number_1 = lEvent.GetInt(); long number_2 = lEvent.GetIntAt(1); long number_3 = lEvent.GetIntAt(2); + double float_1 = lEvent.GetFloatAt(3); Console.WriteLine("my_function_integer 1: {0}", number_1); // 123 Console.WriteLine("my_function_integer 2: {0}", number_2); // 456 Console.WriteLine("my_function_integer 3: {0}", number_3); // 789 + Console.WriteLine("my_function_integer 4: {0}", float_1); // 12345.6789 } public static void my_function_boolean(ref webui_event_t e) { - // JavaScript: - // webui.call('MyID_Three', true, false); + // my_function_boolean(true, false); WebUIEvent lEvent = new WebUIEvent(e); bool status_1 = lEvent.GetBool(); @@ -50,9 +54,8 @@ public static void my_function_boolean(ref webui_event_t e) public static void my_function_raw_binary(ref webui_event_t e) { - // JavaScript: - // webui.call('MyID_RawBinary', new Uint8Array([0x41,0x42,0x43]), big_arr); + // my_function_raw_binary(new Uint8Array([0x41]), new Uint8Array([0x42, 0x43])); WebUIEvent lEvent = new WebUIEvent(e); MemoryStream? stream = lEvent.GetStream(); @@ -65,9 +68,8 @@ public static void my_function_raw_binary(ref webui_event_t e) public static void my_function_with_response(ref webui_event_t e) { - // JavaScript: - // webui.call('MyID_Four', number, 2).then(...) + // my_function_with_response(number, 2).then(...) WebUIEvent lEvent = new WebUIEvent(e); long number = lEvent.GetInt(); diff --git a/demos/console_call_js_from_csharp/console_call_js_from_csharp.cs b/demos/console_call_js_from_csharp/console_call_js_from_csharp.cs index ec85942..5489727 100644 --- a/demos/console_call_js_from_csharp/console_call_js_from_csharp.cs +++ b/demos/console_call_js_from_csharp/console_call_js_from_csharp.cs @@ -39,11 +39,11 @@ "
" + "

0

" + "
" + - " " + + " " + "
" + " " + "
" + - " " + + " " + " " + " " + ""; WebUIWindow window = new WebUIWindow(); -window.Bind("MyButton1", WebUI_Events.my_function_count); -window.Bind("MyButton2", WebUI_Events.my_function_exit); +window.Bind("my_function_count", WebUI_Events.my_function_count); +window.Bind("my_function_exit", WebUI_Events.my_function_exit); window.Show(my_html); WebUI.Wait(); WebUI.Clean(); \ No newline at end of file diff --git a/demos/console_call_js_from_csharp/console_call_js_from_csharp_events.cs b/demos/console_call_js_from_csharp/console_call_js_from_csharp_events.cs index 22be78a..33d248d 100644 --- a/demos/console_call_js_from_csharp/console_call_js_from_csharp_events.cs +++ b/demos/console_call_js_from_csharp/console_call_js_from_csharp_events.cs @@ -12,7 +12,7 @@ public static void my_function_exit(ref webui_event_t e) public static void my_function_count(ref webui_event_t e) { - // This function gets called every time the user clicks on "MyButton1" + // This function gets called every time the user clicks on "my_function_count" WebUIEvent lEvent = new WebUIEvent(e); WebUIWindow? window = lEvent.Window; diff --git a/demos/console_custom_web_server/console_custom_web_server.cs b/demos/console_custom_web_server/console_custom_web_server.cs index b4bd01f..16735a7 100644 --- a/demos/console_custom_web_server/console_custom_web_server.cs +++ b/demos/console_custom_web_server/console_custom_web_server.cs @@ -9,9 +9,9 @@ // Bind HTML elements with C functions window.Bind("my_backend_func", WebUI_Events.my_backend_func); -// Set web server network port WebUI should use -// this mean `webui.js` will be available at: -// http://localhost:8081/webui.js +// Set the web-server/WebSocket port that WebUI should +// use. This means `webui.js` will be available at: +// http://localhost:MY_PORT_NUMBER/webui.js window.SetPort(8081); // Show a new window and show our custom web server diff --git a/demos/console_custom_web_server/console_custom_web_server_events.cs b/demos/console_custom_web_server/console_custom_web_server_events.cs index eeab488..473140d 100644 --- a/demos/console_custom_web_server/console_custom_web_server_events.cs +++ b/demos/console_custom_web_server/console_custom_web_server_events.cs @@ -11,19 +11,19 @@ public static void events(ref webui_event_t e) WebUIEvent lEvent = new WebUIEvent(e); switch (lEvent.EventType) { - case webui_events.WEBUI_EVENT_CONNECTED: + case webui_event.WEBUI_EVENT_CONNECTED: Console.WriteLine("connected."); break; - case webui_events.WEBUI_EVENT_DISCONNECTED: + case webui_event.WEBUI_EVENT_DISCONNECTED: Console.WriteLine("disconnected."); break; - case webui_events.WEBUI_EVENT_MOUSE_CLICK: + case webui_event.WEBUI_EVENT_MOUSE_CLICK: Console.WriteLine("click."); break; - case webui_events.WEBUI_EVENT_NAVIGATION: + case webui_event.WEBUI_EVENT_NAVIGATION: string? lUrl = lEvent.GetString(); string navmessage = $"Navigating to {lUrl}"; Console.WriteLine(navmessage); diff --git a/demos/console_public_network_access/console_public_network_access.cs b/demos/console_public_network_access/console_public_network_access.cs index ad809a2..dea8a65 100644 --- a/demos/console_public_network_access/console_public_network_access.cs +++ b/demos/console_public_network_access/console_public_network_access.cs @@ -69,7 +69,7 @@ // Public Window WebUI_Events.pubWindow.SetPublic(true); // Make URL accessible from public networks WebUI_Events.pubWindow.BindAllEvents(WebUI_Events.public_window_events); // Bind all events -WebUI_Events.pubWindow.ShowBrowser(public_html, webui_browsers.NoBrowser); // Set public window HTML +WebUI_Events.pubWindow.ShowBrowser(public_html, webui_browser.NoBrowser); // Set public window HTML string public_win_url = WebUI_Events.pubWindow.Url; // Get URL of public window // Main Private Window diff --git a/demos/console_public_network_access/console_public_network_access_events.cs b/demos/console_public_network_access/console_public_network_access_events.cs index 948d5f3..df84dba 100644 --- a/demos/console_public_network_access/console_public_network_access_events.cs +++ b/demos/console_public_network_access/console_public_network_access_events.cs @@ -10,13 +10,13 @@ public static void public_window_events(ref webui_event_t e) { // This function gets called every time // there is an event - switch ((webui_events)e.event_type) + switch ((webui_event)e.event_type) { - case webui_events.WEBUI_EVENT_CONNECTED: + case webui_event.WEBUI_EVENT_CONNECTED: prvWindow.Run("document.getElementById(\"Logs\").value += \"New connection.\\n\";"); break; - case webui_events.WEBUI_EVENT_DISCONNECTED: + case webui_event.WEBUI_EVENT_DISCONNECTED: prvWindow.Run("document.getElementById(\"Logs\").value += \"Disconnected.\\n\";"); break; } diff --git a/demos/console_serve_a_folder/console_serve_a_folder.cs b/demos/console_serve_a_folder/console_serve_a_folder.cs index 3bf75ad..a17f045 100644 --- a/demos/console_serve_a_folder/console_serve_a_folder.cs +++ b/demos/console_serve_a_folder/console_serve_a_folder.cs @@ -11,7 +11,7 @@ WebUI_Events.myWindow.BindAllEvents(WebUI_Events.events); // Make Deno as the `.ts` and `.js` interpreter -WebUI_Events.myWindow.SetRuntime(webui_runtimes.Deno); +WebUI_Events.myWindow.SetRuntime(webui_runtime.Deno); // Set a custom files handler WebUI_Events.myWindow.SetFileHandler(WebUI_Events.my_files_handler); diff --git a/demos/console_serve_a_folder/console_serve_a_folder_events.cs b/demos/console_serve_a_folder/console_serve_a_folder_events.cs index e41c8d8..e7a08d7 100644 --- a/demos/console_serve_a_folder/console_serve_a_folder_events.cs +++ b/demos/console_serve_a_folder/console_serve_a_folder_events.cs @@ -23,19 +23,19 @@ public static void events(ref webui_event_t e) WebUIEvent lEvent = new WebUIEvent(e); switch (lEvent.EventType) { - case webui_events.WEBUI_EVENT_CONNECTED: + case webui_event.WEBUI_EVENT_CONNECTED: Console.WriteLine("connected."); break; - case webui_events.WEBUI_EVENT_DISCONNECTED: + case webui_event.WEBUI_EVENT_DISCONNECTED: Console.WriteLine("disconnected."); break; - case webui_events.WEBUI_EVENT_MOUSE_CLICK: + case webui_event.WEBUI_EVENT_MOUSE_CLICK: Console.WriteLine("click."); break; - case webui_events.WEBUI_EVENT_NAVIGATION: + case webui_event.WEBUI_EVENT_NAVIGATION: string? lUrl = lEvent.GetString(); string navmessage = $"Navigating to {lUrl}"; Console.WriteLine(navmessage); diff --git a/demos/console_text_editor/console_text_editor.cs b/demos/console_text_editor/console_text_editor.cs index 663db8c..4794b09 100644 --- a/demos/console_text_editor/console_text_editor.cs +++ b/demos/console_text_editor/console_text_editor.cs @@ -9,10 +9,10 @@ window.SetRootFolder(absPath); // Bind HTML elements with the specified ID to C functions -window.Bind("__close-btn", WebUI_Events.Close); +window.Bind("close_app", WebUI_Events.close_app); // Show the window, preferably in a chromium based browser -if (!window.ShowBrowser("index.html", webui_browsers.ChromiumBased)) +if (!window.ShowBrowser("index.html", webui_browser.ChromiumBased)) { window.Show("index.html"); } diff --git a/demos/console_text_editor/console_text_editor_events.cs b/demos/console_text_editor/console_text_editor_events.cs index 38bfbf7..b54ad95 100644 --- a/demos/console_text_editor/console_text_editor_events.cs +++ b/demos/console_text_editor/console_text_editor_events.cs @@ -4,7 +4,7 @@ namespace console_text_editor { public static class WebUI_Events { - public static void Close(ref webui_event_t e) + public static void close_app(ref webui_event_t e) { WebUI.Exit(); } diff --git a/demos/winforms_call_csharp_from_js/MainForm.cs b/demos/winforms_call_csharp_from_js/MainForm.cs index ec685a0..134c5da 100644 --- a/demos/winforms_call_csharp_from_js/MainForm.cs +++ b/demos/winforms_call_csharp_from_js/MainForm.cs @@ -24,36 +24,39 @@ private void AddLog(String msg) public void my_function_string(WebUIEvent e) { // JavaScript: - // webui.call('MyID_One', 'Hello World', '\u{1F3DD}'); + // my_function_string('Hello', 'World`); string? str_1 = e.GetString(); string? str_2 = e.GetStringAt(1); - AddLog($"my_function_string 1: {str_1}"); // Hello World - AddLog($"my_function_string 2: {str_2}"); // Palmtree + AddLog($"my_function_string 1: {str_1}"); // Hello + AddLog($"my_function_string 2: {str_2}"); // World } public void my_function_integer(WebUIEvent e) { - // JavaScript: - // webui.call('MyID_Two', 123, 456, 789); + // my_function_integer(123, 456, 789, 12345.6789); + + UIntPtr count = e.GetCount(); + AddLog($"my_function_integer: There are {count} arguments in this event"); // 4 long number_1 = e.GetInt(); long number_2 = e.GetIntAt(1); long number_3 = e.GetIntAt(2); + double float_1 = e.GetFloatAt(3); AddLog($"my_function_integer 1: {number_1}"); // 123 AddLog($"my_function_integer 2: {number_2}"); // 456 AddLog($"my_function_integer 3: {number_3}"); // 789 + AddLog($"my_function_integer 4: {float_1}"); // 12345.6789 } public void my_function_boolean(WebUIEvent e) { - // JavaScript: - // webui.call('MyID_Three', true, false); + // my_function_boolean(true, false); bool status_1 = e.GetBool(); bool status_2 = e.GetBoolAt(1); @@ -64,9 +67,8 @@ public void my_function_boolean(WebUIEvent e) public void my_function_raw_binary(WebUIEvent e) { - // JavaScript: - // webui.call('MyID_RawBinary', new Uint8Array([0x41,0x42,0x43]), big_arr); + // my_function_raw_binary(new Uint8Array([0x41]), new Uint8Array([0x42, 0x43])); MemoryStream? stream = e.GetStream(); if (stream != null) @@ -78,9 +80,8 @@ public void my_function_raw_binary(WebUIEvent e) public void my_function_with_response(WebUIEvent e) { - // JavaScript: - // webui.call('MyID_Four', number, 2).then(...) + // my_function_with_response(number, 2).then(...) long number = e.GetInt(); long times = e.GetIntAt(1); @@ -133,13 +134,13 @@ private void ShowBrowserBtn_Click(object sender, EventArgs e) " " + "

WebUI - Call C from JavaScript

" + "

Call C functions with arguments (See the logs in your terminal)

" + - " " + + " " + "
" + - " " + + " " + "
" + - " " + + " " + "
" + - " " + "
" + "

Call a C function that returns a response

" + @@ -153,7 +154,7 @@ private void ShowBrowserBtn_Click(object sender, EventArgs e) " function MyJS() {" + " const MyInput = document.getElementById('MyInputID');" + " const number = MyInput.value;" + - " webui.call('MyID_Four', number, 2).then((response) => {" + + " my_function_with_response(number, 2).then((response) => {" + " MyInput.value = response;" + " });" + " }" + @@ -161,11 +162,11 @@ private void ShowBrowserBtn_Click(object sender, EventArgs e) " " + ""; - _window.Bind("MyID_One"); - _window.Bind("MyID_Two"); - _window.Bind("MyID_Three"); - _window.Bind("MyID_Four"); - _window.Bind("MyID_RawBinary"); + _window.Bind("my_function_string"); + _window.Bind("my_function_integer"); + _window.Bind("my_function_boolean"); + _window.Bind("my_function_with_response"); + _window.Bind("my_function_raw_binary"); _window.OnWebUIEvent += Window_OnWebUIEvent; _window.Show(my_html); timer1.Enabled = true; @@ -173,23 +174,23 @@ private void ShowBrowserBtn_Click(object sender, EventArgs e) private void Window_OnWebUIEvent(object? sender, BindEventArgs e) { - if (e.BindEvent.Element == "MyID_One") + if (e.BindEvent.Element == "my_function_string") { my_function_string(e.BindEvent); } - else if (e.BindEvent.Element == "MyID_Two") + else if (e.BindEvent.Element == "my_function_integer") { my_function_integer(e.BindEvent); } - else if (e.BindEvent.Element == "MyID_Three") + else if (e.BindEvent.Element == "my_function_boolean") { my_function_boolean(e.BindEvent); } - else if (e.BindEvent.Element == "MyID_Four") + else if (e.BindEvent.Element == "my_function_with_response") { my_function_with_response(e.BindEvent); } - else if (e.BindEvent.Element == "MyID_RawBinary") + else if (e.BindEvent.Element == "my_function_raw_binary") { my_function_raw_binary(e.BindEvent); } diff --git a/demos/winforms_call_js_from_csharp/MainForm.cs b/demos/winforms_call_js_from_csharp/MainForm.cs index 8c349e2..19bea49 100644 --- a/demos/winforms_call_js_from_csharp/MainForm.cs +++ b/demos/winforms_call_js_from_csharp/MainForm.cs @@ -19,7 +19,7 @@ public void my_function_exit(WebUIEvent e) public void my_function_count(WebUIEvent e) { - // This function gets called every time the user clicks on "MyButton1" + // This function gets called every time the user clicks on "my_function_count" WebUIWindow? window = e.Window; if (window != null) @@ -55,11 +55,11 @@ public void my_function_count(WebUIEvent e) private void Window_OnWebUIEvent(object? sender, BindEventArgs e) { - if (e.BindEvent.Element == "MyButton1") + if (e.BindEvent.Element == "my_function_count") { my_function_count(e.BindEvent); } - else if (e.BindEvent.Element == "MyButton2") + else if (e.BindEvent.Element == "my_function_exit") { my_function_exit(e.BindEvent); } @@ -107,11 +107,11 @@ private void ShowBrowserBtn_Click(object sender, EventArgs e) "
" + "

0

" + "
" + - " " + + " " + "
" + " " + "
" + - " " + + " " + " " + " " + ""; - _window.Bind("MyButton1"); - _window.Bind("MyButton2"); + _window.Bind("my_function_count"); + _window.Bind("my_function_exit"); _window.OnWebUIEvent += Window_OnWebUIEvent; _window.Show(my_html); } diff --git a/demos/winforms_custom_web_server/MainForm.cs b/demos/winforms_custom_web_server/MainForm.cs index 766f944..3e60864 100644 --- a/demos/winforms_custom_web_server/MainForm.cs +++ b/demos/winforms_custom_web_server/MainForm.cs @@ -27,19 +27,19 @@ public void events(WebUIEvent e) // there is an event switch (e.EventType) { - case webui_events.WEBUI_EVENT_CONNECTED: + case webui_event.WEBUI_EVENT_CONNECTED: AddLog("connected."); break; - case webui_events.WEBUI_EVENT_DISCONNECTED: + case webui_event.WEBUI_EVENT_DISCONNECTED: AddLog("disconnected."); break; - case webui_events.WEBUI_EVENT_MOUSE_CLICK: + case webui_event.WEBUI_EVENT_MOUSE_CLICK: AddLog("click."); break; - case webui_events.WEBUI_EVENT_NAVIGATION: + case webui_event.WEBUI_EVENT_NAVIGATION: string? lUrl = e.GetString(); string navmessage = $"Navigating to {lUrl}"; AddLog(navmessage); @@ -89,9 +89,9 @@ private void ShowBrowserBtn_Click(object sender, EventArgs e) // Bind HTML elements with C functions _window.Bind("my_backend_func"); - // Set web server network port WebUI should use - // this mean `webui.js` will be available at: - // http://localhost:8081/webui.js + // Set the web-server/WebSocket port that WebUI should + // use. This means `webui.js` will be available at: + // http://localhost:MY_PORT_NUMBER/webui.js _window.SetPort(8081); _window.OnWebUIEvent += Window_OnWebUIEvent; diff --git a/demos/winforms_public_network_access/MainForm.cs b/demos/winforms_public_network_access/MainForm.cs index f3e08b8..695253b 100644 --- a/demos/winforms_public_network_access/MainForm.cs +++ b/demos/winforms_public_network_access/MainForm.cs @@ -21,11 +21,11 @@ public void public_window_events(WebUIEvent e) // there is an event switch (e.EventType) { - case webui_events.WEBUI_EVENT_CONNECTED: + case webui_event.WEBUI_EVENT_CONNECTED: prvWindow.Run("document.getElementById(\"Logs\").value += \"New connection.\\n\";"); break; - case webui_events.WEBUI_EVENT_DISCONNECTED: + case webui_event.WEBUI_EVENT_DISCONNECTED: prvWindow.Run("document.getElementById(\"Logs\").value += \"Disconnected.\\n\";"); break; } @@ -112,7 +112,7 @@ private void ShowBrowserBtn_Click(object sender, EventArgs e) pubWindow.SetPublic(true); // Make URL accessible from public networks pubWindow.BindAllEvents(); // Bind all events pubWindow.OnWebUIEvent += pubWindow_OnWebUIEvent; - pubWindow.ShowBrowser(public_html, webui_browsers.NoBrowser); // Set public window HTML + pubWindow.ShowBrowser(public_html, webui_browser.NoBrowser); // Set public window HTML public_win_url = pubWindow.Url; // Get URL of public window // Main Private Window diff --git a/demos/winforms_serve_a_folder/MainForm.cs b/demos/winforms_serve_a_folder/MainForm.cs index ee66c5a..dbae1e2 100644 --- a/demos/winforms_serve_a_folder/MainForm.cs +++ b/demos/winforms_serve_a_folder/MainForm.cs @@ -35,19 +35,19 @@ public void events(WebUIEvent e) // there is an event switch (e.EventType) { - case webui_events.WEBUI_EVENT_CONNECTED: + case webui_event.WEBUI_EVENT_CONNECTED: AddLog("connected."); break; - case webui_events.WEBUI_EVENT_DISCONNECTED: + case webui_event.WEBUI_EVENT_DISCONNECTED: AddLog("disconnected."); break; - case webui_events.WEBUI_EVENT_MOUSE_CLICK: + case webui_event.WEBUI_EVENT_MOUSE_CLICK: AddLog("click."); break; - case webui_events.WEBUI_EVENT_NAVIGATION: + case webui_event.WEBUI_EVENT_NAVIGATION: string? lUrl = e.GetString(); string navmessage = $"Navigating to {lUrl}"; AddLog(navmessage); @@ -103,7 +103,7 @@ private void ShowBrowserBtn_Click(object sender, EventArgs e) _Window.BindAllEvents(); // Make Deno as the `.ts` and `.js` interpreter - _Window.SetRuntime(webui_runtimes.Deno); + _Window.SetRuntime(webui_runtime.Deno); // Set a custom files handler _Window.SetFileHandler(); diff --git a/demos/winforms_text_editor/MainForm.cs b/demos/winforms_text_editor/MainForm.cs index eccd28f..6b3e8c7 100644 --- a/demos/winforms_text_editor/MainForm.cs +++ b/demos/winforms_text_editor/MainForm.cs @@ -10,14 +10,14 @@ public MainForm() InitializeComponent(); } - public void Close(WebUIEvent e) + public void close_app(WebUIEvent e) { WebUI.Exit(); } private void Window_OnWebUIEvent(object? sender, BindEventArgs e) { - Close(e.BindEvent); + close_app(e.BindEvent); } private void ShowBrowserBtn_Click(object sender, EventArgs e) @@ -29,10 +29,10 @@ private void ShowBrowserBtn_Click(object sender, EventArgs e) _window.SetRootFolder(absPath); // Bind HTML elements with the specified ID to C functions - _window.Bind("__close-btn"); + _window.Bind("close_app"); // Show the window, preferably in a chromium based browser - if (!_window.ShowBrowser("index.html", webui_browsers.ChromiumBased)) + if (!_window.ShowBrowser("index.html", webui_browser.ChromiumBased)) { _window.Show("index.html"); } diff --git a/demos/wpf_call_csharp_from_js/MainWindow.xaml.cs b/demos/wpf_call_csharp_from_js/MainWindow.xaml.cs index ddc6030..4014222 100644 --- a/demos/wpf_call_csharp_from_js/MainWindow.xaml.cs +++ b/demos/wpf_call_csharp_from_js/MainWindow.xaml.cs @@ -30,34 +30,39 @@ private void AddLog(String msg) public void my_function_string(WebUIEvent e) { // JavaScript: - // webui.call('MyID_One', 'Hello World', '\u{1F3DD}'); + // my_function_string('Hello', 'World`); string? str_1 = e.GetString(); string? str_2 = e.GetStringAt(1); - AddLog($"my_function_string 1: {str_1}"); // Hello World - AddLog($"my_function_string 2: {str_2}"); // Palmtree + AddLog($"my_function_string 1: {str_1}"); // Hello + AddLog($"my_function_string 2: {str_2}"); // World } public void my_function_integer(WebUIEvent e) { // JavaScript: - // webui.call('MyID_Two', 123, 456, 789); + // my_function_integer(123, 456, 789, 12345.6789); + + UIntPtr count = e.GetCount(); + AddLog($"my_function_integer: There are {count} arguments in this event"); // 4 long number_1 = e.GetInt(); long number_2 = e.GetIntAt(1); long number_3 = e.GetIntAt(2); + double float_1 = e.GetFloatAt(3); AddLog($"my_function_integer 1: {number_1}"); // 123 AddLog($"my_function_integer 2: {number_2}"); // 456 AddLog($"my_function_integer 3: {number_3}"); // 789 + AddLog($"my_function_integer 4: {float_1}"); // 12345.6789 } public void my_function_boolean(WebUIEvent e) { // JavaScript: - // webui.call('MyID_Three', true, false); + // my_function_boolean(true, false); bool status_1 = e.GetBool(); bool status_2 = e.GetBoolAt(1); @@ -69,7 +74,7 @@ public void my_function_boolean(WebUIEvent e) public void my_function_raw_binary(WebUIEvent e) { // JavaScript: - // webui.call('MyID_RawBinary', new Uint8Array([0x41,0x42,0x43]), big_arr); + // my_function_raw_binary(new Uint8Array([0x41]), new Uint8Array([0x42, 0x43])); MemoryStream? stream = e.GetStream(); if (stream != null) @@ -82,7 +87,7 @@ public void my_function_raw_binary(WebUIEvent e) public void my_function_with_response(WebUIEvent e) { // JavaScript: - // webui.call('MyID_Four', number, 2).then(...) + // my_function_with_response(number, 2).then(...) long number = e.GetInt(); long times = e.GetIntAt(1); @@ -135,13 +140,13 @@ private void ShowBrowserBtn_Click(object sender, RoutedEventArgs e) " " + "

WebUI - Call C from JavaScript

" + "

Call C functions with arguments (See the logs in your terminal)

" + - " " + + " " + "
" + - " " + + " " + "
" + - " " + + " " + "
" + - " " + "
" + "

Call a C function that returns a response

" + @@ -155,7 +160,7 @@ private void ShowBrowserBtn_Click(object sender, RoutedEventArgs e) " function MyJS() {" + " const MyInput = document.getElementById('MyInputID');" + " const number = MyInput.value;" + - " webui.call('MyID_Four', number, 2).then((response) => {" + + " my_function_with_response(number, 2).then((response) => {" + " MyInput.value = response;" + " });" + " }" + @@ -163,11 +168,11 @@ private void ShowBrowserBtn_Click(object sender, RoutedEventArgs e) " " + ""; - _window.Bind("MyID_One"); - _window.Bind("MyID_Two"); - _window.Bind("MyID_Three"); - _window.Bind("MyID_Four"); - _window.Bind("MyID_RawBinary"); + _window.Bind("my_function_string"); + _window.Bind("my_function_integer"); + _window.Bind("my_function_boolean"); + _window.Bind("my_function_with_response"); + _window.Bind("my_function_raw_binary"); _window.OnWebUIEvent += new EventHandler(Window_OnWebUIEvent); _window.Show(my_html); @@ -178,23 +183,23 @@ private void ShowBrowserBtn_Click(object sender, RoutedEventArgs e) private void Window_OnWebUIEvent(object? sender, BindEventArgs e) { - if (e.BindEvent.Element == "MyID_One") + if (e.BindEvent.Element == "my_function_string") { my_function_string(e.BindEvent); } - else if (e.BindEvent.Element == "MyID_Two") + else if (e.BindEvent.Element == "my_function_integer") { my_function_integer(e.BindEvent); } - else if (e.BindEvent.Element == "MyID_Three") + else if (e.BindEvent.Element == "my_function_boolean") { my_function_boolean(e.BindEvent); } - else if (e.BindEvent.Element == "MyID_Four") + else if (e.BindEvent.Element == "my_function_with_response") { my_function_with_response(e.BindEvent); } - else if (e.BindEvent.Element == "MyID_RawBinary") + else if (e.BindEvent.Element == "my_function_raw_binary") { my_function_raw_binary(e.BindEvent); } diff --git a/demos/wpf_call_js_from_csharp/MainWindow.xaml.cs b/demos/wpf_call_js_from_csharp/MainWindow.xaml.cs index 8a6db3c..b0a8061 100644 --- a/demos/wpf_call_js_from_csharp/MainWindow.xaml.cs +++ b/demos/wpf_call_js_from_csharp/MainWindow.xaml.cs @@ -23,7 +23,7 @@ public void my_function_exit(WebUIEvent e) public void my_function_count(WebUIEvent e) { - // This function gets called every time the user clicks on "MyButton1" + // This function gets called every time the user clicks on "my_function_count" WebUIWindow? window = e.Window; if (window != null) @@ -59,11 +59,11 @@ public void my_function_count(WebUIEvent e) private void Window_OnWebUIEvent(object? sender, BindEventArgs e) { - if (e.BindEvent.Element == "MyButton1") + if (e.BindEvent.Element == "my_function_count") { my_function_count(e.BindEvent); } - else if (e.BindEvent.Element == "MyButton2") + else if (e.BindEvent.Element == "my_function_exit") { my_function_exit(e.BindEvent); } @@ -111,11 +111,11 @@ private void ShowBrowserBtn_Click(object sender, RoutedEventArgs e) "
" + "

0

" + "
" + - " " + + " " + "
" + " " + "
" + - " " + + " " + " " + " " + ""; - _window.Bind("MyButton1"); - _window.Bind("MyButton2"); + _window.Bind("my_function_count"); + _window.Bind("my_function_exit"); _window.OnWebUIEvent += Window_OnWebUIEvent; _window.Show(my_html); } diff --git a/demos/wpf_custom_web_server/MainWindow.xaml.cs b/demos/wpf_custom_web_server/MainWindow.xaml.cs index 7e10dda..3074e2b 100644 --- a/demos/wpf_custom_web_server/MainWindow.xaml.cs +++ b/demos/wpf_custom_web_server/MainWindow.xaml.cs @@ -32,19 +32,19 @@ public void events(WebUIEvent e) // there is an event switch (e.EventType) { - case webui_events.WEBUI_EVENT_CONNECTED: + case webui_event.WEBUI_EVENT_CONNECTED: AddLog("connected."); break; - case webui_events.WEBUI_EVENT_DISCONNECTED: + case webui_event.WEBUI_EVENT_DISCONNECTED: AddLog("disconnected."); break; - case webui_events.WEBUI_EVENT_MOUSE_CLICK: + case webui_event.WEBUI_EVENT_MOUSE_CLICK: AddLog("click."); break; - case webui_events.WEBUI_EVENT_NAVIGATION: + case webui_event.WEBUI_EVENT_NAVIGATION: string? lUrl = e.GetString(); string navmessage = $"Navigating to {lUrl}"; AddLog(navmessage); @@ -110,9 +110,9 @@ private void ShowBrowserBtn_Click(object sender, RoutedEventArgs e) // Bind HTML elements with C functions _window.Bind("my_backend_func"); - // Set web server network port WebUI should use - // this mean `webui.js` will be available at: - // http://localhost:8081/webui.js + // Set the web-server/WebSocket port that WebUI should + // use. This means `webui.js` will be available at: + // http://localhost:MY_PORT_NUMBER/webui.js _window.SetPort(8081); _window.OnWebUIEvent += Window_OnWebUIEvent; diff --git a/demos/wpf_public_network_access/MainWindow.xaml.cs b/demos/wpf_public_network_access/MainWindow.xaml.cs index 81a0fb6..348fdff 100644 --- a/demos/wpf_public_network_access/MainWindow.xaml.cs +++ b/demos/wpf_public_network_access/MainWindow.xaml.cs @@ -24,11 +24,11 @@ public void public_window_events(WebUIEvent e) // there is an event switch (e.EventType) { - case webui_events.WEBUI_EVENT_CONNECTED: + case webui_event.WEBUI_EVENT_CONNECTED: prvWindow.Run("document.getElementById(\"Logs\").value += \"New connection.\\n\";"); break; - case webui_events.WEBUI_EVENT_DISCONNECTED: + case webui_event.WEBUI_EVENT_DISCONNECTED: prvWindow.Run("document.getElementById(\"Logs\").value += \"Disconnected.\\n\";"); break; } @@ -125,7 +125,7 @@ private void ShowBrowserBtn_Click(object sender, RoutedEventArgs e) pubWindow.SetPublic(true); // Make URL accessible from public networks pubWindow.BindAllEvents(); // Bind all events pubWindow.OnWebUIEvent += pubWindow_OnWebUIEvent; - pubWindow.ShowBrowser(public_html, webui_browsers.NoBrowser); // Set public window HTML + pubWindow.ShowBrowser(public_html, webui_browser.NoBrowser); // Set public window HTML public_win_url = pubWindow.Url; // Get URL of public window // Main Private Window diff --git a/demos/wpf_serve_a_folder/MainWindow.xaml.cs b/demos/wpf_serve_a_folder/MainWindow.xaml.cs index 36f4ccc..c3e42db 100644 --- a/demos/wpf_serve_a_folder/MainWindow.xaml.cs +++ b/demos/wpf_serve_a_folder/MainWindow.xaml.cs @@ -40,19 +40,19 @@ public void events(WebUIEvent e) // there is an event switch (e.EventType) { - case webui_events.WEBUI_EVENT_CONNECTED: + case webui_event.WEBUI_EVENT_CONNECTED: AddLog("connected."); break; - case webui_events.WEBUI_EVENT_DISCONNECTED: + case webui_event.WEBUI_EVENT_DISCONNECTED: AddLog("disconnected."); break; - case webui_events.WEBUI_EVENT_MOUSE_CLICK: + case webui_event.WEBUI_EVENT_MOUSE_CLICK: AddLog("click."); break; - case webui_events.WEBUI_EVENT_NAVIGATION: + case webui_event.WEBUI_EVENT_NAVIGATION: string? lUrl = e.GetString(); string navmessage = $"Navigating to {lUrl}"; AddLog(navmessage); @@ -108,7 +108,7 @@ private void ShowBrowserBtn_Click(object sender, RoutedEventArgs e) _Window.BindAllEvents(); // Make Deno as the `.ts` and `.js` interpreter - _Window.SetRuntime(webui_runtimes.Deno); + _Window.SetRuntime(webui_runtime.Deno); // Set a custom files handler _Window.SetFileHandler(); diff --git a/demos/wpf_text_editor/MainWindow.xaml.cs b/demos/wpf_text_editor/MainWindow.xaml.cs index c84ffd4..e8c9090 100644 --- a/demos/wpf_text_editor/MainWindow.xaml.cs +++ b/demos/wpf_text_editor/MainWindow.xaml.cs @@ -14,14 +14,14 @@ public MainWindow() InitializeComponent(); } - public void Close(WebUIEvent e) + public void close_app(WebUIEvent e) { WebUI.Exit(); } private void Window_OnWebUIEvent(object? sender, BindEventArgs e) { - Close(e.BindEvent); + close_app(e.BindEvent); } private void ShowBrowserBtn_Click(object sender, RoutedEventArgs e) @@ -33,10 +33,10 @@ private void ShowBrowserBtn_Click(object sender, RoutedEventArgs e) _window.SetRootFolder(absPath); // Bind HTML elements with the specified ID to C functions - _window.Bind("__close-btn"); + _window.Bind("close_app"); // Show the window, preferably in a chromium based browser - if (!_window.ShowBrowser("index.html", webui_browsers.ChromiumBased)) + if (!_window.ShowBrowser("index.html", webui_browser.ChromiumBased)) { _window.Show("index.html"); } diff --git a/docs/WebUI4CSharp.chm b/docs/WebUI4CSharp.chm index 4744a1d..49525e5 100644 Binary files a/docs/WebUI4CSharp.chm and b/docs/WebUI4CSharp.chm differ diff --git a/docs/html/_web_u_i_types_8cs.html b/docs/html/_web_u_i_types_8cs.html index 662bf85..656300f 100644 --- a/docs/html/_web_u_i_types_8cs.html +++ b/docs/html/_web_u_i_types_8cs.html @@ -66,44 +66,49 @@ - - - - + + - - - + + - - + + + + +

Enumerations

enum  WebUI4CSharp.webui_browsers {
-  WebUI4CSharp.NoBrowser = 0 -, WebUI4CSharp.AnyBrowser = 1 -, WebUI4CSharp.Chrome -, WebUI4CSharp.Firefox +
enum  WebUI4CSharp.webui_browser {
+  WebUI4CSharp.NoBrowser = 0 +, WebUI4CSharp.AnyBrowser = 1 +, WebUI4CSharp.Chrome +, WebUI4CSharp.Firefox ,
-  WebUI4CSharp.Edge -, WebUI4CSharp.Safari -, WebUI4CSharp.Chromium -, WebUI4CSharp.Opera +  WebUI4CSharp.Edge +, WebUI4CSharp.Safari +, WebUI4CSharp.Chromium +, WebUI4CSharp.Opera ,
-  WebUI4CSharp.Brave -, WebUI4CSharp.Vivaldi -, WebUI4CSharp.Epic -, WebUI4CSharp.Yandex +  WebUI4CSharp.Brave +, WebUI4CSharp.Vivaldi +, WebUI4CSharp.Epic +, WebUI4CSharp.Yandex ,
-  WebUI4CSharp.ChromiumBased +  WebUI4CSharp.ChromiumBased
}
 Supported web browsers. More...
 
enum  WebUI4CSharp.webui_runtimes { WebUI4CSharp.None = 0 -, WebUI4CSharp.Deno -, WebUI4CSharp.NodeJS +
 Supported web browsers. More...
 
enum  WebUI4CSharp.webui_runtime { WebUI4CSharp.None = 0 +, WebUI4CSharp.Deno +, WebUI4CSharp.NodeJS }
 Supported runtimes. More...
 
enum  WebUI4CSharp.webui_events {
-  WebUI4CSharp.WEBUI_EVENT_DISCONNECTED = 0 -, WebUI4CSharp.WEBUI_EVENT_CONNECTED -, WebUI4CSharp.WEBUI_EVENT_MOUSE_CLICK -, WebUI4CSharp.WEBUI_EVENT_NAVIGATION +
 Supported runtimes. More...
 
enum  WebUI4CSharp.webui_event {
+  WebUI4CSharp.WEBUI_EVENT_DISCONNECTED = 0 +, WebUI4CSharp.WEBUI_EVENT_CONNECTED +, WebUI4CSharp.WEBUI_EVENT_MOUSE_CLICK +, WebUI4CSharp.WEBUI_EVENT_NAVIGATION ,
-  WebUI4CSharp.WEBUI_EVENT_CALLBACK +  WebUI4CSharp.WEBUI_EVENT_CALLBACK
}
 WebUI event types. More...
 
 WebUI event types. More...
 
enum  WebUI4CSharp.webui_config { WebUI4CSharp.show_wait_connection = 0 +, WebUI4CSharp.ui_event_blocking + }
 WebUI configuration. More...
 
diff --git a/docs/html/class_web_u_i4_c_sharp_1_1_web_u_i-members.html b/docs/html/class_web_u_i4_c_sharp_1_1_web_u_i-members.html index 016724f..cb6e14e 100644 --- a/docs/html/class_web_u_i4_c_sharp_1_1_web_u_i-members.html +++ b/docs/html/class_web_u_i4_c_sharp_1_1_web_u_i-members.html @@ -67,14 +67,15 @@ - - - - - - - - + + + + + + + + +

Functions

IsAppRunning()WebUI4CSharp.WebUIstatic
Malloc(UIntPtr size)WebUI4CSharp.WebUIstatic
SearchWindow(UIntPtr windowId)WebUI4CSharp.WebUIstatic
SetDefaultRootFolder(string path)WebUI4CSharp.WebUIstatic
SetTimeout(UIntPtr second)WebUI4CSharp.WebUIstatic
SetTLSCertificate(string certificate_pem, string private_key_pem)WebUI4CSharp.WebUIstatic
Wait()WebUI4CSharp.WebUIstatic
WEBUI_MAX_ARGWebUI4CSharp.WebUIstatic
WEBUI_MAX_IDSWebUI4CSharp.WebUIstatic
WEBUI_VERSIONWebUI4CSharp.WebUIstatic
WebUIStringToCSharpString(IntPtr srcString)WebUI4CSharp.WebUIstatic
SetConfig(webui_config option, bool status)WebUI4CSharp.WebUIstatic
SetDefaultRootFolder(string path)WebUI4CSharp.WebUIstatic
SetTimeout(UIntPtr second)WebUI4CSharp.WebUIstatic
SetTLSCertificate(string certificate_pem, string private_key_pem)WebUI4CSharp.WebUIstatic
Wait()WebUI4CSharp.WebUIstatic
WEBUI_MAX_ARGWebUI4CSharp.WebUIstatic
WEBUI_MAX_IDSWebUI4CSharp.WebUIstatic
WEBUI_VERSIONWebUI4CSharp.WebUIstatic
WebUIStringToCSharpString(IntPtr srcString)WebUI4CSharp.WebUIstatic