PeersPage.xaml.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace WinUI
  16. {
  17. /// <summary>
  18. /// Interaction logic for PeersPage.xaml
  19. /// </summary>
  20. public partial class PeersPage : UserControl
  21. {
  22. private List<ZeroTierPeer> peersList = new List<ZeroTierPeer>();
  23. public PeersPage()
  24. {
  25. InitializeComponent();
  26. dataGrid.ItemsSource = peersList;
  27. }
  28. public void SetPeers(List<ZeroTierPeer> list)
  29. {
  30. if (list == null)
  31. return;
  32. foreach(ZeroTierPeer p in list)
  33. {
  34. ZeroTierPeer curPeer = peersList.Find(peer => peer.Equals(p));
  35. if (curPeer == null)
  36. {
  37. peersList.Add(p);
  38. }
  39. else
  40. {
  41. curPeer.Update(p);
  42. }
  43. }
  44. dataGrid.Items.Refresh();
  45. }
  46. }
  47. }