public void copyFrom(PresetData source) { name = source.name; programmer = source.programmer; mcu = source.mcu; port = source.port; baud = source.baud; bitclock = source.bitclock; flashFile = source.flashFile; flashFormat = source.flashFormat; flashOp = source.flashOp; EEPROMFile = source.EEPROMFile; EEPROMFormat = source.EEPROMFormat; EEPROMOp = source.EEPROMOp; force = source.force; disableVerify = source.disableVerify; disableFlashErase = source.disableFlashErase; eraseFlashAndEEPROM = source.eraseFlashAndEEPROM; doNotWrite = source.doNotWrite; lfuse = source.lfuse; hfuse = source.hfuse; efuse = source.efuse; setFuses = source.setFuses; lockBits = source.lockBits; setLock = source.setLock; additional = source.additional; verbosity = source.verbosity; }
private void btnOverwrite_Click(object sender, EventArgs e) { PresetData selectedPreset = (PresetData)cmbPresets.SelectedItem; // Make sure a preset is selected if (selectedPreset != null) { // Make sure its not the default preset if (selectedPreset.name == "Default") { MsgBox.notice("_CANTOVERWRITEDEFAULT"); } else if (MsgBox.confirm("_PRESETOVERWRITE", selectedPreset.name) == DialogResult.OK) { string name = selectedPreset.name; selectedPreset.copyFrom(currentSettings); selectedPreset.name = name; presets.save(); // Select the new preset PresetData p = presets.presets.Find(s => s.name == selectedPreset.name); if (p != null) { cmbPresets.SelectedItem = p; } reloadExportList(); } } }
private void btnDelete_Click(object sender, EventArgs e) { List <PresetData> toDelete = new List <PresetData>(); for (int i = 0; i < clbExport.Items.Count; i++) { if (clbExport.GetItemChecked(i)) { PresetData p = (PresetData)clbExport.Items[i]; if (p.name != "Default") { toDelete.Add(p); } } } if (toDelete.Count > 0) { if (MsgBox.confirm("_DELETEPRESETS", toDelete.Count) == DialogResult.OK) { foreach (PresetData p in toDelete) { presets.remove(p); } presets.save(); reloadExportList(); } } }
private void btnNew_Click(object sender, EventArgs e) { string name; while (true) { // Check name name = performTextInputDialog("_NEWPRESETNAME", ""); if (name == null) { return; } else if (name.Length < 1) { continue; } else if (name == "Default") { MsgBox.notice("_CANTUSEDEFAULT"); continue; } // Check for existing presets with the same name PresetData existingPreset = presets.presets.Find(s => s.name == name); if (existingPreset != null) { if (MsgBox.confirm("_OVERWRITEPRESET", name) != DialogResult.OK) { continue; } presets.remove(existingPreset); } break; } PresetData newPreset = new PresetData(currentSettings); newPreset.name = name; // Add new preset presets.add(newPreset); presets.save(); // Select the new preset PresetData p = presets.presets.Find(s => s.name == name); if (p != null) { cmbPresets.SelectedItem = p; } reloadExportList(); }
private void btnRename_Click(object sender, EventArgs e) { PresetData selectedPreset = (PresetData)cmbPresets.SelectedItem; if (selectedPreset != null) { string name; PresetData p; while (true) { // Check name name = performTextInputDialog("_NEWPRESETNAME", selectedPreset.name); if (name == null) { return; } else if (name == ((PresetData)cmbPresets.SelectedItem).name) { return; } else if (name.Length < 1) { continue; } else if (name == "Default") { MsgBox.notice("_CANTUSEDEFAULT"); continue; } // Check for existing presets with the same name p = presets.presets.Find(s => s.name == name); if (p != null) { if (MsgBox.confirm("_PRESETALREADYEXISTS") != DialogResult.OK) { continue; } presets.remove(p); } break; } selectedPreset.name = name; presets.save(); reloadExportList(); } }
// Defaults private Config() : base() { configVersion = 0; updateCheck = 0; _skipVersion.Major = 0; _skipVersion.Minor = 0; //_skipVersion.Build = 0; //_skipVersion.Revision = 0; toolTips = true; avrdudeLoc = ""; avrdudeConfLoc = ""; avrSizeLoc = ""; language = "english"; hiddenMCUs = new List <string>(); hiddenProgrammers = new List <string>(); previousSettings = new PresetData(); usePreviousSettings = true; }
// Save a preset private void btnPresetSave_Click(object sender, EventArgs e) { // Credits: // Uwe Tanger (Set preset name by typing directly into presets box instead of a popup window) // Check name string name = cmbPresets.Text; if (name.Length < 1) { return; } else if (name == "Default") { MsgBox.notice("Can't change 'Default'"); return; } // Remove old preset with same name PresetData p = presets.presets.Find(s => s.name == name); if (p != null) { presets.remove(p); } // Add new preset presets.add(name); presets.save(); presets.setDataSource(cmbPresets, cmbPresets_SelectedIndexChanged); // Select the new preset p = presets.presets.Find(s => s.name == name); if (p != null) { cmbPresets.SelectedItem = (object)p; } }
private void btnExport_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { Presets export = new Presets(saveFileDialog1.FileName, true); for (int i = 0; i < clbExport.Items.Count; i++) { if (clbExport.GetItemChecked(i)) { PresetData p = (PresetData)clbExport.Items[i]; if (p != null) { export.add(p); Util.consoleWriteLine("_EXPORTINGPRESETS", p.name); } } } export.save(); Util.consoleWriteLine("_EXPORTCOMPLETE"); } }
public PresetData(PresetData source) { copyFrom(source); }
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(); }