diff --git a/src/client/DCSInsight/App.config b/src/client/DCSInsight/App.config
index 1957bad..2192e2f 100644
--- a/src/client/DCSInsight/App.config
+++ b/src/client/DCSInsight/App.config
@@ -10,6 +10,21 @@
%USERPROFILE%\Saved Games\DCS\Scripts\DCS-BIOS\doc\json
+
+ -1
+
+
+ -1
+
+
+ -1
+
+
+ -1
+
+
+ 0
+
\ No newline at end of file
diff --git a/src/client/DCSInsight/DCSInsight.sln.DotSettings b/src/client/DCSInsight/DCSInsight.sln.DotSettings
index 641f1cf..2ce40e6 100644
--- a/src/client/DCSInsight/DCSInsight.sln.DotSettings
+++ b/src/client/DCSInsight/DCSInsight.sln.DotSettings
@@ -9,6 +9,8 @@
TCP
UI
API
+ DCSBIOS
+ JSON
True
True
True
diff --git a/src/client/DCSInsight/Lua/LuaAssistant.cs b/src/client/DCSInsight/Lua/LuaAssistant.cs
index 641aaae..a7e006b 100644
--- a/src/client/DCSInsight/Lua/LuaAssistant.cs
+++ b/src/client/DCSInsight/Lua/LuaAssistant.cs
@@ -10,7 +10,7 @@ internal static class LuaAssistant
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly object LockObject = new();
- private static string _dcsbiosAircraftsLuaLocation;
+ private static string _dcsbiosAircraftLuaLocation;
private static string _dcsbiosModuleLuaFilePath;
private static readonly List> LuaControls = new();
private static readonly List LuaModuleSignatures = new();
@@ -45,9 +45,9 @@ internal static List> GetLuaControls(string aircraf
internal static List GetAircraftList(string dcsbiosJSONPath)
{
dcsbiosJSONPath = Environment.ExpandEnvironmentVariables(dcsbiosJSONPath);
- _dcsbiosAircraftsLuaLocation = $"{dcsbiosJSONPath}\\..\\..\\lib\\modules\\aircraft_modules\\";
- _dcsbiosModuleLuaFilePath = $"{dcsbiosJSONPath}\\..\\..\\lib\\modules\\Module.lua";
- var directoryInfo = new DirectoryInfo(_dcsbiosAircraftsLuaLocation);
+ _dcsbiosAircraftLuaLocation = $@"{dcsbiosJSONPath}\..\..\lib\modules\aircraft_modules\";
+ _dcsbiosModuleLuaFilePath = $@"{dcsbiosJSONPath}\..\..\lib\modules\Module.lua";
+ var directoryInfo = new DirectoryInfo(_dcsbiosAircraftLuaLocation);
IEnumerable files;
try
{
@@ -74,7 +74,7 @@ private static void ReadControlsFromLua(string aircraftId)
// input is a map from category string to a map from key string to control definition
// we read it all then flatten the grand children (the control definitions)
- var lineArray = File.ReadAllLines(_dcsbiosAircraftsLuaLocation + aircraftId + ".lua");
+ var lineArray = File.ReadAllLines(_dcsbiosAircraftLuaLocation + aircraftId + ".lua");
try
{
var luaBuffer = "";
@@ -168,7 +168,7 @@ private static void ReadLuaCommandsFromFile(string aircraftId)
}
catch (Exception ex)
{
- throw new Exception($"{DCSBIOS_LUA_NOT_FOUND_ERROR_MESSAGE} ==>[{_dcsbiosAircraftsLuaLocation}]<=={Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}");
+ throw new Exception($"{DCSBIOS_LUA_NOT_FOUND_ERROR_MESSAGE} ==>[{_dcsbiosAircraftLuaLocation}]<=={Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}");
}
}
diff --git a/src/client/DCSInsight/MainWindow.xaml.cs b/src/client/DCSInsight/MainWindow.xaml.cs
index bd4b39f..0ac7813 100644
--- a/src/client/DCSInsight/MainWindow.xaml.cs
+++ b/src/client/DCSInsight/MainWindow.xaml.cs
@@ -37,6 +37,7 @@ public partial class MainWindow : Window, IErrorListener, IConnectionListener, I
private TCPClientHandler _tcpClientHandler;
private bool _isConnected;
private bool _rangeTesting;
+ private LuaWindow _luaWindow;
public MainWindow()
{
@@ -48,6 +49,7 @@ public MainWindow()
public void Dispose()
{
+ _luaWindow?.Close();
ItemsControlAPI.Items.Clear();
ICEventHandler.DetachErrorListener(this);
ICEventHandler.DetachConnectionListener(this);
@@ -65,6 +67,10 @@ private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
ShowVersionInfo();
SetFormState();
CheckBoxTop.IsChecked = true;
+
+ Top = Settings.Default.MainWindowTop.CompareTo(-1) == 0 ? Top : Settings.Default.MainWindowTop;
+ Left = Settings.Default.MainWindowLeft.CompareTo(-1) == 0 ? Left : Settings.Default.MainWindowLeft;
+
_formLoaded = true;
}
catch (Exception ex)
@@ -256,6 +262,10 @@ private void MainWindow_OnClosing(object sender, CancelEventArgs e)
{
try
{
+ Settings.Default.MainWindowTop = Top;
+ Settings.Default.MainWindowLeft = Left;
+ Settings.Default.Save();
+ _luaWindow?.Close();
_isConnected = false;
_tcpClientHandler?.Disconnect();
}
@@ -594,7 +604,10 @@ private void TextBlockSetDCSBIOSLocation_OnMouseDown(object sender, MouseButtonE
{
var settingsWindow = new SettingsWindow();
settingsWindow.ShowDialog();
- Settings.Default.DCSBiosJSONLocation = settingsWindow.DcsBiosJSONLocation;
+ if (settingsWindow.DialogResult == true)
+ {
+ Settings.Default.DCSBiosJSONLocation = settingsWindow.DcsBiosJSONLocation;
+ }
Settings.Default.Save();
}
catch (Exception ex)
@@ -607,8 +620,9 @@ private void ButtonLuaWindow_OnClick(object sender, RoutedEventArgs e)
{
try
{
- var luaWindow = new LuaWindow();
- luaWindow.Show();
+ _luaWindow?.Close();
+ _luaWindow = new LuaWindow();
+ _luaWindow.Show();
}
catch (Exception ex)
{
diff --git a/src/client/DCSInsight/Properties/Settings.Designer.cs b/src/client/DCSInsight/Properties/Settings.Designer.cs
index 7b210ab..23a49f5 100644
--- a/src/client/DCSInsight/Properties/Settings.Designer.cs
+++ b/src/client/DCSInsight/Properties/Settings.Designer.cs
@@ -34,5 +34,65 @@ public string DCSBiosJSONLocation {
this["DCSBiosJSONLocation"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("-1")]
+ public double MainWindowTop {
+ get {
+ return ((double)(this["MainWindowTop"]));
+ }
+ set {
+ this["MainWindowTop"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("-1")]
+ public double MainWindowLeft {
+ get {
+ return ((double)(this["MainWindowLeft"]));
+ }
+ set {
+ this["MainWindowLeft"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("-1")]
+ public double LuaWindowTop {
+ get {
+ return ((double)(this["LuaWindowTop"]));
+ }
+ set {
+ this["LuaWindowTop"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("-1")]
+ public double LuaWindowLeft {
+ get {
+ return ((double)(this["LuaWindowLeft"]));
+ }
+ set {
+ this["LuaWindowLeft"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public int MainScreenId {
+ get {
+ return ((int)(this["MainScreenId"]));
+ }
+ set {
+ this["MainScreenId"] = value;
+ }
+ }
}
}
diff --git a/src/client/DCSInsight/Properties/Settings.settings b/src/client/DCSInsight/Properties/Settings.settings
index 0f10864..fd82c68 100644
--- a/src/client/DCSInsight/Properties/Settings.settings
+++ b/src/client/DCSInsight/Properties/Settings.settings
@@ -5,5 +5,20 @@
%USERPROFILE%\Saved Games\DCS\Scripts\DCS-BIOS\doc\json
+
+ -1
+
+
+ -1
+
+
+ -1
+
+
+ -1
+
+
+ 0
+
\ No newline at end of file
diff --git a/src/client/DCSInsight/Windows/LuaWindow.xaml b/src/client/DCSInsight/Windows/LuaWindow.xaml
index 3ab0a0f..94ea8bb 100644
--- a/src/client/DCSInsight/Windows/LuaWindow.xaml
+++ b/src/client/DCSInsight/Windows/LuaWindow.xaml
@@ -7,8 +7,25 @@
mc:Ignorable="d"
Title="" Height="400" Width="Auto" MaxWidth="800"
Loaded="LuaWindow_OnLoaded"
- WindowStartupLocation="CenterScreen"
- KeyDown="LuaWindow_OnKeyDown" Icon="/Images/Magnifier_icon.png">
+ WindowStartupLocation="Manual"
+ KeyDown="LuaWindow_OnKeyDown" Icon="/Images/Magnifier_icon.png"
+ Closing="LuaWindow_OnClosing">
+
+
+
+
+
+
+
+
+
+
+
+
@@ -24,7 +41,11 @@
-
+
+
+
+
+
diff --git a/src/client/DCSInsight/Windows/LuaWindow.xaml.cs b/src/client/DCSInsight/Windows/LuaWindow.xaml.cs
index 8dedce6..826b985 100644
--- a/src/client/DCSInsight/Windows/LuaWindow.xaml.cs
+++ b/src/client/DCSInsight/Windows/LuaWindow.xaml.cs
@@ -1,16 +1,19 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Media;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Documents;
+using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Shapes;
using ControlReference.CustomControls;
using DCSInsight.Lua;
using DCSInsight.Misc;
using DCSInsight.Properties;
+using Clipboard = System.Windows.Clipboard;
using Cursors = System.Windows.Input.Cursors;
+using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
namespace DCSInsight.Windows
@@ -24,6 +27,8 @@ public partial class LuaWindow
private List _aircraftList = new();
private List> _luaControls = new();
private TextBlockSelectable _textBlockSelectable;
+ private Popup _popupSearch;
+ private DataGrid _dataGridValues;
public LuaWindow()
{
@@ -48,11 +53,17 @@ private void LuaWindow_OnLoaded(object sender, RoutedEventArgs e)
_textBlockSelectable.MouseLeave += TextBlock_OnMouseLeave;
SetContextMenu(_textBlockSelectable);
+ _popupSearch = (Popup)FindResource("PopUpSearchResults");
+ _popupSearch.Height = 400;
+ _dataGridValues = (DataGrid)LogicalTreeHelper.FindLogicalNode(_popupSearch, "DataGridValues");
+
_textBlockSelectable.FontFamily = new System.Windows.Media.FontFamily("Consolas");
_textBlockSelectable.Width = Double.NaN;
- var border = new Border();
- border.Child = _textBlockSelectable;
+ var border = new Border
+ {
+ Child = _textBlockSelectable
+ };
StackPanelLuaCommand.Children.Add(border);
StackPanelLuaCommand.Children.Add(new Line());
@@ -61,6 +72,12 @@ private void LuaWindow_OnLoaded(object sender, RoutedEventArgs e)
LoadAircraft();
SetFormState();
+
+ TextBoxSearch.Focus();
+
+ Top = Settings.Default.LuaWindowTop.CompareTo(-1) == 0 ? Top : Settings.Default.LuaWindowTop;
+ Left = Settings.Default.LuaWindowTop.CompareTo(-1) == 0 ? Left : Settings.Default.LuaWindowTop;
+
_isLoaded = true;
}
catch (Exception exception)
@@ -71,11 +88,19 @@ private void LuaWindow_OnLoaded(object sender, RoutedEventArgs e)
private void LuaWindow_OnKeyDown(object sender, KeyEventArgs e)
{
-
+ try
+ {
+ if (e.Key == Key.Escape)
+ {
+ Close();
+ }
+ }
+ catch (Exception exception)
+ {
+ Common.ShowMessageBox(exception.Message + Environment.NewLine + exception.StackTrace);
+ }
}
-
-
-
+
private void TextBlock_OnMouseEnter(object sender, MouseEventArgs e)
{
try
@@ -99,19 +124,19 @@ private void TextBlock_OnMouseLeave(object sender, MouseEventArgs e)
Common.ShowMessageBox(exception.Message + Environment.NewLine + exception.StackTrace);
}
}
-
-
+
private void SetContextMenu(TextBlockSelectable textBlock)
{
try
{
- //_contextMenu.Opened += TextBlockContextMenuOpened;
ContextMenu contextMenu = new();
contextMenu.Opened += TextBlock_ContextMenuOpened;
contextMenu.Tag = textBlock;
- var menuItemCopy = new MenuItem();
- menuItemCopy.Tag = textBlock;
- menuItemCopy.Header = "Copy";
+ var menuItemCopy = new MenuItem
+ {
+ Tag = textBlock,
+ Header = "Copy"
+ };
menuItemCopy.Click += MenuItemCopy_OnClick;
contextMenu.Items.Add(menuItemCopy);
textBlock.ContextMenu = contextMenu;
@@ -228,7 +253,7 @@ private void TextBoxSearch_OnKeyUp(object sender, KeyEventArgs e)
{
try
{
- //TextBoxSearchCommon.AdjustShownPopupData(TextBoxSearch, _popupSearch, _dataGridValues, _luaControls);
+ TextBoxSearchLuaControls.AdjustShownPopupData(TextBoxSearch, _popupSearch, _dataGridValues, _luaControls);
SetFormState();
}
catch (Exception ex)
@@ -239,7 +264,55 @@ private void TextBoxSearch_OnKeyUp(object sender, KeyEventArgs e)
private void TextBoxSearch_OnPreviewKeyDown(object sender, KeyEventArgs e)
{
-
+ TextBoxSearchLuaControls.HandleFirstSpace(sender, e);
+ }
+
+ private void LuaWindow_OnClosing(object sender, CancelEventArgs e)
+ {
+ try
+ {
+ Settings.Default.LuaWindowTop = Top;
+ Settings.Default.LuaWindowLeft = Left;
+ Settings.Default.Save();
+ }
+ catch (Exception ex)
+ {
+ Common.ShowErrorMessageBox(ex);
+ }
+ }
+
+ private void DataGridValues_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ LuaControlSelected(true);
+ }
+
+ private void DataGridValues_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ LuaControlSelected(true);
+ }
+
+ private void DataGridValues_OnMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ LuaControlSelected(false);
+ }
+
+ private void LuaControlSelected(bool keepSearchOpen)
+ {
+ try
+ {
+ if (_dataGridValues.SelectedItems.Count == 1)
+ {
+ var keyValuePair = (KeyValuePair)_dataGridValues.SelectedItem;
+ ComboBoxLuaControls.SelectedItem = keyValuePair;
+ SetFormState();
+ }
+ _popupSearch.IsOpen = keepSearchOpen;
+ SetFormState();
+ }
+ catch (Exception ex)
+ {
+ Common.ShowErrorMessageBox(ex);
+ }
}
}
}
diff --git a/src/client/DCSInsight/Windows/SettingsWindow.xaml b/src/client/DCSInsight/Windows/SettingsWindow.xaml
index 8540759..c718ea7 100644
--- a/src/client/DCSInsight/Windows/SettingsWindow.xaml
+++ b/src/client/DCSInsight/Windows/SettingsWindow.xaml
@@ -22,7 +22,7 @@
-
+
diff --git a/src/client/DCSInsight/Windows/SettingsWindow.xaml.cs b/src/client/DCSInsight/Windows/SettingsWindow.xaml.cs
index ee71561..20bedcc 100644
--- a/src/client/DCSInsight/Windows/SettingsWindow.xaml.cs
+++ b/src/client/DCSInsight/Windows/SettingsWindow.xaml.cs
@@ -53,7 +53,8 @@ private void SettingsWindow_OnLoaded(object sender, RoutedEventArgs e)
private void CheckDCSBIOSStatus()
{
- var result = Common.CheckJSONDirectory(TextBoxDcsBiosJSONLocation.Text);
+ var result = Common.CheckJSONDirectory(Environment.ExpandEnvironmentVariables(TextBoxDcsBiosJSONLocation.Text));
+ ButtonOk.IsEnabled = false;
if (result.Item1 == false && result.Item2 == false)
{
@@ -72,13 +73,12 @@ private void CheckDCSBIOSStatus()
LabelDCSBIOSNotFound.Foreground = Brushes.LimeGreen;
LabelDCSBIOSNotFound.Content = " JSON files found.";
+ ButtonOk.IsEnabled = true;
}
private void LoadSettings()
{
- var settingsFolder = Settings.Default.DCSBiosJSONLocation;
-
- TextBoxDcsBiosJSONLocation.Text = settingsFolder;
+ TextBoxDcsBiosJSONLocation.Text = Settings.Default.DCSBiosJSONLocation;
}
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e)