NetworkInfoView.xaml.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 NetworkInfoView.xaml
  19. /// </summary>
  20. public partial class NetworkInfoView : UserControl
  21. {
  22. ZeroTierNetwork network;
  23. public NetworkInfoView(ZeroTierNetwork network)
  24. {
  25. InitializeComponent();
  26. this.network = network;
  27. UpdateNetworkData();
  28. }
  29. private void UpdateNetworkData()
  30. {
  31. this.networkId.Text = network.NetworkId;
  32. this.networkName.Text = network.NetworkName;
  33. this.networkStatus.Text = network.NetworkStatus;
  34. this.networkType.Text = network.NetworkType;
  35. this.macAddress.Text = network.MacAddress;
  36. this.mtu.Text = network.MTU.ToString();
  37. this.broadcastEnabled.Text = (network.BroadcastEnabled ? "ENABLED" : "DISABLED");
  38. this.bridgingEnabled.Text = (network.Bridge ? "ENABLED" : "DISABLED");
  39. this.deviceName.Text = network.DeviceName;
  40. string iplist = "";
  41. for (int i = 0; i < network.AssignedAddresses.Length; ++i)
  42. {
  43. iplist += network.AssignedAddresses[i];
  44. if (i < (network.AssignedAddresses.Length - 1))
  45. iplist += "\n";
  46. }
  47. this.managedIps.Text = iplist;
  48. }
  49. public bool HasNetwork(ZeroTierNetwork network)
  50. {
  51. if (this.network.NetworkId.Equals(network.NetworkId))
  52. return true;
  53. return false;
  54. }
  55. }
  56. }