using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using Autolabor; namespace LoraGamepad.Models; public class CBPortItem { public string PortName { get; set; } public CBPortItem(string name) { PortName = name; } public static ObservableCollection GetPortList() { ObservableCollection portList = new ObservableCollection(); List infos = SerialPort.FindPorts(); foreach (var portInfo in infos) { portList.Add(new CBPortItem(portInfo.port)); } return portList; } } public class CBPortItemCompare : IEqualityComparer { public bool Equals(CBPortItem? x, CBPortItem? y) { if (ReferenceEquals(x, y)) return true; if (ReferenceEquals(x, null)) return false; if (ReferenceEquals(y, null)) return false; if (x.GetType() != y.GetType()) return false; return x.PortName == y.PortName; } public int GetHashCode(CBPortItem obj) { return obj.PortName.GetHashCode(); } }