⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setupform.cs

📁 Csharp编写的关于智能手机(smartphone)闹钟程序
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace MyClock
{
	/// <summary>
	/// SetupForm 的摘要说明。
	/// </summary>
	public class SetupForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.ListBox BgList;
		private System.Windows.Forms.PictureBox picBg;
		private System.Windows.Forms.Button BtnOk;
		private System.Windows.Forms.Button BtnCancle;

		public string SkinName,SkinFile;
		private System.Windows.Forms.GroupBox groupBox2;
		public String BackColor1 , BackColor2 , FontColor ;
		public bool SoundH,SoundHH;
		private System.Windows.Forms.Button BtnColor1;
		private System.Windows.Forms.Button BtnColor2;
		private System.Windows.Forms.Button BtnColor3;
		private System.Windows.Forms.CheckBox checkBoxSoundH;
		private System.Windows.Forms.CheckBox checkBoxSoundHH;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public SetupForm()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//

			LoadData();

			this.BtnColor1 .BackColor = Color.FromName (BackColor1);
			this.BtnColor2.BackColor = Color.FromName (BackColor2);
			this.BtnColor3 .BackColor = Color.FromName (FontColor);

			this.checkBoxSoundH .Checked = SoundH;
			this.checkBoxSoundHH .Checked = SoundHH ;
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.picBg = new System.Windows.Forms.PictureBox();
			this.BgList = new System.Windows.Forms.ListBox();
			this.BtnOk = new System.Windows.Forms.Button();
			this.BtnCancle = new System.Windows.Forms.Button();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.BtnColor3 = new System.Windows.Forms.Button();
			this.BtnColor2 = new System.Windows.Forms.Button();
			this.BtnColor1 = new System.Windows.Forms.Button();
			this.checkBoxSoundH = new System.Windows.Forms.CheckBox();
			this.checkBoxSoundHH = new System.Windows.Forms.CheckBox();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.picBg,
																					this.BgList});
			this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox1.Location = new System.Drawing.Point(8, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(304, 152);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "背景设置";
			// 
			// picBg
			// 
			this.picBg.BackColor = System.Drawing.Color.Black;
			this.picBg.Location = new System.Drawing.Point(136, 24);
			this.picBg.Name = "picBg";
			this.picBg.Size = new System.Drawing.Size(144, 112);
			this.picBg.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
			this.picBg.TabIndex = 1;
			this.picBg.TabStop = false;
			// 
			// BgList
			// 
			this.BgList.ItemHeight = 12;
			this.BgList.Items.AddRange(new object[] {
														"巴布豆",
														"米老鼠",
														"面板",
														"史努比",
														"小女孩",
														"鱼骨头"});
			this.BgList.Location = new System.Drawing.Point(16, 24);
			this.BgList.Name = "BgList";
			this.BgList.Size = new System.Drawing.Size(88, 112);
			this.BgList.TabIndex = 0;
			this.BgList.SelectedIndexChanged += new System.EventHandler(this.BgList_SelectedIndexChanged);
			// 
			// BtnOk
			// 
			this.BtnOk.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.BtnOk.Location = new System.Drawing.Point(144, 264);
			this.BtnOk.Name = "BtnOk";
			this.BtnOk.TabIndex = 1;
			this.BtnOk.Text = "确定";
			this.BtnOk.Click += new System.EventHandler(this.BtnOk_Click);
			// 
			// BtnCancle
			// 
			this.BtnCancle.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.BtnCancle.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.BtnCancle.Location = new System.Drawing.Point(236, 264);
			this.BtnCancle.Name = "BtnCancle";
			this.BtnCancle.TabIndex = 2;
			this.BtnCancle.Text = "取消";
			this.BtnCancle.Click += new System.EventHandler(this.BtnCancle_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.checkBoxSoundHH,
																					this.checkBoxSoundH,
																					this.BtnColor3,
																					this.BtnColor2,
																					this.BtnColor1});
			this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox2.Location = new System.Drawing.Point(8, 168);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(304, 88);
			this.groupBox2.TabIndex = 3;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "时钟面板";
			// 
			// BtnColor3
			// 
			this.BtnColor3.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.BtnColor3.Location = new System.Drawing.Point(208, 24);
			this.BtnColor3.Name = "BtnColor3";
			this.BtnColor3.TabIndex = 2;
			this.BtnColor3.Text = "字体颜色";
			this.BtnColor3.Click += new System.EventHandler(this.BtnColor3_Click);
			// 
			// BtnColor2
			// 
			this.BtnColor2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.BtnColor2.Location = new System.Drawing.Point(112, 24);
			this.BtnColor2.Name = "BtnColor2";
			this.BtnColor2.TabIndex = 1;
			this.BtnColor2.Text = "背景色二";
			this.BtnColor2.Click += new System.EventHandler(this.BtnColor2_Click);
			// 
			// BtnColor1
			// 
			this.BtnColor1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.BtnColor1.Location = new System.Drawing.Point(16, 24);
			this.BtnColor1.Name = "BtnColor1";
			this.BtnColor1.TabIndex = 0;
			this.BtnColor1.Text = "背景色一";
			this.BtnColor1.Click += new System.EventHandler(this.BtnColor1_Click);
			// 
			// checkBoxSoundH
			// 
			this.checkBoxSoundH.Location = new System.Drawing.Point(16, 56);
			this.checkBoxSoundH.Name = "checkBoxSoundH";
			this.checkBoxSoundH.TabIndex = 3;
			this.checkBoxSoundH.Text = "整点声音报时";
			// 
			// checkBoxSoundHH
			// 
			this.checkBoxSoundHH.Location = new System.Drawing.Point(192, 56);
			this.checkBoxSoundHH.Name = "checkBoxSoundHH";
			this.checkBoxSoundHH.TabIndex = 4;
			this.checkBoxSoundHH.Text = "半点声音报时";
			// 
			// SetupForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.BtnCancle;
			this.ClientSize = new System.Drawing.Size(322, 295);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.groupBox2,
																		  this.BtnCancle,
																		  this.BtnOk,
																		  this.groupBox1});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "SetupForm";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "程序设置";
			this.TopMost = true;
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void BgList_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			SkinName = this.BgList .SelectedItem .ToString ();
			SkinFile = "Skin\\" + SkinName + ".bmp";

			Bitmap bmp = new Bitmap (SkinFile);
			this.picBg .Image = bmp ;
		}

		private void BtnCancle_Click(object sender, System.EventArgs e)
		{
			this.BackColor1 = "";
			this.SkinFile = "";
			this.Close ();
		}

		private void BtnColor1_Click(object sender, System.EventArgs e)
		{
			ColorPicker dlg = new ColorPicker ();
			DialogResult result = dlg.ShowDialog ();
			if(dlg.SelectedColor != "")
			{
				this.BtnColor1 .BackColor = Color.FromName (dlg.SelectedColor );
				this.BackColor1 =dlg.SelectedColor;
			}

		}

		private void BtnColor2_Click(object sender, System.EventArgs e)
		{
			ColorPicker dlg = new ColorPicker ();
			DialogResult result = dlg.ShowDialog ();
			if(dlg.SelectedColor != "")
			{
				this.BtnColor2 .BackColor = Color.FromName (dlg.SelectedColor );
				this.BackColor2 =dlg.SelectedColor;
			}

	
		}

		private void BtnColor3_Click(object sender, System.EventArgs e)
		{
			ColorPicker dlg = new ColorPicker ();
			DialogResult result = dlg.ShowDialog ();
			if(dlg.SelectedColor != "")
			{
				this.BtnColor3 .BackColor = Color.FromName (dlg.SelectedColor );
				this.FontColor = dlg.SelectedColor ;
			}

		}

		private void BtnOk_Click(object sender, System.EventArgs e)
		{
			if(this.BgList .SelectedItem == null )
				this.SkinFile = "" ;

			SoundH = this.checkBoxSoundH .Checked ;
			SoundHH = this.checkBoxSoundHH .Checked ;
			this.SaveData ();
			this.Close ();
		}


		private void LoadData()
		{
			string path = Application.StartupPath ;

			Ini ini = new Ini(path+"\\Set.ini"); 

			//BmpFileStr = ini.IniReadValue ("Main","BmpFileStr");

			FontColor = ini.IniReadValue ("Main","FontColor");
			BackColor1 = ini.IniReadValue ("Main","LabelColorOne");
			BackColor2 = ini.IniReadValue ("Main","LabelColorTwo");

			SoundH = Convert.ToBoolean (ini.IniReadValue ("Main","SoundH"));
			SoundHH = Convert.ToBoolean (ini.IniReadValue ("Main","SoundHH"));

		}

		private void SaveData()
		{
			string path = Application.StartupPath ;

			Ini ini = new Ini(path+"\\Set.ini"); 

			ini.IniWriteValue ("Main","FontColor",FontColor);
			ini.IniWriteValue ("Main","LabelColorOne",BackColor1);
			ini.IniWriteValue ("Main","LabelColorTwo",BackColor2);

			ini.IniWriteValue ("Main","SoundH",SoundH.ToString ());
			ini.IniWriteValue ("Main","SoundHH",SoundHH.ToString ());
		}


	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -