public void InitMe(string OldAddr, SegmentConfig S) { if (S.CheckWords != null) { string[] CWS = S.CheckWords.Split(','); foreach (string CW in CWS) { string[] Parts = CW.Split(':'); if (Parts.Length == 4) { if (!comboCheckword.Items.Contains(Parts[3])) { comboCheckword.Items.Add(Parts[3]); } } } } if (OldAddr.Length > 0) { string[] Extras = OldAddr.Split(','); foreach (string Extra in Extras) { listExtra.Items.Add(Extra); } } }
private void saveXML(string fileName) { try { if (fileName.Length == 0) { fileName = SelectSaveFile("XML files (*.xml)|*.xml|All files (*.*)|*.*"); } if (fileName.Length == 0) { return; } if (PCM.Segments.Count > 0) { SegmentConfig S = PCM.Segments[0]; S.Version = txtVersion.Text; PCM.Segments[0] = S; } Logger("Saving to file: " + Path.GetFileName(fileName), false); Debug.WriteLine("Saving to file: " + Path.GetFileName(fileName)); PCM.saveConfigFile(fileName); labelXML.Text = PCM.configFile; frmpatcher.labelXML.Text = PCM.configFile + " (v " + txtVersion.Text + ")";; Logger(" [OK]"); } catch (Exception ex) { Logger(ex.Message); } }
private void btnOK_Click(object sender, EventArgs e) { SegmentConfig S = PCM.Segments[CurrentSegment]; S.SearchAddresses = txtSearchAddresses.Text; S.Searchfor = txtSearchfor.Text; //S.Searchfrom = txtSearchfrom.Text; //S.SearchNot = chkNot.Checked; PCM.Segments[CurrentSegment] = S; this.DialogResult = DialogResult.OK; }
private void btnAdd_Click(object sender, EventArgs e) { SegmentConfig S = new SegmentConfig(); PCM.Segments.Add(S); frmSegmentSettings frmSS = new frmSegmentSettings(); frmSS.EditSegment(PCM, PCM.Segments.Count - 1); if (frmSS.ShowDialog(this) == DialogResult.OK) { InitMe(); } }
private void btnOK_Click(object sender, EventArgs e) { SegmentConfig S = PCM.Segments[CurrentSegment]; S.CheckWords = ""; for (int s = 0; s < listCheckwords.Items.Count; s++) { if (s > 0) { S.CheckWords += ","; } S.CheckWords += listCheckwords.Items[s].SubItems[0].Text + ":" + listCheckwords.Items[s].SubItems[1].Text + ":" + listCheckwords.Items[s].SubItems[2].Text + ":" + listCheckwords.Items[s].SubItems[3].Text; } PCM.Segments[CurrentSegment] = S; this.DialogResult = DialogResult.OK; this.Close(); }
private void btnCopy_Click(object sender, EventArgs e) { if (listSegments.SelectedItems.Count == 0) { return; } int CurrentSel = (int)listSegments.SelectedItems[0].Tag; SegmentConfig S = PCM.Segments[CurrentSel]; PCM.Segments.Add(S); frmSegmentSettings frmSS = new frmSegmentSettings(); frmSS.EditSegment(PCM, PCM.Segments.Count - 1); if (frmSS.ShowDialog(this) == DialogResult.OK) { InitMe(); } }
private void btnMoveDown_Click(object sender, EventArgs e) { if (listSegments.SelectedItems.Count == 0) { return; } if ((int)listSegments.SelectedItems[0].Tag == listSegments.Items.Count - 1) { return; } SegmentConfig Stmp = new SegmentConfig(); int CurrentSel = (int)listSegments.SelectedItems[0].Tag; Stmp = PCM.Segments[CurrentSel + 1]; PCM.Segments[CurrentSel + 1] = PCM.Segments[CurrentSel]; PCM.Segments[CurrentSel] = Stmp; InitMe(); listSegments.Items[CurrentSel + 1].Selected = true; }
public void LoadFile(string FileName) { try { Segments.Clear(); Logger("Loading file: " + Path.GetFileName(FileName), false); System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(List <SegmentConfig>)); System.IO.StreamReader file = new System.IO.StreamReader(FileName); Segments = (List <SegmentConfig>)reader.Deserialize(file); file.Close(); if (Segments[0].Version == null || Segments[0].Version == "") { SegmentConfig S = Segments[0]; S.Version = "1"; Segments[0] = S; } listSegments.Items.Clear(); for (int s = 0; s < Segments.Count; s++) { var item = new ListViewItem(Segments[s].Name); if (Segments[s].Addresses != null) { item.SubItems.Add(Segments[s].Addresses); } else { item.SubItems.Add(""); } item.Tag = s; listSegments.Items.Add(item); } Logger(" [OK]"); XMLFile = FileName; labelXML.Text = Path.GetFileName(XMLFile); txtVersion.Text = Segments[0].Version; } catch (Exception ex) { Logger(ex.Message); } }
private void btnMoveUp_Click(object sender, EventArgs e) { if (listSegments.SelectedItems.Count == 0) { return; } if (listSegments.SelectedItems[0].Text == PCM.Segments[0].Name) { return; } SegmentConfig Stmp = new SegmentConfig(); int CurrentSel = (int)listSegments.SelectedItems[0].Tag; Stmp = PCM.Segments[CurrentSel - 1]; PCM.Segments[CurrentSel - 1] = PCM.Segments[CurrentSel]; PCM.Segments[CurrentSel] = Stmp; InitMe(); listSegments.Items[CurrentSel - 1].Selected = true; labelXML.Text = ""; }
public void InitMe(PcmFile PCM1, int SegmentNr) { PCM = PCM1; CurrentSegment = SegmentNr; listCheckwords.Clear(); listCheckwords.View = View.Details; listCheckwords.Columns.Add("Checkword"); listCheckwords.Columns.Add("Location"); listCheckwords.Columns.Add("Data Location"); listCheckwords.Columns.Add("Key"); listCheckwords.Columns[0].Width = 100; listCheckwords.Columns[1].Width = 100; listCheckwords.Columns[2].Width = 130; listCheckwords.Columns[3].Width = 100; listCheckwords.MultiSelect = false; listCheckwords.CheckBoxes = false; listCheckwords.FullRowSelect = true; SegmentConfig S = PCM.Segments[SegmentNr]; if (S.CheckWords == null) { return; } string[] Rows = S.CheckWords.Split(','); foreach (string Row in Rows) { string[] Parts = Row.Split(':'); if (Parts.Length == 4) { var item = new ListViewItem(Parts[0]); item.SubItems.Add(Parts[1]); item.SubItems.Add(Parts[2]); item.SubItems.Add(Parts[3]); listCheckwords.Items.Add(item); } } }
private void saveXML() { try { string FileName; if (XMLFile == "") { FileName = SelectSaveFile("XML files (*.xml)|*.xml|All files (*.*)|*.*"); } else { FileName = XMLFile; } if (FileName.Length < 1) { return; } SegmentConfig S = Segments[0]; S.Version = txtVersion.Text; Segments[0] = S; Logger("Saving to file: " + Path.GetFileName(FileName), false); Debug.WriteLine("Saving to file: " + Path.GetFileName(FileName)); using (FileStream stream = new FileStream(FileName, FileMode.Create)) { System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <SegmentConfig>)); writer.Serialize(stream, Segments); stream.Close(); } Logger(" [OK]"); } catch (Exception ex) { Logger(ex.Message); } }
private void btnApply_Click(object sender, EventArgs e) { SegmentConfig S = PCM.Segments[CurrentSegment]; S.Name = txtSegmentName.Text; S.Addresses = txtSegmentAddress.Text; S.SwapAddress = txtSwapAddr.Text; S.CS1Address = txtCS1Address.Text; S.CS2Address = txtCS2Address.Text; S.CS1Blocks = txtCS1Block.Text; S.CS2Blocks = txtCS2Block.Text; S.PNAddr = txtPNAddr.Text; S.VerAddr = txtVerAddr.Text; S.SegNrAddr = txtNrAddr.Text; S.ExtraInfo = txtExtrainfo.Text; S.Eeprom = chkEeprom.Checked; S.Comment = txtComment.Text; S.CheckWords = txtCheckWords.Text; if (radioCS1None.Checked) { S.CS1Method = CSMethod_None; } if (radioCS1Crc16.Checked) { S.CS1Method = CSMethod_crc16; } if (radioCS1Crc32.Checked) { S.CS1Method = CSMethod_crc32; } if (radioCS1SUM.Checked) { S.CS1Method = CSMethod_Bytesum; } if (radioCS1WordSum.Checked) { S.CS1Method = CSMethod_Wordsum; } if (radioCS1DwordSum.Checked) { S.CS1Method = CSMethod_Dwordsum; } if (radioCS2None.Checked) { S.CS2Method = CSMethod_None; } if (radioCS2Crc16.Checked) { S.CS2Method = CSMethod_crc16; } if (radioCS2Crc32.Checked) { S.CS2Method = CSMethod_crc32; } if (radioCS2SUM.Checked) { S.CS2Method = CSMethod_Bytesum; } if (radioCS2WordSum.Checked) { S.CS2Method = CSMethod_Wordsum; } if (radioCS2DwordSum.Checked) { S.CS2Method = CSMethod_Dwordsum; } S.CS1SwapBytes = checkSwapBytes1.Checked; if (radioCS1Complement0.Checked) { S.CS1Complement = 0; } if (radioCS1Complement1.Checked) { S.CS1Complement = 1; } if (radioCS1Complement2.Checked) { S.CS1Complement = 2; } if (radioCS2Complement0.Checked) { S.CS2Complement = 0; } if (radioCS2Complement1.Checked) { S.CS2Complement = 1; } if (radioCS2Complement2.Checked) { S.CS2Complement = 2; } S.CS2SwapBytes = checkSwapBytes2.Checked; if (comboCVN.Text == "None") { S.CVN = 0; } if (comboCVN.Text == "Checksum 1") { S.CVN = 1; } if (comboCVN.Text == "Checksum 2") { S.CVN = 2; } PCM.Segments[CurrentSegment] = S; }
public void EditSegment(PcmFile PCM1, int SegNr) { PCM = PCM1; labelXML.Text = PCM.configFile + " (v " + PCM.Segments[0].Version + ")"; CurrentSegment = SegNr; SegmentConfig S = PCM.Segments[SegNr]; txtSegmentName.Text = S.Name; txtSegmentAddress.Text = S.Addresses; txtSwapAddr.Text = S.SwapAddress; txtCS1Address.Text = S.CS1Address; txtCS2Address.Text = S.CS2Address; txtCS1Block.Text = S.CS1Blocks; txtCS2Block.Text = S.CS2Blocks; txtPNAddr.Text = S.PNAddr; txtVerAddr.Text = S.VerAddr; txtNrAddr.Text = S.SegNrAddr; txtExtrainfo.Text = S.ExtraInfo; chkEeprom.Checked = S.Eeprom; txtComment.Text = S.Comment; txtCheckWords.Text = S.CheckWords; checkSwapBytes1.Checked = S.CS1SwapBytes; checkSwapBytes2.Checked = S.CS2SwapBytes; if (S.CS1Method == CSMethod_None) { radioCS1None.Checked = true; } if (S.CS1Method == CSMethod_crc16) { radioCS1Crc16.Checked = true; } if (S.CS1Method == CSMethod_crc32) { radioCS1Crc32.Checked = true; } if (S.CS1Method == CSMethod_Bytesum) { radioCS1SUM.Checked = true; } if (S.CS1Method == CSMethod_Wordsum) { radioCS1WordSum.Checked = true; } if (S.CS1Method == CSMethod_Dwordsum) { radioCS1DwordSum.Checked = true; } if (S.CS2Method == CSMethod_None) { radioCS2None.Checked = true; } if (S.CS2Method == CSMethod_crc16) { radioCS2Crc16.Checked = true; } if (S.CS2Method == CSMethod_crc32) { radioCS2Crc32.Checked = true; } if (S.CS2Method == CSMethod_Bytesum) { radioCS2SUM.Checked = true; } if (S.CS2Method == CSMethod_Wordsum) { radioCS2WordSum.Checked = true; } if (S.CS2Method == CSMethod_Dwordsum) { radioCS2DwordSum.Checked = true; } if (S.CS1Complement == 0) { radioCS1Complement0.Checked = true; } if (S.CS1Complement == 1) { radioCS1Complement1.Checked = true; } if (S.CS1Complement == 2) { radioCS1Complement2.Checked = true; } if (S.CS2Complement == 0) { radioCS2Complement0.Checked = true; } if (S.CS2Complement == 1) { radioCS2Complement1.Checked = true; } if (S.CS2Complement == 2) { radioCS2Complement2.Checked = true; } if (S.CVN == 0) { comboCVN.Text = "None"; } if (S.CVN == 1) { comboCVN.Text = "Checksum 1"; } if (S.CVN == 2) { comboCVN.Text = "Checksum 2"; } }