Skip to content

Commit

Permalink
v1.2.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-heyns committed Jul 7, 2022
1 parent 75c7310 commit 883bc4a
Show file tree
Hide file tree
Showing 24 changed files with 1,200 additions and 904 deletions.
2 changes: 1 addition & 1 deletion Terminal2/App.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand Down
48 changes: 34 additions & 14 deletions Terminal2/Comms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,19 @@ public Comms(Label[] leds, Label[] controls, EventQueue inputQueue)
_controls = controls;
_inputQueue = inputQueue;
foreach (Label led in _leds)
led.Visible = false;
{
led.Text = "-";
led.Visible = true;
led.Enabled = false;
led.BackColor = Color.LightGray;
}
foreach (Label control in _controls)
control.Visible = false;
{
control.Text = "-";
control.Visible = true;
control.Enabled = false;
control.BackColor = Color.LightGray;
}
}

public void SetEmbellishments(Embellishments embellishments)
Expand Down Expand Up @@ -438,9 +448,19 @@ public void Disconnect()
// don't check - always force - might be waiting

foreach (Label led in _leds)
led.Visible = false;
{
led.Text = "-";
led.Visible = true;
led.Enabled = false;
led.BackColor = Color.LightGray;
}
foreach (Label control in _controls)
control.Visible = false;
{
control.Text = "-";
control.Visible = true;
control.Enabled = false;
control.BackColor = Color.LightGray;
}

_connected = false;
_connectionString = "Disconnected";
Expand Down Expand Up @@ -663,40 +683,40 @@ private void SerialPinChangeHandler(object sender, SerialPinChangedEventArgs e)
private void SetupSerialControls()
{
_controls[0].Text = "DTR";
_controls[0].Visible = true;
_controls[0].Enabled = true;
_controls[0].BackColor = Color.White;

_controls[1].Text = "RTS";
_controls[1].Visible = true;
_controls[1].Enabled = true;
_controls[1].BackColor = Color.White;
}

private void SetupSerialLEDs()
{
_leds[0].Text = "CTS";
_leds[0].Visible = true;
_leds[0].Enabled = true;
if (_com.CtsHolding)
_leds[0].BackColor = Color.Lime;
else
_leds[0].BackColor = Color.White;
_leds[0].BackColor = Color.LightGray;

_leds[1].Text = "DSR";
_leds[1].Visible = true;
_leds[1].Enabled = true;
if (_com.DsrHolding)
_leds[1].BackColor = Color.Lime;
else
_leds[1].BackColor = Color.White;
_leds[1].BackColor = Color.LightGray;

_leds[2].Text = "CD";
_leds[2].Visible = true;
_leds[2].Enabled = true;
if (_com.CDHolding)
_leds[2].BackColor = Color.Lime;
else
_leds[2].BackColor = Color.White;
_leds[2].BackColor = Color.LightGray;

_leds[3].Text = "RI";
_leds[3].Visible = true;
_leds[3].BackColor = Color.White;
_leds[3].Enabled = true;
_leds[3].BackColor = Color.LightGray;
}

public int DataWaiting()
Expand Down
46 changes: 46 additions & 0 deletions Terminal2/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,52 @@ public static void Initialise()
Directory.SetCurrentDirectory(_directory);
}

public static void Backup()
{
string lastDay = string.Empty;
string lastDayFilename = _directory + $"\\Backup";
if (File.Exists(lastDayFilename))
{
try
{
lastDay = File.ReadAllText(lastDayFilename);
}
catch { }
}

string today = DateTime.Now.DayOfWeek.ToString();

if (lastDay != today)
{
string backupDir = _directory + $"\\{today}";
if (!Directory.Exists(backupDir))
Directory.CreateDirectory(backupDir);

if (Directory.Exists(backupDir))
{
try
{
var dir = Directory.EnumerateFiles(_directory);
foreach (string s in dir)
{
if (s.EndsWith(".profile"))
{
string name = Path.GetFileNameWithoutExtension(s);
string newName = backupDir + $"\\{name}.profile";
if (File.Exists(newName))
File.Delete(newName);

if (!File.Exists(newName))
File.Copy(s, newName);
}
}
File.WriteAllText(lastDayFilename, today);
}
catch { }
}
}
}

public static bool Find(string name)
{
try
Expand Down
Loading

0 comments on commit 883bc4a

Please sign in to comment.