Skip to content

Commit

Permalink
v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Fragtality committed Dec 13, 2023
1 parent 1991399 commit e6b4848
Show file tree
Hide file tree
Showing 36 changed files with 1,742 additions and 86 deletions.
29 changes: 29 additions & 0 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$projdir = "C:\Users\Fragtality\source\repos\FenixQuartz"
$instBinDir = $projdir + "\Installer\bin\Release\app.publish"
$version = "v1.2.0"

#Create Lock
cd $projdir
if (-not (Test-Path -Path "build.lck")) {
"lock" | Out-File -File "build.lck"
}
else {
exit 0
}

cd "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64"
#WT2GSX
Write-Host "Building FenixQuartz"
.\msbuild.exe ($projdir + "\FenixQuartz.sln") /t:FenixQuartz:rebuild /p:Configuration="Release" /p:BuildProjectReferences=false | Out-Null

#Installer
Write-Host "Building Installer"
.\msbuild.exe ($projdir + "\FenixQuartz.sln") /t:Installer:rebuild /p:Configuration="Release" /p:BuildProjectReferences=false | Out-Null

Copy-Item -Path ($instBinDir + "\Installer.exe") -Destination ($projdir + "\Releases\FenixQuartz-Installer-" + $version + ".exe") -Force

#Remove lock
cd $projdir
if ((Test-Path -Path "build.lck")) {
Remove-Item -Path "build.lck"
}
Binary file modified FenixQuartz-latest.zip
Binary file not shown.
6 changes: 6 additions & 0 deletions FenixQuartz.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.2.32526.322
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FenixQuartz", "FenixQuartz\FenixQuartz.csproj", "{7C52FCDC-2E51-4615-A2A2-49AFA487A7EC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Installer", "Installer\Installer.csproj", "{BF3DD08A-7547-4352-B1DD-9A343D757421}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{7C52FCDC-2E51-4615-A2A2-49AFA487A7EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C52FCDC-2E51-4615-A2A2-49AFA487A7EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C52FCDC-2E51-4615-A2A2-49AFA487A7EC}.Release|Any CPU.Build.0 = Release|Any CPU
{BF3DD08A-7547-4352-B1DD-9A343D757421}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF3DD08A-7547-4352-B1DD-9A343D757421}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF3DD08A-7547-4352-B1DD-9A343D757421}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF3DD08A-7547-4352-B1DD-9A343D757421}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
21 changes: 0 additions & 21 deletions FenixQuartz/App.config

This file was deleted.

