void Button6Click(object sender, EventArgs e) { if (_addAction == AddActions.Interface) { AddEditInterfaceDialog d = new AddEditInterfaceDialog(Configuration, null); if (d.ShowDialog(this) == DialogResult.OK) { // dodanie interfejsu List <RS232Configuration> rss = new List <RS232Configuration>(Configuration.Interfaces); rss.Add(d.Interface); Configuration.Interfaces = rss.ToArray(); InterfaceTreeNode node = new InterfaceTreeNode(d.Interface); _root.Nodes.Add(node); treeView1.SelectedNode = node; } return; } if (_addAction == AddActions.Device) { contextMenuStrip2.Show(button6, new Point(0, 0)); } }
public ConfigurationDialog(XMLConfiguration xmlConfiguration, HomeSimCockpitSDK.ILog log, HomeSimCockpitSDK.IModule module) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); Configuration = xmlConfiguration; _root = treeView1.Nodes[0]; // pokazanie interfejsów i urządzeń Array.Sort <RS232Configuration>(xmlConfiguration.Interfaces); Array.Sort <LEDDevice>(xmlConfiguration.LEDDevices); Array.Sort <LCDDevice>(xmlConfiguration.LCDDevices); Array.Sort <LEDDisplayDevice>(xmlConfiguration.LEDDisplayDevices); Array.Sort <KeysDevice>(xmlConfiguration.KeysDevices); Array.Sort <Steppers.StepperDevice>(xmlConfiguration.StepperDevices); Array.Sort <Servos.ServoDevice>(xmlConfiguration.ServoDevices); for (int i = 0; i < xmlConfiguration.Interfaces.Length; i++) { InterfaceTreeNode node = new InterfaceTreeNode(xmlConfiguration.Interfaces[i]); _root.Nodes.Add(node); // dodanie wszystkich LCDDevice podpiętych do tego interfejsu for (int j = 0; j < xmlConfiguration.LCDDevices.Length; j++) { if (xmlConfiguration.LCDDevices[j].Interface == xmlConfiguration.Interfaces[i]) { TreeNode n = new TreeNode(xmlConfiguration.LCDDevices[j].Name2); n.Tag = xmlConfiguration.LCDDevices[j]; node.Nodes.Add(n); } } // dodanie wszystkich LEDDevice podpiętych do tego interfejsu for (int j = 0; j < xmlConfiguration.LEDDevices.Length; j++) { if (xmlConfiguration.LEDDevices[j].Interface == xmlConfiguration.Interfaces[i]) { TreeNode n = new TreeNode(xmlConfiguration.LEDDevices[j].Name2); n.Tag = xmlConfiguration.LEDDevices[j]; node.Nodes.Add(n); } } // dodanie wszystkich LEDDisplayDevice podpiętych do tego interfejsu for (int j = 0; j < xmlConfiguration.LEDDisplayDevices.Length; j++) { if (xmlConfiguration.LEDDisplayDevices[j].Interface == xmlConfiguration.Interfaces[i]) { TreeNode n = new TreeNode(xmlConfiguration.LEDDisplayDevices[j].Name2); n.Tag = xmlConfiguration.LEDDisplayDevices[j]; node.Nodes.Add(n); } } // dodanie wszystkich StepperDevice podpiętych do tego interfejsu for (int j = 0; j < xmlConfiguration.StepperDevices.Length; j++) { if (xmlConfiguration.StepperDevices[j].Interface == xmlConfiguration.Interfaces[i]) { TreeNode n = new TreeNode(xmlConfiguration.StepperDevices[j].Name2); n.Tag = xmlConfiguration.StepperDevices[j]; node.Nodes.Add(n); } } // dodanie wszystkich ServoDevice podpiętych do tego interfejsu for (int j = 0; j < xmlConfiguration.ServoDevices.Length; j++) { if (xmlConfiguration.ServoDevices[j].Interface == xmlConfiguration.Interfaces[i]) { TreeNode n = new TreeNode(xmlConfiguration.ServoDevices[j].Name2); n.Tag = xmlConfiguration.ServoDevices[j]; node.Nodes.Add(n); } } // dodanie wszystkich KeysDevice podpiętych do tego interfejsu for (int j = 0; j < xmlConfiguration.KeysDevices.Length; j++) { if (xmlConfiguration.KeysDevices[j].Interface == xmlConfiguration.Interfaces[i]) { TreeNode n = new TreeNode(xmlConfiguration.KeysDevices[j].Name2); n.Tag = xmlConfiguration.KeysDevices[j]; node.Nodes.Add(n); } } } treeView1.ExpandAll(); treeView1.SelectedNode = _root; ShowVariables(); _log = log; _module = module; }