01 — 前言:題外的話 大家可能發(fā)現(xiàn)這個(gè)號(hào)現(xiàn)在原創(chuàng)越來(lái)越少了,其實(shí)小編并沒有放棄持續(xù)更新,只是把一手原創(chuàng)放到了 【dotnet編程大全】這個(gè)號(hào)了,那個(gè)號(hào)目前原創(chuàng)主要更新的是wpf mvvm方面的知識(shí),框架用的Caliburn.Micro,關(guān)于這個(gè)框架介紹,不了解的自行百度。有興趣學(xué)習(xí)的可以關(guān)注: 相關(guān)經(jīng)典原創(chuàng)文章鏈接:點(diǎn)擊可以查看原文 C# WPF框架Caliburn.Micro入門實(shí)例1 C# WPF MVVM項(xiàng)目實(shí)戰(zhàn)(進(jìn)階①) C# WPF MVVM項(xiàng)目實(shí)戰(zhàn)(進(jìn)階②) C# WPF mvvm模式下combobox綁定(list<enum>、Dictionary<int,string>) C# WPF MVVM模式下在主窗體顯示子窗體并獲取結(jié)果 C# WPF Caliburn.Micro框架下利用Mef加載其它項(xiàng)目界面 C# WPF文本框TextEdit不以科學(xué)計(jì)數(shù)法顯示 C# datagridview、datagrid、GridControl增加行號(hào) C# 看懂這100+行代碼,你就真正入門了(經(jīng)典) C# WPF項(xiàng)目實(shí)戰(zhàn)(經(jīng)典) WPF XAML 為項(xiàng)目設(shè)置全局樣式 02 — 主窗體 String title = LogoConfig.GetLogoConfig("Title"); if(title.Length>0) { this.Text = title; panelCaption.Text = title; }
String logoImage = LogoConfig.GetLogoConfig("Logo"); if (logoImage.Length > 0) { logoImage = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "image\\" + logoImage); Image logo = Image.FromFile(logoImage); pictureLogo.Image = logo; }
logoImage = LogoConfig.GetLogoConfig("Image"); if (logoImage.Length > 0) { logoImage = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "image\\" + logoImage); Image brand = Image.FromFile(logoImage); pictureBrand.Image = brand; } 03 — 類文件 using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace EvenTHZSystem { class LogoConfig { static Dictionary<string, string> logoconfigmap = new Dictionary<string, string>(); static bool bInitialized = false; public static string GetLogoConfig(string key) {
if (!bInitialized) { try { String logoConfig = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + "image\\logo.config");
using (StreamReader reader = new StreamReader(logoConfig)) { while (!reader.EndOfStream) { String line = reader.ReadLine(); string[] kv = line.Split('='); if (kv != null) { logoconfigmap.Add(kv[0], kv[1]); } } }
} catch { } bInitialized = true; }
string value = ""; try { value = logoconfigmap[key]; } catch { } return value; } } }
配置文件: |
|
來(lái)自: ontheroad96j47 > 《待分類》