RFC3489Page.xaml.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. namespace NatTypeTester.Views;
  2. [ExposeServices(typeof(IViewFor<RFC3489ViewModel>))]
  3. [UsedImplicitly]
  4. internal sealed partial class RFC3489Page : ITransientDependency
  5. {
  6. public RFC3489Page(RFC3489ViewModel viewModel)
  7. {
  8. InitializeComponent();
  9. ViewModel = viewModel;
  10. this.WhenActivated(d =>
  11. {
  12. this.OneWayBind(ViewModel, vm => vm.Result3489.NatType, v => v.NatTypeTextBox.Text).DisposeWith(d);
  13. this.Bind(ViewModel, vm => vm.Result3489.LocalEndPoint, v => v.LocalEndComboBox.Text).DisposeWith(d);
  14. LocalEndComboBox.Events().LostFocus.Subscribe(_ => LocalEndComboBox.Text = ViewModel.Result3489.LocalEndPoint?.ToString()).DisposeWith(d);
  15. this.OneWayBind(ViewModel, vm => vm.Result3489.PublicEndPoint, v => v.PublicEndTextBox.Text).DisposeWith(d);
  16. this.BindCommand(ViewModel, vm => vm.TestClassicNatType, v => v.TestButton).DisposeWith(d);
  17. this.Events().KeyDown
  18. .Where(x => x.Key is VirtualKey.Enter && TestButton.Command.CanExecute(default))
  19. .Subscribe(_ => TestButton.Command.Execute(default))
  20. .DisposeWith(d);
  21. ViewModel.TestClassicNatType.ThrownExceptions.Subscribe(ex => ex.HandleExceptionWithContentDialogAsync(Content.XamlRoot).Forget()).DisposeWith(d);
  22. });
  23. }
  24. }