/// <summary> /// ComboBox事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (sender == null) { return; } ComboBox cbb = (ComboBox)sender; cbb.Enabled = false; cbb.Focus(); switch (cbb.Name) { case "comboBox_VSVersion": CIniFile ini = new CIniFile(Application.StartupPath + @"\Config.ini", true); if (ini.CIniFileSectionExists("VS版本")) { ini.CIniFileEraseSection("VS版本"); } ini.CIniFileWriteInt("VS版本", this.comboBox_VSVersion.Text, this.comboBox_VSVersion.SelectedIndex); break; default: break; } cbb.Focus(); cbb.Enabled = true; }
/// <summary> /// ComboBox控件发生变化 /// </summary> /// <param name="cbb"></param> private void UI_ComboBox_SelectedIndexChanged(ComboBox cbb) { //cbb.Enabled = false; switch (cbb.Name) { //---芯片类型发生变化 case "comboBox_ChipType": if (!string.IsNullOrEmpty(this.comboBox_ChipType.Text)) { if (this.comboBox_ChipType.Text != this.defaultCMcuFunc.mMcuInfoParam.mTypeName) { //---芯片类型发生改变,但是不在加载配置文件 this.McuTypeChanged(this.comboBox_ChipType.Text, false); //---打印器件型号 CRichTextBoxPlus.AppendTextInfoTopWithDataTime(this.cRichTextBoxEx_ChipMsg, "器件型号是:" + this.defaultCMcuFunc.mMcuInfoParam.mTypeName, Color.Black); //---写入配置信息 CIniFile ini = new CIniFile(Application.StartupPath + @"\Config.ini", true); //---记录设备信息 if (ini.CIniFileSectionExists("ChipID")) { ini.CIniFileEraseSection("ChipID"); } ini.CIniFileWriteInt("ChipID", this.comboBox_ChipType.Text, this.comboBox_ChipType.SelectedIndex); //---写入设备接口信息 if (ini.CIniFileSectionExists("Interface")) { ini.CIniFileEraseSection("Interface"); } ini.CIniFileWriteInt("Interface", this.comboBox_ChipInterface.Text, this.comboBox_ChipInterface.SelectedIndex); } } break; //---芯片接口发生变化 case "comboBox_ChipInterface": break; default: break; } //---任务空闲 this.defaultTaskIdle = false; //cbb.Enabled = true; }
/// <summary> /// /// </summary> /// <param name="bt"></param> private void UI_Button_Click(Button bt) { switch (bt.Name) { //---设备接口发生变化 case "button_SetChipInterface": if (!string.IsNullOrEmpty(this.comboBox_ChipInterface.Text)) { switch (this.comboBox_ChipInterface.Text.ToUpper()) { case "ISP": if (this.defaultCMcuFunc.GetType() != typeof(CMcuFuncAVR8BitsISP)) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsISP(this.defaultCMcuFunc); } break; case "JTAG": if (this.defaultCMcuFunc.GetType() != typeof(CMcuFuncAVR8BitsJTAG)) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsJTAG(this.defaultCMcuFunc); } break; case "HVPP": if (this.defaultCMcuFunc.GetType() != typeof(CMcuFuncAVR8BitsHVPP)) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsHVPP(this.defaultCMcuFunc); } break; case "HVSP": if (this.defaultCMcuFunc.GetType() != typeof(CMcuFuncAVR8BitsHVSP)) { this.defaultCMcuFunc = new CMcuFuncAVR8BitsHVSP(this.defaultCMcuFunc); } break; default: break; } //---写入配置信息 CIniFile ini = new CIniFile(Application.StartupPath + @"\Config.ini", true); //---记录设备接口 if (ini.CIniFileSectionExists("Interface")) { ini.CIniFileEraseSection("Interface"); } ini.CIniFileWriteInt("Interface", this.comboBox_ChipInterface.Text, this.comboBox_ChipInterface.SelectedIndex); this.cMcuFormAVR8BitsFuseAndLockControl_ChipFuse.mCMcuFunc = this.defaultCMcuFunc; } else { CMessageBoxPlus.Show(this, "???不识别的编程接口", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; //---读取供电电压 case "button_ReadChipPWR": this.defaultCMcuFunc.CMcuFunc_ReadChipPower(this.textBox_ChipPWR, this.cRichTextBoxEx_ChipMsg); break; //---设置供电电压 case "button_SetChipPWR": this.defaultCMcuFunc.CMcuFunc_WriteChipPower(this.textBox_ChipPWR, this.cRichTextBoxEx_ChipMsg, this.checkBox_ChipPWR.Checked); break; //---设置编程时钟 case "button_SetChipClock": this.defaultCMcuFunc.CMcuFunc_SetProgClock((byte)this.trackBar_ChipClock.Value, this.cRichTextBoxEx_ChipMsg); break; //---加载Flash数据 case "button_LoadFlashFile": this.defaultCMcuFunc.CMcuFunc_LoadFlashHexFile(this.cHexBox_Flash, this.label_FlashSize, this.cRichTextBoxEx_ChipMsg); break; //---加载Eeprom case "button_LoadEepromFile": this.defaultCMcuFunc.CMcuFunc_LoadEepromHexFile(this.cHexBox_Eeprom, this.label_EepromSize, this.cRichTextBoxEx_ChipMsg); break; //---保存Flash case "button_SaveFlashFile": this.defaultCMcuFunc.CMcuFunc_SaveFlashHexFile(this.cHexBox_Flash, this.cRichTextBoxEx_ChipMsg); break; //---保存EEPROM文件 case "button_SaveEepromFile": this.defaultCMcuFunc.CMcuFunc_SaveEepromHexFile(this.cHexBox_Eeprom, this.cRichTextBoxEx_ChipMsg); break; //---自动 case "button_AutoChip": case "button_ChipAuto": this.defaultCMcuFunc.CMcuFunc_DoChipTask(this.defaultCMcuFunc.mMcuInfoParam.mChipFuse, Convert.ToByte(this.mLockFuse.Text, 16), this.cHexBox_Flash, this.cHexBox_Eeprom, this.cRichTextBoxEx_ChipMsg, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---擦除 case "button_Erase": case "button_EraseChip": this.defaultCMcuFunc.CMcuFunc_EraseChip(this.mLockFuse, this.cRichTextBoxEx_ChipMsg); break; //---存储器查空操作 case "button_CheckEmpty": this.defaultCMcuFunc.CMcuFunc_CheckChipMemeryEmpty(this.cRichTextBoxEx_ChipMsg, false); break; //---读取识别字 case "button_ReadIDChip": case "button_ReadChipID": this.defaultCMcuFunc.CMcuFunc_ReadChipID(this.cRichTextBoxEx_ChipMsg, this); break; //---读取Flash case "button_ReadChipFlash": this.defaultCMcuFunc.CMcuFunc_ReadChipFlash(this.cHexBox_Flash, this.cRichTextBoxEx_ChipMsg, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---编程Flash case "button_WriteChipFlash": this.defaultCMcuFunc.CMcuFunc_WriteChipFlash(this.cHexBox_Flash, this.cRichTextBoxEx_ChipMsg, true, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---校验Flash case "button_CheckChipFlash": this.defaultCMcuFunc.CMcuFunc_CheckChipFlash(this.cHexBox_Flash, this.cRichTextBoxEx_ChipMsg, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---读取Eeprom case "button_ReadChipEeprom": this.defaultCMcuFunc.CMcuFunc_ReadChipEeprom(this.cHexBox_Eeprom, this.cRichTextBoxEx_ChipMsg, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---编程Eeprom case "button_WriteChipEeprom": this.defaultCMcuFunc.CMcuFunc_WriteChipEeprom(this.cHexBox_Eeprom, this.cRichTextBoxEx_ChipMsg, true, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---校验Eeprom case "button_CheckChipEeprom": this.defaultCMcuFunc.CMcuFunc_CheckChipEeprom(this.cHexBox_Eeprom, this.cRichTextBoxEx_ChipMsg, this.toolStripLabel_ChipState, this.toolStripLabel_ChipTime, this.toolStripProgressBar_ChipBar); break; //---编程熔丝位 case "button_WriteChipFuse": this.defaultCMcuFunc.CMcuFunc_WriteChipFuse(this.cMcuFormAVR8BitsFuseAndLockControl_ChipFuse.mCMcuFunc.mMcuInfoParam.mChipFuse, this.cRichTextBoxEx_ChipMsg); break; //---编程加密位 case "button_WriteChipLock": this.defaultCMcuFunc.CMcuFunc_WriteChipLock(this.mLockFuse, this.cRichTextBoxEx_ChipMsg); break; //---读取ROM信息 case "button_ReadChipROM": this.defaultCMcuFunc.CMcuFunc_ReadChipRom(this.cHexBox_ROM, this.cRichTextBoxEx_ChipMsg, true); break; default: break; } //---任务空闲 this.defaultTaskIdle = false; }