Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
最新的DevExpress WinForm版本中,開(kāi)發(fā)者可以使用WinForm產(chǎn)品線(通過(guò)DevExpress AlertControl和ToastNotificationManager)創(chuàng)建兩種類(lèi)型的通知/警報(bào),最近技術(shù)團(tuán)隊(duì)還推薦使用DevExpress ToastNotificationManager來(lái)顯示原生 Windows 10+ 通知。
DevExpress Universal Subscription官方最新版免費(fèi)下載試用,歷史版本下載,在線文檔和幫助文件下載-慧都網(wǎng)
盡管自定義選項(xiàng)有些有限(toast 僅提供九個(gè)布局模板),但ToastNotificationManager 代表了比傳統(tǒng)的基于面板的AlertControl更好、更現(xiàn)代的替代方案。
在最新版中為AlertControl發(fā)布的HTML & CSS 模板,允許開(kāi)發(fā)人員創(chuàng)建時(shí)尚的警告通知,同時(shí)可利用AlertControl 本身的簡(jiǎn)單性。下圖說(shuō)明了技術(shù)團(tuán)隊(duì)提供的一些示例模板(查找您喜歡的模板并將其復(fù)制到項(xiàng)目中):
大多數(shù)通知只是一個(gè)帶有幾個(gè)文本塊、圖像和按鈕的矩形,設(shè)計(jì)這樣簡(jiǎn)單的對(duì)象對(duì)每個(gè)人來(lái)說(shuō)都應(yīng)該相對(duì)容易——無(wú)論您有 HTML 和 CSS 經(jīng)驗(yàn),還是開(kāi)始在WinForms 應(yīng)用程序中利用其潛力。 例如以下模板創(chuàng)建一個(gè)帶有圖標(biāo)、標(biāo)題、描述和“確定”按鈕的通知。
<div class="container">
<div class="popup">
<img src="${SvgImage}" class="image" />
<div class="caption">Notification Title</div>
<div class="text">This notification uses a web-inspired template.</div>
<div id="okButton" class="ok-button">OK</div>
</div>
</div>
請(qǐng)注意,在此示例標(biāo)記中,通知標(biāo)題和說(shuō)明是靜態(tài)字符串。 如果您要為用戶(hù)顯示一條消息,此解決方案就可以正常工作。
當(dāng)然我們的數(shù)據(jù)綁定功能提供了更大的靈活性——您可以創(chuàng)建一個(gè)模板并將不同的數(shù)據(jù)對(duì)象傳遞給它。 因此,您可以為多個(gè)通知消息重用一個(gè)模板。
如果您更喜歡此選項(xiàng),請(qǐng)使用 ${Data_property_name} 占位符,如下所示:
<div class="text">${Caption}</div>
<div class="text">${Text}</div>
“Caption”和“Text”是標(biāo)準(zhǔn)占位符,可以通過(guò) AlertControl.Show 重載直接替換:
alertControl1.Show(this, "Sample caption", "Sample notification text");
您可以添加模板設(shè)計(jì)所需的任意數(shù)量的占位符,但請(qǐng)記住處理 AlertControl.BeforeFormShow 事件并將數(shù)據(jù)對(duì)象傳遞給 e.HtmlPopup.DataContext 屬性。 例如,下面的代碼使用 div 元素來(lái)顯示由五個(gè)占位符組合而成的字符串:兩個(gè)用于字符串值(FullName、Ticker),兩個(gè)用于數(shù)字(Percentage、Price),一個(gè)用于自定義 Direction 枚舉值。
<div class="message-text">
${FullName} ({Ticker}) {Direction} {Percentage}%. The current price is ${Price}.
</div>
通知圖像也在運(yùn)行時(shí)檢索,img 標(biāo)簽使用占位符替代靜態(tài) src 屬性值。
<img src="${StockImage}" class="message-image" />
此示例應(yīng)用程序使用 StockInfo 類(lèi)對(duì)象作為數(shù)據(jù)項(xiàng)。
public class StockInfo {
public StockInfo(string ticker, string fullName, Direction direction,
double percentage, double price, SvgImage img) {
Ticker = ticker;
FullName = fullName;
Direction = direction;
Percentage = percentage;
Price = price;
StockImage = img;
}
public string Ticker { get; set; }
public string FullName { get; set; }
public Direction Direction { get; set; }
public double Percentage { get; set; }
public double Price { get; set; }
public SvgImage StockImage { get; set; }
}
public enum Direction {
[Description("rises")]
Up,
[Description("falls")]
Down
}
當(dāng)數(shù)據(jù)項(xiàng)的 "Price" 值在短時(shí)間內(nèi)發(fā)生顯著變化時(shí)會(huì)觸發(fā)通知,相應(yīng)的項(xiàng)目分配給 AlertControl.BeforeFormShow 事件處理程序中的 e.HtmlPopup.DataContext 屬性。
void AlertControl1_BeforeFormShow(object sender, AlertFormEventArgs e) {
// TODO: Retrieve a data item
e.HtmlPopup.DataContext = myStockInfoInstance;
}
因此,通知會(huì)從指定為 DataContext 的數(shù)據(jù)項(xiàng)中檢索其 ${Field_Name} 占位符的數(shù)據(jù)。 請(qǐng)注意,邊條的顏色會(huì)根據(jù) "Direction" 枚舉值而變化。
DevExpress WinForm
DevExpress WinForm擁有180+組件和UI庫(kù),能為Windows Forms平臺(tái)創(chuàng)建具有影響力的業(yè)務(wù)解決方案。DevExpress WinForms能完美構(gòu)建流暢、美觀且易于使用的應(yīng)用程序,無(wú)論是Office風(fēng)格的界面,還是分析處理大批量的業(yè)務(wù)數(shù)據(jù),它都能輕松勝任!
PNotify是一個(gè)原生JavaScript通知和確認(rèn)/提示庫(kù)。PNotify可以根據(jù)Web Notifications規(guī)范提供桌面通知,并返回瀏覽器內(nèi)通知。PNotify是目前筆者正在項(xiàng)目中使用的一個(gè)通知提示組件,功能非常豐富,可以讓你的Web項(xiàng)目通知和提示更加的優(yōu)雅!
https://github.com/sciactive/pnotify
npm install --save pnotify # Material style: npm install --save material-design-icons # Animate module: npm install --save animate.css # NonBlock module: npm install --save nonblockjs
PNotify模塊目錄如下:
要想看真實(shí)效果的朋友可以直接看官方提供的demo,非常的豐富示例,絕對(duì)讓你有使用它的沖動(dòng),咱們通過(guò)截圖來(lái)看一下:
具體的效果只有使用了之后才會(huì)體會(huì)到,絕對(duì)值得使用!
import PNotify from 'pnotify/dist/es/PNotify'; import PNotifyButtons from 'pnotify/dist/es/PNotifyButtons'; PNotify.alert('Notice me, senpai!');
import PNotify from 'pnotify/dist/es/PNotify'; import PNotifyButtons from 'pnotify/dist/es/PNotifyButtons'; //... export class WhateverComponent { constructor() { PNotifyButtons; // Initiate the module. Important! PNotify.alert('Notice me, senpai!'); } }
<script type="text/javascript" src="node_modules/pnotify/dist/iife/PNotify.js"></script> <script type="text/javascript" src="node_modules/pnotify/dist/iife/PNotifyButtons.js"></script> <script type="text/javascript"> PNotify.alert('Notice me, senpai!'); </script>
import PNotify from 'node_modules/pnotify/dist/es/PNotify.js'; import PNotifyButtons from 'node_modules/pnotify/dist/es/PNotifyButtons.js'; PNotify.alert('Notice me, senpai!');
<link href="node_modules/pnotify/dist/PNotifyBrightTheme.css" rel="stylesheet" type="text/css" />
Material 樣式模塊:
import PNotifyStyleMaterial from 'pnotify/dist/es/PNotifyStyleMaterial.js'; // or var PNotifyStyleMaterial = require('pnotify/dist/umd/PNotifyStyleMaterial.js'); // Set default styling. PNotify.defaults.styling = 'material'; // This icon setting requires the Material Icons font. (See below.) PNotify.defaults.icons = 'material';
# The official Google package: npm install --save material-design-icons # OR, An unofficial package that only includes the font: npm install --save material-design-icon-fonts
要將Bootstrap設(shè)置為默認(rèn)樣式,請(qǐng)?jiān)趯?dǎo)入PNotify后從下面包含相應(yīng)的設(shè)置:
PNotify.defaults.styling = 'bootstrap3'; // Bootstrap version 3 PNotify.defaults.icons = 'bootstrap3'; // glyphicons // or PNotify.defaults.styling = 'bootstrap4'; // Bootstrap version 4
要將Font Awesome設(shè)置為默認(rèn)圖標(biāo),請(qǐng)?jiān)趯?dǎo)入PNotify后從下面包含相應(yīng)的設(shè)置:
PNotify.defaults.icons = 'fontawesome4'; // Font Awesome 4 // or PNotify.defaults.icons = 'fontawesome5'; // Font Awesome 5
// 手動(dòng)設(shè)置類(lèi)型 PNotify.alert({ text: "I'm an alert.", type: 'notice' }); // 自動(dòng)設(shè)置類(lèi)型。 PNotify.notice({ text: "I'm a notice." }); PNotify.info({ text: "I'm an info message." }); PNotify.success({ text: "I'm a success message." }); PNotify.error({ text: "I'm an error message." });
以上只是簡(jiǎn)單的介紹,如果你想讓你的瀏覽器推送通知不是很簡(jiǎn)陋,筆者認(rèn)為是時(shí)候使用這樣一個(gè)插件來(lái)助你解決這個(gè)問(wèn)題了:
PNotify是筆者用過(guò)的最優(yōu)雅的提示通知組件,推薦給需要的人!
evExpress WinForms擁有180+組件和UI庫(kù),能為Windows Forms平臺(tái)創(chuàng)建具有影響力的業(yè)務(wù)解決方案。DevExpress WinForms能完美構(gòu)建流暢、美觀且易于使用的應(yīng)用程序,無(wú)論是Office風(fēng)格的界面,還是分析處理大批量的業(yè)務(wù)數(shù)據(jù),它都能輕松勝任!
DevExpress WinForm 控件已正式發(fā)布v23.1版本,此版本全新升級(jí)HTML & CSS的可重用模板、增強(qiáng)Ribbon組件功能、新增Office 365樣式等,歡迎下載最新版體驗(yàn)!
DevExpress WinForms Subscription官方最新版免費(fèi)下載試用,歷史版本下載,在線文檔和幫助文件下載-慧都網(wǎng)
DevExpress WinForms HTML & CSS模板庫(kù)包括一組預(yù)先設(shè)計(jì)的模板,這些模板基于官方WinForms演示應(yīng)用程序中使用的模板。您可以“按原樣”使用這些模板,也可以根據(jù)需要進(jìn)行定制。當(dāng)然您也可以創(chuàng)建一個(gè)HTML & CSS模板,將模板保存到庫(kù)中,并在需要時(shí)在任何項(xiàng)目中使用它。
現(xiàn)在可以將圖像標(biāo)簽綁定到具有圖像名稱(chēng)的數(shù)據(jù)源字段中,HTML模板檢查數(shù)據(jù)字段是否包含SVG或位圖。如果沒(méi)有,則模板在SvgImageCollection(分配給控件的htmlages屬性)中查找具有指定名稱(chēng)的圖像。
HTML
<img class="icon" src="${IconName}"/>
DevExpress WinForms Ribbon控件附帶了一個(gè)全新的Office 365渲染樣式。
當(dāng)我們使用新的Office 365樣式時(shí),WinForm Ribbon控件在功能區(qū)表單的頂部顯示一個(gè)搜索框,并在 Ribbon UI的右下方顯示顯示功能區(qū)選項(xiàng)。
使用以下API在其他 Ribbon樣式中啟用新的UI增強(qiáng)功能:
Backstage View(后臺(tái)視圖)項(xiàng)目現(xiàn)在包括一個(gè)新的對(duì)齊選項(xiàng),此選項(xiàng)允許您將項(xiàng)目對(duì)齊到后臺(tái)視圖的頂部和底部,以及標(biāo)題欄和快速訪問(wèn)工具欄的左側(cè)和右側(cè)(當(dāng)它顯示在Ribbon控件下方時(shí))。
C#
backstageViewItem.Alignment = BackstageViewItemAlignment.Bottom;
新版本中實(shí)現(xiàn)了新的API來(lái)顯示受Office啟發(fā)的彈出式通知和警報(bào)。
新的API包括:
C#
using DevExpress.XtraBars.Ribbon;
void ShowMessage() {
RibbonMessageArgs args = new RibbonMessageArgs();
args.Caption = "What's New";
args.Text = "Explore new WinForms-related features we expect to introduce in our first major update this year (v23.1).";
args.Icon = MessageBoxIcon.Information;
args.Buttons = new DialogResult[] { DialogResult.OK };
args.Showing += Args_Showing;
Ribbon.ShowMessage(args);
Ribbon.MessageClosed += Ribbon_MessageClosed;
}
void Ribbon_MessageClosed(object sender, RibbonMessageClosedArgs e) {
if(e.Result == DialogResult.OK)
Data.Utils.SafeProcess.Start("https://community.devexpress.com/blogs/winforms/archive/2023/02/16/devexpress-winforms-roadmap-23-1.aspx");
}
void Args_Showing(object sender, RibbonMessageShowingArgs e) {
e.Buttons[DialogResult.OK].Caption = "Explore Roadmap";
}
Page header項(xiàng)(BarButtonItem和BarCheckitem)可以根據(jù)矢量皮膚中的背景顏色調(diào)整文本和SVG圖標(biāo)的顏色,背景色必須設(shè)置為皮膚顏色(在設(shè)計(jì)時(shí),切換到“DX Skins”選項(xiàng)卡來(lái)選擇皮膚顏色)。
更多DevExpress線上公開(kāi)課、中文教程資訊請(qǐng)上中文網(wǎng)獲取
*請(qǐng)認(rèn)真填寫(xiě)需求信息,我們會(huì)在24小時(shí)內(nèi)與您取得聯(lián)系。