diff --git a/src/client/DCSInsight/UserControls/UserControlAPI.xaml b/src/client/DCSInsight/UserControls/UserControlAPI.xaml index 4b1c4e4..6c81049 100644 --- a/src/client/DCSInsight/UserControls/UserControlAPI.xaml +++ b/src/client/DCSInsight/UserControls/UserControlAPI.xaml @@ -25,7 +25,8 @@ - + + diff --git a/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs b/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs index 6a12472..e195256 100644 --- a/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs +++ b/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs @@ -49,14 +49,15 @@ protected override void SetFormState() if (ButtonSend == null) throw new Exception("ButtonSend is null."); ButtonSend.IsEnabled = !TextBoxParameterList.Any(o => string.IsNullOrEmpty(o.Text)) && IsConnected; - - if (DCSAPI.ReturnsData && !IsLuaConsole) + + if (DCSAPI.ReturnsData) { if (ComboBoxPollTimes == null || CheckBoxPolling == null) throw new Exception("ComboBoxPollTimes or CheckBoxPolling is null."); CheckBoxPolling.IsEnabled = ButtonSend.IsEnabled; ComboBoxPollTimes.IsEnabled = CheckBoxPolling.IsChecked == false; } + CanSend = ButtonSend.IsEnabled; } catch (Exception ex) @@ -88,6 +89,9 @@ private void BuildLuaConsoleUI() TextBoxSyntax.MouseLeave -= Common.MouseLeave; StackPanelBottom.Visibility = Visibility.Visible; + StackPanelLinks.Visibility = Visibility.Visible; + StackPanelConsolePolling.Visibility = Visibility.Visible; + var dockPanelParameters = Application.Current.MainWindow.FindChild("DockPanelParameters") ?? throw new Exception("Failed to find DockPanelParameters"); dockPanelParameters.LastChildFill = true; var controlList = new List(); @@ -164,6 +168,14 @@ void LabelDefaultLuaOnMouseDown(object sender, MouseButtonEventArgs e) labelDefaultLua.Tag = textBoxLuaCode; StackPanelLinks.Children.Add(labelDefaultLua); + StackPanelConsolePolling.Children.Add(GetLabelKeepResults()); + StackPanelConsolePolling.Children.Add(GetCheckBoxKeepResults()); + StackPanelConsolePolling.Children.Add(GetLabelPolling()); + StackPanelConsolePolling.Children.Add(GetCheckBoxPolling()); + StackPanelConsolePolling.Children.Add(GetLabelPollingInterval()); + StackPanelConsolePolling.Children.Add(GetComboBoxPollTimes()); + StackPanelConsolePolling.UpdateLayout(); + controlList.Add(textBoxLuaCode); TextBoxParameterList.Add(textBoxLuaCode); diff --git a/src/client/DCSInsight/UserControls/UserControlAPIBase.cs b/src/client/DCSInsight/UserControls/UserControlAPIBase.cs index 43e2b7b..20162bf 100644 --- a/src/client/DCSInsight/UserControls/UserControlAPIBase.cs +++ b/src/client/DCSInsight/UserControls/UserControlAPIBase.cs @@ -227,8 +227,10 @@ private void CheckBoxPolling_OnChecked(object sender, RoutedEventArgs e) { try { - var comboBoxPollTimes = (ComboBox)sender; - StartPolling(int.Parse(comboBoxPollTimes.SelectedValue.ToString() ?? "500")); + if (ComboBoxPollTimes == null) + throw new ArgumentException("ComboBoxPollTimes has not been created, cannot poll."); + + StartPolling(int.Parse(ComboBoxPollTimes.SelectedValue.ToString() ?? "500")); SetFormState(); } catch (Exception ex)