private void TreeGridView1_SelectionChanged(object sender, EventArgs e) { RegisterEntry re = null; foreach (TreeGridNode item in treeGridView1.SelectedRows) { try { re = RegList[(int)item.Cells["IndexColumn"].Value]; int index = (int)item.Cells["SecondaryIndexColumn"].Value; if (index != -1) { re = re.GetFields()[index]; //MessageBox.Show(re.GetIndex().ToString() + ", " + index); } else { //MessageBox.Show(re.GetIndex().ToString()); } break; } catch (NullReferenceException) { //do nothing for groups return; } } if (re != null) { RegNameText.Text = re.GetName(); CommentText.Text = re.GetComment(); InitText.Text = re.GetInit(); int index = LSBOpts.FindStringExact(re.GetLSB().ToString()); if (index == -1) { index = 0; } LSBOpts.SelectedIndex = index; index = LSBOpts.FindStringExact(re.GetLSB().ToString()); if (index == -1) { index = 0; } LSBOpts.SelectedIndex = index; index = MSBOpts.FindStringExact(re.GetMSB().ToString()); if (index == -1) { index = 31; } MSBOpts.SelectedIndex = index; index = MAISOpts.FindStringExact(re.GetMAIS().ToString()); if (index == -1) { index = 0; } MAISOpts.SelectedIndex = index; index = TypeOpts.FindStringExact(re.GetRegType().ToString()); if (index == -1) { index = 0; } TypeOpts.SelectedIndex = index; index = FPGAOpts.FindStringExact(re.GetFPGA().ToString()); if (index == -1) { index = 0; } FPGAOpts.SelectedIndex = index; RegGroupOpts.SelectedIndex = RegGroupOpts.FindStringExact(re.GetGroup()); if (re.GetIsComment()) { ErrorMessage.Text = ""; } else if (!re.GetValid()) { ErrorMessage.Text = re.GetReason(); } else { ErrorMessage.Text = ""; } } }
public static bool ValidEntry(RegisterEntry entry) { if (entry.GetIsComment()) { return(true); } bool b = true; if (!entry.IsValidAddress()) { entry.SetReason("The register " + entry.GetName() + " has invalid address: " + entry.GetAddress()); entry.SetValid(false); b = false; } if (!entry.IsValidMAIS()) { entry.SetReason("The register " + entry.GetName() + " has invalid MAIS field: " + entry.GetMAIS()); entry.SetValid(false); b = false; } if (!entry.IsValidLSB()) { entry.SetReason("The register " + entry.GetName() + "(" + entry.GetAddress() + ") has LSB out of range [0, 32)"); entry.SetValid(false); b = false; } if (!entry.IsValidLSB()) { entry.SetReason("The register " + entry.GetName() + "(" + entry.GetAddress() + ") has MSB out of range [0, 32)"); entry.SetValid(false); b = false; } if (!entry.IsValidLsbMsb()) { entry.SetReason("The register " + entry.GetName() + "(" + entry.GetAddress() + ") has MSB < LSB"); entry.SetValid(false); b = false; } return(b); }