Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #77

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 47 additions & 43 deletions src/Publish_DCS-INSIGHT.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,54 @@ if (($null -eq $env:dcsinsightReleaseDestinationFolderPath) -or (-not (Test-Path
exit
}

#---------------------------------
# Release version management
#---------------------------------
Write-Host "Starting release version management" -foregroundcolor "Green"
#Get Path to csproj
$projectFilePath = $clientPath + "\DCSInsight.csproj"
If (-not(Test-Path $projectFilePath)) {
Write-Host "Fatal error. Project path not found: $projectPath" -foregroundcolor "Red"
exit
}

#Readind project file
$xml = [xml](Get-Content $projectFilePath)
[string]$assemblyVersion = $xml.Project.PropertyGroup.AssemblyVersion

#Split the Version Numbers
$avMajor, $avMinor, $avPatch = $assemblyVersion.Split('.')

Write-Host "Current assembly version is: $assemblyVersion" -foregroundcolor "Green"

#Sets new version into Project
#Warning: for this to work, since the PropertyGroup is indexed, AssemblyVersion must be in the FIRST Propertygroup (or else, change the index).
Write-Host "What kind of release is this? If not minor then patch version will be incremented." -foregroundcolor "Green"
$isMinorRelease = Read-Host "Minor release? Y/N"

if ($isMinorRelease.Trim().ToLower().Equals("y")) {
[int]$avMinor = [int]$avMinor + 1
[int]$avPatch = 0
}
else {
[int]$avPatch = [int]$avPatch + 1
$changeProjectVersion = Read-Host "Change Project Version? Y/N"

if($changeProjectVersion.Trim().ToLower().Equals("y"))
{
#---------------------------------
# Release version management
#---------------------------------
Write-Host "Starting release version management" -foregroundcolor "Green"
#Get Path to csproj
$projectFilePath = $clientPath + "\DCSInsight.csproj"
If (-not(Test-Path $projectFilePath)) {
Write-Host "Fatal error. Project path not found: $projectPath" -foregroundcolor "Red"
exit
}

#Readind project file
$xml = [xml](Get-Content $projectFilePath)
[string]$assemblyVersion = $xml.Project.PropertyGroup.AssemblyVersion

#Split the Version Numbers
$avMajor, $avMinor, $avPatch = $assemblyVersion.Split('.')

Write-Host "Current assembly version is: $assemblyVersion" -foregroundcolor "Green"

#Sets new version into Project
#Warning: for this to work, since the PropertyGroup is indexed, AssemblyVersion must be in the FIRST Propertygroup (or else, change the index).
Write-Host "What kind of release is this? If not minor then patch version will be incremented." -foregroundcolor "Green"
$isMinorRelease = Read-Host "Minor release? Y/N"

if ($isMinorRelease.Trim().ToLower().Equals("y")) {
[int]$avMinor = [int]$avMinor + 1
[int]$avPatch = 0
}
else {
[int]$avPatch = [int]$avPatch + 1
}

#Sets new version into Project
#Warning: for this to work, since the PropertyGroup is indexed, AssemblyVersion must be in the FIRST Propertygroup (or else, change the index).
$xml.Project.PropertyGroup.AssemblyVersion = "$avMajor.$avMinor.$avPatch".Trim()
[string]$assemblyVersion = $xml.Project.PropertyGroup.AssemblyVersion
Write-Host "New assembly version is $assemblyVersion" -foregroundcolor "Green"

#Saving project file
$xml.Save($projectFilePath)
Write-Host "Project file updated" -foregroundcolor "Green"
Write-Host "Finished release version management" -foregroundcolor "Green"
}

#Sets new version into Project
#Warning: for this to work, since the PropertyGroup is indexed, AssemblyVersion must be in the FIRST Propertygroup (or else, change the index).
$xml.Project.PropertyGroup.AssemblyVersion = "$avMajor.$avMinor.$avPatch".Trim()
[string]$assemblyVersion = $xml.Project.PropertyGroup.AssemblyVersion
Write-Host "New assembly version is $assemblyVersion" -foregroundcolor "Green"

#Saving project file
$xml.Save($projectFilePath)
Write-Host "Project file updated" -foregroundcolor "Green"
Write-Host "Finished release version management" -foregroundcolor "Green"

#---------------------------------
# Client publishing
#---------------------------------
Expand Down
23 changes: 11 additions & 12 deletions src/client/DCSInsight/Communication/TCPClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
using Newtonsoft.Json;
using NLog;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using DCSInsight.Interfaces;

namespace DCSInsight.Communication
Expand All @@ -19,7 +18,7 @@ internal class TCPClientHandler : IDisposable, ICommandListener

{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly Channel<DCSAPI> _asyncCommandsChannel = Channel.CreateUnbounded<DCSAPI>();
private readonly ConcurrentQueue<DCSAPI> _commandsQueue = new();
private TcpClient? _tcpClient;
private Thread? _clientThread;
private bool _isRunning;
Expand Down Expand Up @@ -48,7 +47,7 @@ public void Dispose()
GC.SuppressFinalize(this);
}

private async void ClientThread()
private void ClientThread()
{
if (_tcpClient == null) return;

Expand Down Expand Up @@ -88,11 +87,12 @@ private async void ClientThread()
_requestAPIList = false;
}

if (_asyncCommandsChannel.Reader.Count > 0 && _responseReceived)
if (_commandsQueue.Count > 0 && _responseReceived)
{
var cts = new CancellationTokenSource(100);
var dcsApi = await _asyncCommandsChannel.Reader.ReadAsync(cts.Token);
if (!_commandsQueue.TryDequeue(out var dcsApi)) continue;

if (LogJSON) Logger.Info(JsonConvert.SerializeObject(dcsApi, Formatting.Indented));

_tcpClient.GetStream().Write(Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(dcsApi) + "\n"));
_responseReceived = false;
}
Expand Down Expand Up @@ -209,17 +209,16 @@ public void Disconnect()
}
}

