コード例 #1
0
        private async void SendButton_Click(object sender,
                                            RoutedEventArgs e)
        {
            SendButton.IsEnabled = false;

            SendButton.Focus();

            var result = await PostApi.AddComment(
                SettingsManager.PersistentSettings.CurrentUser.Token,
                PostId, ContentTextBox.Text, IsAnonymous)
                         .ConfigureAwait(true);

            if (result.IsError)
            {
                await DialogManager.ShowErrorDialog(result.Message)
                .ConfigureAwait(true);

                SendButton.IsEnabled = true;
                return;
            }

            ContentTextBox.Text = string.Empty;

            RaiseEvent(new RoutedEventArgs(CommentAddEvent));

            ContentTextBox.Focus();

            SendButton.IsEnabled = true;
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: alski/ndistribute
 private void TextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter &&
         e.KeyboardDevice.Modifiers == ModifierKeys.None)
     {
         SendButton.Focus();
         ((ChatViewModel)SendButton.DataContext).SendCommand.Execute(null);
         ((TextBox)sender).Focus();
     }
 }
コード例 #3
0
 private void ContentTextBox_KeyUp(object sender,
                                   KeyEventArgs e)
 {
     if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control) && e.Key == Key.Enter)
     {
         if (SendButton.IsEnabled)
         {
             SendButton.Focus();
             SendButton_Click(this, new RoutedEventArgs());
         }
     }
 }