public componentInfoUserControl(MainWindow mainWindow, DBManager dbManager) { this.dbManager = dbManager; this.mainWindow = mainWindow; batteryPanel = new BatteryInfo(this, dbManager); motorPanel = new MotorInfo(this, dbManager); propellerPanel = new PropellerInfo(this, dbManager); batteryPanel.Location = new Point(10, 50); motorPanel.Location = new Point(10, 50); propellerPanel.Location = new Point(10, 50); InitializeComponent(); Controls.Add(batteryPanel); Controls.Add(motorPanel); Controls.Add(propellerPanel); batteryPanel.deactivateControl(); }
public void displayComponentInfo(TreeView treeView) { try { //Check if the root node is "Batteries" if (treeView.SelectedNode.Parent.Parent.Text.Equals("Batteries")) { //If there is another panel currently displayed, hide it try { currentPanel.deactivateControl(); } catch { Exception e = new NullReferenceException(); } //Show the battery panel and set it as the currently displayed panel batteryPanel.activateControl(); typeInfoLabel.Text = "Battery"; currentPanel = batteryPanel; batteryPanel.update(treeControl.getTreeView()); } if(treeView.SelectedNode.Parent.Parent.Text.Equals("Propellers")) { //If there is another panel currently displayed, hide it try { currentPanel.deactivateControl(); } catch { Exception e = new NullReferenceException(); } //Show the propeller panel and set it as the currently displayed panel propellerPanel.activateControl(); typeInfoLabel.Text = "Propeller"; currentPanel = propellerPanel; propellerPanel.update(treeControl.getTreeView()); } } catch { try { //If this node does not have a parent node which also has a parent node, then do nothing. if (treeView.SelectedNode.Parent.Text.Equals("Motors")) { //If there is another panel currently displayed, hide it try { currentPanel.deactivateControl(); } catch { } //Show the motor panel and set it as the currently displayed panel motorPanel.activateControl(); typeInfoLabel.Text = "Motor"; currentPanel = motorPanel; motorPanel.update(treeControl.getTreeView()); } } catch { } } }