// Options private void btnOptions_Click(object sender, EventArgs e) { FormOptions fOptions = new FormOptions(); fOptions.toolTips = Config.Prop.toolTips; fOptions.avrdudeLocation = Config.Prop.avrdudeLoc; fOptions.avrdudeConfLocation = Config.Prop.avrdudeConfLoc; fOptions.avrSizeLocation = Config.Prop.avrSizeLoc; if (fOptions.ShowDialog() != DialogResult.OK) { return; } Config.Prop.toolTips = fOptions.toolTips; ToolTips.Active = Config.Prop.toolTips; bool changedAvrdudeLoc = (Config.Prop.avrdudeLoc != fOptions.avrdudeLocation); bool changedAvrdudeConfLoc = (Config.Prop.avrdudeConfLoc != fOptions.avrdudeConfLocation); bool changedAvrSizeLoc = (Config.Prop.avrSizeLoc != fOptions.avrSizeLocation); Config.Prop.avrdudeLoc = fOptions.avrdudeLocation; Config.Prop.avrdudeConfLoc = fOptions.avrdudeConfLocation; Config.Prop.avrSizeLoc = fOptions.avrSizeLocation; if (changedAvrdudeLoc || changedAvrdudeConfLoc) { avrdude.load(); if (changedAvrdudeConfLoc) { setComboBoxDataSource(cmbMCU, avrdude.mcus, "fullName"); setComboBoxDataSource(cmbProg, avrdude.programmers, "fullName"); } } if (changedAvrSizeLoc) { avrsize.load(); fileFlash.updateSize(); fileEEPROM.updateSize(); } }
private void Form1_Load(object sender, EventArgs e) { // Load saved configuration Config.Prop.load(); cmdLine = new CmdLine(this); avrdude = new Avrdude(); avrsize = new Avrsize(); avrdude.OnProcessStart += avrdude_OnProcessStart; avrdude.OnProcessEnd += avrdude_OnProcessEnd; avrdude.OnVersionChange += avrdude_OnVersionChange; avrdude.OnDetectedMCU += avrdude_OnDetectedMCU; avrdude.load(); avrsize.load(); // Setup memory files/usage bars // Flash fileFlash = new MemTypeFile(txtFlashFile, avrsize); fileFlash.sizeChanged += fileFlash_sizeChanged; pbFlashUsage.Width = txtFlashFile.Width; pbFlashUsage.Height = 3; pbFlashUsage.Location = new Point(txtFlashFile.Location.X, txtFlashFile.Location.Y - pbFlashUsage.Height); pbFlashUsage.Image = new Bitmap(pbFlashUsage.Width, pbFlashUsage.Height); memoryUsageBar(fileFlash, pbFlashUsage, 0); // EEPROM fileEEPROM = new MemTypeFile(txtEEPROMFile, avrsize); fileEEPROM.sizeChanged += fileEEPROM_sizeChanged; pbEEPROMUsage.Width = txtEEPROMFile.Width; pbEEPROMUsage.Height = 3; pbEEPROMUsage.Location = new Point(txtEEPROMFile.Location.X, txtEEPROMFile.Location.Y - pbEEPROMUsage.Height); pbEEPROMUsage.Image = new Bitmap(pbEEPROMUsage.Width, pbEEPROMUsage.Height); memoryUsageBar(fileEEPROM, pbEEPROMUsage, 0); enableClientAreaDrag(Controls); // Update serial ports etc cmbPort.DropDown += cbPort_DropDown; // Drag and drop flash file gbFlashFile.AllowDrop = true; gbFlashFile.DragEnter += event_DragEnter; gbFlashFile.DragDrop += event_DragDrop; // Drag and drop EEPROM file gbEEPROMFile.AllowDrop = true; gbEEPROMFile.DragEnter += event_DragEnter; gbEEPROMFile.DragDrop += event_DragDrop; // Flash file openFileDialog1.Filter = "Hex files (*.hex)|*.hex"; openFileDialog1.Filter += "|EEPROM files (*.eep)|*.eep"; openFileDialog1.Filter += "|All files (*.*)|*.*"; openFileDialog1.CheckFileExists = false; openFileDialog1.FileName = ""; openFileDialog1.Title = "Open flash file"; // EEPROM file openFileDialog2.Filter = "EEPROM files (*.eep)|*.eep"; openFileDialog2.Filter += "|Hex files (*.hex)|*.hex"; openFileDialog2.Filter += "|All files (*.*)|*.*"; openFileDialog2.CheckFileExists = false; openFileDialog2.FileName = ""; openFileDialog2.Title = "Open EEPROM file"; // MCU & programmer combo box data source setComboBoxDataSource(cmbMCU, avrdude.mcus, "fullName"); cmbMCU.SelectedIndexChanged += cmbMCU_SelectedIndexChanged; setComboBoxDataSource(cmbProg, avrdude.programmers, "fullName"); cmbProg.SelectedIndexChanged += cmbProg_SelectedIndexChanged; // USBasp frequency settings cmbUSBaspFreq.Hide(); setComboBoxDataSource(cmbUSBaspFreq, Avrdude.USBaspFreqs, "name"); cmbUSBaspFreq.Width = txtBitClock.Width; cmbUSBaspFreq.Left = txtBitClock.Left; cmbUSBaspFreq.Top = txtBitClock.Top; // Flash & EEPROM file formats setComboBoxDataSource(cmbFlashFormat, Avrdude.fileFormats, "fullName"); setComboBoxDataSource(cmbEEPROMFormat, Avrdude.fileFormats, "fullName"); // Verbosity levels cmdVerbose.Items.Clear(); for (byte i=0;i<5;i++) cmdVerbose.Items.Add(i); cmdVerbose.SelectedIndex = 0; // Tool tips ToolTips = new ToolTip(); ToolTips.ReshowDelay = 100; ToolTips.UseAnimation = false; ToolTips.UseFading = false; ToolTips.SetToolTip(cmbProg, "Programmer"); ToolTips.SetToolTip(cmbMCU, "MCU to program"); ToolTips.SetToolTip(cmbPort, "Set COM/LTP/USB port"); ToolTips.SetToolTip(txtBaudRate, "Port baud rate"); ToolTips.SetToolTip(txtBitClock, "Bit clock period (us)"); ToolTips.SetToolTip(txtFlashFile, "Hex file (.hex)" + Environment.NewLine + "You can also drag and drop files here"); ToolTips.SetToolTip(pFlashOp, ""); ToolTips.SetToolTip(txtEEPROMFile, "EEPROM file (.eep)" + Environment.NewLine + "You can also drag and drop files here"); ToolTips.SetToolTip(pEEPROMOp, ""); ToolTips.SetToolTip(cbForce, "Skip signature check"); ToolTips.SetToolTip(cbNoVerify, "Don't verify after writing"); ToolTips.SetToolTip(cbDisableFlashErase, "Don't erase flash before writing"); ToolTips.SetToolTip(cbEraseFlashEEPROM, "Erase both flash and EEPROM"); ToolTips.SetToolTip(cbDoNotWrite, "Don't write anything, used for debugging AVRDUDE"); ToolTips.SetToolTip(txtLFuse, "Low fuse"); ToolTips.SetToolTip(txtHFuse, "High fuse"); ToolTips.SetToolTip(txtEFuse, "Extended fuse"); ToolTips.SetToolTip(txtLock, "Lock bits"); ToolTips.SetToolTip(btnFlashGo, "Only write/read/verify flash"); ToolTips.SetToolTip(btnEEPROMGo, "Only write/read/verify EEPROM"); ToolTips.SetToolTip(btnWriteFuses, "Write fuses now"); ToolTips.SetToolTip(btnWriteLock, "Write lock now"); ToolTips.SetToolTip(cbSetFuses, "Write fuses when programming"); ToolTips.SetToolTip(cbSetLock, "Write lock when programming"); // Load saved presets presets = new Presets(this); presets.load(); presets.setDataSource(cmbPresets); // Enable/disable tool tips based on saved config ToolTips.Active = Config.Prop.toolTips; ready = true; // If a preset has not been specified by the command line then use the last used preset // Credits: // Uwe Tanger (specifing preset in command line) // neptune (sticky presets) if (presetToLoad == null) presetToLoad = Config.Prop.preset; // Load preset PresetData p = presets.presets.Find(s => s.name == presetToLoad); cmbPresets.SelectedItem = (p != null) ? p : presets.presets.Find(s => s.name == "Default"); // Check for updates UpdateCheck.check.checkNow(); }
private void Form1_Load(object sender, EventArgs e) { // Load saved configuration Config.Prop.load(); // Persist window location across sessions // Credits: // gl.tter if (Config.Prop.windowLocation != null && Config.Prop.windowLocation != new Point(0, 0)) { Location = Config.Prop.windowLocation; } cmdLine = new CmdLine(this); avrdude = new Avrdude(); avrsize = new Avrsize(); avrdude.OnProcessStart += avrdude_OnProcessStart; avrdude.OnProcessEnd += avrdude_OnProcessEnd; avrdude.OnVersionChange += avrdude_OnVersionChange; avrdude.OnDetectedMCU += avrdude_OnDetectedMCU; avrdude.load(); avrsize.load(); // Setup memory files/usage bars // Flash fileFlash = new MemTypeFile(txtFlashFile, avrsize); fileFlash.sizeChanged += fileFlash_sizeChanged; pbFlashUsage.Width = txtFlashFile.Width; pbFlashUsage.Height = 3; pbFlashUsage.Location = new Point(txtFlashFile.Location.X, txtFlashFile.Location.Y - pbFlashUsage.Height); pbFlashUsage.Image = new Bitmap(pbFlashUsage.Width, pbFlashUsage.Height); memoryUsageBar(fileFlash, pbFlashUsage, 0); // EEPROM fileEEPROM = new MemTypeFile(txtEEPROMFile, avrsize); fileEEPROM.sizeChanged += fileEEPROM_sizeChanged; pbEEPROMUsage.Width = txtEEPROMFile.Width; pbEEPROMUsage.Height = 3; pbEEPROMUsage.Location = new Point(txtEEPROMFile.Location.X, txtEEPROMFile.Location.Y - pbEEPROMUsage.Height); pbEEPROMUsage.Image = new Bitmap(pbEEPROMUsage.Width, pbEEPROMUsage.Height); memoryUsageBar(fileEEPROM, pbEEPROMUsage, 0); enableClientAreaDrag(Controls); // Update serial ports etc cmbPort.DropDown += cbPort_DropDown; // Drag and drop flash file gbFlashFile.AllowDrop = true; gbFlashFile.DragEnter += event_DragEnter; gbFlashFile.DragDrop += event_DragDrop; // Drag and drop EEPROM file gbEEPROMFile.AllowDrop = true; gbEEPROMFile.DragEnter += event_DragEnter; gbEEPROMFile.DragDrop += event_DragDrop; // Flash file openFileDialog1.Filter = "Hex files (*.hex)|*.hex"; openFileDialog1.Filter += "|EEPROM files (*.eep)|*.eep"; openFileDialog1.Filter += "|All files (*.*)|*.*"; openFileDialog1.CheckFileExists = false; openFileDialog1.FileName = ""; openFileDialog1.Title = "Open flash file"; // EEPROM file openFileDialog2.Filter = "EEPROM files (*.eep)|*.eep"; openFileDialog2.Filter += "|Hex files (*.hex)|*.hex"; openFileDialog2.Filter += "|All files (*.*)|*.*"; openFileDialog2.CheckFileExists = false; openFileDialog2.FileName = ""; openFileDialog2.Title = "Open EEPROM file"; // MCU & programmer combo box data source setComboBoxDataSource(cmbMCU, avrdude.mcus, "fullName"); cmbMCU.SelectedIndexChanged += cmbMCU_SelectedIndexChanged; setComboBoxDataSource(cmbProg, avrdude.programmers, "fullName"); cmbProg.SelectedIndexChanged += cmbProg_SelectedIndexChanged; // USBasp frequency settings cmbUSBaspFreq.Hide(); setComboBoxDataSource(cmbUSBaspFreq, Avrdude.USBaspFreqs, "name"); cmbUSBaspFreq.Width = txtBitClock.Width; cmbUSBaspFreq.Left = txtBitClock.Left; cmbUSBaspFreq.Top = txtBitClock.Top; // Flash & EEPROM file formats setComboBoxDataSource(cmbFlashFormat, Avrdude.fileFormats, "fullName"); setComboBoxDataSource(cmbEEPROMFormat, Avrdude.fileFormats, "fullName"); // Verbosity levels cmdVerbose.Items.Clear(); for (byte i = 0; i < 5; i++) { cmdVerbose.Items.Add(i); } cmdVerbose.SelectedIndex = 0; // Tool tips ToolTips = new ToolTip(); ToolTips.ReshowDelay = 100; ToolTips.UseAnimation = false; ToolTips.UseFading = false; ToolTips.SetToolTip(cmbProg, "Programmer"); ToolTips.SetToolTip(cmbMCU, "MCU to program"); ToolTips.SetToolTip(cmbPort, "Set COM/LTP/USB port"); ToolTips.SetToolTip(txtBaudRate, "Port baud rate"); ToolTips.SetToolTip(txtBitClock, "Bit clock period (us)"); ToolTips.SetToolTip(txtFlashFile, "Hex file (.hex)" + Environment.NewLine + "You can also drag and drop files here"); ToolTips.SetToolTip(pFlashOp, ""); ToolTips.SetToolTip(txtEEPROMFile, "EEPROM file (.eep)" + Environment.NewLine + "You can also drag and drop files here"); ToolTips.SetToolTip(pEEPROMOp, ""); ToolTips.SetToolTip(cbForce, "Skip signature check"); ToolTips.SetToolTip(cbNoVerify, "Don't verify after writing"); ToolTips.SetToolTip(cbDisableFlashErase, "Don't erase flash before writing" + Environment.NewLine + "Use this if you only want to update EEPROM"); ToolTips.SetToolTip(cbEraseFlashEEPROM, "Erase both flash and EEPROM"); ToolTips.SetToolTip(cbDoNotWrite, "Don't write anything, used for debugging AVRDUDE"); ToolTips.SetToolTip(txtLFuse, "Low fuse"); ToolTips.SetToolTip(txtHFuse, "High fuse"); ToolTips.SetToolTip(txtEFuse, "Extended fuse"); ToolTips.SetToolTip(txtLock, "Lock bits"); ToolTips.SetToolTip(btnFlashGo, "Only write/read/verify flash"); ToolTips.SetToolTip(btnEEPROMGo, "Only write/read/verify EEPROM"); ToolTips.SetToolTip(btnWriteFuses, "Write fuses now"); ToolTips.SetToolTip(btnWriteLock, "Write lock now"); ToolTips.SetToolTip(btnReadFuses, "Read fuses now"); ToolTips.SetToolTip(btnReadLock, "Read lock now"); ToolTips.SetToolTip(cbSetFuses, "Write fuses when programming"); ToolTips.SetToolTip(cbSetLock, "Write lock when programming"); // Load saved presets presets = new Presets(this); presets.load(); presets.setDataSource(cmbPresets); // Enable/disable tool tips based on saved config ToolTips.Active = Config.Prop.toolTips; ready = true; // If a preset has not been specified by the command line then use the last used preset // Credits: // Uwe Tanger (specifing preset in command line) // neptune (sticky presets) if (presetToLoad == null) { presetToLoad = Config.Prop.preset; } // Load preset PresetData p = presets.presets.Find(s => s.name == presetToLoad); cmbPresets.SelectedItem = (p != null) ? p : presets.presets.Find(s => s.name == "Default"); // Check for updates UpdateCheck.check.checkNow(); }