DataEntry.S620 changes, ver. 2.26.1584

This commit is contained in:
Milan Hanajik
2021-01-26 14:54:51 +01:00
parent b2df02dd1b
commit 8ec062b165
7 changed files with 141 additions and 22 deletions
@@ -0,0 +1,24 @@
///
/// Copyright (c) 2021 Sensus Slovensko a.s.
///
using System;
using System.Drawing;
namespace TBF.BenchControl.DataEntry.S620
{
public class ColorFlashEventArgs : EventArgs
{
public int FlashTime;
public Color FlashColor;
public int BeepTime;
public int BeepFrequency;
public ColorFlashEventArgs(int flashTime, Color flashColor, int beepTime, int beepFrequency)
{
FlashTime = flashTime;
FlashColor = flashColor;
BeepTime = beepTime;
BeepFrequency = beepFrequency;
}
}
}
@@ -1,5 +1,5 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
/// Copyright (c) 2020-2021 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
@@ -9,6 +9,7 @@ using TBF.BenchControl.Sequences;
using TBF.Resources;
using Oracle.DataAccess.Client;
using System.Diagnostics;
using System.Drawing;
namespace TBF.BenchControl.DataEntry.S620
{
@@ -64,6 +65,7 @@ namespace TBF.BenchControl.DataEntry.S620
{
InitializeComponent();
ControlBox = false;
BackColor = SystemColors.Control;
firstSN = 0;
snDigits = 0;
@@ -112,6 +114,18 @@ namespace TBF.BenchControl.DataEntry.S620
enabledSerialNrBoxes = new List<TextBox>();
enabledCounterNrBoxes = new List<TextBox>();
ColorFlashHandler += delegate(object sender, ColorFlashEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<ColorFlashEventArgs>(OnColorFlash), sender, args); }
else OnColorFlash(sender, args);
};
BeepHandler += delegate(object sender, ColorFlashEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<ColorFlashEventArgs>(OnBeep), sender, args); }
else OnBeep(sender, args);
};
completed = false;
StartForceCloseHandler();
}
@@ -468,6 +482,28 @@ namespace TBF.BenchControl.DataEntry.S620
{
if (bodyNrBoxes[i] == currentFocusOwner)
{
bool isUnique = true;
int j;
for (j = 0; j < i; j++)
{
if (bodyNrBoxes[i].Text == bodyNrBoxes[j].Text)
{
isUnique = false;
break;
}
else
{
bodyNrBoxes[j].ForeColor = Color.Black;
}
}
if (!isUnique)
{
bodyNrBoxes[j].ForeColor = Color.Red;
bodyNrBoxes[i].Text = string.Empty;
ColorFlashAndBeep(this, new ColorFlashEventArgs(3000, Color.Yellow, 700, 500));
return;
}
if (waterMeters[i].PassedFromTests())
{
serialNrBoxes[i].Text = GetNextSerialNr().ToString(); /// WM Passed
@@ -476,6 +512,8 @@ namespace TBF.BenchControl.DataEntry.S620
{
serialNrBoxes[i].Text = "0"; /// WM failed
}
break;
}
}
@@ -689,5 +727,61 @@ namespace TBF.BenchControl.DataEntry.S620
return 0; /// No free serial number found
}
/// <summary>
/// Called from the state machine when an operation forces a modeless dialog close.
/// </summary>
public static void ColorFlashAndBeep(object sender, ColorFlashEventArgs args)
{
if (ColorFlashHandler != null)
{
try { ColorFlashHandler(sender, args); }
catch (Exception) { }
}
if (BeepHandler != null)
{
try { BeepHandler(sender, args); }
catch (Exception) { }
}
}
public static event EventHandler<ColorFlashEventArgs> BeepHandler;
public static event EventHandler<ColorFlashEventArgs> ColorFlashHandler;
void OnBeep(object sender, ColorFlashEventArgs args)
{
if (args.BeepFrequency > 0 && args.BeepTime > 0)
{
Console.Beep(args.BeepFrequency, args.BeepTime);
}
}
private static System.Windows.Forms.Timer colorFlashDurationTimer;
void OnColorFlash(object sender, ColorFlashEventArgs args)
{
// start timer here
if (colorFlashDurationTimer == null)
{
colorFlashDurationTimer = new System.Windows.Forms.Timer();
colorFlashDurationTimer.Tick += (s, e) => { ColorFlashAction(); };
}
BackColor = args.FlashColor;
colorFlashDurationTimer.Interval = args.FlashTime;
colorFlashDurationTimer.Start();
}
// Specify what you want to happen when the Elapsed event is
// raised.
private void ColorFlashAction()
{
BackColor = SystemColors.Control;
colorFlashDurationTimer.Stop();
colorFlashDurationTimer.Enabled = false;
}
}
}
@@ -121,14 +121,14 @@ namespace TBF.BenchControl.DataEntry.S620
comboBox21, comboBox22, comboBox23, comboBox24, comboBox25, comboBox26, comboBox27, comboBox28, comboBox29, comboBox30,
comboBox31, comboBox32, comboBox33, comboBox34, comboBox35, comboBox36, comboBox37, comboBox38, comboBox39, comboBox40,
};
serialNrBoxes = new TextBox[]
counterNrBoxes = new TextBox[]
{
textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8, textBox9, textBox10,
textBox11, textBox12, textBox13, textBox14, textBox15, textBox16, textBox17, textBox18, textBox19, textBox20,
textBox21, textBox22, textBox23, textBox24, textBox25, textBox26, textBox27, textBox28, textBox29, textBox30,
textBox31, textBox32, textBox33, textBox34, textBox35, textBox36, textBox37, textBox38, textBox39, textBox40,
};
counterNrBoxes = new TextBox[]
serialNrBoxes = new TextBox[]
{
textBox41, textBox42, textBox43, textBox44, textBox45, textBox46, textBox47, textBox48, textBox49, textBox50,
textBox51, textBox52, textBox53, textBox54, textBox55, textBox56, textBox57, textBox58, textBox59, textBox60,
@@ -5407,7 +5407,7 @@
<value>NoControl</value>
</data>
<data name="snLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>336, 22</value>
<value>467, 22</value>
</data>
<data name="snLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>97, 16</value>
@@ -5440,7 +5440,7 @@
<value>NoControl</value>
</data>
<data name="bodyLabel2.Location" type="System.Drawing.Point, System.Drawing">
<value>788, 22</value>
<value>790, 22</value>
</data>
<data name="bodyLabel2.Size" type="System.Drawing.Size, System.Drawing">
<value>93, 16</value>
@@ -5473,7 +5473,7 @@
<value>NoControl</value>
</data>
<data name="snLabel2.Location" type="System.Drawing.Point, System.Drawing">
<value>942, 22</value>
<value>1075, 22</value>
</data>
<data name="snLabel2.Size" type="System.Drawing.Size, System.Drawing">
<value>97, 16</value>
@@ -5707,7 +5707,7 @@
<value>NoControl</value>
</data>
<data name="counterLabel2.Location" type="System.Drawing.Point, System.Drawing">
<value>1066, 22</value>
<value>933, 22</value>
</data>
<data name="counterLabel2.Size" type="System.Drawing.Size, System.Drawing">
<value>113, 16</value>
@@ -5740,7 +5740,7 @@
<value>NoControl</value>
</data>
<data name="counterLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>459, 22</value>
<value>326, 22</value>
</data>
<data name="counterLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>113, 16</value>
+2 -2
View File
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.26.1583.0")]
[assembly: AssemblyFileVersion("2.26.1583.0")]
[assembly: AssemblyVersion("2.26.1584.0")]
[assembly: AssemblyFileVersion("2.26.1584.0")]
+1
View File
@@ -350,6 +350,7 @@
<Compile Include="BenchControl\DataEntry\S620\CheckItems\OkNok.designer.cs">
<DependentUpon>OkNok.cs</DependentUpon>
</Compile>
<Compile Include="BenchControl\DataEntry\S620\ColorFlashEventArgs.cs" />
<Compile Include="BenchControl\DataEntry\S620\FocusPressedEventArgs.cs" />
<Compile Include="BenchControl\DataEntry\S620\FormForMechanicalMeters.cs">
<SubType>Form</SubType>