-
大小: 37.48MB文件類型: .7z金幣: 1下載: 0 次發(fā)布日期: 2023-07-05
- 語言: C#
- 標(biāo)簽:
資源簡介
C#項目開發(fā)案例+源代碼,適合想快速入門C#+.NET的學(xué)習(xí)。
代碼片段和文件信息
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設(shè)置文件中的內(nèi)容,并顯示在相應(yīng)的下拉列表中
????????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設(shè)置文件的內(nèi)容
????????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(“定時錄像設(shè)置成功“?“提示“?MessageBoxButtons.OK?MessageBoxIcon.Information);
????????}
????????//在計時器中調(diào)用自定義方法監(jiān)控各控件可用狀態(tài)
????????private?void?timer1_Tick(object?sender?EventArgs?e)
????????{
????????????ControlState();
????????}
????????//關(guān)閉當(dāng)前窗體
????????private?void?btnClose_Click(object?sender?EventArgs?e)
????????{
????????????this.Close();
????????}
????????#region?根據(jù)錄像頻率下拉列表框中的選擇項控制其他控件的可用狀態(tài)
????????///?
????????///?根據(jù)錄像頻率下拉列表框中的選擇項控制其他控件的可用狀態(tài)
????????///?
????????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條碼秤開發(fā).rar
評論
共有 條評論