public async Task AddAsyncCommand(DCSAPI dcsApi)
public void AddCommand(DCSAPI dcsApi)
{
var cts = new CancellationTokenSource(100);
await _asyncCommandsChannel.Writer.WriteAsync(dcsApi, cts.Token);
_commandsQueue.Enqueue(dcsApi);
}

public async void SendCommand(SendCommandEventArgs args)
public void SendCommand(SendCommandEventArgs args)
{
try
{
await AddAsyncCommand(args.APIObject);
_commandsQueue.Enqueue(args.APIObject);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Windows.Media;
using DCSInsight.Misc;

namespace ControlReference.CustomControls
namespace DCSInsight.CustomControls
{
internal class TextBlockSelectable : TextBlock
{
Expand Down
68 changes: 0 additions & 68 deletions src/client/DCSInsight/DCSInsight - Backup.csproj

This file was deleted.

2 changes: 1 addition & 1 deletion src/client/DCSInsight/DCSInsight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- for WinForms -->
<AssemblyName>dcs-insight</AssemblyName>
<Version>1.0.0</Version>
<AssemblyVersion>1.9.2</AssemblyVersion>
<AssemblyVersion>1.9.3</AssemblyVersion>
<ApplicationIcon>Images\Magnifier_icon.ico</ApplicationIcon>
<Company>DCS-Skunkworks</Company>
</PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/client/DCSInsight/DCSInsight.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DCSAPI/@EntryIndexedValue">DCSAPI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DCSAPIS/@EntryIndexedValue">DCSAPIS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DCSBIOS/@EntryIndexedValue">DCSBIOS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IC/@EntryIndexedValue">IC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=JSON/@EntryIndexedValue">JSON</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LED/@EntryIndexedValue">LED</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TCP/@EntryIndexedValue">TCP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
Expand Down
3 changes: 3 additions & 0 deletions src/client/DCSInsight/JSON/DCSAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public DCSAPI(int id,

public enum ParameterTypeEnum
{
// ReSharper disable once InconsistentNaming
number = 0,
// ReSharper disable once UnusedMember.Global
// ReSharper disable once InconsistentNaming
str = 1
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/DCSInsight/Lua/LuaAssistant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private static KeyValuePair<string, string> CopyControlFromLuaBuffer(string luaB
end, 5, "ARC-210 Display", "COMSEC submode (PT/CT/CT-TD)")
*/
var startIndex = luaBuffer.IndexOf("\"", StringComparison.Ordinal);
var endIndex = luaBuffer.IndexOf("\"", luaBuffer.IndexOf("\"") + 1);
var endIndex = luaBuffer.IndexOf("\"", luaBuffer.IndexOf("\"", StringComparison.Ordinal) + 1, StringComparison.Ordinal);
var controlId = luaBuffer.Substring(startIndex + 1, endIndex - startIndex - 1);

return new KeyValuePair<string, string>(controlId, luaBuffer);
Expand Down
8 changes: 6 additions & 2 deletions src/client/DCSInsight/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private void Connect()
if (ItemsControlAPI.Items.Count > 0 && Settings.Default.AskForReloadAPIList)
{
var windowAskReloadAPIDialog = new WindowAskReloadAPIDialog();
windowAskReloadAPIDialog.Owner = this;
windowAskReloadAPIDialog.ShowDialog();
}

Expand Down Expand Up @@ -161,7 +162,7 @@ public void ConnectionStatus(ConnectionEventArgs args)
}

Dispatcher?.BeginInvoke((Action)(() => SetConnectionStatus(args.IsConnected)));
Dispatcher?.BeginInvoke((Action)SetFormState); ;
Dispatcher?.BeginInvoke((Action)SetFormState);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -570,6 +571,7 @@ private void TextBlockSetDCSBIOSLocation_OnMouseDown(object sender, MouseButtonE
try
{
var settingsWindow = new SettingsWindow();
settingsWindow.Owner = this;
settingsWindow.ShowDialog();
if (settingsWindow.DialogResult == true)
{
Expand All @@ -589,7 +591,8 @@ private void ButtonLuaWindow_OnClick(object sender, RoutedEventArgs e)
{
_luaWindow?.Close();
_luaWindow = new LuaWindow();
_luaWindow.Show();
_luaWindow.Show();
_luaWindow.Left = Left + Width;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -623,6 +626,7 @@ private void TextBlockAPIReload_OnMouseDown(object sender, MouseButtonEventArgs
try
{
var windowAskReloadAPIDialog = new WindowAskReloadAPIDialog();
windowAskReloadAPIDialog.Owner = this;
windowAskReloadAPIDialog.ShowDialog();
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace DCSInsight.UserControls
/// </summary>
public partial class UserControlPulseLED : UserControl, IDisposable, IAsyncDisposable
{
private readonly Timer _timerLoopPulse;
private Timer? _timerLoopPulse;

public UserControlPulseLED()
{
Expand All @@ -26,6 +26,7 @@ public UserControlPulseLED()
public void Dispose()
{
_timerLoopPulse?.Dispose();
_timerLoopPulse = null;
GC.SuppressFinalize(this);
}

Expand All @@ -34,6 +35,7 @@ public async ValueTask DisposeAsync()
if (_timerLoopPulse != null)
{
await _timerLoopPulse.DisposeAsync();
_timerLoopPulse = null;
GC.SuppressFinalize(this);
}
}
Expand All @@ -54,7 +56,7 @@ public void Pulse(int milliseconds = 300)
{
Dispatcher?.BeginInvoke((Action)(() => SetPulseImage(true)));

_timerLoopPulse.Change(milliseconds, milliseconds);
_timerLoopPulse?.Change(milliseconds, milliseconds);
//Dispatcher?.BeginInvoke((Action)(SetFormState));
}
catch (Exception ex)
Expand All @@ -69,7 +71,7 @@ private void PulseTimerCallback(object? state)
{
Dispatcher?.BeginInvoke((Action)(() => SetPulseImage(false)));
//Dispatcher?.BeginInvoke((Action)(() => ToolBarMain.UpdateLayout()));
_timerLoopPulse.Change(Timeout.Infinite, Timeout.Infinite);
_timerLoopPulse?.Change(Timeout.Infinite, Timeout.Infinite);
//Dispatcher?.BeginInvoke((Action)(SetFormState));
}
catch (Exception ex)
Expand Down
7 changes: 3 additions & 4 deletions src/client/DCSInsight/Windows/LuaWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:customControls="clr-namespace:ControlReference.CustomControls"
xmlns:customControls="clr-namespace:DCSInsight.CustomControls"
mc:Ignorable="d"
Title="" Height="400" Width="Auto" MaxWidth="800"
Loaded="LuaWindow_OnLoaded"
WindowStartupLocation="Manual"
Loaded="LuaWindow_OnLoaded"
KeyDown="LuaWindow_OnKeyDown" Icon="/Images/Magnifier_icon.png"
Closing="LuaWindow_OnClosing">
<Window.Resources>
Expand Down Expand Up @@ -49,7 +48,7 @@
</DockPanel>

<ScrollViewer Grid.Row="1" Grid.Column="0">
<StackPanel Name="StackPanelLuaCommand" Height="Auto" Width="Auto" Grid.Row="1" Grid.Column="0" Margin="10,5,10,5">
<StackPanel Name="StackPanelLuaCommand" Height="Auto" Width="Auto" Margin="10,5,10,5">
<StackPanel.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="Margin" Value="0,10,0,0" />
Expand Down
Loading
Loading