76 changes: 58 additions & 18 deletions FenixQuartz/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using H.NotifyIcon;
using Serilog;
using System;
using System.Configuration;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;
Expand All @@ -12,35 +12,75 @@ namespace FenixQuartz
{
public partial class App : Application
{
public static readonly bool devGUI = Convert.ToBoolean(ConfigurationManager.AppSettings["debugGUI"]);
public static readonly string FenixExecutable = Convert.ToString(ConfigurationManager.AppSettings["FenixExecutable"]) ?? "FenixSystem";
public static readonly string logFilePath = Convert.ToString(ConfigurationManager.AppSettings["logFilePath"]) ?? "FenixQuartz.log";
public static readonly string logLevel = Convert.ToString(ConfigurationManager.AppSettings["logLevel"]) ?? "Debug";
public static readonly bool waitForConnect = Convert.ToBoolean(ConfigurationManager.AppSettings["waitForConnect"]);
public static readonly int offsetBase = Convert.ToInt32(ConfigurationManager.AppSettings["offsetBase"], 16);
public static readonly bool rawValues = Convert.ToBoolean(ConfigurationManager.AppSettings["rawValues"]);
public static readonly bool useLvars = Convert.ToBoolean(ConfigurationManager.AppSettings["useLvars"]);
public static readonly int updateIntervall = Convert.ToInt32(ConfigurationManager.AppSettings["updateIntervall"]);
public static readonly string altScaleDelim = Convert.ToString(ConfigurationManager.AppSettings["altScaleDelim"]) ?? " ";
public static readonly bool addFcuMode = Convert.ToBoolean(ConfigurationManager.AppSettings["addFcuMode"]);
public static readonly bool ooMode = Convert.ToBoolean(ConfigurationManager.AppSettings["ooMode"]);
public static readonly string lvarPrefix = Convert.ToString(ConfigurationManager.AppSettings["lvarPrefix"]);
public static readonly bool ignoreBatteries = Convert.ToBoolean(ConfigurationManager.AppSettings["ignoreBatteries"]);
public static readonly bool perfCaptainSide = Convert.ToBoolean(ConfigurationManager.AppSettings["perfCaptainSide"]);
public static readonly int perfButtonHold = Convert.ToInt32(ConfigurationManager.AppSettings["perfButtonHold"]);
public static readonly string groupName = "FenixQuartz";
public static bool devGUI;
public static string FenixExecutable;
public static string logFilePath;
public static string logLevel;
public static bool waitForConnect;
public static int offsetBase;
public static bool rawValues;
public static bool useLvars;
public static int updateIntervall;
public static string altScaleDelim;
public static bool addFcuMode;
public static bool ooMode;
public static string lvarPrefix;
public static bool ignoreBatteries;
public static bool perfCaptainSide;
public static int perfButtonHold;
public static string groupName = "FenixQuartz";

public static new App Current => Application.Current as App;
public static string ConfigFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\FenixQuartz\FenixQuartz.config";
public static string AppDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\FenixQuartz\bin";
public static ConfigurationFile ConfigurationFile = new();

public static bool CancellationRequested { get; set; } = false;
public static bool RestartRequested { get; set; } = false;
public static bool ServiceExited { get; set; } = false;

private TaskbarIcon notifyIcon;
public static QuartzService Service;

protected static void LoadConfiguration()
{
ConfigurationFile.LoadConfiguration();
devGUI = Convert.ToBoolean(ConfigurationFile.GetSetting("debugGUI", "true"));
FenixExecutable = Convert.ToString(ConfigurationFile.GetSetting("FenixExecutable", "FenixSystem"));
logFilePath = @"..\log\" + Convert.ToString(ConfigurationFile.GetSetting("logFilePath", "FenixQuartz.log"));
logLevel = Convert.ToString(ConfigurationFile.GetSetting("logLevel", "Debug"));
waitForConnect = Convert.ToBoolean(ConfigurationFile.GetSetting("waitForConnect", "true"));
offsetBase = Convert.ToInt32(ConfigurationFile.GetSetting("offsetBase", "0x5408"), 16);
rawValues = Convert.ToBoolean(ConfigurationFile.GetSetting("rawValues", "false"));
useLvars = Convert.ToBoolean(ConfigurationFile.GetSetting("useLvars", "false"));
updateIntervall = Convert.ToInt32(ConfigurationFile.GetSetting("updateIntervall", "100"));
altScaleDelim = Convert.ToString(ConfigurationFile.GetSetting("altScaleDelim", " "));
addFcuMode = Convert.ToBoolean(ConfigurationFile.GetSetting("addFcuMode", "true"));
ooMode = Convert.ToBoolean(ConfigurationFile.GetSetting("ooMode", "false"));
lvarPrefix = Convert.ToString(ConfigurationFile.GetSetting("lvarPrefix", "FNX2PLD_"));
ignoreBatteries = Convert.ToBoolean(ConfigurationFile.GetSetting("ignoreBatteries", "false"));
perfCaptainSide = Convert.ToBoolean(ConfigurationFile.GetSetting("perfCaptainSide", "true"));
perfButtonHold = Convert.ToInt32(ConfigurationFile.GetSetting("perfButtonHold", "1000"));
}

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);

Directory.SetCurrentDirectory(AppDir);

if (!File.Exists(ConfigFilePath))
{
ConfigFilePath = Directory.GetCurrentDirectory() + @"\FenixQuartz.config";
if (!File.Exists(ConfigFilePath))
{
MessageBox.Show("No Configuration File found! Closing ...", "Critical Error", MessageBoxButton.OK, MessageBoxImage.Error);
Application.Current.Shutdown();
return;
}
}

LoadConfiguration();
InitLog();
InitSystray();

Expand Down
70 changes: 70 additions & 0 deletions FenixQuartz/ConfigurationFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System.Collections.Generic;
using System.IO;
using System.Xml;

namespace FenixQuartz
{
public class ConfigurationFile
{
private Dictionary<string, string> appSettings = new();
private XmlDocument xmlDoc = new();

public string this[string key]
{
get => GetSetting(key);
set => SetSetting(key, value);
}

public void LoadConfiguration()
{
xmlDoc = new();
xmlDoc.LoadXml(File.ReadAllText(App.ConfigFilePath));

XmlNode xmlSettings = xmlDoc.ChildNodes[1];
appSettings.Clear();
foreach(XmlNode child in xmlSettings.ChildNodes)
appSettings.Add(child.Attributes["key"].Value, child.Attributes["value"].Value);
}

public void SaveConfiguration()
{
foreach (XmlNode child in xmlDoc.ChildNodes[1])
child.Attributes["value"].Value = appSettings[child.Attributes["key"].Value];

xmlDoc.Save(App.ConfigFilePath);
}

public string GetSetting(string key, string defaultValue = "")
{
if (appSettings.ContainsKey(key))
return appSettings[key];
else
{
XmlNode newNode = xmlDoc.CreateElement("add");

XmlAttribute attribute = xmlDoc.CreateAttribute("key");
attribute.Value = key;
newNode.Attributes.Append(attribute);

attribute = xmlDoc.CreateAttribute("value");
attribute.Value = defaultValue;
newNode.Attributes.Append(attribute);

xmlDoc.ChildNodes[1].AppendChild(newNode);
appSettings.Add(key, defaultValue);
SaveConfiguration();

return defaultValue;
}
}

public void SetSetting(string key, string value)
{
if (appSettings.ContainsKey(key))
{
appSettings[key] = value;
SaveConfiguration();
}
}
}
}
2 changes: 1 addition & 1 deletion FenixQuartz/ElementManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ElementManager(List<OutputDefinition> definitions)
{ "BAT2-1", new MemoryPattern("61 00 69 00 72 00 63 00 72 00 61 00 66 00 74 00 2E 00 65 00 6C 00 65 00 63 00 74 00 72 00 69 00 63 00 61 00 6C 00 2E 00 62 00 61 00 74 00 74 00 65 00 72 00 79 00 31 00 2E") },
{ "BAT2-2", new MemoryPattern("00 00 42 00 61 00 74 00 74 00 65 00 72 00 79 00 20 00 32 00") },
{ "RUDDER-1", new MemoryPattern("00 00 52 00 75 00 64 00 64 00 65 00 72 00 20 00 74 00 72 00 69 00 6D 00 20 00 64 00 69 00 73 00 70 00 6C 00 61 00 79 00 20 00 64 00 61 00 73 00 68 00 65 00 64 00") },
{ "PERF", new MemoryPattern("40 A1 ?? ?? ?? 7F 00 00 00 00 00 00 00 00 00 00 01 00 00 00 ?? 00 00 00 01 00 00 00 ?? 00 00 00 01 00 00 00 ?? 00 00 00") },
{ "PERF", new MemoryPattern("?? ?? ?? ?? ?? 7F 00 00 00 00 00 00 00 00 00 00 01 00 00 00 ?? 00 00 00 01 00 00 00 ?? 00 00 00 01 00 00 00 ?? 00 00 00", 2) },
};

