diff --git a/src/client/DCSInsight/MainWindow.xaml b/src/client/DCSInsight/MainWindow.xaml index d0f5ce0..5c9381c 100644 --- a/src/client/DCSInsight/MainWindow.xaml +++ b/src/client/DCSInsight/MainWindow.xaml @@ -43,7 +43,7 @@ - dcs-insight + dcs-insight wiki @@ -55,7 +55,10 @@ set dcs-bios - API Reload Setting + api reload setting + + + view client log diff --git a/src/client/DCSInsight/MainWindow.xaml.cs b/src/client/DCSInsight/MainWindow.xaml.cs index 0f047c0..e3ea7e3 100644 --- a/src/client/DCSInsight/MainWindow.xaml.cs +++ b/src/client/DCSInsight/MainWindow.xaml.cs @@ -487,22 +487,7 @@ private void ShowVersionInfo() Common.ShowErrorMessageBox(ex); } } - - private void TextBlockAppInfo_OnMouseDown(object sender, MouseButtonEventArgs e) - { - try - { - TryOpenLogFileWithTarget("logfile"); - if (_tcpClientHandler == null) return; - - _tcpClientHandler.LogJSON = true; - } - catch (Exception ex) - { - Common.ShowErrorMessageBox(ex); - } - } - + private void ButtonRangeTest_OnClick(object sender, RoutedEventArgs e) { try @@ -645,5 +630,20 @@ private void TextBlockAPIReload_OnMouseDown(object sender, MouseButtonEventArgs Common.ShowErrorMessageBox(ex); } } + + private void TextBlockViewLog_OnMouseDown(object sender, MouseButtonEventArgs e) + { + try + { + TryOpenLogFileWithTarget("logfile"); + if (_tcpClientHandler == null) return; + + _tcpClientHandler.LogJSON = true; + } + catch (Exception ex) + { + Common.ShowErrorMessageBox(ex); + } + } } } diff --git a/src/client/DCSInsight/Misc/Common.cs b/src/client/DCSInsight/Misc/Common.cs index bc884a5..b7e8b37 100644 --- a/src/client/DCSInsight/Misc/Common.cs +++ b/src/client/DCSInsight/Misc/Common.cs @@ -29,8 +29,7 @@ internal static string GetApplicationPath() internal static void ShowErrorMessageBox(Exception ex, string? message = null) { - if(message != null) Logger.Error(ex, message); - + Logger.Error(ex, message ?? ""); MessageBox.Show(ex.Message, $"Details logged to error log.{Environment.NewLine}{ex.Source}", MessageBoxButton.OK, MessageBoxImage.Error); } diff --git a/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs b/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs index eab6c74..6a12472 100644 --- a/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs +++ b/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs @@ -16,14 +16,13 @@ namespace DCSInsight.UserControls /// public partial class UserControlAPI : UserControlAPIBase { - private readonly DockPanel _dockPanelParameters; public UserControlAPI(DCSAPI dcsAPI, bool isConnected) : base(dcsAPI, isConnected) { InitializeComponent(); LabelResultBase = LabelResult; TextBoxResultBase = TextBoxResult; - _dockPanelParameters = Application.Current.MainWindow.FindChild("DockPanelParameters") ?? throw new Exception("Failed to find DockPanelParameters"); + } private void UserControlAPI_OnLoaded(object sender, RoutedEventArgs e) @@ -85,9 +84,12 @@ private void BuildLuaConsoleUI() try { TextBoxSyntax.Text = DCSAPI.Syntax; - TextBoxSyntax.ToolTip = $"Click to copy syntax. (API Id = {DCSAPI.Id})"; + TextBoxSyntax.MouseEnter -= Common.MouseEnter; + TextBoxSyntax.MouseLeave -= Common.MouseLeave; + StackPanelBottom.Visibility = Visibility.Visible; - _dockPanelParameters.LastChildFill = true; + var dockPanelParameters = Application.Current.MainWindow.FindChild("DockPanelParameters") ?? throw new Exception("Failed to find DockPanelParameters"); + dockPanelParameters.LastChildFill = true; var controlList = new List(); var textBoxLuaCode = new TextBox @@ -106,10 +108,7 @@ private void BuildLuaConsoleUI() VerticalScrollBarVisibility = ScrollBarVisibility.Auto }; - TextBoxSyntax.PreviewMouseDown -= TextBoxSyntax_OnPreviewMouseDown; - TextBoxSyntax.MouseEnter -= Common.MouseEnter; - TextBoxSyntax.MouseLeave -= Common.MouseLeave; - TextBoxSyntax.ToolTip = null; + textBoxLuaCode.PreviewKeyDown += TextBoxLuaCode_OnPreviewKeyDown; var brushConverter = new BrushConverter().ConvertFromString("#0000FF"); var labelConsoleWarning = new Label @@ -164,9 +163,7 @@ void LabelDefaultLuaOnMouseDown(object sender, MouseButtonEventArgs e) labelDefaultLua.Tag = textBoxLuaCode; StackPanelLinks.Children.Add(labelDefaultLua); - - textBoxLuaCode.KeyUp += TextBoxParameter_OnKeyUp; - + controlList.Add(textBoxLuaCode); TextBoxParameterList.Add(textBoxLuaCode); diff --git a/src/client/DCSInsight/UserControls/UserControlAPIBase.cs b/src/client/DCSInsight/UserControls/UserControlAPIBase.cs index 9897add..43e2b7b 100644 --- a/src/client/DCSInsight/UserControls/UserControlAPIBase.cs +++ b/src/client/DCSInsight/UserControls/UserControlAPIBase.cs @@ -101,7 +101,7 @@ private string ResultTextBoxFirstLine() if (string.IsNullOrEmpty(textBoxResultText)) return ""; - return textBoxResultText.Contains('\n', StringComparison.Ordinal) ? textBoxResultText : textBoxResultText[..textBoxResultText.IndexOf("\n", StringComparison.Ordinal)]; + return textBoxResultText.Contains('\n', StringComparison.Ordinal) == false ? textBoxResultText : textBoxResultText[..textBoxResultText.IndexOf("\n", StringComparison.Ordinal)]; } internal void SetResult(DCSAPI dcsApi) @@ -155,7 +155,7 @@ public void SetConnectionStatus(bool connected) } } - protected void ButtonSend_OnClick(object sender, RoutedEventArgs e) + private void ButtonSend_OnClick(object sender, RoutedEventArgs e) { try { @@ -266,15 +266,25 @@ private void TextBoxParameter_OnKeyDown_Number(object sender, KeyEventArgs e) Common.ShowErrorMessageBox(ex); } } + + private void CheckBoxKeepResults_OnUnchecked(object sender, RoutedEventArgs e) + { + try + { + _keepResults = false; + SetFormState(); + } + catch (Exception ex) + { + Common.ShowErrorMessageBox(ex); + } + } - protected void TextBoxParameter_OnKeyUp(object sender, KeyEventArgs e) + private void CheckBoxKeepResults_OnChecked(object sender, RoutedEventArgs e) { try { - if (e.Key == Key.Enter && CanSend) - { - SendCommand(); - } + _keepResults = true; SetFormState(); } catch (Exception ex) @@ -283,11 +293,17 @@ protected void TextBoxParameter_OnKeyUp(object sender, KeyEventArgs e) } } - private void CheckBoxKeepResults_OnUnchecked(object sender, RoutedEventArgs e) + protected void TextBoxLuaCode_OnPreviewKeyDown(object sender, KeyEventArgs e) { try { - _keepResults = false; + if (e.Key == Key.Enter && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && CanSend) + { + SendCommand(); + e.Handled = true; + return; + } + SetFormState(); } catch (Exception ex) @@ -296,11 +312,14 @@ private void CheckBoxKeepResults_OnUnchecked(object sender, RoutedEventArgs e) } } - private void CheckBoxKeepResults_OnChecked(object sender, RoutedEventArgs e) + private void TextBoxParameter_OnKeyUp(object sender, KeyEventArgs e) { try { - _keepResults = true; + if (e.Key == Key.Enter && CanSend) + { + SendCommand(); + } SetFormState(); } catch (Exception ex)