Adjustment: Graphics added, to be tested
This commit is contained in:
parent
5653628bf7
commit
0c4da37e85
@ -16,6 +16,9 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
||||
public bool Completed { get { return completed; } }
|
||||
bool completed;
|
||||
|
||||
|
||||
Rectangle[] rects;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
@ -27,6 +30,14 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
||||
completed = false;
|
||||
tr = null;
|
||||
|
||||
|
||||
rects = new Rectangle[WaterMetersCount];
|
||||
for (int i = 0; i < WaterMetersCount; i++)
|
||||
{
|
||||
rects[i] = new Rectangle(385, 30 + 90 * i, 324, 57);
|
||||
}
|
||||
|
||||
|
||||
/// Attach to 'AdjustmentInProgress' handler
|
||||
UiBridge.Bridge.AdjustmentInProgressHandler += delegate(object sender, UiBridge.AdjustmentInProgressEventArgs args)
|
||||
{
|
||||
@ -83,9 +94,16 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
||||
wmErrorTextBox6.Text = "---";
|
||||
}
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
completed = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
void OnAdjustmentInProgress(object sender, UiBridge.AdjustmentInProgressEventArgs args)
|
||||
{
|
||||
tr = args.TestResult;
|
||||
Redraw();
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
@ -98,19 +116,52 @@ namespace TBF.BenchControl.TestMethods.Adjustment
|
||||
if (WaterMetersCount >= 4) wmErrorTextBox4.Text = tr.Meters[3].VolumeErrorPct.ToString("F1");
|
||||
if (WaterMetersCount >= 5) wmErrorTextBox5.Text = tr.Meters[4].VolumeErrorPct.ToString("F1");
|
||||
if (WaterMetersCount >= 6) wmErrorTextBox6.Text = tr.Meters[5].VolumeErrorPct.ToString("F1");
|
||||
}
|
||||
Invalidate(new Rectangle(380, 30, 330, 500));
|
||||
}
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
completed = true;
|
||||
Close();
|
||||
for (int i = 0; i < WaterMetersCount; i++) Invalidate(rects[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void WMErrorsForm_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
if (tr != null)
|
||||
{
|
||||
System.Drawing.Graphics graphics = this.CreateGraphics();
|
||||
|
||||
for (int i = 0; i < WaterMetersCount; i++)
|
||||
{
|
||||
PaintOne(graphics, rects[i], tr.Meters[i].VolumeErrorPct, tr.ErrLimLo, tr.ErrLimHi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PaintOne(System.Drawing.Graphics g, Rectangle r, float value, float limLo, float limHi)
|
||||
{
|
||||
Rectangle rect1 = new Rectangle(r.Left, r.Top, r.Width / 3, r.Height);
|
||||
Rectangle rect2 = new Rectangle(r.Left + r.Width / 3, r.Top, r.Width / 3, r.Height);
|
||||
Rectangle rect3 = new Rectangle(r.Left + 2 * (r.Width / 3), r.Top, r.Width / 3, r.Height);
|
||||
|
||||
Brush redBrush = new SolidBrush(Color.FromName("Salmon"));
|
||||
Brush greenBrush = new SolidBrush(Color.FromName("LightGreen"));
|
||||
g.FillRectangle(redBrush, rect1);
|
||||
g.FillRectangle(greenBrush, rect2);
|
||||
g.FillRectangle(redBrush, rect3);
|
||||
|
||||
int x0 = r.Left + r.Width / 2;
|
||||
int dx = r.Height / 3;
|
||||
int x = (int)((float)r.Width * (2.0 * value - limLo - limHi) / (limHi - limLo) / 6.0f + 0.5f);
|
||||
|
||||
if (x0 - dx + x >= r.Left && x0 + dx + x < r.Left + r.Width)
|
||||
{
|
||||
Point[] triangle = new Point[3]
|
||||
{
|
||||
new Point(x0 - dx + x, r.Top),
|
||||
new Point(x0 + dx + x, r.Top),
|
||||
new Point(x0 + x, r.Top + 2 * r.Height / 3),
|
||||
};
|
||||
|
||||
Brush blackBrush = new SolidBrush(Color.Black);
|
||||
g.FillPolygon(blackBrush, triangle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user