NetworkInfoView.xaml.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. private APIHandler handler;
  23. private ZeroTierNetwork network;
  24. public NetworkInfoView(APIHandler handler, ZeroTierNetwork network)
  25. {
  26. InitializeComponent();
  27. this.handler = handler;
  28. this.network = network;
  29. UpdateNetworkData();
  30. }
  31. private void UpdateNetworkData()
  32. {
  33. this.networkId.Text = network.NetworkId;
  34. this.networkName.Text = network.NetworkName;
  35. this.networkStatus.Text = network.NetworkStatus;
  36. this.networkType.Text = network.NetworkType;
  37. this.macAddress.Text = network.MacAddress;
  38. this.mtu.Text = network.MTU.ToString();
  39. this.broadcastEnabled.Text = (network.BroadcastEnabled ? "ENABLED" : "DISABLED");
  40. this.bridgingEnabled.Text = (network.Bridge ? "ENABLED" : "DISABLED");
  41. this.deviceName.Text = network.DeviceName;
  42. string iplist = "";
  43. for (int i = 0; i < network.AssignedAddresses.Length; ++i)
  44. {
  45. iplist += network.AssignedAddresses[i];
  46. if (i < (network.AssignedAddresses.Length - 1))
  47. iplist += "\n";
  48. }
  49. this.managedIps.Text = iplist;
  50. }
  51. public bool HasNetwork(ZeroTierNetwork network)
  52. {
  53. if (this.network.NetworkId.Equals(network.NetworkId))
  54. return true;
  55. return false;
  56. }
  57. private void leaveButton_Click(object sender, RoutedEventArgs e)
  58. {
  59. handler.LeaveNetwork(network.NetworkId);
  60. }
  61. }
  62. }