MainWindow.xaml.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace WinUI
  17. {
  18. /// <summary>
  19. /// Interaction logic for MainWindow.xaml
  20. /// </summary>
  21. public partial class MainWindow : Window
  22. {
  23. APIHandler handler = new APIHandler();
  24. public MainWindow()
  25. {
  26. InitializeComponent();
  27. updateStatus();
  28. updateNetworks();
  29. }
  30. private void updateStatus()
  31. {
  32. var status = handler.GetStatus();
  33. this.networkId.Content = status.Address;
  34. this.versionString.Content = status.Version;
  35. this.onlineStatus.Content = (status.Online ? "ONLINE" : "OFFLINE");
  36. }
  37. private void updateNetworks()
  38. {
  39. var networks = handler.GetNetworks();
  40. networksPage.setNetworks(networks);
  41. }
  42. private void joinButton_Click(object sender, RoutedEventArgs e)
  43. {
  44. }
  45. private void OnNetworkEntered(object sender, TextCompositionEventArgs e)
  46. {
  47. Regex regex = new Regex("[0-9a-fxA-FX]");
  48. e.Handled = !regex.IsMatch(e.Text);
  49. }
  50. }
  51. }