01
—
前言:题外的话
大家可能发现这个号现在原创越来越少了,其实小编并没有放弃持续更新,只是把一手原创放到了 【dotnet编程大全】这个号了,那个号目前原创主要更新的是wpf mvvm方面的知识,框架用的Caliburn.Micro,关于这个框架介绍,不了解的自行百度。有兴趣学习的可以关注:
相关经典原创文章链接:点击可以查看原文
C# WPF框架Caliburn.Micro快速搭建
C# WPF框架Caliburn.Micro入门实例1
C# WPF MVVM项目实战(进阶①)
C# WPF MVVM项目实战(进阶②)
C# WPF项目实战
C# WPF mvvm模式下combobox绑定(list<enum>、Dictionary<int,string>)
C# WPF MVVM模式下在主窗体显示子窗体并获取结果
C# WPF Caliburn.Micro框架下利用Mef加载其它项目界面
C# WPF文本框TextEdit不以科学计数法显示
C# 通过正则表达式来限制控件输入有效性
C# datagridview、datagrid、GridControl增加行号
C# =>符号的使用
C# 无意间写了一段线程死锁的代码
C# 看懂这100+行代码,你就真正入门了(经典)
C# WPF项目实战(经典)
WPF 如何修改button圆角(经典)
WPF XAML 为项目设置全局样式
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;}}
}
配置文件: