資源簡介
C#項目開發案例+源代碼,適合想快速入門C#+.NET的學習。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
namespace?VideoMonitor
{
????public?partial?class?frmAutoVideo?:?Form
????{
????????public?frmAutoVideo()
????????{
????????????InitializeComponent();
????????}
????????#region?實例化公共類對象,并定義公共變量
????????CommonClass.DataOperate?dataoperate?=?new?VideoMonitor.CommonClass.DataOperate();
????????string?strName?=?Application.StartupPath?+?“\\VideoSet.ini“;//定義要讀取的INI文件
????????#endregion
????????//窗體加載時讀取INI設置文件中的內容,并顯示在相應的下拉列表中
????????private?void?frmAutoVideo_Load(object?sender?EventArgs?e)
????????{
????????????timer1.Start();
????????????for?(int?i?=?1;?i?31;?i++)
????????????{
????????????????cboxDate.Items.Add(i);//給日期下拉列表賦值
????????????}
????????????cboxVideo.Text?=?dataoperate.ReadString(“VideoSet“?“Frequency“?““?strName);
????????????NUDownHour.Value?=?Convert.ToDecimal(dataoperate.ReadString(“VideoSet“?“Hour“?““?strName));
????????????NUDownMin.Value?=?Convert.ToDecimal(dataoperate.ReadString(“VideoSet“?“Min“?““?strName));
????????????cboxWeek.Text?=?dataoperate.ReadString(“VideoSet“?“Week“?““?strName);
????????????cboxDate.Text?=?dataoperate.ReadString(“VideoSet“?“Date“?““?strName);
????????}
????????//單擊“確定”按鈕,修改INI設置文件的內容
????????private?void?btnSure_Click(object?sender?EventArgs?e)
????????{
????????????CommonClass.DataOperate.WritePrivateProfileString(“VideoSet“?“Frequency“?cboxVideo.Text?strName);
????????????CommonClass.DataOperate.WritePrivateProfileString(“VideoSet“?“Hour“?NUDownHour.Value.ToString()?strName);
????????????CommonClass.DataOperate.WritePrivateProfileString(“VideoSet“?“Min“?NUDownMin.Value.ToString()?strName);
????????????CommonClass.DataOperate.WritePrivateProfileString(“VideoSet“?“Week“?cboxWeek.Text?strName);
????????????CommonClass.DataOperate.WritePrivateProfileString(“VideoSet“?“Date“?cboxDate.Text?strName);
????????????MessageBox.Show(“定時錄像設置成功“?“提示“?MessageBoxButtons.OK?MessageBoxIcon.Information);
????????}
????????//在計時器中調用自定義方法監控各控件可用狀態
????????private?void?timer1_Tick(object?sender?EventArgs?e)
????????{
????????????ControlState();
????????}
????????//關閉當前窗體
????????private?void?btnClose_Click(object?sender?EventArgs?e)
????????{
????????????this.Close();
????????}
????????#region?根據錄像頻率下拉列表框中的選擇項控制其他控件的可用狀態
????????///?
????????///?根據錄像頻率下拉列表框中的選擇項控制其他控件的可用狀態
????????///?
????????private?void?ControlState()
????????{
????????????int?index?=?cboxVideo.SelectedIndex;
????????????switch?(index)
????????????{
????????????????case?0:
????????????????????NUDownHour.Enabled?=?NUDownMin.Enabled?=?true;
????????????????????cboxWeek.Enabled?=?cboxDate.Enabled?=?false;
????????????????????break;
????????????????case?1:
????????????????????NUDownHour.Enabled?=?NUDownMin.Enabled?=?cboxWeek.Enabled?=?true;
??????????????
- 上一篇:c#操作mongodb含完整源碼
- 下一篇:頂尖LS2X條碼秤開發.rar
評論
共有 條評論