Visual Studio中。net桌面应用的HTML5 UI

时间:2022-03-05 08:42:37

Does anybody happen to know if it is possible to develop a .NET based desktop app in Visual Studio with HTML5 as a front-end?

有没有人知道在Visual Studio中以HTML5为前端开发基于。net的桌面应用是否可能?

I know the answer on MSDN a couple of years back seemed to be no, but I'm wondering if there has been any change.

我知道几年前在MSDN上的答案似乎是否定的,但我想知道是否有任何改变。

I know you can develop JavaScript based desktop apps with things like Chrome Apps, but I'm wondering if you can do the whole thing (except for the UI) in .NET in Visual Studio. I'm also aware I could code it all in JavaScript and talk to .NET web services, but again I just want it all in the desktop app.

我知道你可以用Chrome开发基于JavaScript的桌面应用,但是我想知道你是否可以在Visual Studio的。net中完成所有的事情(除了UI)。我还意识到我可以用JavaScript编写所有代码,并与。net web服务对话,但同样,我只想把所有代码都放在桌面应用程序中。

3 个解决方案

#1


5  

You can use DotNetBrowser library to use HTML5 in .NET desktop applications.

您可以使用DotNetBrowser库在. net桌面应用程序中使用HTML5。

The library provides a Chromium-based WPF component that can be embedded into your .NET application. The component supports calling JavaScript from C# and vice versa. Chromium engine will act as a HTML5 interpreter in this case.

该库提供了一个基于chrome的WPF组件,可以嵌入到。net应用程序中。该组件支持从c#调用JavaScript,反之亦然。在这种情况下,Chromium引擎将充当HTML5解释器。

Here's code example that demonstrates how to load HTML into the component and get HTML of the loaded web page:

下面的代码示例演示如何将HTML加载到组件中,并获得已加载web页面的HTML:

using System;
using DotNetBrowser;

namespace MyNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Provide path to the directory with DotNetBrowser Chromium binaries.
            Environment.SetEnvironmentVariable("DOTNETBROWSER_BIN_DIR", @"D:\Library\Chromium");

            // Create Browser instance.
            Browser browser = BrowserFactory.Create();

            // Register frame loading event listener.
            browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
            {
                // Wait until main document of the web page is loaded completely.
                if (e.IsMainFrame)
                {
                    // Get HTML of the loaded web page and write it to Console.
                    Console.Out.WriteLine(e.Browser.GetHTML());
                }
            }
            // Load HTML content from string .
            browser.LoadHTML("<html><body><h2>Hello World!</h2></body></html>"); 
            // Load google.com to get its HTML content.
            browser.LoadURL("http://www.google.com");
        }
    }
}

To find out how to configure MS Visual Studio 2013 Project with DotNetBrowser you can take a look at Quick Start Guide.

要了解如何使用DotNetBrowser配置MS Visual Studio 2013项目,请参阅快速入门指南。

It's free for Open-Source projects ;)

对开源项目是免费的)

#2


0  

If you are thinking about a Windows 8 Store app that runs on a desktop (full-screen "metro" app) then they did make JavaScript a first-class citizen for WinRT.

如果你正在考虑一个运行在桌面(全屏“metro”应用)上的Windows 8 Store应用,那么他们确实让JavaScript成为WinRT的一级公民。

Create your first Windows Store app using JavaScript (MSDN Article)

使用JavaScript创建您的第一个Windows Store应用程序(MSDN文章)

#3


0  

We write angular front ends and set chrome as the desktop process rather than explorer. Chrome runs in kiosk mode. Have IIS runing c# asp.net back end

我们编写了角度前端,并将chrome设置为桌面进程而不是浏览器。Chrome在kiosk模式下运行。有IIS运行c# asp.net后端吗

#1


5  

You can use DotNetBrowser library to use HTML5 in .NET desktop applications.

您可以使用DotNetBrowser库在. net桌面应用程序中使用HTML5。

The library provides a Chromium-based WPF component that can be embedded into your .NET application. The component supports calling JavaScript from C# and vice versa. Chromium engine will act as a HTML5 interpreter in this case.

该库提供了一个基于chrome的WPF组件,可以嵌入到。net应用程序中。该组件支持从c#调用JavaScript,反之亦然。在这种情况下,Chromium引擎将充当HTML5解释器。

Here's code example that demonstrates how to load HTML into the component and get HTML of the loaded web page:

下面的代码示例演示如何将HTML加载到组件中,并获得已加载web页面的HTML:

using System;
using DotNetBrowser;

namespace MyNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Provide path to the directory with DotNetBrowser Chromium binaries.
            Environment.SetEnvironmentVariable("DOTNETBROWSER_BIN_DIR", @"D:\Library\Chromium");

            // Create Browser instance.
            Browser browser = BrowserFactory.Create();

            // Register frame loading event listener.
            browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
            {
                // Wait until main document of the web page is loaded completely.
                if (e.IsMainFrame)
                {
                    // Get HTML of the loaded web page and write it to Console.
                    Console.Out.WriteLine(e.Browser.GetHTML());
                }
            }
            // Load HTML content from string .
            browser.LoadHTML("<html><body><h2>Hello World!</h2></body></html>"); 
            // Load google.com to get its HTML content.
            browser.LoadURL("http://www.google.com");
        }
    }
}

To find out how to configure MS Visual Studio 2013 Project with DotNetBrowser you can take a look at Quick Start Guide.

要了解如何使用DotNetBrowser配置MS Visual Studio 2013项目,请参阅快速入门指南。

It's free for Open-Source projects ;)

对开源项目是免费的)

#2


0  

If you are thinking about a Windows 8 Store app that runs on a desktop (full-screen "metro" app) then they did make JavaScript a first-class citizen for WinRT.

如果你正在考虑一个运行在桌面(全屏“metro”应用)上的Windows 8 Store应用,那么他们确实让JavaScript成为WinRT的一级公民。

Create your first Windows Store app using JavaScript (MSDN Article)

使用JavaScript创建您的第一个Windows Store应用程序(MSDN文章)

#3


0  

We write angular front ends and set chrome as the desktop process rather than explorer. Chrome runs in kiosk mode. Have IIS runing c# asp.net back end

我们编写了角度前端,并将chrome设置为桌面进程而不是浏览器。Chrome在kiosk模式下运行。有IIS运行c# asp.net后端吗