private void SubHardwareAdded(IHardware hardware, Node node) { HardwareNode hardwareNode = new HardwareNode(hardware, _settings, _unitManager); hardwareNode.PlotSelectionChanged += PlotSelectionChanged; InsertSorted(node.Nodes, hardwareNode); foreach (IHardware subHardware in hardware.SubHardware) { SubHardwareAdded(subHardware, hardwareNode); } }
private void InsertSorted(IList <Node> nodes, HardwareNode node) { int i = 0; while (i < nodes.Count && nodes[i] is HardwareNode && ((HardwareNode)nodes[i]).Hardware.HardwareType <= node.Hardware.HardwareType) { i++; } nodes.Insert(i, node); }