diff --git a/src/client/DCSInsight/DCSInsight.csproj b/src/client/DCSInsight/DCSInsight.csproj
index 47724a5..2edde4c 100644
--- a/src/client/DCSInsight/DCSInsight.csproj
+++ b/src/client/DCSInsight/DCSInsight.csproj
@@ -6,17 +6,17 @@
true
dcs-insight
1.0.0
- 1.7.9
+ 1.8.0
Images\Magnifier_icon.ico
+
-
@@ -28,14 +28,15 @@
+
-
+
Always
-
+
diff --git a/src/client/DCSInsight/Images/cue_banner_search.png b/src/client/DCSInsight/Images/cue_banner_search.png
new file mode 100644
index 0000000..e82f998
Binary files /dev/null and b/src/client/DCSInsight/Images/cue_banner_search.png differ
diff --git a/src/client/DCSInsight/MainWindow.xaml b/src/client/DCSInsight/MainWindow.xaml
index b459047..5825dea 100644
--- a/src/client/DCSInsight/MainWindow.xaml
+++ b/src/client/DCSInsight/MainWindow.xaml
@@ -43,6 +43,9 @@
dcs-insight
+
+ wiki
+
diff --git a/src/client/DCSInsight/MainWindow.xaml.cs b/src/client/DCSInsight/MainWindow.xaml.cs
index 4f0cdfc..c0bf74b 100644
--- a/src/client/DCSInsight/MainWindow.xaml.cs
+++ b/src/client/DCSInsight/MainWindow.xaml.cs
@@ -511,5 +511,24 @@ private void ButtonRangeTest_OnClick(object sender, RoutedEventArgs e)
Common.ShowErrorMessageBox(ex);
}
}
+
+ private void TextBlockAppWiki_OnMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ Process.Start(new ProcessStartInfo
+ {
+ FileName = "https://github.com/DCS-Skunkworks/dcs-insight/wiki",
+ UseShellExecute = true
+ });
+ }
+
+ private void UIElement_OnMouseEnter(object sender, MouseEventArgs e)
+ {
+ Mouse.OverrideCursor = Cursors.Hand;
+ }
+
+ private void UIElement_OnMouseLeave(object sender, MouseEventArgs e)
+ {
+ Mouse.OverrideCursor = Cursors.Arrow;
+ }
}
}
diff --git a/src/client/DCSInsight/Misc/LoSetCommand.cs b/src/client/DCSInsight/Misc/LoSetCommand.cs
index bc6651a..24d3361 100644
--- a/src/client/DCSInsight/Misc/LoSetCommand.cs
+++ b/src/client/DCSInsight/Misc/LoSetCommand.cs
@@ -1,31 +1,39 @@
-using System;
+using NLog;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows;
+using System.Windows.Shapes;
namespace DCSInsight.Misc
{
internal class LoSetCommand
{
+ private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+ private const string CommandsFile = "iCommands.txt";
+
public string Description { get; private set; }
public string Code { get; private set; }
internal static List LoadCommands()
{
var result = new List();
- var resourceStream = Application.GetResourceStream(new Uri(@"/dcs-insight;component/Items/iCommands.txt", UriKind.Relative));
- if (resourceStream == null) return result;
+ var loSetCommandsFile = $"{AppDomain.CurrentDomain.BaseDirectory}{CommandsFile}";
+ if (!File.Exists(loSetCommandsFile))
+ {
+ Logger.Error($"Failed to find {CommandsFile} in base directory.");
+ return result;
+ }
- var streamReader = new StreamReader(resourceStream.Stream);
- string line;
+ var stringArray = File.ReadAllLines(loSetCommandsFile);
- while ((line = streamReader.ReadLine()) != null)
+ foreach (var s in stringArray)
{
- if(!line.Trim().StartsWith("i") || !line.Contains('\t') || line.Contains('/')) continue;
+ if (string.IsNullOrEmpty(s) || !s.Trim().StartsWith("i") || !s.Contains('\t') || s.Contains('/') || s.Contains(':')) continue;
- var array = line.Split('\t');
- result.Add(new LoSetCommand{Code = array[1].Trim(), Description = array[0].Trim() });
+ var array = s.Split('\t');
+ result.Add(new LoSetCommand { Code = array[1].Trim(), Description = array[0].Trim() });
}
result = result.OrderBy(o => o.Description).ToList();
diff --git a/src/client/DCSInsight/Misc/TextBoxSearchCommon.cs b/src/client/DCSInsight/Misc/TextBoxSearchCommon.cs
new file mode 100644
index 0000000..aafddb9
--- /dev/null
+++ b/src/client/DCSInsight/Misc/TextBoxSearchCommon.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+
+namespace DCSInsight.Misc
+{
+ internal static class TextBoxSearchCommon
+ {
+ internal static void SetBackgroundSearchBanner(TextBox textBoxSearch)
+ {
+ try
+ {
+ //new Uri(@"/dcs-insight;component/Images/cue_banner_search.png", UriKind.Relative)),
+ if (string.IsNullOrEmpty(textBoxSearch.Text))
+ {
+ // Create an ImageBrush.
+ var textImageBrush = new ImageBrush
+ {
+ ImageSource = new BitmapImage(
+ new Uri("pack://application:,,,/dcs-insight;component/Images/cue_banner_search.png", UriKind.RelativeOrAbsolute)),
+ AlignmentX = AlignmentX.Left,
+ Stretch = Stretch.Uniform
+ };
+
+ // Use the brush to paint the button's background.
+ textBoxSearch.Background = textImageBrush;
+ }
+ else
+ {
+ textBoxSearch.Background = null;
+ }
+ }
+ catch (Exception ex)
+ {
+ Common.ShowErrorMessageBox(ex);
+ }
+ }
+
+ internal static void AdjustShownPopupData(TextBox textBoxSearch, Popup popupSearch, DataGrid dataGridValues, IEnumerable loSetCommands)
+ {
+ try
+ {
+ popupSearch.PlacementTarget = textBoxSearch;
+ popupSearch.Placement = PlacementMode.Bottom;
+ dataGridValues.Tag = textBoxSearch;
+ if (!popupSearch.IsOpen)
+ {
+ popupSearch.IsOpen = true;
+ }
+
+ if (string.IsNullOrEmpty(textBoxSearch.Text))
+ {
+ dataGridValues.DataContext = loSetCommands;
+ dataGridValues.ItemsSource = loSetCommands;
+ dataGridValues.Items.Refresh();
+ return;
+ }
+ var subList = loSetCommands.Where(loSetCommand => (!string.IsNullOrWhiteSpace(loSetCommand.Description) &&
+ loSetCommand.Description.ToUpper().Contains(textBoxSearch.Text.ToUpper()))
+ || (!string.IsNullOrWhiteSpace(loSetCommand.Code) && loSetCommand.Code.ToUpper().Contains(textBoxSearch.Text.ToUpper())));
+ dataGridValues.DataContext = subList;
+ dataGridValues.ItemsSource = subList;
+ dataGridValues.Items.Refresh();
+ }
+ catch (Exception ex)
+ {
+ Common.ShowErrorMessageBox(ex, "AdjustShownPopupData()");
+ }
+ }
+
+ internal static void HandleFirstSpace(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Space && ((TextBox)sender).Text == "")
+ {
+ e.Handled = true;
+ }
+ }
+ }
+}
diff --git a/src/client/DCSInsight/UserControls/UserControlAPIBase.cs b/src/client/DCSInsight/UserControls/UserControlAPIBase.cs
index 65fe6e3..5ea3cb3 100644
--- a/src/client/DCSInsight/UserControls/UserControlAPIBase.cs
+++ b/src/client/DCSInsight/UserControls/UserControlAPIBase.cs
@@ -22,7 +22,6 @@ public abstract partial class UserControlAPIBase : UserControl, IDisposable, IAs
protected readonly DCSAPI DCSAPI;
protected bool IsControlLoaded;
protected readonly List TextBoxParameterList = new();
- protected readonly List ComboBoxParameterList = new();
protected bool IsConnected;
protected readonly Timer PollingTimer;
protected bool CanSend;
diff --git a/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml b/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml
index 2db21f4..372e001 100644
--- a/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml
+++ b/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml
@@ -7,6 +7,22 @@
Loaded="UserControlLoSetCommandAPI_OnLoaded"
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="800" Height="auto" IsTabStop="True">
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml.cs b/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml.cs
index ea12884..574f1a1 100644
--- a/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml.cs
+++ b/src/client/DCSInsight/UserControls/UserControlLoSetCommandAPI.xaml.cs
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
using System.Windows.Input;
using DCSInsight.Events;
using DCSInsight.JSON;
@@ -17,6 +19,12 @@ namespace DCSInsight.UserControls
public partial class UserControlLoSetCommandAPI : UserControlAPIBase
{
+ private Popup _popupSearch;
+ private DataGrid _dataGridValues;
+ private List _loSetCommands;
+ private LoSetCommand _loSetCommand;
+ private TextBox _textBoxSearch;
+
public UserControlLoSetCommandAPI(DCSAPI dcsAPI, bool isConnected) : base(dcsAPI, isConnected)
{
InitializeComponent();
@@ -40,6 +48,10 @@ private void UserControlLoSetCommandAPI_OnLoaded(object sender, RoutedEventArgs
{
if (IsControlLoaded) return;
+ _loSetCommands = LoSetCommand.LoadCommands();
+ _popupSearch = (Popup)FindResource("PopUpSearchResults");
+ _popupSearch.Height = 400;
+ _dataGridValues = (DataGrid)LogicalTreeHelper.FindLogicalNode(_popupSearch, "DataGridValues");
IsTabStop = true;
BuildUI();
@@ -92,22 +104,24 @@ protected override void BuildUI()
};
controlList.Add(label);
- if (dcsAPIParameterType.ParameterName == "iCommand")
+ if (dcsAPIParameterType.ParameterName.StartsWith('i'))
{
var commands = LoSetCommand.LoadCommands();
- var comboBox = new ComboBox
+ _textBoxSearch = new TextBox
{
- Name = "ComboBox" + dcsAPIParameterType.Id,
+ Name = "TextBox" + dcsAPIParameterType.Id,
Tag = dcsAPIParameterType.Id,
- MinWidth = 100,
+ MinWidth = 150,
MaxWidth = 350,
Height = 20,
- IsReadOnly = true,
- DisplayMemberPath = "Description",
- ItemsSource = commands
};
- controlList.Add(comboBox);
- ComboBoxParameterList.Add(comboBox);
+
+ _textBoxSearch.TextChanged += TextBoxSearch_OnTextChanged;
+ _textBoxSearch.KeyUp += TextBoxSearch_OnKeyUp;
+ _textBoxSearch.PreviewKeyDown += TextBoxSearch_PreviewKeyDown;
+ TextBoxSearchCommon.SetBackgroundSearchBanner(_textBoxSearch);
+ controlList.Add(_textBoxSearch);
+ TextBoxParameterList.Add(_textBoxSearch);
}
else
{
@@ -218,7 +232,12 @@ protected override void BuildUI()
Mouse.OverrideCursor = Cursors.Arrow;
}
}
-
+
+ private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ throw new NotImplementedException();
+ }
+
public override void SetResult(DCSAPI dcsApi)
{
try
@@ -245,18 +264,6 @@ protected override void SendCommand()
{
try
{
- foreach (var comboBox in ComboBoxParameterList)
- {
- var parameterId = (int)comboBox.Tag;
- foreach (var parameter in DCSAPI.Parameters)
- {
- if (parameter.Id == parameterId)
- {
- var loSetCommand = (LoSetCommand)comboBox.SelectedItem;
- parameter.Value = loSetCommand.Code;
- }
- }
- }
foreach (var textBox in TextBoxParameterList)
{
var parameterId = (int)textBox.Tag;
@@ -277,5 +284,82 @@ protected override void SendCommand()
Common.ShowErrorMessageBox(ex);
}
}
+
+ private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ try
+ {
+ if (_dataGridValues.SelectedItems.Count == 1)
+ {
+ _loSetCommand = (LoSetCommand)_dataGridValues.SelectedItem;
+ _textBoxSearch.Text = _loSetCommand.Code;
+ }
+ SetFormState();
+ }
+ catch (Exception ex)
+ {
+ Common.ShowErrorMessageBox(ex);
+ }
+ }
+
+ private void Control_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ try
+ {
+ if (_dataGridValues.SelectedItems.Count == 1)
+ {
+ _loSetCommand = (LoSetCommand)_dataGridValues.SelectedItem;
+ _textBoxSearch.Text = _loSetCommand.Code;
+ SetFormState();
+ }
+ _popupSearch.IsOpen = false;
+ SetFormState();
+ }
+ catch (Exception ex)
+ {
+ Common.ShowErrorMessageBox(ex);
+ }
+ }
+
+ private void UIElement_OnMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ try
+ {
+ if (_dataGridValues.SelectedItems.Count == 1)
+ {
+ _loSetCommand = (LoSetCommand)_dataGridValues.SelectedItem;
+ _textBoxSearch.Text = _loSetCommand.Code;
+ }
+ _popupSearch.IsOpen = false;
+ SetFormState();
+ }
+ catch (Exception ex)
+ {
+ Common.ShowErrorMessageBox(ex);
+ }
+ }
+
+ private void TextBoxSearch_OnKeyUp(object sender, KeyEventArgs e)
+ {
+ try
+ {
+ TextBoxSearchCommon.AdjustShownPopupData(((TextBox)sender), _popupSearch, _dataGridValues, _loSetCommands);
+ SetFormState();
+ }
+ catch (Exception ex)
+ {
+ Common.ShowErrorMessageBox(ex);
+ }
+ }
+
+ private void TextBoxSearch_OnTextChanged(object sender, TextChangedEventArgs e)
+ {
+ TextBoxSearchCommon.SetBackgroundSearchBanner(((TextBox)sender));
+ }
+
+ private void TextBoxSearch_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ TextBoxSearchCommon.HandleFirstSpace(sender, e);
+ }
}
}
diff --git a/src/client/DCSInsight/Items/iCommands.txt b/src/client/DCSInsight/iCommands.txt
similarity index 100%
rename from src/client/DCSInsight/Items/iCommands.txt
rename to src/client/DCSInsight/iCommands.txt
diff --git a/src/server/Scripts/DCS-INSIGHT/ServerSettings.lua b/src/server/Scripts/DCS-INSIGHT/ServerSettings.lua
index 503ee3c..040e831 100644
--- a/src/server/Scripts/DCS-INSIGHT/ServerSettings.lua
+++ b/src/server/Scripts/DCS-INSIGHT/ServerSettings.lua
@@ -9,6 +9,6 @@ ServerSettings.TCP_address = "*"
ServerSettings.TCP_port = 7790
-- Log incoming and outgoing JSON
-ServerSettings.Log_JSON = false
+ServerSettings.Log_JSON = true
return ServerSettings
diff --git a/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua b/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua
index 3e6acfc..dd6a7fd 100644
--- a/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua
+++ b/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua
@@ -320,7 +320,12 @@ end
function APIHandler:verify_entries()
local message = "Following api have been loaded :\n"
for i = 1, #self.commandsTable do
- message = message .. self.commandsTable[i].id .. " : " .. self.commandsTable[i].apiInfo.api_syntax .. "\n"
+ message = message
+ .. "* "
+ .. self.commandsTable[i].id
+ .. " : "
+ .. self.commandsTable[i].apiInfo.api_syntax
+ .. "\n"
end
Log:log(message)