You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.9 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceAppDemo
{
public partial class ChangeSkinForm : Form
{
public ChangeSkinForm()
{
InitializeComponent();
}
string gSkinName = "";
private void btnOK_Click(object sender, EventArgs e)
{
//配置文件写入操作
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["ConfigSkinName"].Value = gSkinName;
config.Save(ConfigurationSaveMode.Modified);
MessageBox.Show("皮肤更换成功,请重启系统后查看皮肤效果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
return;
}
private void ChangeSkinForm_Load(object sender, EventArgs e)
{
ConfigurationManager.RefreshSection("appSettings"); //强制重新载入
string sSkinName = ConfigurationManager.AppSettings.Get("ConfigSkinName");
this.lbSkin.DataSource = new DirectoryInfo("Skins").GetFiles();
this.lbSkin.DisplayMember = "Name";
for (int i = 0; i < lbSkin.Items.Count; i++)
{
if (lbSkin.Items[i].ToString() == sSkinName)
{
this.lbSkin.SelectedIndex = i;
break;
}
}
}
private void btnNo_Click(object sender, EventArgs e)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["ConfigSkinName"].Value = "Default";
config.Save(ConfigurationSaveMode.Modified);
MessageBox.Show("恢复系统默认皮肤成功,请重启系统后查看效果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
return;
}
private void lbSkin_DoubleClick(object sender, EventArgs e)
{
//配置文件写入操作
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["ConfigSkinName"].Value = gSkinName;
config.Save(ConfigurationSaveMode.Modified);
MessageBox.Show("皮肤更换成功,请重启系统后查看皮肤效果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
return;
}
private void lbSkin_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.lbSkin.SelectedItem != null)
gSkinName = (this.lbSkin.SelectedItem as FileInfo).Name;
}
}
}