Clear out nullable warnings

This commit is contained in:
Jens True 2022-05-01 22:29:00 +02:00
parent 300377e7ca
commit 660b5a8e49
5 changed files with 25 additions and 17 deletions

@ -40,9 +40,11 @@ namespace Tidstagning
{ {
get get
{ {
if (Assembly.GetExecutingAssembly().GetName().Version != null) Version? version = Assembly.GetExecutingAssembly().GetName().Version;
if (version is not null)
{ {
return Assembly.GetExecutingAssembly().GetName().Version.ToString(); return version.ToString();
} }
else else
{ {

@ -12,10 +12,6 @@ namespace Tidstagning
{ {
public partial class ConfigUI : Form public partial class ConfigUI : Form
{ {
private String OnCommand = "";
private String OffCommand = "";
public ConfigUI() public ConfigUI()
{ {
InitializeComponent(); InitializeComponent();

@ -77,6 +77,7 @@ namespace Tidstagning
if (e.RowIndex >= 0 && e.ColumnIndex == grid.Columns["DNF"].Index) if (e.RowIndex >= 0 && e.ColumnIndex == grid.Columns["DNF"].Index)
{ {
entries[e.RowIndex].DNF(); entries[e.RowIndex].DNF();
if(liste is not null)
liste.WriteDNF(entries[e.RowIndex]); liste.WriteDNF(entries[e.RowIndex]);
grid.ClearSelection(); grid.ClearSelection();
@ -86,12 +87,14 @@ namespace Tidstagning
if (e.RowIndex >= 0 && e.ColumnIndex == grid.Columns["Complete"].Index) if (e.RowIndex >= 0 && e.ColumnIndex == grid.Columns["Complete"].Index)
{ {
entries[e.RowIndex].Complete(); entries[e.RowIndex].Complete();
if(liste is not null)
liste.WriteComplete(entries[e.RowIndex]); liste.WriteComplete(entries[e.RowIndex]);
grid.ClearSelection(); grid.ClearSelection();
grid.CurrentCell = null; grid.CurrentCell = null;
entries.RemoveAt(e.RowIndex); entries.RemoveAt(e.RowIndex);
if(horn is not null)
horn.Sound((uint)numericSignalLength.Value); horn.Sound((uint)numericSignalLength.Value);
} }
grid.Refresh(); grid.Refresh();
@ -113,6 +116,7 @@ namespace Tidstagning
if (checkStartProcedure.Checked) if (checkStartProcedure.Checked)
{ {
liste.Write("Automatisk Start Procedure er aktiv."); liste.Write("Automatisk Start Procedure er aktiv.");
if(horn is not null)
startprocedure.setObjects(horn, liste); startprocedure.setObjects(horn, liste);
} }
else else
@ -126,8 +130,11 @@ namespace Tidstagning
{ {
btnStop.Enabled = false; btnStop.Enabled = false;
btnStart.Enabled = true; btnStart.Enabled = true;
if (liste is not null)
{
liste.WriteFooter(); liste.WriteFooter();
liste.Close(); liste.Close();
}
checkStartProcedure.Enabled = true; checkStartProcedure.Enabled = true;
flowLayoutPanelConfiguration.Enabled = true; flowLayoutPanelConfiguration.Enabled = true;
} }
@ -140,6 +147,7 @@ namespace Tidstagning
private void btnTest_Click(object sender, EventArgs e) private void btnTest_Click(object sender, EventArgs e)
{ {
if(horn is not null)
horn.Sound((uint)numericSignalLength.Value); horn.Sound((uint)numericSignalLength.Value);
} }
@ -154,7 +162,7 @@ namespace Tidstagning
private void comboComport_SelectedIndexChanged(object sender, EventArgs e) private void comboComport_SelectedIndexChanged(object sender, EventArgs e)
{ {
if (comboComport.Items.Count != 0) if (comboComport is not null && comboComport.Items.Count != 0 && comboComport.SelectedItem is not null)
{ {
horn = new Relay(comboComport.SelectedItem.ToString()); horn = new Relay(comboComport.SelectedItem.ToString());
Properties.Settings.Default.ComPort = comboComport.SelectedItem.ToString(); Properties.Settings.Default.ComPort = comboComport.SelectedItem.ToString();

@ -5,9 +5,8 @@ using System.Windows.Forms;
namespace Tidstagning namespace Tidstagning
{ {
static class Program class Program
{ {
public class Options public class Options
{ {
[Option('c', "config", Required = false, HelpText = "Enable configuration menu.")] [Option('c', "config", Required = false, HelpText = "Enable configuration menu.")]
@ -20,7 +19,6 @@ namespace Tidstagning
CommandLine.Parser.Default.ParseArguments<Options>(args) CommandLine.Parser.Default.ParseArguments<Options>(args)
.WithParsed(RunOptions) .WithParsed(RunOptions)
.WithNotParsed(HandleParseError); .WithNotParsed(HandleParseError);
} }
static void RunOptions(Options opts) static void RunOptions(Options opts)
{ {

@ -24,6 +24,10 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.0-preview1" /> <PackageReference Include="CommandLineParser" Version="2.9.0-preview1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0-preview.3.22175.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0-preview.3.22175.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0-preview.3.22175.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0-preview.3.22175.4" />
<PackageReference Include="System.IO.Ports" Version="7.0.0-preview.3.22175.4" /> <PackageReference Include="System.IO.Ports" Version="7.0.0-preview.3.22175.4" />
</ItemGroup> </ItemGroup>