开源组件NanUI一周年 - 使用HTML/CSS/JS来构建.Net Winform应用程序界面
NanUI是什么
NanUI基于ChromiumFX項(xiàng)目進(jìn)行開發(fā),它能讓你在你的Winform應(yīng)用程序中使用HTML5/CSS3/Javascript等網(wǎng)頁技術(shù)來呈現(xiàn)用戶界面(類似Electron)。同時(shí)NanUI提供了原生窗口和定制化的無標(biāo)題欄無邊框窗口,你能使用全部的網(wǎng)頁技術(shù)來設(shè)計(jì)和呈現(xiàn)你的應(yīng)用程序界面。
開源方式
NanUI基于MIT協(xié)議,所以無論你使用NanUI來開發(fā)商業(yè)項(xiàng)目或者開源、免費(fèi)項(xiàng)目都將不受任何限制,只需要遵照協(xié)議文件中規(guī)定的,在你的軟件中聲明使用了NanUI技術(shù)即可。
系列文檔
NanUI簡介
開始使用NanUI
打包并使用內(nèi)嵌式的HTML/CSS/JS資源
使用網(wǎng)頁來設(shè)計(jì)整個(gè)窗口
如何實(shí)現(xiàn)C#與Javascript相互掉用(待更新。。。)
如何處理NanUI中的下載過程 - DonwloadHandler的使用(待更新。。。)
如何處理NanUI中的彈窗過程 - LifeSpanHandler的使用(待更新。。。)
如何控制Javascript對(duì)話框 - JsDialogHandler的使用(待更新。。。)
自定義資源處理程序 (待更新。。。)
源碼和包
你可以通過GitHub獲取NanUI的源碼以及示例代碼,穩(wěn)定版的NanUI包通過Nuget進(jìn)行分發(fā)。NanUI支持.NET4.0/4.5/4.6/4.7和更新版本的Windows窗體應(yīng)用。
獲取源碼
git clone https://github.com/NetDimension/NanUI.gitNuget包管理器
常規(guī)版本(CEF 3.2987.1601.gf035232 / Chromium 57.0.2987.133)
PM> Install-Package NetDimension.NanUIWindowXP版本(CEF 3.2526.1366.g8617e7c / Chromium 47.0.2526.80)
PM> Install-Package NetDimension.NanUI.XP推薦使用Nuget包管理器安裝NanUI程序集將自動(dòng)安裝對(duì)應(yīng)的CEF依賴項(xiàng),一鍵安裝方便使用。
如何編譯源碼和示例
編譯當(dāng)前版本的NanUI需要支持C#7.0語法的編譯器,推薦的編譯工具有且只有Visual Studio 2017。
如何使用
初始化NanUI
namespace TestApplication{ ? ?using NetDimension.NanUI; ?
?static class Program{[STAThread] ? ? ? ?static void Main(string[] args) ? ? ? ?{Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false); ? ? ? ? ?
?//初始化CEF: 設(shè)置CEF的相關(guān)Path//如果要使用Nuget自動(dòng)下載的fx文件夾結(jié)構(gòu),需要手動(dòng)指定各個(gè)文件夾的路徑var result = Bootstrap.Load(PlatformArch.Auto, System.IO.Path.Combine(Application.StartupPath, "fx"), System.IO.Path.Combine(Application.StartupPath, "fx\\Resources"), System.IO.Path.Combine(Application.StartupPath, "fx\\Resources\\locales")); ? ? ? ? ? ?if (result){ ? ? ? ? ? ? ? ?// Load embedded html/css resources in assembly.Bootstrap.RegisterAssemblyResources(System.Reflection.Assembly.GetExecutingAssembly());Application.Run(new Form1());Application.Exit();}}} }
使用原生的窗口樣式來使用NanUI
namespace TestApplication{ ??public partial class Form1 : Formium{ ? ? ? ?public Form1() ? ? ? ? ?
?//Load embedded resource index.html and not set form to no border style by the second parameter.: base("http://res.app.local/index.html", false) ? ? ?
? ?{InitializeComponent();}} }
使用無邊框模式來使用NanUI
namespace TestApplication{ ? ?public partial class Form1 : Formium{ ? ? ? ?public Form1() ? ? ? ? ? ?//Load embedded resource index.html and set form to no border style by igrone the second parameter or set it to true.: base("http://res.app.local/index.html") ? ? ? ?{InitializeComponent();}} }請(qǐng)注意:如果使用Visual Studio 2015或者更低的版本開發(fā)和調(diào)試NanUI應(yīng)用程序,需要在項(xiàng)目屬性的調(diào)試選項(xiàng)卡中關(guān)閉“啟用VS承載進(jìn)程”選項(xiàng),否則調(diào)試時(shí)將出現(xiàn)頁面不加載白屏的情況。如圖所示:
社群和幫助
GitHub
https://github.com/NetDimension/NanUI/
交流群QQ群
521854872
原文地址:https://www.cnblogs.com/linxuanchen/p/NanUI-Introduction.html
.NET社區(qū)新聞,深度好文,歡迎訪問公眾號(hào)文章匯總 http://www.csharpkit.com
總結(jié)
以上是生活随笔為你收集整理的开源组件NanUI一周年 - 使用HTML/CSS/JS来构建.Net Winform应用程序界面的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 助力中小企业级连云端,促进工业互联网平台
- 下一篇: ABP前端使用阿里云angular2 U