All Projects → webview-cs → webview-cs

webview-cs / webview-cs

Licence: MIT license
C# Bindings to https://github.com/zserge/webview

Programming Languages

C#
18002 projects
powershell
5483 projects

Projects that are alternatives of or similar to webview-cs

coc-webview
Using an external browser to support the webview in coc.nvim.
Stars: ✭ 21 (-80.91%)
Mutual labels:  webview
QuickWebKit
A great & strong plugin based WebViewController. 一款基于插件的 WebView 视图控制器,您可以基于它设计您的浏览器插件,然后像积木一样来组装它们。
Stars: ✭ 29 (-73.64%)
Mutual labels:  webview
RobustWebView
Android WebView H5 秒开方案总结
Stars: ✭ 38 (-65.45%)
Mutual labels:  webview
webview
Build cross platform desktop apps with Elixir and web technologies.
Stars: ✭ 18 (-83.64%)
Mutual labels:  webview
flutter webview
A complete tutorial series on Flutter webview.
Stars: ✭ 39 (-64.55%)
Mutual labels:  webview
flutter app o2o
flutter高校食堂o2o预定服务,商业级应用,持续升级,完全开源。
Stars: ✭ 45 (-59.09%)
Mutual labels:  webview
TeadsSDK-iOS
Teads SDK iOS Sample App - Check out an open-source sample of the Teads iOS SDK implementation
Stars: ✭ 22 (-80%)
Mutual labels:  webview
MkBrowser
🌐 一个简易的 Android 网页浏览器 A simple Android web browser
Stars: ✭ 55 (-50%)
Mutual labels:  webview
ios-visionkit-webview
Element detection with Vision Framework and CoreML
Stars: ✭ 26 (-76.36%)
Mutual labels:  webview
cordova-plugin-x5-tbs
Use Tencent Browser Service(TBS) instead of System WebView for Cordova App
Stars: ✭ 65 (-40.91%)
Mutual labels:  webview
webview
Cross-platform header-only webview library for C++
Stars: ✭ 59 (-46.36%)
Mutual labels:  webview
tesla auth
Securely generate API tokens for third-party access to your Tesla.
Stars: ✭ 114 (+3.64%)
Mutual labels:  webview
vscode-android-webview-debug
Debug your JavaScript code running in WebViews on any Android device from VS Code.
Stars: ✭ 18 (-83.64%)
Mutual labels:  webview
X5Bridge
Three party libraries of Tencent x5webview and JS interaction
Stars: ✭ 17 (-84.55%)
Mutual labels:  webview
flutter examples
Random flutter examples
Stars: ✭ 18 (-83.64%)
Mutual labels:  webview
Webview
Android WebView,Js互调
Stars: ✭ 22 (-80%)
Mutual labels:  webview
gowebview
tool to build android apps with WebView from your golang http server; moved to gitlab.com/microo8/gowebview
Stars: ✭ 35 (-68.18%)
Mutual labels:  webview
autojs-webView
autojs的webView实现,支持初始化脚本注入、jsBridge两端互调
Stars: ✭ 38 (-65.45%)
Mutual labels:  webview
VHLWebView
微信/支付宝样式的网络浏览器控件。WKwebview 封装,js bridge和拦截url方式两种方法实现 oc和js交互
Stars: ✭ 14 (-87.27%)
Mutual labels:  webview
ux-lab
No description or website provided.
Stars: ✭ 49 (-55.45%)
Mutual labels:  webview

webview-cs

Build status

C# Bindings to https://github.com/zserge/webview. Easily create cross-platform desktop applications with web technologies.

Installation

You can get your hands on Webview.Core from NuGet:

PM> Install-Package Webview.Core

or from the dotnet command line:

$ dotnet add package Webview.Core

Examples

There are two main APIs to create a webview; the simple API, and the builder API. With the simple API all interaction takes place via the Webview.Webview.Simple method. This allows you to quickly get a webview running, but doesn't provide the ability to register an invoke callback for JS amongst other things. This is a good starting place.

using Webview

[STAThread]
public static void Main(string[] args)
{
    Webview.Webview.Simple("Window Title", "https://google.com"))    
}

You can also provide an initial window size and control if the window can be resized:

using Webview;
using System.Drawing;

Webview.Webview.Simple(
  "Title",
  Content.FromHtml("<html><h1>Hello World!"),
  size: new Size(500, 200),
  resizable: true
)

For the builder API you first need to create a WebviewBuilder. A fluent API allows you to choose how the Webview is created. Once built the resulting view must manually be Run to display the window.

using Webview;
using System.Drawing;

new WebviewBuilder(new Uri("http://google.com"))
    .WithSize(new Size(1024, 768))
    .Resizeable()
    .Debug()
    .WithInvokeCallback((webview, action) => {
      Console.WriteLine("Action: {0}", action);
    })
    .Build()
    .Run();

If you're program is going to outlive the Webview you can wrap it in a using statement to make sure unmanaged resources are disposed of when you expect them to be:

using Webview;

using (var webview = new WebviewBuider("Title", Content.FromHtml("<p>Hello World")
                        .WithCallback(MyCallbackFunction))
                        .Build())
{
    webview.Run();
}

ASP .NET Core WebHost

To create a standalone desktop application out of an ASP.NET Core website, use the Webview.WebHost nuget package.

PM> Install-Package Webview.WebHost

or from the dotnet command line:

$ dotnet add package Webview.WebHost

Replace the default Main function in Program.cs with this:

using Webview.WebHost;
...
    [STAThread]
    public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).WithDynamicPort().WithNoOutput().Build().RunWebview();
        }

To create the standalone executable, the project must be published.

$ dotnet publish -r win10-x64 -c Release

Supported runtime identifiers are 'win10-x64', 'win10-x64', 'osx-x64', and 'linux-x64'.

Windows Console Gotchas

Note - Windows has the concept of console and windows applications. For this reason, we need to attribute the main function:

[STAThread] // This is mandatory in Windows for the webview to be displayed.
static void Main(string[] args) {
    ...
}

Adding an Application Icon on Windows

To add an icon to your Windows application create a .NET Framework executable instead of a .NET Core one and attach an icon to that. See this issue for more information.

Feature Status

  • Run webview with standard parameters.
  • Builder API for creating webviews.
  • Native binaries for:
  • Linux x64
  • macOS x64
  • Windows10 x64
  • WebHostBuilder and WebHost extensions for running a .NET Core website as a desktop application
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].