Skip to content

Commit

Permalink
Merge pull request #19 from josh-seagrave/dev
Browse files Browse the repository at this point in the history
Many fixes
  • Loading branch information
Joshua Seagrave authored Dec 3, 2021
2 parents 756629d + e4d4b8b commit ada5f82
Show file tree
Hide file tree
Showing 18 changed files with 625 additions and 723 deletions.
15 changes: 15 additions & 0 deletions EasyCPDLC/App.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="EasyCPDLC.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
Expand All @@ -12,4 +17,14 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<userSettings>
<EasyCPDLC.Properties.Settings>
<setting name="StayOnTop" serializeAs="String">
<value>False</value>
</setting>
<setting name="PlayAudibleAlert" serializeAs="String">
<value>True</value>
</setting>
</EasyCPDLC.Properties.Settings>
</userSettings>
</configuration>
16 changes: 13 additions & 3 deletions EasyCPDLC/EasyCPDLC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@
<Compile Include="RequestForm.Designer.cs">
<DependentUpon>RequestForm.cs</DependentUpon>
</Compile>
<Compile Include="SettingsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SettingsForm.Designer.cs">
<DependentUpon>SettingsForm.cs</DependentUpon>
</Compile>
<Compile Include="TelexForm.cs">
<SubType>Form</SubType>
</Compile>
Expand All @@ -186,6 +192,9 @@
<EmbeddedResource Include="RequestForm.resx">
<DependentUpon>RequestForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SettingsForm.resx">
<DependentUpon>SettingsForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="TelexForm.resx">
<DependentUpon>TelexForm.cs</DependentUpon>
</EmbeddedResource>
Expand All @@ -199,19 +208,20 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Resources\Notification.wav" />
<Content Include="Resources\Oxygen-Regular.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\B612Mono-Regular.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\Oxygen-Bold.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="App.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\honk.wav" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Artboard 1.ico" />
<EmbeddedResource Include="EZCPDLCIcon_64.ico" />
Expand Down
35 changes: 26 additions & 9 deletions EasyCPDLC/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 70 additions & 13 deletions EasyCPDLC/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace EasyCPDLC
{
public partial class MainForm : Form
{

public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
private const int cGrip = 16;
Expand All @@ -59,6 +60,32 @@ public partial class MainForm : Form

private RequestForm rForm;
private TelexForm tForm;
private SettingsForm sForm;

public bool stayOnTop
{
get
{
return Properties.Settings.Default.StayOnTop;
}
set
{
Properties.Settings.Default.StayOnTop = value;
this.TopMost = value;
}
}

public bool playSound
{
get
{
return Properties.Settings.Default.PlayAudibleAlert;
}
set
{
Properties.Settings.Default.PlayAudibleAlert = value;
}
}

public int messageOutCounter = 1;
private bool _connected;
Expand All @@ -85,6 +112,8 @@ public bool connected
}
}
}

