private static Dictionary <int, DeviceSymbol> GetDeviceSymbolById(E3Project project, E3Text text, Dictionary <int, DeviceConnection> deviceConnectionById) { NormalDevice device = project.GetNormalDeviceById(0); DevicePin pin = project.GetDevicePinById(0); Dictionary <int, DeviceSymbol> deviceSymbolById = new Dictionary <int, DeviceSymbol>(); foreach (int connectionId in deviceConnectionById.Keys) { DeviceConnection deviceConnection = deviceConnectionById[connectionId]; int startId = deviceConnection.StartDeviceId; int endId = deviceConnection.EndDeviceId; if (!deviceSymbolById.ContainsKey(startId)) { device.Id = startId; deviceSymbolById.Add(startId, new DeviceSymbol(device, pin)); } if (!deviceSymbolById.ContainsKey(endId)) { device.Id = endId; deviceSymbolById.Add(endId, new DeviceSymbol(device, pin)); } deviceSymbolById[startId].ConnectionIds.Add(connectionId); deviceSymbolById[endId].ConnectionIds.Add(connectionId); } foreach (DeviceSymbol deviceSymbol in deviceSymbolById.Values) { deviceSymbol.SetCableIds(deviceConnectionById); deviceSymbol.SetPinsAndHeightAndNameWidth(deviceConnectionById, deviceSymbolById, text); } return(deviceSymbolById); }
private void GetPins(Dictionary <int, DeviceConnection> deviceConnectionById, Dictionary <int, DeviceSymbol> deviceSymbolById, E3Text text) { Dictionary <string, SymbolPin> topPinByName = new Dictionary <string, SymbolPin>(); Dictionary <string, SymbolPin> bottomPinByName = new Dictionary <string, SymbolPin>(); foreach (int connectionId in ConnectionIds) { DeviceConnection connection = deviceConnectionById[connectionId]; int connectedId; string pinName; if (id == connection.StartDeviceId) { connectedId = connection.EndDeviceId; pinName = connection.StartPinName; } else { connectedId = connection.StartDeviceId; pinName = connection.EndPinName; } string connectedAssignment = deviceSymbolById[connectedId].Assignment; if (!String.IsNullOrEmpty(Assignment) && String.IsNullOrEmpty(connectedAssignment)) { if (!topPinByName.ContainsKey(pinName)) { SymbolPin pin = new SymbolPin(pinName, connection.Signal, text, smallFont); topPinByName.Add(pinName, pin); } topPinByName[pinName].CableIds.Add(connection.CableId); } else { if (!bottomPinByName.ContainsKey(pinName)) { SymbolPin pin = new SymbolPin(pinName, connection.Signal, text, smallFont); bottomPinByName.Add(pinName, pin); } bottomPinByName[pinName].CableIds.Add(connection.CableId); } } topPins = topPinByName.Values.ToList(); bottomPins = bottomPinByName.Values.ToList(); NaturalSortingStringComparer stringComparer = new NaturalSortingStringComparer(); topPins.Sort((p1, p2) => stringComparer.Compare(p1.Name, p2.Name)); bottomPins.Sort((p1, p2) => stringComparer.Compare(p1.Name, p2.Name)); }