private void viewByAddress_Click(object sender, EventArgs e) { uint address = 0; string addressText = addressInput.Text; try { if (addressText.Length > 2 && addressText.Substring(0, 2) == "0x") { address = Convert.ToUInt32(addressText, 16); } else { address = Convert.ToUInt32(addressText); } } catch { address = 0; } if (address > 0) { UnitView unitView = new UnitView(ushort.MaxValue, address); customViews.Add(address, unitView); unitView.Show(); } else { MessageBox.Show("Invalid Address."); } }
void treeViewUnits_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { UInt16 unitIndex = UInt16.MaxValue; try { if (e.Node.Name.Length > 0 && e.Node.Name[0] == 'p') { unitIndex = Convert.ToUInt16(e.Node.Name.Substring(1)); } else if (e.Node.Name.Length > 0 && e.Node.Name[0] == 's') { unitIndex = Convert.ToUInt16(e.Node.Name.Substring(1)); } else { unitIndex = Convert.ToUInt16(e.Node.Name.Substring(0)); } } catch { unitIndex = UInt16.MaxValue; } if (unitIndex != UInt16.MaxValue && !unitViews.ContainsKey(unitIndex)) { UnitView unitView = new UnitView(unitIndex, unitIndexToPtr(unitIndex)); unitViews.Add(unitIndex, unitView); unitView.Show(); } }