public string pendingLogon = null;
private string _currentATCUnit;
public string currentATCUnit
{
Expand Down Expand Up @@ -137,7 +166,7 @@ public string currentATCUnit
ToolStripMenuItem deleteAllMenu;
ToolStripMenuItem freeTextMenu;

private SoundPlayer player = new SoundPlayer(Properties.Resources.honk);
private SoundPlayer player = new SoundPlayer(Properties.Resources.notification);
private RegistryKey regKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\EasyCPDLC");

private static Regex hoppieParse = new Regex(@"{(.*?)}");
Expand All @@ -161,6 +190,7 @@ public MainForm()
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

InitializeComponent();
this.TopMost = stayOnTop;
this.FormBorderStyle = FormBorderStyle.None;
this.DoubleBuffered = true;
this.SetStyle(ControlStyles.ResizeRedraw, true);
Expand Down Expand Up @@ -194,18 +224,26 @@ private void MainForm_Load(object sender, EventArgs e)

private async void CheckNewVersion()
{
var client = new GitHubClient(new ProductHeaderValue("EasyCPDLC"));
var releases = await client.Repository.Release.GetAll("josh-seagrave", "EasyCPDLC");
var latest = releases[0];
string latestVersion = latest.TagName.Replace("cpdlc", "");
if(latestVersion != System.Windows.Forms.Application.ProductVersion)
try
{
DialogResult updateBox = MessageBox.Show(String.Format("New Version {0} Available to download from Github. This application will now exit. Would you like me to take you to the Github page for the latest release?", latestVersion), "New Version Available", MessageBoxButtons.YesNo);
if(updateBox == DialogResult.Yes)
var client = new GitHubClient(new ProductHeaderValue("EasyCPDLC"));
var releases = await client.Repository.Release.GetAll("josh-seagrave", "EasyCPDLC");
var latest = releases[0];
string latestVersion = latest.TagName.Replace("cpdlc", "");
if (latestVersion != System.Windows.Forms.Application.ProductVersion)
{
System.Diagnostics.Process.Start(latest.HtmlUrl);
DialogResult updateBox = MessageBox.Show(String.Format("New Version {0} Available to download from Github. This application will now exit. Would you like me to take you to the Github page for the latest release?", latestVersion), "New Version Available", MessageBoxButtons.YesNo);
if (updateBox == DialogResult.Yes)
{
System.Diagnostics.Process.Start(latest.HtmlUrl);
}
System.Windows.Forms.Application.Exit();
}
System.Windows.Forms.Application.Exit();
}

catch
{

}
}

Expand Down Expand Up @@ -272,6 +310,7 @@ private void freeTextMessage(object sender, EventArgs e)
CPDLCMessage message = (CPDLCMessage)sourceControl;

tForm = new TelexForm(this, message.recipient);
tForm.TopMost = stayOnTop;
tForm.Show();
}
private async void RogerMessage(object sender, EventArgs e)
Expand Down Expand Up @@ -571,7 +610,7 @@ private async Task TelexParser(string response)

format_response += _modify[1];
WriteMessage(format_response, type, sender);
player.Play();
if (playSound) { player.Play(); }
FlashWindow.Flash(this);
}
}
Expand Down Expand Up @@ -613,14 +652,17 @@ private async Task CPDLCParser(string _response, string _sender)
}
if (messageString.StartsWith("LOGON ACCEPTED"))
{
return;
currentATCUnit = pendingLogon;
}
string message = callsign + " " + messageString.Replace("@@", "N/A").Replace("@", Environment.NewLine).Replace("_", "");
message = Regex.Replace(message, @"\s+", " ");

if (message == "LOGOFF")
Logger.Debug(message);

if (message.Contains("LOGOFF"))
{
currentATCUnit = null;
pendingLogon = null;
}

WriteMessage(message, "CPDLC", _sender, false, header);
Expand Down Expand Up @@ -740,6 +782,7 @@ private void telexButton_Click(object sender, EventArgs e)
private void requestButton_Click(object sender, EventArgs e)
{
rForm = new RequestForm(this);
rForm.TopMost = stayOnTop;
rForm.Show();
}

Expand Down Expand Up @@ -786,6 +829,20 @@ protected override void WndProc(ref Message m)
}
base.WndProc(ref m);
}

private void settingsButton_Click(object sender, EventArgs e)
{
bool[] settings = new bool[] { stayOnTop, playSound };
sForm = new SettingsForm(this, settings);
sForm.TopMost = stayOnTop;
if (sForm.ShowDialog(this) == DialogResult.OK)
{
settings = sForm.settings;
stayOnTop = settings[0];
playSound = settings[1];
Properties.Settings.Default.Save();
}
}
}
internal class NoHighlightRenderer : ToolStripProfessionalRenderer
{
Expand Down
24 changes: 22 additions & 2 deletions EasyCPDLC/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ada5f82

Please sign in to comment.