InitializeScanner();
Expand Down
19 changes: 19 additions & 0 deletions FenixQuartz/FenixQuartz.config.numlvar
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="debugGUI" value="true" />
<add key="FenixExecutable" value="FenixSystem" />
<add key="logFilePath" value="FenixQuartz.log" />
<add key="logLevel" value="Debug" />
<add key="waitForConnect" value="true" />
<add key="offsetBase" value="0x5408" />
<add key="rawValues" value="true" />
<add key="useLvars" value="true" />
<add key="updateIntervall" value="100" />
<add key="altScaleDelim" value=" "/>
<add key="addFcuMode" value="true"/>
<add key="ooMode" value="false"/>
<add key="lvarPrefix" value="FNX2PLD_"/>
<add key="ignoreBatteries" value="false"/>
<add key="perfCaptainSide" value="true"/>
<add key="perfButtonHold" value="1000"/>
</appSettings>
19 changes: 19 additions & 0 deletions FenixQuartz/FenixQuartz.config.numoffset
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="debugGUI" value="true" />
<add key="FenixExecutable" value="FenixSystem" />
<add key="logFilePath" value="FenixQuartz.log" />
<add key="logLevel" value="Debug" />
<add key="waitForConnect" value="true" />
<add key="offsetBase" value="0x5408" />
<add key="rawValues" value="true" />
<add key="useLvars" value="false" />
<add key="updateIntervall" value="100" />
<add key="altScaleDelim" value=" "/>
<add key="addFcuMode" value="true"/>
<add key="ooMode" value="false"/>
<add key="lvarPrefix" value="FNX2PLD_"/>
<add key="ignoreBatteries" value="false"/>
<add key="perfCaptainSide" value="true"/>
<add key="perfButtonHold" value="1000"/>
</appSettings>
19 changes: 19 additions & 0 deletions FenixQuartz/FenixQuartz.config.string
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="debugGUI" value="true" />
<add key="FenixExecutable" value="FenixSystem" />
<add key="logFilePath" value="FenixQuartz.log" />
<add key="logLevel" value="Debug" />
<add key="waitForConnect" value="true" />
<add key="offsetBase" value="0x5408" />
<add key="rawValues" value="false" />
<add key="useLvars" value="false" />
<add key="updateIntervall" value="100" />
<add key="altScaleDelim" value=" "/>
<add key="addFcuMode" value="true"/>
<add key="ooMode" value="false"/>
<add key="lvarPrefix" value="FNX2PLD_"/>
<add key="ignoreBatteries" value="false"/>
<add key="perfCaptainSide" value="true"/>
<add key="perfButtonHold" value="1000"/>
</appSettings>
11 changes: 7 additions & 4 deletions FenixQuartz/FenixQuartz.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="FSUIPCClientDLL" Version="3.3.7" />
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.118" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="FSUIPCClientDLL" Version="3.3.8" />
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.123" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -52,6 +52,9 @@
</ItemGroup>

