コード例 #1
0
 private void UIElement_OnLostFocus(object sender, RoutedEventArgs e)
 {
     try
     {
         if (_viewModel.IpAddress == _client.IpAddress && _viewModel.Port == _client.Port)
         {
             return;
         }
         _client?.Disconnect();
         _client.IpAddress = _viewModel.IpAddress;
         _client.Port      = _viewModel.Port;
     }
     catch (Exception ex)
     {
         MessageBox.Show(this.GetParentWindowRecurs(), ex.Message);
     }
 }
コード例 #2
0
 private async void DisconnectButton_OnClick(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!_client.IsConnected)
         {
             throw new InvalidOperationException("client not connected");
         }
         IsEnabled = false;
         await _client.Disconnect();
     }
     catch (Exception ex)
     {
         MessageBox.Show(this.GetParentWindowRecurs(), ex.Message);
     }
     finally
     {
         IsEnabled = true;
     }
 }