private void droneListBox_MouseDoubleClick(object sender, MouseEventArgs e) { if (droneListBox.SelectedItem == null) { return; } DroneEntry entry = (DroneEntry)droneListBox.SelectedItem; Connect(entry.Address); }
private void HandlePacket(byte[] packet, IPEndPoint sender) { try { using (MemoryStream stream = new MemoryStream(packet)) { PacketBuffer buffer = new PacketBuffer(stream); if (packet.Length < 3 || buffer.ReadByte() != 'F' || buffer.ReadByte() != 'L' || buffer.ReadByte() != 'Y') { Log.Debug("Hello: Invalid magic value!"); return; } if (buffer.ReadByte() != (byte)HelloPacketType.Answer) return; DroneEntry entry = new DroneEntry(); entry.Address = sender.Address; entry.LastFound = DateTime.Now; entry.Name = buffer.ReadString(); entry.Model = buffer.ReadString(); entry.SerialCode = buffer.ReadString(); entry.FirmwareVersion = buffer.ReadByte(); AddDrone(entry); } } catch (Exception e) { Log.Error(e.ToString()); } }
private bool UpdateDrone(DroneEntry entry) { for (int i = 0; i < foundDrones.Count; i++) { DroneEntry e = foundDrones[i]; if (e.Address.Equals(entry.Address)) { foundDrones[i] = DroneEntry.UpdateEntry(entry); if (!e.Equals(entry)) InvokeEvent(); return true; } } return false; }
private void AddDrone(DroneEntry entry) { lock(foundDrones) { if (UpdateDrone(entry)) return; // alte Drone mit gleicher IP-Adresse entfernen RemoveDrone(entry.Address); foundDrones.Add(entry); } InvokeEvent(); }
public DroneListChangedEventArgs(DroneEntry[] entries) { this.Entries = entries; }