SettingView.xaml.cs 928 B

123456789101112131415161718192021222324252627282930313233343536
  1. using NatTypeTester.ViewModels;
  2. using ReactiveUI;
  3. using STUN.Enums;
  4. using System.Reactive.Disposables;
  5. namespace NatTypeTester.Views
  6. {
  7. public partial class SettingView
  8. {
  9. public SettingView(SettingViewModel viewModel)
  10. {
  11. InitializeComponent();
  12. ViewModel = viewModel;
  13. this.WhenActivated(d =>
  14. {
  15. this.Bind(ViewModel, vm => vm.Config.ProxyServer, v => v.ProxyServerTextBox.Text).DisposeWith(d);
  16. this.Bind(ViewModel, vm => vm.Config.ProxyUser, v => v.ProxyUsernameTextBox.Text).DisposeWith(d);
  17. this.Bind(ViewModel, vm => vm.Config.ProxyPassword, v => v.ProxyPasswordTextBox.Text).DisposeWith(d);
  18. this.Bind(ViewModel,
  19. vm => vm.Config.ProxyType,
  20. v => v.ProxyRadioButtons.SelectedIndex,
  21. type => (int)type,
  22. index =>
  23. {
  24. var type = (ProxyType)index;
  25. ProxyConfigGrid.IsEnabled = type is not ProxyType.Plain;
  26. return type;
  27. }).DisposeWith(d);
  28. });
  29. }
  30. }
  31. }