Static code analysis
This commit is contained in:
parent
a12e02736c
commit
3511bf1c7e
17
MainUI.Designer.cs
generated
17
MainUI.Designer.cs
generated
@ -40,9 +40,9 @@
|
|||||||
this.txtHeader = new System.Windows.Forms.TextBox();
|
this.txtHeader = new System.Windows.Forms.TextBox();
|
||||||
this.grid = new System.Windows.Forms.DataGridView();
|
this.grid = new System.Windows.Forms.DataGridView();
|
||||||
this.Complete = new System.Windows.Forms.DataGridViewButtonColumn();
|
this.Complete = new System.Windows.Forms.DataGridViewButtonColumn();
|
||||||
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
|
||||||
this.DNF = new System.Windows.Forms.DataGridViewButtonColumn();
|
this.DNF = new System.Windows.Forms.DataGridViewButtonColumn();
|
||||||
this.entryBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
this.entryBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||||
|
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.txtLog = new System.Windows.Forms.TableLayoutPanel();
|
this.txtLog = new System.Windows.Forms.TableLayoutPanel();
|
||||||
this.lblClock = new System.Windows.Forms.Label();
|
this.lblClock = new System.Windows.Forms.Label();
|
||||||
this.flowLayoutPanelConfiguration = new System.Windows.Forms.FlowLayoutPanel();
|
this.flowLayoutPanelConfiguration = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
@ -205,13 +205,6 @@
|
|||||||
this.Complete.ReadOnly = true;
|
this.Complete.ReadOnly = true;
|
||||||
this.Complete.Text = "Mål";
|
this.Complete.Text = "Mål";
|
||||||
//
|
//
|
||||||
// nameDataGridViewTextBoxColumn
|
|
||||||
//
|
|
||||||
this.nameDataGridViewTextBoxColumn.DataPropertyName = "SailNumber";
|
|
||||||
this.nameDataGridViewTextBoxColumn.HeaderText = "Sejlnummer";
|
|
||||||
this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
|
|
||||||
this.nameDataGridViewTextBoxColumn.Width = 198;
|
|
||||||
//
|
|
||||||
// DNF
|
// DNF
|
||||||
//
|
//
|
||||||
this.DNF.HeaderText = "DNF";
|
this.DNF.HeaderText = "DNF";
|
||||||
@ -220,6 +213,13 @@
|
|||||||
this.DNF.Text = "Udgået";
|
this.DNF.Text = "Udgået";
|
||||||
this.DNF.UseColumnTextForButtonValue = true;
|
this.DNF.UseColumnTextForButtonValue = true;
|
||||||
//
|
//
|
||||||
|
// nameDataGridViewTextBoxColumn
|
||||||
|
//
|
||||||
|
this.nameDataGridViewTextBoxColumn.DataPropertyName = "SailNumber";
|
||||||
|
this.nameDataGridViewTextBoxColumn.HeaderText = "Sejlnummer";
|
||||||
|
this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
|
||||||
|
this.nameDataGridViewTextBoxColumn.Width = 198;
|
||||||
|
//
|
||||||
// txtLog
|
// txtLog
|
||||||
//
|
//
|
||||||
this.txtLog.ColumnCount = 3;
|
this.txtLog.ColumnCount = 3;
|
||||||
@ -365,6 +365,7 @@
|
|||||||
this.Name = "MainUI";
|
this.Name = "MainUI";
|
||||||
this.Text = "Tidstagning";
|
this.Text = "Tidstagning";
|
||||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||||
|
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainUI_FormClosed);
|
||||||
this.Load += new System.EventHandler(this.Form1_Load);
|
this.Load += new System.EventHandler(this.Form1_Load);
|
||||||
this.panel1.ResumeLayout(false);
|
this.panel1.ResumeLayout(false);
|
||||||
this.panel1.PerformLayout();
|
this.panel1.PerformLayout();
|
||||||
|
25
MainUI.cs
25
MainUI.cs
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Tidstagning
|
namespace Tidstagning
|
||||||
@ -98,7 +99,7 @@ namespace Tidstagning
|
|||||||
|
|
||||||
private void btnStart_Click(object sender, EventArgs e)
|
private void btnStart_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (txtHeader.Text == "")
|
if (txtHeader.Text.Trim().Length == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Udfyld løbs titel");
|
MessageBox.Show("Udfyld løbs titel");
|
||||||
return;
|
return;
|
||||||
@ -140,7 +141,7 @@ namespace Tidstagning
|
|||||||
|
|
||||||
private void Clock_Tick(object sender, EventArgs e)
|
private void Clock_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
lblClock.Text = DateTime.Now.ToString("HH:mm:ss");
|
lblClock.Text = DateTime.Now.ToString("HH:mm:ss", new CultureInfo("da-DK"));
|
||||||
if (checkStartProcedure.Checked)
|
if (checkStartProcedure.Checked)
|
||||||
{
|
{
|
||||||
textStartProcedure.Text = startprocedure.TextualRepresentation();
|
textStartProcedure.Text = startprocedure.TextualRepresentation();
|
||||||
@ -184,7 +185,8 @@ namespace Tidstagning
|
|||||||
grid.Focus();
|
grid.Focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch(InvalidOperationException)
|
||||||
|
{ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +200,7 @@ namespace Tidstagning
|
|||||||
grid.Rows[e.RowIndex].Height = 30;
|
grid.Rows[e.RowIndex].Height = 30;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch
|
catch(InvalidOperationException)
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,8 +208,10 @@ namespace Tidstagning
|
|||||||
|
|
||||||
private void buttonConfig_Click(object sender, EventArgs e)
|
private void buttonConfig_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ConfigUI configui = new();
|
using (ConfigUI configui = new())
|
||||||
configui.ShowDialog();
|
{
|
||||||
|
configui.ShowDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void numericSignalLength_ValueChanged(object sender, EventArgs e)
|
private void numericSignalLength_ValueChanged(object sender, EventArgs e)
|
||||||
@ -216,5 +220,14 @@ namespace Tidstagning
|
|||||||
Properties.Settings.Default.SignalLength = (uint)numericSignalLength.Value;
|
Properties.Settings.Default.SignalLength = (uint)numericSignalLength.Value;
|
||||||
Properties.Settings.Default.Save();
|
Properties.Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MainUI_FormClosed(object sender, FormClosedEventArgs e)
|
||||||
|
{
|
||||||
|
if (liste is not null)
|
||||||
|
{
|
||||||
|
liste.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
Procedure.cs
13
Procedure.cs
@ -2,6 +2,8 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System;
|
using System;
|
||||||
using Timer = System.Threading.Timer;
|
using Timer = System.Threading.Timer;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Tidstagning
|
namespace Tidstagning
|
||||||
{
|
{
|
||||||
class Procedure
|
class Procedure
|
||||||
@ -12,7 +14,7 @@ namespace Tidstagning
|
|||||||
uint signalLength = 500;
|
uint signalLength = 500;
|
||||||
|
|
||||||
Timer? delayTimer;
|
Timer? delayTimer;
|
||||||
Int16 idx = 0;
|
int idx;
|
||||||
|
|
||||||
public Procedure()
|
public Procedure()
|
||||||
{
|
{
|
||||||
@ -37,9 +39,9 @@ namespace Tidstagning
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
signaler.Add(DateTime.Parse(input_filtered));
|
signaler.Add(DateTime.Parse(input_filtered, new CultureInfo("da-DK")));
|
||||||
}
|
}
|
||||||
catch
|
catch(ArgumentNullException)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Failed to parse: " + input);
|
Debug.WriteLine("Failed to parse: " + input);
|
||||||
}
|
}
|
||||||
@ -66,7 +68,7 @@ namespace Tidstagning
|
|||||||
{
|
{
|
||||||
t += " ";
|
t += " ";
|
||||||
}
|
}
|
||||||
t += signal.ToString() + "\r\n";
|
t += signal.ToString(new CultureInfo("da-DK")) + "\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
@ -116,7 +118,8 @@ namespace Tidstagning
|
|||||||
}
|
}
|
||||||
if (log is not null)
|
if (log is not null)
|
||||||
{
|
{
|
||||||
log.Write("Næste signal: " + alertTime.ToString(@"HH\:mm\:ss") + " Om: " + timeToGo.ToString(@"hh\:mm\:ss"));
|
;
|
||||||
|
log.Write("Næste signal: " + alertTime.ToString(@"HH\:mm\:ss", new CultureInfo("da-DK")) + " Om: " + timeToGo.ToString(@"hh\:mm\:ss", new CultureInfo("da-DK")));
|
||||||
}
|
}
|
||||||
delayTimer = new Timer(x =>
|
delayTimer = new Timer(x =>
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using CommandLine;
|
using CommandLine;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System;
|
using System;
|
||||||
|
[assembly: CLSCompliant(false)]
|
||||||
|
|
||||||
namespace Tidstagning
|
namespace Tidstagning
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
|
7
Relay.cs
7
Relay.cs
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO.Ports;
|
using System.IO.Ports;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ namespace Tidstagning
|
|||||||
public bool output_on;
|
public bool output_on;
|
||||||
};
|
};
|
||||||
Queue<SignalSpec> signals = new Queue<SignalSpec>();
|
Queue<SignalSpec> signals = new Queue<SignalSpec>();
|
||||||
bool processing_queue = false;
|
bool processing_queue;
|
||||||
|
|
||||||
public Relay()
|
public Relay()
|
||||||
{
|
{
|
||||||
@ -36,7 +37,7 @@ namespace Tidstagning
|
|||||||
com.Open();
|
com.Open();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -67,7 +68,7 @@ namespace Tidstagning
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.WriteLine("Requesting horn for: " + time.ToString() + "ms");
|
Debug.WriteLine("Requesting horn for: " + time.ToString(new CultureInfo("da-DK")) + "ms");
|
||||||
SignalSpec on_signal;
|
SignalSpec on_signal;
|
||||||
on_signal.duration = time;
|
on_signal.duration = time;
|
||||||
on_signal.output_on = true;
|
on_signal.output_on = true;
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Tidstagning
|
namespace Tidstagning
|
||||||
{
|
{
|
||||||
class ResultList
|
class ResultList : IDisposable
|
||||||
{
|
{
|
||||||
System.IO.StreamWriter filehandle_log;
|
System.IO.StreamWriter filehandle_log;
|
||||||
System.IO.StreamWriter filehandle_results;
|
System.IO.StreamWriter filehandle_results;
|
||||||
@ -11,12 +13,12 @@ namespace Tidstagning
|
|||||||
public ResultList(string filename, Tidstagning.MainUI log_object)
|
public ResultList(string filename, Tidstagning.MainUI log_object)
|
||||||
{
|
{
|
||||||
filename = MakeSafeFilename(filename, '_');
|
filename = MakeSafeFilename(filename, '_');
|
||||||
filehandle_log = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".txt");
|
filehandle_log = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss", new CultureInfo("da-DK")) + ".txt");
|
||||||
filehandle_results = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".csv");
|
filehandle_results = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss", new CultureInfo("da-DK")) + ".csv");
|
||||||
parentForm = log_object;
|
parentForm = log_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string MakeSafeFilename(string filename, char replaceChar)
|
private static string MakeSafeFilename(string filename, char replaceChar)
|
||||||
{
|
{
|
||||||
foreach (char c in System.IO.Path.GetInvalidFileNameChars())
|
foreach (char c in System.IO.Path.GetInvalidFileNameChars())
|
||||||
{
|
{
|
||||||
@ -30,7 +32,7 @@ namespace Tidstagning
|
|||||||
this.racenumber = header;
|
this.racenumber = header;
|
||||||
Write("----------------------------");
|
Write("----------------------------");
|
||||||
Write(header);
|
Write(header);
|
||||||
Write("Løb startet den: " + DateTime.Now.ToString());
|
Write("Løb startet den: " + DateTime.Now.ToString(new CultureInfo("da-DK")));
|
||||||
Write("----------------------------");
|
Write("----------------------------");
|
||||||
WriteCSV("RaceNo,SailNo,Finish,Code,");
|
WriteCSV("RaceNo,SailNo,Finish,Code,");
|
||||||
}
|
}
|
||||||
@ -39,19 +41,19 @@ namespace Tidstagning
|
|||||||
public void WriteFooter()
|
public void WriteFooter()
|
||||||
{
|
{
|
||||||
Write("----------------------------");
|
Write("----------------------------");
|
||||||
Write("Løb afsluttet den: " + DateTime.Now.ToString());
|
Write("Løb afsluttet den: " + DateTime.Now.ToString(new CultureInfo("da-DK")));
|
||||||
Write("----------------------------");
|
Write("----------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteComplete(Entry Boat)
|
public void WriteComplete(Entry Boat)
|
||||||
{
|
{
|
||||||
Write("Fuldført! - " + Boat.Name + " - " + Boat.Completed_Time.ToString());
|
Write("Fuldført! - " + Boat.Name + " - " + Boat.Completed_Time.ToString(new CultureInfo("da-DK")));
|
||||||
WriteCSV(this.racenumber + "," + Boat.SailNumber + "," + Boat.Completed_Time.ToString("HH:mm:ss") + ", ,");
|
WriteCSV(this.racenumber + "," + Boat.SailNumber + "," + Boat.Completed_Time.ToString("HH:mm:ss", new CultureInfo("da-DK")) + ", ,");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteDNF(Entry Boat)
|
public void WriteDNF(Entry Boat)
|
||||||
{
|
{
|
||||||
Write("Udgået! - " + Boat.Name + " - " + Boat.Completed_Time.ToString());
|
Write("Udgået! - " + Boat.Name + " - " + Boat.Completed_Time.ToString(new CultureInfo("da-DK")));
|
||||||
WriteCSV(this.racenumber + "," + Boat.SailNumber + "," + "00:00:00,DNC,");
|
WriteCSV(this.racenumber + "," + Boat.SailNumber + "," + "00:00:00,DNC,");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,8 +73,15 @@ namespace Tidstagning
|
|||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
filehandle_log.Close();
|
filehandle_log.Close();
|
||||||
|
filehandle_log.Dispose();
|
||||||
filehandle_results.Close();
|
filehandle_results.Close();
|
||||||
|
filehandle_results.Dispose();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,11 @@
|
|||||||
<StartupObject>Tidstagning.Program</StartupObject>
|
<StartupObject>Tidstagning.Program</StartupObject>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
<Configurations>Release</Configurations>
|
<Configurations>Release</Configurations>
|
||||||
|
<AnalysisLevel>latest-all</AnalysisLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
<Optimize>true</Optimize>
|
<Optimize>False</Optimize>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 16
|
|
||||||
VisualStudioVersion = 16.0.32901.82
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tidstagning", "Tidstagning.csproj", "{24861418-B1D3-4A24-AE31-3E696E98B1B5}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{24861418-B1D3-4A24-AE31-3E696E98B1B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{24861418-B1D3-4A24-AE31-3E696E98B1B5}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {910E5B5A-8C92-4A02-B47E-4A8735ECEE9C}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
Loading…
Reference in New Issue
Block a user