<ItemGroup>
<None Update="FenixQuartz.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Microsoft.FlightSimulator.SimConnect.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
Expand Down
Binary file modified FenixQuartz/Microsoft.FlightSimulator.SimConnect.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion FenixQuartz/QuartzService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void WriteAssignmentFile()
output.AppendLine(App.lvarPrefix + "speedVR");
output.AppendLine(App.lvarPrefix + "speedV2");

File.WriteAllText("Assignments.txt", output.ToString());
File.WriteAllText("..\\Assignments.txt", output.ToString());
}
}
}
Binary file modified FenixQuartz/SimConnect.dll
Binary file not shown.
6 changes: 6 additions & 0 deletions Installer/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
9 changes: 9 additions & 0 deletions Installer/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="Installer.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Installer"
StartupUri="InstallerWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
8 changes: 8 additions & 0 deletions Installer/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Windows;

namespace Installer
{
public partial class App : Application
{
}
}
Binary file added Installer/AppPackage.zip
Binary file not shown.
19 changes: 19 additions & 0 deletions Installer/FenixQuartz.config.numlvar
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="debugGUI" value="true" />
<add key="FenixExecutable" value="FenixSystem" />
<add key="logFilePath" value="FenixQuartz.log" />
<add key="logLevel" value="Debug" />
<add key="waitForConnect" value="true" />
<add key="offsetBase" value="0x5408" />
<add key="rawValues" value="true" />
<add key="useLvars" value="true" />
<add key="updateIntervall" value="100" />
<add key="altScaleDelim" value=" "/>
<add key="addFcuMode" value="true"/>
<add key="ooMode" value="false"/>
<add key="lvarPrefix" value="FNX2PLD_"/>
<add key="ignoreBatteries" value="false"/>
<add key="perfCaptainSide" value="true"/>
<add key="perfButtonHold" value="1000"/>
</appSettings>
Loading

0 comments on commit e6b4848

Please sign in to comment.