SettingView.xaml.cs 1009 B

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