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版本中,開發者可以使用WinForm產品線(通過DevExpress AlertControl和ToastNotificationManager)創建兩種類型的通知/警報,最近技術團隊還推薦使用DevExpress ToastNotificationManager來顯示原生 Windows 10+ 通知。
DevExpress Universal Subscription官方最新版免費下載試用,歷史版本下載,在線文檔和幫助文件下載-慧都網
盡管自定義選項有些有限(toast 僅提供九個布局模板),但ToastNotificationManager 代表了比傳統的基于面板的AlertControl更好、更現代的替代方案。
在最新版中為AlertControl發布的HTML & CSS 模板,允許開發人員創建時尚的警告通知,同時可利用AlertControl 本身的簡單性。下圖說明了技術團隊提供的一些示例模板(查找您喜歡的模板并將其復制到項目中):
大多數通知只是一個帶有幾個文本塊、圖像和按鈕的矩形,設計這樣簡單的對象對每個人來說都應該相對容易——無論您有 HTML 和 CSS 經驗,還是開始在WinForms 應用程序中利用其潛力。 例如以下模板創建一個帶有圖標、標題、描述和“確定”按鈕的通知。
<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>
請注意,在此示例標記中,通知標題和說明是靜態字符串。 如果您要為用戶顯示一條消息,此解決方案就可以正常工作。
當然我們的數據綁定功能提供了更大的靈活性——您可以創建一個模板并將不同的數據對象傳遞給它。 因此,您可以為多個通知消息重用一個模板。
如果您更喜歡此選項,請使用 ${Data_property_name} 占位符,如下所示:
<div class="text">${Caption}</div>
<div class="text">${Text}</div>
“Caption”和“Text”是標準占位符,可以通過 AlertControl.Show 重載直接替換:
alertControl1.Show(this, "Sample caption", "Sample notification text");
您可以添加模板設計所需的任意數量的占位符,但請記住處理 AlertControl.BeforeFormShow 事件并將數據對象傳遞給 e.HtmlPopup.DataContext 屬性。 例如,下面的代碼使用 div 元素來顯示由五個占位符組合而成的字符串:兩個用于字符串值(FullName、Ticker),兩個用于數字(Percentage、Price),一個用于自定義 Direction 枚舉值。
<div class="message-text">
${FullName} ({Ticker}) {Direction} {Percentage}%. The current price is ${Price}.
</div>
通知圖像也在運行時檢索,img 標簽使用占位符替代靜態 src 屬性值。
<img src="${StockImage}" class="message-image" />
此示例應用程序使用 StockInfo 類對象作為數據項。
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
}
當數據項的 "Price" 值在短時間內發生顯著變化時會觸發通知,相應的項目分配給 AlertControl.BeforeFormShow 事件處理程序中的 e.HtmlPopup.DataContext 屬性。
void AlertControl1_BeforeFormShow(object sender, AlertFormEventArgs e) {
// TODO: Retrieve a data item
e.HtmlPopup.DataContext = myStockInfoInstance;
}
因此,通知會從指定為 DataContext 的數據項中檢索其 ${Field_Name} 占位符的數據。 請注意,邊條的顏色會根據 "Direction" 枚舉值而變化。
DevExpress WinForm
DevExpress WinForm擁有180+組件和UI庫,能為Windows Forms平臺創建具有影響力的業務解決方案。DevExpress WinForms能完美構建流暢、美觀且易于使用的應用程序,無論是Office風格的界面,還是分析處理大批量的業務數據,它都能輕松勝任!
ataGear數據可視化分析平臺提供了導入靜態HTML模板的功能,使您可以利用已有的任意HTML網頁資源制作數據可視化看板。
首先,您需要準備一套已設置好布局的靜態HTML模板,其中包含的HTML網頁及相關資源,例如:
index.html
css/
|---style.css
|---images
|---bg.png
|---bg_head.png
js/
|---index.js
|---common.js
它的靜態效果如下圖所示:
然后,將這套靜態HTML模板壓縮到一個ZIP文件中,使用DataGear看板的[導入]功能,將這個ZIP文件導入為看板。
導入成功后,打開看板編輯界面,為HTML模板中的div元素添加dg-chart-widget屬性綁定圖表組件,例如:
...
<div class="panel-content"
dg-chart-widget="圖表組件ID"></div>
...
其中,圖表組件ID 是圖表管理列表中的一個圖表條目ID。
設置完所有的div元素后,一個數據可視化看板就制作完成了,點擊[保存并展示]按鈕,即可查看展示效果。
等等,默認的展示效果差強人意……,沒關系,自定義展示效果也很簡單!
首先,自定義圖表主題,打開看板編輯界面,為<body>標簽添加dg-chart-theme自定義圖表主題,如下代碼:
...
<body dg-chart-theme="{color:'#F0F0F0',
backgroundColor:'transparent',
actualBackgroundColor:'#050d3c'}">
...
</body>
...
然后,自定義圖表設置項,為<body>標簽添加dg-chart-options屬性,定義全局圖表設置項:
<body ... dg-chart-options="{title:{show:false},
legend:{top:0},grid:{top:25}}">
<!--隱藏標題、圖例頂部展示、坐標系距頂部25像素,具體參考echarts設置項-->
大功告成!
官網地址:http://www.datagear.tech
源碼地址:
https://gitee.com/datagear/datagear
https://github.com/datageartech/datagear
們可以使用以下的方式去渲染html
func main() {
router := gin.Default()
router.LoadHTMLGlob("templates/*")
//router.LoadHTMLFiles("templates/template1.html", "templates/template2.html")
router.GET("/index", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"title": "Main website",
})
})
router.Run(":8080")
}
在html中我們可以使用特殊的雙花括號來渲染title這個值
<html>
<h1>
{{ .title }}
</h1>
</html>
值得注意的是這種方式并不是gin特有的,而是golang特有的,它還有其他的模板語法。
{{$article := "hello"}}
也可以給變量賦值
{{$article := .ArticleContent}}
{{funcname .arg1 .arg2}}
{{if .condition}}
{{end}}
{{if .condition1}}
{{else if .contition2}}
{{end}}
{{if not .condition}}
{{end}}
{{if and .condition1 .condition2}}
{{end}}
{{if or .condition1 .condition2}}
{{end}}
{{if eq .var1 .var2}}
{{end}}
{{if ne .var1 .var2}}
{{end}}
(less than){{if lt .var1 .var2}}
{{end}}
{{if le .var1 .var2}}
{{end}}
{{if gt .var1 .var2}}
{{end}}
{{if ge .var1 .var2}}
{{end}}
{{range $i, $v := .slice}}
{{end}}
{{template "navbar"}}
*請認真填寫需求信息,我們會在24小時內與您取得聯系。