diff --git a/src/client/DCSInsight/DCSInsight.csproj b/src/client/DCSInsight/DCSInsight.csproj index c81e709..ba5f39e 100644 --- a/src/client/DCSInsight/DCSInsight.csproj +++ b/src/client/DCSInsight/DCSInsight.csproj @@ -8,7 +8,7 @@ dcs-insight 1.0.0 - 1.9.0 + 1.9.1 Images\Magnifier_icon.ico diff --git a/src/client/DCSInsight/MainWindow.xaml b/src/client/DCSInsight/MainWindow.xaml index b47795c..4195a94 100644 --- a/src/client/DCSInsight/MainWindow.xaml +++ b/src/client/DCSInsight/MainWindow.xaml @@ -5,6 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Icon="/dcs-insight;component/Images/Magnifier_icon.png" xmlns:local="clr-namespace:DCSInsight" + xmlns:misc="clr-namespace:DCSInsight.Misc" mc:Ignorable="d" Title="DCS-Insight" Height="560" Width="750" WindowStartupLocation="CenterScreen" Closing="MainWindow_OnClosing" Loaded="MainWindow_OnLoaded"> @@ -44,13 +45,13 @@ dcs-insight - + wiki - + check version - + set dcs-bios diff --git a/src/client/DCSInsight/MainWindow.xaml.cs b/src/client/DCSInsight/MainWindow.xaml.cs index c9d36d6..79d48c1 100644 --- a/src/client/DCSInsight/MainWindow.xaml.cs +++ b/src/client/DCSInsight/MainWindow.xaml.cs @@ -528,16 +528,6 @@ private void TextBlockAppWiki_OnMouseDown(object sender, MouseButtonEventArgs e) }); } - private void UIElement_OnMouseEnter(object sender, MouseEventArgs e) - { - Mouse.OverrideCursor = Cursors.Hand; - } - - private void UIElement_OnMouseLeave(object sender, MouseEventArgs e) - { - Mouse.OverrideCursor = Cursors.Arrow; - } - private async void TextBlockCheckNewVersion_OnMouseDown(object sender, MouseButtonEventArgs e) { try diff --git a/src/client/DCSInsight/Misc/Common.cs b/src/client/DCSInsight/Misc/Common.cs index 5ff2358..0b87287 100644 --- a/src/client/DCSInsight/Misc/Common.cs +++ b/src/client/DCSInsight/Misc/Common.cs @@ -14,6 +14,8 @@ internal static class Common private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); internal static bool LuaConsoleIsLoaded; internal static bool LuaConsoleSearchWarningGiven; + public static MouseEventHandler MouseEnter => UIElement_OnMouseEnterHandIcon; + public static MouseEventHandler MouseLeave => UIElement_OnMouseLeaveNormalIcon; internal static void ShowMessageBox(string message) { diff --git a/src/client/DCSInsight/UserControls/UserControlAPI.xaml b/src/client/DCSInsight/UserControls/UserControlAPI.xaml index cec4582..4b1c4e4 100644 --- a/src/client/DCSInsight/UserControls/UserControlAPI.xaml +++ b/src/client/DCSInsight/UserControls/UserControlAPI.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:userControls="clr-namespace:DCSInsight.UserControls" + xmlns:misc="clr-namespace:DCSInsight.Misc" Loaded="UserControlAPI_OnLoaded" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="800" Height="auto" IsTabStop="True"> @@ -23,7 +24,7 @@ - + diff --git a/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs b/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs index cd20c99..3376ee6 100644 --- a/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs +++ b/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs @@ -101,8 +101,8 @@ private void BuildLuaConsoleUI() }; TextBoxSyntax.PreviewMouseDown -= TextBoxSyntax_OnPreviewMouseDown; - TextBoxSyntax.MouseEnter -= TextBoxSyntax_OnMouseEnter; - TextBoxSyntax.MouseLeave -= TextBoxSyntax_OnMouseLeave; + TextBoxSyntax.MouseEnter -= Common.MouseEnter; + TextBoxSyntax.MouseLeave -= Common.MouseLeave; TextBoxSyntax.ToolTip = null; @@ -158,17 +158,7 @@ void LabelDefaultLuaOnMouseDown(object sender, MouseButtonEventArgs e) controlList.Add(textBoxLuaCode); TextBoxParameterList.Add(textBoxLuaCode); - ButtonSend = new Button - { - Content = "Send", - Height = 20, - Width = 50, - VerticalAlignment = VerticalAlignment.Center, - Margin = new Thickness(20, 0, 0, 0) - }; - ButtonSend.Click += ButtonSend_OnClick; - - StackPanelBottom.Children.Add(ButtonSend); + StackPanelBottom.Children.Add(GetButtonSend()); ItemsControlParameters.ItemsSource = controlList; Common.LuaConsoleIsLoaded = true; @@ -200,104 +190,25 @@ private void BuildGenericUI() var controlList = new List(); - foreach (var dcsAPIParameterType in DCSAPI.Parameters) + foreach (var dcsAPIParameter in DCSAPI.Parameters) { - var label = new Label - { - Content = dcsAPIParameterType.ParameterName.Replace("_", "__"), - VerticalAlignment = VerticalAlignment.Center - }; - controlList.Add(label); - - - var textBoxParameter = new TextBox - { - Name = "TextBox" + dcsAPIParameterType.Id, - Tag = dcsAPIParameterType.Id, - MinWidth = 50, - Height = 20, - IsTabStop = true - }; - - if (dcsAPIParameterType.Type == ParameterTypeEnum.number) - { - textBoxParameter.KeyDown += TextBoxParameter_OnKeyDown_Number; - } - textBoxParameter.KeyUp += TextBoxParameter_OnKeyUp; + controlList.Add(GetLabelParameterName(dcsAPIParameter.ParameterName)); + var textBoxParameter = GetTextBoxParameter(dcsAPIParameter); controlList.Add(textBoxParameter); TextBoxParameterList.Add(textBoxParameter); } - ButtonSend = new Button - { - Content = "Send", - Height = 20, - Width = 50, - VerticalAlignment = VerticalAlignment.Center, - Margin = new Thickness(20, 0, 0, 0) - }; - ButtonSend.Click += ButtonSend_OnClick; - - controlList.Add(ButtonSend); + controlList.Add(GetButtonSend()); if (DCSAPI.ReturnsData) { - LabelKeepResults = new Label - { - Content = "Keep results", - VerticalAlignment = VerticalAlignment.Center, - Margin = new Thickness(10, 0, 0, 0) - }; - controlList.Add(LabelKeepResults); - - CheckBoxKeepResults = new CheckBox - { - Margin = new Thickness(0, 0, 0, 0), - VerticalAlignment = VerticalAlignment.Center - }; - CheckBoxKeepResults.Checked += CheckBoxKeepResults_OnChecked; - CheckBoxKeepResults.Unchecked += CheckBoxKeepResults_OnUnchecked; - controlList.Add(CheckBoxKeepResults); - - LabelPolling = new Label - { - Content = "Poll", - VerticalAlignment = VerticalAlignment.Center, - Margin = new Thickness(10, 0, 0, 0) - }; - controlList.Add(LabelPolling); - - CheckBoxPolling = new CheckBox - { - Margin = new Thickness(0, 0, 0, 0), - VerticalAlignment = VerticalAlignment.Center - - }; - CheckBoxPolling.Checked += CheckBoxPolling_OnChecked; - CheckBoxPolling.Unchecked += CheckBoxPolling_OnUnchecked; - controlList.Add(CheckBoxPolling); - - LabelPollingInterval = new Label - { - Content = "Interval (ms) :", - VerticalAlignment = VerticalAlignment.Center, - Margin = new Thickness(10, 0, 0, 0) - }; - controlList.Add(LabelPollingInterval); - - ComboBoxPollTimes = new ComboBox - { - Height = 20, - Margin = new Thickness(2, 0, 0, 0), - VerticalAlignment = VerticalAlignment.Center, - }; - ComboBoxPollTimes.DataContextChanged += ComboBoxPollTimes_OnDataContextChanged; - ComboBoxPollTimes.Items.Add(100); - ComboBoxPollTimes.Items.Add(500); - ComboBoxPollTimes.Items.Add(1000); - ComboBoxPollTimes.Items.Add(2000); - ComboBoxPollTimes.SelectedIndex = 0; + controlList.Add(GetLabelKeepResults()); + controlList.Add(GetCheckBoxKeepResults()); + controlList.Add(GetLabelPolling()); + controlList.Add(GetCheckBoxPolling()); + controlList.Add(GetLabelPollingInterval()); + controlList.Add(GetComboBoxPollTimes()); controlList.Add(ComboBoxPollTimes); } diff --git a/src/client/DCSInsight/UserControls/UserControlAPIBase.cs b/src/client/DCSInsight/UserControls/UserControlAPIBase.cs index ef8a012..809443e 100644 --- a/src/client/DCSInsight/UserControls/UserControlAPIBase.cs +++ b/src/client/DCSInsight/UserControls/UserControlAPIBase.cs @@ -28,11 +28,7 @@ public abstract partial class UserControlAPIBase : UserControl, IDisposable, IAs protected bool CanSend; private bool _keepResults; protected Button ButtonSend; - protected Label LabelKeepResults; - protected CheckBox CheckBoxKeepResults; - protected Label LabelPolling; protected CheckBox CheckBoxPolling; - protected Label LabelPollingInterval; protected ComboBox ComboBoxPollTimes; protected Label LabelResultBase; protected TextBox TextBoxResultBase; @@ -313,11 +309,13 @@ protected void CheckBoxKeepResults_OnChecked(object sender, RoutedEventArgs e) } } - protected void TextBoxSyntax_OnMouseEnter(object sender, MouseEventArgs e) + protected void TextBoxSyntax_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) { try { - Mouse.OverrideCursor = Cursors.Hand; + var textBox = (TextBox)sender; + Clipboard.SetText(textBox.Text); + SystemSounds.Asterisk.Play(); } catch (Exception ex) { @@ -325,30 +323,120 @@ protected void TextBoxSyntax_OnMouseEnter(object sender, MouseEventArgs e) } } - protected void TextBoxSyntax_OnMouseLeave(object sender, MouseEventArgs e) + protected static Label GetLabelParameterName(string parameterName) { - try + return new Label { - Mouse.OverrideCursor = Cursors.Arrow; - } - catch (Exception ex) + Content = parameterName.Replace("_", "__"), + VerticalAlignment = VerticalAlignment.Center + }; + } + protected TextBox GetTextBoxParameter(ParameterInfo parameterInfo) + { + var textBox = new TextBox + { + Name = "TextBox" + parameterInfo.Id, + Tag = parameterInfo.Id, + MinWidth = 50, + Height = 20, + IsTabStop = true + }; + + + if (parameterInfo.Type == ParameterTypeEnum.number) { - Common.ShowErrorMessageBox(ex); + textBox.KeyDown += TextBoxParameter_OnKeyDown_Number; } + textBox.KeyUp += TextBoxParameter_OnKeyUp; + + return textBox; } - protected void TextBoxSyntax_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) + protected Button GetButtonSend() { - try + ButtonSend = new Button + { + Content = "Send", + Height = 20, + Width = 50, + VerticalAlignment = VerticalAlignment.Center, + Margin = new Thickness(20, 0, 0, 0) + }; + ButtonSend.Click += ButtonSend_OnClick; + + return ButtonSend; + } + + protected Label GetLabelKeepResults() + { + return new Label { - var textBox = (TextBox)sender; - Clipboard.SetText(textBox.Text); - SystemSounds.Asterisk.Play(); - } - catch (Exception ex) + Content = "Keep results", + VerticalAlignment = VerticalAlignment.Center, + Margin = new Thickness(10, 0, 0, 0) + }; + } + + protected CheckBox GetCheckBoxKeepResults() + { + var checkBoxKeepResults = new CheckBox + { + Margin = new Thickness(0, 0, 0, 0), + VerticalAlignment = VerticalAlignment.Center + }; + checkBoxKeepResults.Checked += CheckBoxKeepResults_OnChecked; + checkBoxKeepResults.Unchecked += CheckBoxKeepResults_OnUnchecked; + return checkBoxKeepResults; + } + + protected static Label GetLabelPolling() + { + return new Label { - Common.ShowErrorMessageBox(ex); - } + Content = "Poll", + VerticalAlignment = VerticalAlignment.Center, + Margin = new Thickness(10, 0, 0, 0) + }; + } + + protected CheckBox GetCheckBoxPolling() + { + CheckBoxPolling = new CheckBox + { + Margin = new Thickness(0, 0, 0, 0), + VerticalAlignment = VerticalAlignment.Center + + }; + CheckBoxPolling.Checked += CheckBoxPolling_OnChecked; + CheckBoxPolling.Unchecked += CheckBoxPolling_OnUnchecked; + return CheckBoxPolling; + } + + protected static Label GetLabelPollingInterval() + { + return new Label + { + Content = "Interval (ms) :", + VerticalAlignment = VerticalAlignment.Center, + Margin = new Thickness(10, 0, 0, 0) + }; + } + + protected ComboBox GetComboBoxPollTimes() + { + ComboBoxPollTimes = new ComboBox + { + Height = 20, + Margin = new Thickness(2, 0, 0, 0), + VerticalAlignment = VerticalAlignment.Center + }; + ComboBoxPollTimes.DataContextChanged += ComboBoxPollTimes_OnDataContextChanged; + ComboBoxPollTimes.Items.Add(100); + ComboBoxPollTimes.Items.Add(500); + ComboBoxPollTimes.Items.Add(1000); + ComboBoxPollTimes.Items.Add(2000); + ComboBoxPollTimes.SelectedIndex = 0; + return ComboBoxPollTimes; } } } diff --git a/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml b/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml index 372e001..3e7584e 100644 --- a/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml +++ b/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:userControls="clr-namespace:DCSInsight.UserControls" + xmlns:misc="clr-namespace:DCSInsight.Misc" Loaded="UserControlLoSetCommandAPI_OnLoaded" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="800" Height="auto" IsTabStop="True"> @@ -38,7 +39,7 @@ - + diff --git a/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml.cs b/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml.cs index 4c1e1c6..1df5ad7 100644 --- a/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml.cs +++ b/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml.cs @@ -82,22 +82,22 @@ protected override void BuildUI() var controlList = new List(); - foreach (var dcsAPIParameterType in DCSAPI.Parameters) + foreach (var dcsAPIParameter in DCSAPI.Parameters) { var label = new Label { - Content = dcsAPIParameterType.ParameterName.Replace("_", "__"), + Content = dcsAPIParameter.ParameterName.Replace("_", "__"), VerticalAlignment = VerticalAlignment.Center }; controlList.Add(label); - if (dcsAPIParameterType.ParameterName.StartsWith('i')) + if (dcsAPIParameter.ParameterName.StartsWith('i')) { var commands = LoSetCommand.LoadCommands(); _textBoxSearchICommand = new TextBox { - Name = "TextBox" + dcsAPIParameterType.Id, - Tag = dcsAPIParameterType.Id, + Name = "TextBox" + dcsAPIParameter.Id, + Tag = dcsAPIParameter.Id, MinWidth = 150, MaxWidth = 350, Height = 20, @@ -112,97 +112,25 @@ protected override void BuildUI() } else { - var textBox = new TextBox - { - Name = "TextBox" + dcsAPIParameterType.Id, - Tag = dcsAPIParameterType.Id, - MinWidth = 50, - MaxWidth = 100, - Height = 20, - IsTabStop = true - }; + var textBoxParameter = GetTextBoxParameter(dcsAPIParameter); + controlList.Add(textBoxParameter); + TextBoxParameterList.Add(textBoxParameter); - if (dcsAPIParameterType.Type == ParameterTypeEnum.number) - { - textBox.KeyDown += TextBoxParameter_OnKeyDown_Number; - } - textBox.KeyUp += TextBoxParameter_OnKeyUp; - - controlList.Add(textBox); - TextBoxParameterList.Add(textBox); + controlList.Add(textBoxParameter); + TextBoxParameterList.Add(textBoxParameter); } } - ButtonSend = new Button - { - Content = "Send", - Height = 20, - Width = 50, - VerticalAlignment = VerticalAlignment.Center, - Margin = new Thickness(20, 0, 0, 0) - }; - ButtonSend.Click += ButtonSend_OnClick; - controlList.Add(ButtonSend); + controlList.Add(GetButtonSend()); if (DCSAPI.ReturnsData) { - LabelKeepResults = new Label - { - Content = "Keep results", - VerticalAlignment = VerticalAlignment.Center, - Margin = new Thickness(10, 0, 0, 0) - }; - controlList.Add(LabelKeepResults); - - CheckBoxKeepResults = new CheckBox - { - Margin = new Thickness(0, 0, 0, 0), - VerticalAlignment = VerticalAlignment.Center - }; - CheckBoxKeepResults.Checked += CheckBoxKeepResults_OnChecked; - CheckBoxKeepResults.Unchecked += CheckBoxKeepResults_OnUnchecked; - controlList.Add(CheckBoxKeepResults); - - LabelPolling = new Label - { - Content = "Poll", - VerticalAlignment = VerticalAlignment.Center, - Margin = new Thickness(10, 0, 0, 0) - }; - controlList.Add(LabelPolling); - - CheckBoxPolling = new CheckBox - { - Margin = new Thickness(0, 0, 0, 0), - VerticalAlignment = VerticalAlignment.Center - - }; - CheckBoxPolling.Checked += CheckBoxPolling_OnChecked; - CheckBoxPolling.Unchecked += CheckBoxPolling_OnUnchecked; - controlList.Add(CheckBoxPolling); - - LabelPollingInterval = new Label - { - Content = "Interval (ms) :", - VerticalAlignment = VerticalAlignment.Center, - Margin = new Thickness(10, 0, 0, 0) - }; - controlList.Add(LabelPollingInterval); - - ComboBoxPollTimes = new ComboBox - { - Height = 20, - Margin = new Thickness(2, 0, 0, 0), - VerticalAlignment = VerticalAlignment.Center - }; - ComboBoxPollTimes.DataContextChanged += ComboBoxPollTimes_OnDataContextChanged; - ComboBoxPollTimes.Items.Add(50); - ComboBoxPollTimes.Items.Add(100); - ComboBoxPollTimes.Items.Add(500); - ComboBoxPollTimes.Items.Add(1000); - ComboBoxPollTimes.Items.Add(2000); - ComboBoxPollTimes.SelectedIndex = 0; - controlList.Add(ComboBoxPollTimes); + controlList.Add(GetLabelKeepResults()); + controlList.Add(GetCheckBoxKeepResults()); + controlList.Add(GetLabelPolling()); + controlList.Add(GetCheckBoxPolling()); + controlList.Add(GetLabelPollingInterval()); + controlList.Add(GetComboBoxPollTimes()); } ItemsControlParameters.ItemsSource = controlList; diff --git a/src/server/Scripts/DCS-INSIGHT/_ServerSettingsDevelopment.lua b/src/server/Scripts/DCS-INSIGHT/_ServerSettingsDevelopment.lua deleted file mode 100644 index 64e0356..0000000 --- a/src/server/Scripts/DCS-INSIGHT/_ServerSettingsDevelopment.lua +++ /dev/null @@ -1,19 +0,0 @@ -module("ServerSettingsDevelopment", package.seeall) - ---- @class ServerSettingsDevelopment : APIBase ---- @field TCP_address string ---- @field TCP_port integer -local ServerSettingsDevelopment = {} - -ServerSettingsDevelopment.TCP_address = "*" -ServerSettingsDevelopment.TCP_port = 7790 - --- Log incoming and outgoing JSON -ServerSettingsDevelopment.Log_JSON = false - --- WARNING! This function enables arbitrary lua code to be --- executed on your computer, including calls to package os (Operating System). --- Do NOT enable unless your are firewalled. -ServerSettingsDevelopment.EnableLuaConsole = true - -return ServerSettingsDevelopment