216 Star 1.8K Fork 402

GVPdotNET China / NanUI

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

WinFormium 项目(曾用名:NanUI)

用 HTML, CSS 和 JavaScript 轻松构建功能强大的 WinForm 应用程序。

WinFormium

Click [Here] to see the English version.

GitHub Nuget Nuget

一直以来 NanUI 的发型版本都处于测试阶段,经过了 9 年的迭代,是时候为 NanUI 发布正式版了!在 NanUI v1.0 正式版发布时,将正式启用项目的新名称 - WinFormium

⭐ 关于

WinFormium 是 .NET 平台上的一个开源框架(曾用名:NanUI),用于使用 HTML5、CSS3 和 JavaScript 创建 WinForm 应用程序的用户界面。 它基于 Xilium.CefGlue 项目,该项目是 Chromium Embedded Framework (CEF) 的 .NET 实现。

如果您正在寻找一个用于创建具有现代用户界面的 WinForm 应用程序的框架,WinFormium 是一个不错的选择。 您可以使用 HTML、CSS 和 JavaScript 创建用户界面,并使用 C# 编写应用程序的业务逻辑。

如果您喜欢 👍,请给 WinFormium 项目一颗星 ⭐。

如果这个项目对你有帮助,请考虑资助它。

支付宝 微信

🖥️ 环境要求

开发环境

  • .NET Framework 4.6.2 或更高版本 / .NET 6.0 或更高版本
  • Visual Studio 2019 或更高版本(强烈建议使用 VS2022)

部署环境

  • Microsoft Windows 7 Service Pack 1 或更高版本
  • .Net Framework 4.6.2 或更高版本
  • .NET 6.0 需要 Windows 7 Service Pack 1 或更高版本
  • .NET 7.0/8.0 需要 Windows 10 或 Windows 11

这是一个 仅限 Windows 的框架,所以它目前不能在 Linux 或者 MacOS 环境运行。

支持的最低 Windows 版本是 Windows 7 Service Pack 1,并且 Windows 7 不支持某些功能(例如 DirectComposition 离屏渲染)。

🧰 入门

按照以下步骤即可创建一个简单的 WinFormium 应用程序:

1. 通过默认模板创建一个 WinForm 应用程序。

2. 安装 WinFormium NuGet 包

打开 NuGet 包管理器来安装或使用 NuGet 包管理器控制台,然后运行以下命令来安装 WinFormium nuget 包:

PM> Install-Package NetDimension.NanUI

安装 WinFormium 所依赖的 Chromium Embedded Framework 依赖项:

PM> Install-Package NetDimension.NanUI.Runtime

CEF 运行库巨大,再加上众所周知的原因,中国内地玩家请自行设置 NuGet 使用国内镜像。

3. 一个基本的 WinFormium 应用程序需要以下代码:

按如下示例修改 Program.cs 文件中的代码:

using WinFormium;

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        var builder = WinFormiumApp.CreateBuilder();

        builder.UseWinFormiumApp<MyApp>();

        var app = builder.Build();

        app.Run();
    }
}

创建一个类继承 WinFormiumStartup 来配置应用程序:

using WinFormium;

class MyAPP : WinFormiumStartup
{
    protected override MainWindowCreationAction? UseMainWindow(MainWindowOptions opts)
    {
        // 设置应用程序的主窗体
        return opts.UseMainFormium<MyWindow>();
    }

    protected override void WinFormiumMain(string[] args)
    {
        // Main函数中的代码应该在这里,该函数只在主进程中运行。这样可以防止子进程运行一些不正确的初始化代码。
        ApplicationConfiguration.Initialize();
    }

    protected override void ConfigurationChromiumEmbedded(ChromiumEnvironmentBuiler cef)
    {
        // 在此处配置 Chromium Embedded Framwork
    }

    protected override void ConfigureServices(IServiceCollection services)
    {
        // 在这里配置该应用程序的服务
    }
}

创建一个类实现 Formium,用于配置应用程序的主窗口:

using WinFormium;
using WinFormium.Forms;

class MyWindow : Formium
{
    public MyWindow()
    {
        Url = "https://www.google.com";
    }

    protected override FormStyle ConfigureWindowStyle(WindowStyleBuilder builder)
    {
        // 此处配置窗口的样式和属性,或留空以使用默认样式

        var style = builder.UseSystemForm();

        style.TitleBar = false;

        style.DefaultAppTitle = "My first WinFomrim app";

        return style;
    }
}

4. 生成并运行你的第一个 WinFormium 应用程序

📖 文档

有关更多信息,请参阅 - 文档

🤖 示例代码

🔗 第三方库引用和工具集

🏆 灵感来源

在创建此版本的 WinFormium 时,我受到以下歌曲和专辑的启发,特此感谢。

  • Strandels - Chance Of Rain
  • One Direction - What a Feeling (Made In The A.M.)
  • Thomas Rhett - VHS (Center Point Road)
  • Sammy Kershaw - She Don't Know She's Beautiful (Haunted Heart)
  • Chrissy Steele - Two Bodies (Magnet To Steele)
  • Halestorm - I Like It Heavy (Into the Wild Life)
  • Joan Jett & The Blackhearts - I Hate Myself for Loving You (Up Your Alley)
The MIT License (MIT) Copyrights (C) 2014 - present, Xuanchen Lin (Mr.JSON). All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

NanUI是一个开放源代码的.NET项目,它适用于希望使用HTML5 / CSS3等前端技术来构建Windows窗体应用用户界面的.NET / .NET Core开发人员。 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/dotnetchina/NanUI.git
git@gitee.com:dotnetchina/NanUI.git
dotnetchina
NanUI
NanUI
master

搜索帮助