diff --git a/ui/dockpane/DialogDockpane.xaml b/ui/dockpane/DialogDockpane.xaml index b62fab7..fd7b7fc 100644 --- a/ui/dockpane/DialogDockpane.xaml +++ b/ui/dockpane/DialogDockpane.xaml @@ -61,7 +61,7 @@ - + diff --git a/ui/dockpane/DialogDockpane.xaml.cs b/ui/dockpane/DialogDockpane.xaml.cs index 6d535d6..306cf19 100644 --- a/ui/dockpane/DialogDockpane.xaml.cs +++ b/ui/dockpane/DialogDockpane.xaml.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections.Specialized; using System.ComponentModel; using System.IO; using System.Net.Http; @@ -14,6 +15,7 @@ using Microsoft.Extensions.Logging; using System.Text.Json; using System.Threading; using System.Windows.Documents; +using System.Windows.Input; using System.Windows.Media; using ArcGIS.Desktop.Core; using ArcGIS.Desktop.Core.Geoprocessing; @@ -639,5 +641,43 @@ namespace LinkToolAddin.ui.dockpane string model = ModelComboBox.SelectedValue.ToString(); log.Info(model); } + + private void QuestionTextbox_OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) + { + // Shift + Enter: 插入换行 + QuestionTextbox.SelectedText = Environment.NewLine; + e.Handled = true; + } + else + { + // Enter: 触发发送 + e.Handled = true; + SendButton_OnClick(sender, null); + } + } + } + + private void QuestionTextbox_OnPreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) + { + // Shift + Enter: 插入换行 + QuestionTextbox.SelectedText = Environment.NewLine; + e.Handled = true; + } + else + { + // Enter: 触发发送 + e.Handled = true; + SendButton_OnClick(sender, null); + } + } + } } }