Static code analysis
This commit is contained in:
17
MainUI.Designer.cs
generated
17
MainUI.Designer.cs
generated
@ -40,9 +40,9 @@
|
||||
this.txtHeader = new System.Windows.Forms.TextBox();
|
||||
this.grid = new System.Windows.Forms.DataGridView();
|
||||
this.Complete = new System.Windows.Forms.DataGridViewButtonColumn();
|
||||
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.DNF = new System.Windows.Forms.DataGridViewButtonColumn();
|
||||
this.entryBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.txtLog = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.lblClock = new System.Windows.Forms.Label();
|
||||
this.flowLayoutPanelConfiguration = new System.Windows.Forms.FlowLayoutPanel();
|
||||
@ -205,13 +205,6 @@
|
||||
this.Complete.ReadOnly = true;
|
||||
this.Complete.Text = "Mål";
|
||||
//
|
||||
// nameDataGridViewTextBoxColumn
|
||||
//
|
||||
this.nameDataGridViewTextBoxColumn.DataPropertyName = "SailNumber";
|
||||
this.nameDataGridViewTextBoxColumn.HeaderText = "Sejlnummer";
|
||||
this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
|
||||
this.nameDataGridViewTextBoxColumn.Width = 198;
|
||||
//
|
||||
// DNF
|
||||
//
|
||||
this.DNF.HeaderText = "DNF";
|
||||
@ -220,6 +213,13 @@
|
||||
this.DNF.Text = "Udgået";
|
||||
this.DNF.UseColumnTextForButtonValue = true;
|
||||
//
|
||||
// nameDataGridViewTextBoxColumn
|
||||
//
|
||||
this.nameDataGridViewTextBoxColumn.DataPropertyName = "SailNumber";
|
||||
this.nameDataGridViewTextBoxColumn.HeaderText = "Sejlnummer";
|
||||
this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn";
|
||||
this.nameDataGridViewTextBoxColumn.Width = 198;
|
||||
//
|
||||
// txtLog
|
||||
//
|
||||
this.txtLog.ColumnCount = 3;
|
||||
@ -365,6 +365,7 @@
|
||||
this.Name = "MainUI";
|
||||
this.Text = "Tidstagning";
|
||||
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.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
|
25
MainUI.cs
25
MainUI.cs
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Tidstagning
|
||||
@ -98,7 +99,7 @@ namespace Tidstagning
|
||||
|
||||
private void btnStart_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (txtHeader.Text == "")
|
||||
if (txtHeader.Text.Trim().Length == 0)
|
||||
{
|
||||
MessageBox.Show("Udfyld løbs titel");
|
||||
return;
|
||||
@ -140,7 +141,7 @@ namespace Tidstagning
|
||||
|
||||
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)
|
||||
{
|
||||
textStartProcedure.Text = startprocedure.TextualRepresentation();
|
||||
@ -184,7 +185,8 @@ namespace Tidstagning
|
||||
grid.Focus();
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch(InvalidOperationException)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,7 +200,7 @@ namespace Tidstagning
|
||||
grid.Rows[e.RowIndex].Height = 30;
|
||||
|
||||
}
|
||||
catch
|
||||
catch(InvalidOperationException)
|
||||
{ }
|
||||
}
|
||||
|
||||
@ -206,8 +208,10 @@ namespace Tidstagning
|
||||
|
||||
private void buttonConfig_Click(object sender, EventArgs e)
|
||||
{
|
||||
ConfigUI configui = new();
|
||||
configui.ShowDialog();
|
||||
using (ConfigUI configui = new())
|
||||
{
|
||||
configui.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void numericSignalLength_ValueChanged(object sender, EventArgs e)
|
||||
@ -216,5 +220,14 @@ namespace Tidstagning
|
||||
Properties.Settings.Default.SignalLength = (uint)numericSignalLength.Value;
|
||||
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;
|
||||
using Timer = System.Threading.Timer;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Tidstagning
|
||||
{
|
||||
class Procedure
|
||||
@ -12,7 +14,7 @@ namespace Tidstagning
|
||||
uint signalLength = 500;
|
||||
|
||||
Timer? delayTimer;
|
||||
Int16 idx = 0;
|
||||
int idx;
|
||||
|
||||
public Procedure()
|
||||
{
|
||||
@ -37,9 +39,9 @@ namespace Tidstagning
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -66,7 +68,7 @@ namespace Tidstagning
|
||||
{
|
||||
t += " ";
|
||||
}
|
||||
t += signal.ToString() + "\r\n";
|
||||
t += signal.ToString(new CultureInfo("da-DK")) + "\r\n";
|
||||
}
|
||||
}
|
||||
return t;
|
||||
@ -116,7 +118,8 @@ namespace Tidstagning
|
||||
}
|
||||
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 =>
|
||||
{
|
||||
|
@ -1,6 +1,8 @@
|
||||
using CommandLine;
|
||||
using System.Windows.Forms;
|
||||
using System;
|
||||
[assembly: CLSCompliant(false)]
|
||||
|
||||
namespace Tidstagning
|
||||
{
|
||||
class Program
|
||||
|
7
Relay.cs
7
Relay.cs
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO.Ports;
|
||||
using System.Threading;
|
||||
|
||||
@ -16,7 +17,7 @@ namespace Tidstagning
|
||||
public bool output_on;
|
||||
};
|
||||
Queue<SignalSpec> signals = new Queue<SignalSpec>();
|
||||
bool processing_queue = false;
|
||||
bool processing_queue;
|
||||
|
||||
public Relay()
|
||||
{
|
||||
@ -36,7 +37,7 @@ namespace Tidstagning
|
||||
com.Open();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -67,7 +68,7 @@ namespace Tidstagning
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.WriteLine("Requesting horn for: " + time.ToString() + "ms");
|
||||
Debug.WriteLine("Requesting horn for: " + time.ToString(new CultureInfo("da-DK")) + "ms");
|
||||
SignalSpec on_signal;
|
||||
on_signal.duration = time;
|
||||
on_signal.output_on = true;
|
||||
|
@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
namespace Tidstagning
|
||||
{
|
||||
class ResultList
|
||||
class ResultList : IDisposable
|
||||
{
|
||||
System.IO.StreamWriter filehandle_log;
|
||||
System.IO.StreamWriter filehandle_results;
|
||||
@ -11,12 +13,12 @@ namespace Tidstagning
|
||||
public ResultList(string filename, Tidstagning.MainUI log_object)
|
||||
{
|
||||
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_results = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".csv");
|
||||
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", new CultureInfo("da-DK")) + ".csv");
|
||||
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())
|
||||
{
|
||||
@ -30,7 +32,7 @@ namespace Tidstagning
|
||||
this.racenumber = header;
|
||||
Write("----------------------------");
|
||||
Write(header);
|
||||
Write("Løb startet den: " + DateTime.Now.ToString());
|
||||
Write("Løb startet den: " + DateTime.Now.ToString(new CultureInfo("da-DK")));
|
||||
Write("----------------------------");
|
||||
WriteCSV("RaceNo,SailNo,Finish,Code,");
|
||||
}
|
||||
@ -39,19 +41,19 @@ namespace Tidstagning
|
||||
public void WriteFooter()
|
||||
{
|
||||
Write("----------------------------");
|
||||
Write("Løb afsluttet den: " + DateTime.Now.ToString());
|
||||
Write("Løb afsluttet den: " + DateTime.Now.ToString(new CultureInfo("da-DK")));
|
||||
Write("----------------------------");
|
||||
}
|
||||
|
||||
public void WriteComplete(Entry Boat)
|
||||
{
|
||||
Write("Fuldført! - " + Boat.Name + " - " + Boat.Completed_Time.ToString());
|
||||
WriteCSV(this.racenumber + "," + Boat.SailNumber + "," + Boat.Completed_Time.ToString("HH:mm:ss") + ", ,");
|
||||
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", new CultureInfo("da-DK")) + ", ,");
|
||||
}
|
||||
|
||||
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,");
|
||||
}
|
||||
|
||||
@ -71,8 +73,15 @@ namespace Tidstagning
|
||||
public void Close()
|
||||
{
|
||||
filehandle_log.Close();
|
||||
filehandle_log.Dispose();
|
||||
filehandle_results.Close();
|
||||
filehandle_results.Dispose();
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,11 @@
|
||||
<StartupObject>Tidstagning.Program</StartupObject>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Configurations>Release</Configurations>
|
||||
<AnalysisLevel>latest-all</AnalysisLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<Optimize>true</Optimize>
|
||||
<Optimize>False</Optimize>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</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
|
Reference in New Issue
Block a user