/** * Tests the compatibility of 2 components or a component and a PC * */ private void button3_Click(object sender, EventArgs e) { // if we have a pc if (treeView1.Nodes.Count > 0) { // if we have selected a component int selectedIndex = listBox1.SelectedIndex; if (selectedIndex > -1) { // if we have selected a node if (treeView1.SelectedNode != null) { Component selectedComponent = session.components[selectedIndex]; List <int> ls = HardwareUtil.getAddrOfNode(treeView1.SelectedNode); if (HardwareCompatibilityManager.isCompatible(selectedComponent, session.computers[ls[0]])) { HardwareUtil.compatibilityInfo("The component is compatible!"); } else { HardwareUtil.compatibilityInfo("The component is not compatible."); } } } } }
/** * Adds the component to the selected PC * */ private void button4_Click(object sender, EventArgs e) { // if we have a pc if (treeView1.Nodes.Count > 0) { // if we have selected a component int selectedComponent = listBox1.SelectedIndex; if (selectedComponent > -1) { // if we have selected a node if (treeView1.SelectedNode != null) { // this is done poorly but works for now List <int> ls = HardwareUtil.getAddrOfNode(treeView1.SelectedNode); // Add a node to tree and add its associated component to the session if (HardwareCompatibilityManager.isCompatible(session.components[selectedComponent], session.computers[ls[0]])) { treeView1.Nodes[ls[0]].Nodes.Add(session.components[selectedComponent].Name); session.computers[ls[0]].addComponent(session.components[selectedComponent]); } else { String msg = String.Format( "Component `{0}` (platform `{1}`) is not compatible with PC {2} (platform `{3}`).", session.components[selectedComponent].Name, session.components[selectedComponent].Platform, session.computers[ls[0]].ID, session.computers[ls[0]].Platform ); HardwareUtil.compatibilityAlert(msg); } treeView1.ExpandAll(); } } } }