Possibility to display previous results ('Show' button), ver.2.7.305

This commit is contained in:
Milan Hanajik 2016-06-10 16:30:29 +02:00
parent d439d94645
commit 147fb6fb30
18 changed files with 1113 additions and 557 deletions

View File

@ -113,13 +113,24 @@ namespace Results
return d;
}
public static BatchResults FromBatch(Batch batch)
{
int wmCount = batch.WaterMeters.Count;
if (wmCount == 0) return null;
public TestRslt GetTestRslt(string name, int part)
BatchResults batchResults = new BatchResults(wmCount);
batchResults.Batch = batch;
batchResults.WaterMeters = new WaterMeter[wmCount];
for (int i = 0; i < wmCount; i++) batchResults.WaterMeters[i] = batch.WaterMeters[i];
return batchResults;
}
public TestRslt GetTestRslt(string name, int part)
{
return Batch.GetTestRslt(name, part);
}
public MeterTestRslt GetMeterTestRslt(string name, int wmnr0, Config.Entities.CompoundMeterId meterId)
{
if (WaterMeters[wmnr0] != null)

View File

@ -0,0 +1,60 @@
namespace Results.Forms
{
partial class BatchResultsDlg
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.SuspendLayout();
//
// mainFlowLayoutPanel
//
this.mainFlowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainFlowLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.mainFlowLayoutPanel.Name = "mainFlowLayoutPanel";
this.mainFlowLayoutPanel.Size = new System.Drawing.Size(1058, 721);
this.mainFlowLayoutPanel.TabIndex = 0;
//
// BatchResultsDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1058, 721);
this.Controls.Add(this.mainFlowLayoutPanel);
this.Name = "BatchResultsDlg";
this.Text = "Results";
this.Load += new System.EventHandler(this.BatchResultsDlg_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.FlowLayoutPanel mainFlowLayoutPanel;
}
}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Config.Entities;
using Results.Resources;
namespace Results.Forms
{
public partial class BatchResultsDlg : Form
{
public MetersArrangement MetersArrangement { set { ctrl.MetersArrangement = value; } }
public TestsArrangement TestsArrangement { set { ctrl.TestsArrangement = value; } }
public int NrMetersInOneGroup { set { ctrl.NrMetersInOneGroup = value; } }
public IList<Results.ItemSpec> RsltItems_Screen_SingleWM { set { ctrl.RsltItems_Screen_SingleWM = value; } }
public IList<Results.ItemSpec> RsltItems_Screen_CombinedWM { set { ctrl.RsltItems_Screen_CombinedWM = value; } }
public int[] RsltsClmnWidths { set { ctrl.RsltsClmnWidths = value; } }
public Results.BatchResults Results { set { results = value; ctrl.Display(results); } }
Results.BatchResults results;
Results.UiControls.BatchResultsCtrl ctrl;
public BatchResultsDlg()
{
InitializeComponent();
Text = Strings.Results;
ctrl = new Results.UiControls.BatchResultsCtrl();
mainFlowLayoutPanel.Controls.Add(ctrl);
ctrl.Dock = DockStyle.Fill;
}
public BatchResultsDlg(Results.BatchResults results)
: this()
{
this.results = results;
}
private void BatchResultsDlg_Load(object sender, EventArgs e)
{
if (results != null) ctrl.Display(results);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -582,6 +582,15 @@ namespace Results.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Results.
/// </summary>
internal static string Results {
get {
return ResourceManager.GetString("Results", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Selected results.
/// </summary>

View File

@ -156,6 +156,12 @@
<data name="Remove_all" xml:space="preserve">
<value>Odebrat vše</value>
</data>
<data name="Result" xml:space="preserve">
<value>Výsledek</value>
</data>
<data name="Results" xml:space="preserve">
<value>Výsledky</value>
</data>
<data name="Selected_results" xml:space="preserve">
<value>Vybrané výsledky</value>
</data>

View File

@ -372,4 +372,7 @@
<data name="Year" xml:space="preserve">
<value>Eichjahr</value>
</data>
<data name="Results" xml:space="preserve">
<value>Ergebnisse</value>
</data>
</root>

View File

@ -375,4 +375,7 @@
<data name="Year" xml:space="preserve">
<value>Year</value>
</data>
<data name="Results" xml:space="preserve">
<value>Results</value>
</data>
</root>

View File

@ -67,6 +67,12 @@
<Compile Include="Entities\WaterMeterData.cs" />
<Compile Include="Entities\WaterMeter.cs" />
<Compile Include="DB.cs" />
<Compile Include="Forms\BatchResultsDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\BatchResultsDlg.Designer.cs">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\ListViewEx.cs">
<SubType>Component</SubType>
</Compile>
@ -98,6 +104,12 @@
<DesignTime>True</DesignTime>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
<Compile Include="UiControls\BatchResultsCtrl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UiControls\BatchResultsCtrl.Designer.cs">
<DependentUpon>BatchResultsCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Utils.cs" />
<Compile Include="WMeterRsltItemSpec.cs" />
</ItemGroup>
@ -114,6 +126,9 @@
<Folder Include="Printers\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\BatchResultsDlg.resx">
<DependentUpon>BatchResultsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ListViewEx.resx">
<DependentUpon>ListViewEx.cs</DependentUpon>
</EmbeddedResource>
@ -130,6 +145,9 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="UiControls\BatchResultsCtrl.resx">
<DependentUpon>BatchResultsCtrl.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Resources\Headpic.png" />

View File

@ -0,0 +1,57 @@
namespace Results.UiControls
{
partial class BatchResultsCtrl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.SuspendLayout();
//
// flowLayoutPanel
//
this.flowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel.Name = "flowLayoutPanel";
this.flowLayoutPanel.Size = new System.Drawing.Size(581, 346);
this.flowLayoutPanel.TabIndex = 0;
//
// BatchResultsCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.flowLayoutPanel);
this.Name = "BatchResultsCtrl";
this.Size = new System.Drawing.Size(581, 346);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel;
}
}

View File

@ -0,0 +1,358 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using log4net;
using Config.Entities;
namespace Results.UiControls
{
public partial class BatchResultsCtrl : UserControl
{
static readonly ILog log = LogManager.GetLogger(typeof(BatchResultsCtrl));
///
/// Public members
///
public MetersArrangement MetersArrangement;
public TestsArrangement TestsArrangement;
public int NrMetersInOneGroup;
public IList<Results.ItemSpec> RsltItems_Screen_SingleWM;
public IList<Results.ItemSpec> RsltItems_Screen_CombinedWM;
public int[] RsltsClmnWidths
{
get
{
if (firstListView == null) return null;
/// Update and return column widths
int[] temp = new int[firstListView.Columns.Count];
for (int i = 0; i < firstListView.Columns.Count; i++)
{
temp[i] = firstListView.Columns[i].Width;
}
rsltsClmnWidths = temp;
return temp;
}
set
{
rsltsClmnWidths = value;
}
}
public bool Compound { get { return Compound; } } /// To inform configuration dialog which configuration is active
///
/// Private members
///
Results.BatchResults results;
bool compound;
ListView firstListView;
public int[] rsltsClmnWidths;
int rsltsClmnCount { get { return (rsltsClmnWidths != null) ? rsltsClmnWidths.Length : 0; } }
int lvWidth;
int lvHeight;
public BatchResultsCtrl()
{
InitializeComponent();
}
public void Display(Results.BatchResults results)
{
this.results = results;
Redraw();
}
/// <summary>
/// Re-draw the results. Apply new settings if they changed.
/// </summary>
public void Redraw()
{
this.SuspendLayout();
try
{
/// Determine how many water meters were enabled for result evaluation and printing
int enabledWMsCount = 0;
for (int i = 0; i < results.WMPositionsCount; i++)
{
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
{
enabledWMsCount++;
}
}
int metersInOneGroup = Math.Max(1, Math.Min(enabledWMsCount, NrMetersInOneGroup));
int nrGroups = Math.Max(1, (enabledWMsCount + NrMetersInOneGroup - 1) / metersInOneGroup);
if (MetersArrangement == MetersArrangement.Horizontally)
{
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
lvWidth = flowLayoutPanel.Width / metersInOneGroup - 6;
lvHeight = flowLayoutPanel.Height / nrGroups - 6;
}
else
{
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
lvWidth = flowLayoutPanel.Width / nrGroups - 6;
lvHeight = flowLayoutPanel.Height / metersInOneGroup - 6;
}
flowLayoutPanel.Controls.Clear();
flowLayoutPanel.WrapContents = true;
flowLayoutPanel.AutoScroll = true;
bool first = true;
for (int i = 0; i < results.WMPositionsCount; i++)
{
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
{
if (TestsArrangement == TestsArrangement.Rows)
{
ListView lview = GetResultsTestsAreRows(results.WaterMeters[i], i + 1);
if (first) { firstListView = lview; first = false; }
if (lview != null) flowLayoutPanel.Controls.Add(lview);
}
else
{
ListView lview = GetResultsTestsAreColumns(results.WaterMeters[i], i + 1);
if (first) { firstListView = lview; first = false; }
if (lview != null) flowLayoutPanel.Controls.Add(lview);
}
}
}
}
catch (Exception e)
{
log.FatalFormat("Redrawing results failed : {0}", e.Message);
if (e.InnerException != null)
{
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
}
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
}
this.ResumeLayout(false);
}
/// <summary>
/// Get an empty ListView control with appropriate parameters.
/// </summary>
/// <returns>ListView control</returns>
ListView GetListView()
{
ListView lview = new ListView();
lview.AllowColumnReorder = false;
lview.Dock = System.Windows.Forms.DockStyle.None;
lview.FullRowSelect = true;
lview.GridLines = true;
lview.Location = new System.Drawing.Point(0, 0);
lview.Size = new System.Drawing.Size(lvWidth, lvHeight);
lview.TabIndex = 0;
lview.UseCompatibleStateImageBehavior = false;
lview.View = System.Windows.Forms.View.Details;
return lview;
}
/// <summary>
/// Get decorated test names for a specified watermeter
/// </summary>
/// <param name="wMtr">Watermeter results entity</param>
/// <returns>A list of strings</returns>
IList<string> GetAllDecoratedTestNames(Results.Entities.WaterMeter wMtr)
{
IList<string> testNames = new List<string>();
foreach (var mtr in wMtr.MeterTestRslts)
{
if ((mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound)
&& mtr.TestDone
&& (mtr.Publish() != Config.Entities.Publish.Never)
&& (mtr.Publish() != Config.Entities.Publish.Internal))
{
testNames.Add(mtr.Name());
}
}
return testNames;
}
/// <summary>
/// Get a ListView control filled with results of the meter 'mtr'
/// </summary>
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
/// <returns>ListView object</returns>
ListView GetResultsTestsAreRows(Results.Entities.WaterMeter wMtr, int printedWMNr)
{
compound = wMtr.Compound();
ListView lview = GetListView();
IList<Results.ItemSpec> items = (compound ? RsltItems_Screen_CombinedWM : RsltItems_Screen_SingleWM);
if (items == null || items.Count == 0) return lview;
// Header
lview.Columns.Add(printedWMNr.ToString(), (rsltsClmnCount > 0) ? rsltsClmnWidths[0] : 40);
int i = 1;
foreach (var item in items)
{
lview.Columns.Add(item.ClmnHeaderText, (rsltsClmnCount > i) ? rsltsClmnWidths[i] : 70);
i++;
}
IList<string> testNames = GetAllDecoratedTestNames(wMtr);
int ix = 0;
foreach (var mtr in wMtr.MeterTestRslts)
{
if ((mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound)
&& mtr.TestDone
&& (mtr.Publish() != Config.Entities.Publish.Never)
&& (mtr.Publish() != Config.Entities.Publish.Internal))
{
ListViewItem lvi = new ListViewItem(testNames[ix++]);
foreach (var item in items)
{
string str;
if (compound)
{
var main = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
var aux = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
str = (item.CanPrintCombined && main != null && aux != null)
? item.PrintCombined(main, aux, mtr)
: string.Empty;
}
else
{
str = item.CanPrintSingle ? item.Print(mtr) : string.Empty;
}
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
lview.Items.Add(lvi);
}
}
return lview;
}
/// <summary>
/// Get a ListView control filled with results of the meter 'mtr'
/// </summary>
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
/// <returns>ListView object</returns>
ListView GetResultsTestsAreColumns(Results.Entities.WaterMeter wMtr, int printedWMNr)
{
compound = wMtr.Compound();
ListView lview = GetListView();
IList<Results.ItemSpec> items = (compound ? RsltItems_Screen_CombinedWM : RsltItems_Screen_SingleWM);
if (items == null || items.Count == 0) return lview;
// Header
lview.Columns.Add(printedWMNr.ToString(), (rsltsClmnCount > 0) ? rsltsClmnWidths[0] : 40);
int i = 1;
foreach (var str in GetAllDecoratedTestNames(wMtr))
{
lview.Columns.Add(str, (rsltsClmnCount > i) ? rsltsClmnWidths[i] : 70);
i++;
}
foreach (var item in items)
{
ListViewItem lvi = new ListViewItem(item.ClmnHeaderText);
if (compound)
{
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr.CompoundMeterId == (byte)CompoundMeterId.Compound && mtr.TestDone
&& (mtr.Publish() != Config.Entities.Publish.Never)
&& (mtr.Publish() != Config.Entities.Publish.Internal))
{
var main = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
var aux = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
string str = (item.CanPrintCombined && main != null && aux != null)
? item.PrintCombined(main, aux, mtr)
: string.Empty;
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
}
else
{
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr.TestDone && (mtr.Publish() != Config.Entities.Publish.Never)
&& (mtr.Publish() != Config.Entities.Publish.Internal))
{
string str = !item.CanPrintSingle ? string.Empty : item.Print(mtr);
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
}
lview.Items.Add(lvi);
}
return lview;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -28,117 +28,129 @@
/// </summary>
private void InitializeComponent()
{
this.sendButton = new System.Windows.Forms.Button();
this.sentCheckBox = new System.Windows.Forms.CheckBox();
this.failedCountLabel = new System.Windows.Forms.Label();
this.passedCountLabel = new System.Windows.Forms.Label();
this.purchaseOrderLabel = new System.Windows.Forms.Label();
this.procedureLabel = new System.Windows.Forms.Label();
this.endTimeLabel = new System.Windows.Forms.Label();
this.startTimeLabel = new System.Windows.Forms.Label();
this.batchNrLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// sendButton
//
this.sendButton.Location = new System.Drawing.Point(832, 2);
this.sendButton.Name = "sendButton";
this.sendButton.Size = new System.Drawing.Size(75, 23);
this.sendButton.TabIndex = 15;
this.sendButton.Text = "Again";
this.sendButton.UseVisualStyleBackColor = true;
this.sendButton.Click += new System.EventHandler(this.sendButton_Click);
//
// sentCheckBox
//
this.sentCheckBox.AutoSize = true;
this.sentCheckBox.Location = new System.Drawing.Point(748, 6);
this.sentCheckBox.Name = "sentCheckBox";
this.sentCheckBox.Size = new System.Drawing.Size(48, 17);
this.sentCheckBox.TabIndex = 14;
this.sentCheckBox.Text = "Sent";
this.sentCheckBox.UseVisualStyleBackColor = true;
//
// failedCountLabel
//
this.failedCountLabel.AutoSize = true;
this.failedCountLabel.Location = new System.Drawing.Point(681, 7);
this.failedCountLabel.Name = "failedCountLabel";
this.failedCountLabel.Size = new System.Drawing.Size(48, 13);
this.failedCountLabel.TabIndex = 13;
this.failedCountLabel.Text = "failedCnt";
//
// passedCountLabel
//
this.passedCountLabel.AutoSize = true;
this.passedCountLabel.Location = new System.Drawing.Point(590, 7);
this.passedCountLabel.Name = "passedCountLabel";
this.passedCountLabel.Size = new System.Drawing.Size(57, 13);
this.passedCountLabel.TabIndex = 12;
this.passedCountLabel.Text = "passedCnt";
//
// purchaseOrderLabel
//
this.purchaseOrderLabel.AutoSize = true;
this.purchaseOrderLabel.Location = new System.Drawing.Point(490, 7);
this.purchaseOrderLabel.Name = "purchaseOrderLabel";
this.purchaseOrderLabel.Size = new System.Drawing.Size(77, 13);
this.purchaseOrderLabel.TabIndex = 11;
this.purchaseOrderLabel.Text = "purchaseOrder";
//
// procedureLabel
//
this.procedureLabel.AutoSize = true;
this.procedureLabel.Location = new System.Drawing.Point(334, 7);
this.procedureLabel.Name = "procedureLabel";
this.procedureLabel.Size = new System.Drawing.Size(55, 13);
this.procedureLabel.TabIndex = 10;
this.procedureLabel.Text = "procedure";
//
// endTimeLabel
//
this.endTimeLabel.AutoSize = true;
this.endTimeLabel.Location = new System.Drawing.Point(188, 7);
this.endTimeLabel.Name = "endTimeLabel";
this.endTimeLabel.Size = new System.Drawing.Size(48, 13);
this.endTimeLabel.TabIndex = 9;
this.endTimeLabel.Text = "endTime";
//
// startTimeLabel
//
this.startTimeLabel.AutoSize = true;
this.startTimeLabel.Location = new System.Drawing.Point(54, 7);
this.startTimeLabel.Name = "startTimeLabel";
this.startTimeLabel.Size = new System.Drawing.Size(50, 13);
this.startTimeLabel.TabIndex = 8;
this.startTimeLabel.Text = "startTime";
//
// batchNrLabel
//
this.batchNrLabel.AutoSize = true;
this.batchNrLabel.Location = new System.Drawing.Point(3, 7);
this.batchNrLabel.Name = "batchNrLabel";
this.batchNrLabel.Size = new System.Drawing.Size(24, 13);
this.batchNrLabel.TabIndex = 16;
this.batchNrLabel.Text = "bNr";
//
// PreviousResultCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.batchNrLabel);
this.Controls.Add(this.sendButton);
this.Controls.Add(this.sentCheckBox);
this.Controls.Add(this.failedCountLabel);
this.Controls.Add(this.passedCountLabel);
this.Controls.Add(this.purchaseOrderLabel);
this.Controls.Add(this.procedureLabel);
this.Controls.Add(this.endTimeLabel);
this.Controls.Add(this.startTimeLabel);
this.Name = "PreviousResultCtrl";
this.Size = new System.Drawing.Size(925, 26);
this.ResumeLayout(false);
this.PerformLayout();
this.sendButton = new System.Windows.Forms.Button();
this.sentCheckBox = new System.Windows.Forms.CheckBox();
this.failedCountLabel = new System.Windows.Forms.Label();
this.passedCountLabel = new System.Windows.Forms.Label();
this.purchaseOrderLabel = new System.Windows.Forms.Label();
this.procedureLabel = new System.Windows.Forms.Label();
this.endTimeLabel = new System.Windows.Forms.Label();
this.startTimeLabel = new System.Windows.Forms.Label();
this.batchNrLabel = new System.Windows.Forms.Label();
this.showButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// sendButton
//
this.sendButton.Location = new System.Drawing.Point(832, 2);
this.sendButton.Name = "sendButton";
this.sendButton.Size = new System.Drawing.Size(75, 23);
this.sendButton.TabIndex = 15;
this.sendButton.Text = "Again";
this.sendButton.UseVisualStyleBackColor = true;
this.sendButton.Click += new System.EventHandler(this.sendButton_Click);
//
// sentCheckBox
//
this.sentCheckBox.AutoSize = true;
this.sentCheckBox.Location = new System.Drawing.Point(748, 6);
this.sentCheckBox.Name = "sentCheckBox";
this.sentCheckBox.Size = new System.Drawing.Size(48, 17);
this.sentCheckBox.TabIndex = 14;
this.sentCheckBox.Text = "Sent";
this.sentCheckBox.UseVisualStyleBackColor = true;
//
// failedCountLabel
//
this.failedCountLabel.AutoSize = true;
this.failedCountLabel.Location = new System.Drawing.Point(681, 7);
this.failedCountLabel.Name = "failedCountLabel";
this.failedCountLabel.Size = new System.Drawing.Size(48, 13);
this.failedCountLabel.TabIndex = 13;
this.failedCountLabel.Text = "failedCnt";
//
// passedCountLabel
//
this.passedCountLabel.AutoSize = true;
this.passedCountLabel.Location = new System.Drawing.Point(590, 7);
this.passedCountLabel.Name = "passedCountLabel";
this.passedCountLabel.Size = new System.Drawing.Size(57, 13);
this.passedCountLabel.TabIndex = 12;
this.passedCountLabel.Text = "passedCnt";
//
// purchaseOrderLabel
//
this.purchaseOrderLabel.AutoSize = true;
this.purchaseOrderLabel.Location = new System.Drawing.Point(490, 7);
this.purchaseOrderLabel.Name = "purchaseOrderLabel";
this.purchaseOrderLabel.Size = new System.Drawing.Size(77, 13);
this.purchaseOrderLabel.TabIndex = 11;
this.purchaseOrderLabel.Text = "purchaseOrder";
//
// procedureLabel
//
this.procedureLabel.AutoSize = true;
this.procedureLabel.Location = new System.Drawing.Point(334, 7);
this.procedureLabel.Name = "procedureLabel";
this.procedureLabel.Size = new System.Drawing.Size(55, 13);
this.procedureLabel.TabIndex = 10;
this.procedureLabel.Text = "procedure";
//
// endTimeLabel
//
this.endTimeLabel.AutoSize = true;
this.endTimeLabel.Location = new System.Drawing.Point(188, 7);
this.endTimeLabel.Name = "endTimeLabel";
this.endTimeLabel.Size = new System.Drawing.Size(48, 13);
this.endTimeLabel.TabIndex = 9;
this.endTimeLabel.Text = "endTime";
//
// startTimeLabel
//
this.startTimeLabel.AutoSize = true;
this.startTimeLabel.Location = new System.Drawing.Point(54, 7);
this.startTimeLabel.Name = "startTimeLabel";
this.startTimeLabel.Size = new System.Drawing.Size(50, 13);
this.startTimeLabel.TabIndex = 8;
this.startTimeLabel.Text = "startTime";
//
// batchNrLabel
//
this.batchNrLabel.AutoSize = true;
this.batchNrLabel.Location = new System.Drawing.Point(3, 7);
this.batchNrLabel.Name = "batchNrLabel";
this.batchNrLabel.Size = new System.Drawing.Size(24, 13);
this.batchNrLabel.TabIndex = 16;
this.batchNrLabel.Text = "bNr";
//
// showButton
//
this.showButton.Location = new System.Drawing.Point(913, 2);
this.showButton.Name = "showButton";
this.showButton.Size = new System.Drawing.Size(75, 23);
this.showButton.TabIndex = 17;
this.showButton.Text = "Show";
this.showButton.UseVisualStyleBackColor = true;
this.showButton.Click += new System.EventHandler(this.showButton_Click);
//
// PreviousResultCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.showButton);
this.Controls.Add(this.batchNrLabel);
this.Controls.Add(this.sendButton);
this.Controls.Add(this.sentCheckBox);
this.Controls.Add(this.failedCountLabel);
this.Controls.Add(this.passedCountLabel);
this.Controls.Add(this.purchaseOrderLabel);
this.Controls.Add(this.procedureLabel);
this.Controls.Add(this.endTimeLabel);
this.Controls.Add(this.startTimeLabel);
this.Name = "PreviousResultCtrl";
this.Size = new System.Drawing.Size(1016, 26);
this.ResumeLayout(false);
this.PerformLayout();
}
@ -153,6 +165,7 @@
private System.Windows.Forms.Label endTimeLabel;
private System.Windows.Forms.Label startTimeLabel;
private System.Windows.Forms.Label batchNrLabel;
private System.Windows.Forms.Button showButton;
}
}

View File

@ -78,5 +78,10 @@ namespace TBF.Forms
{
parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr));
}
private void showButton_Click(object sender, EventArgs e)
{
parent.OnShowResults(this, new PreviousResultIdEventArgs(BatchNr));
}
}
}

View File

@ -36,7 +36,12 @@ namespace TBF.Forms
else DoSendAgain(sndr, args);
};
}
ShowResultsHandler += delegate(object sndr, PreviousResultIdEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<PreviousResultIdEventArgs>(DoShowResults), sndr, args); }
else DoShowResults(sndr, args);
};
}
private void PreviousResultsDlg_Load(object sender, EventArgs e)
{
@ -129,6 +134,40 @@ namespace TBF.Forms
}
public event EventHandler<PreviousResultIdEventArgs> ShowResultsHandler;
/// <summary>
/// Called from PreviousResultCtrl when 'Show' button pressed.
/// </summary>
public void OnShowResults(object sender, PreviousResultIdEventArgs data)
{
if (ShowResultsHandler == null) return;
try { ShowResultsHandler(sender, data); }
catch (Exception e) { log.Error("ShowResultsHandler(...) failed", e); }
}
public void DoShowResults(object sender, PreviousResultIdEventArgs data)
{
Results.Forms.BatchResultsDlg dlg = new Results.Forms.BatchResultsDlg();
dlg.MetersArrangement = Program.LocalSettings.ResultsConfigMeters;
dlg.TestsArrangement = Program.LocalSettings.ResultsConfigTests;
dlg.NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup);
dlg.RsltItems_Screen_SingleWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
dlg.RsltItems_Screen_CombinedWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
dlg.RsltsClmnWidths = Program.LocalSettings.RsltsClmnWidths;
foreach (var b in batches)
{
if (b.BatchNr == data.BatchNr)
{
dlg.Results = Results.BatchResults.FromBatch(b);
break;
}
}
}
void Redraw()
{
SuspendLayout();

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.7.303.1")]
[assembly: AssemblyFileVersion("2.7.303.1")]
[assembly: AssemblyVersion("2.7.305.1")]
[assembly: AssemblyFileVersion("2.7.305.1")]

View File

@ -31,104 +31,102 @@ namespace TBF.Screens
/// </summary>
private void InitializeComponent()
{
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.columnWidthsButton = new System.Windows.Forms.Button();
this.previousResultsButton = new System.Windows.Forms.Button();
this.configureButton = new System.Windows.Forms.Button();
this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout();
this.SuspendLayout();
//
// splitContainer
//
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer.IsSplitterFixed = true;
this.splitContainer.Location = new System.Drawing.Point(0, 0);
this.splitContainer.Name = "splitContainer";
this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer.Panel1
//
this.splitContainer.Panel1.BackColor = System.Drawing.SystemColors.Control;
this.splitContainer.Panel1.Controls.Add(this.columnWidthsButton);
this.splitContainer.Panel1.Controls.Add(this.previousResultsButton);
this.splitContainer.Panel1.Controls.Add(this.configureButton);
//
// splitContainer.Panel2
//
this.splitContainer.Panel2.Controls.Add(this.flowLayoutPanel);
this.splitContainer.Size = new System.Drawing.Size(1057, 706);
this.splitContainer.SplitterDistance = 42;
this.splitContainer.TabIndex = 0;
//
// columnWidthsButton
//
this.columnWidthsButton.Location = new System.Drawing.Point(126, 10);
this.columnWidthsButton.Name = "columnWidthsButton";
this.columnWidthsButton.Size = new System.Drawing.Size(120, 30);
this.columnWidthsButton.TabIndex = 1;
this.columnWidthsButton.Text = "Save column widths";
this.columnWidthsButton.UseVisualStyleBackColor = true;
this.columnWidthsButton.Click += new System.EventHandler(this.columnWidthsButton_Click);
//
// previousResultsButton
//
this.previousResultsButton.Location = new System.Drawing.Point(252, 10);
this.previousResultsButton.Name = "previousResultsButton";
this.previousResultsButton.Size = new System.Drawing.Size(147, 30);
this.previousResultsButton.TabIndex = 2;
this.previousResultsButton.Text = "Previous results";
this.previousResultsButton.UseVisualStyleBackColor = true;
this.previousResultsButton.Click += new System.EventHandler(this.previousResultsButton_Click);
//
// configureButton
//
this.configureButton.Location = new System.Drawing.Point(20, 10);
this.configureButton.Name = "configureButton";
this.configureButton.Size = new System.Drawing.Size(100, 30);
this.configureButton.TabIndex = 0;
this.configureButton.Text = "Configure";
this.configureButton.UseVisualStyleBackColor = true;
this.configureButton.Click += new System.EventHandler(this.configureButton_Click);
//
// flowLayoutPanel
//
this.flowLayoutPanel.AutoScroll = true;
this.flowLayoutPanel.BackColor = System.Drawing.SystemColors.Control;
this.flowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel.Name = "flowLayoutPanel";
this.flowLayoutPanel.Size = new System.Drawing.Size(1057, 660);
this.flowLayoutPanel.TabIndex = 0;
//
// ResultsTabPageCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Silver;
this.Controls.Add(this.splitContainer);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.Name = "ResultsTabPageCtrl";
this.Size = new System.Drawing.Size(1057, 706);
this.Load += new System.EventHandler(this.ResultsTabPageCtrl_Load);
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
this.splitContainer.ResumeLayout(false);
this.ResumeLayout(false);
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.columnWidthsButton = new System.Windows.Forms.Button();
this.previousResultsButton = new System.Windows.Forms.Button();
this.configureButton = new System.Windows.Forms.Button();
this.batchResultsCtrl = new Results.UiControls.BatchResultsCtrl();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout();
this.SuspendLayout();
//
// splitContainer
//
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer.IsSplitterFixed = true;
this.splitContainer.Location = new System.Drawing.Point(0, 0);
this.splitContainer.Name = "splitContainer";
this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer.Panel1
//
this.splitContainer.Panel1.BackColor = System.Drawing.SystemColors.Control;
this.splitContainer.Panel1.Controls.Add(this.columnWidthsButton);
this.splitContainer.Panel1.Controls.Add(this.previousResultsButton);
this.splitContainer.Panel1.Controls.Add(this.configureButton);
//
// splitContainer.Panel2
//
this.splitContainer.Panel2.Controls.Add(this.batchResultsCtrl);
this.splitContainer.Size = new System.Drawing.Size(1057, 706);
this.splitContainer.SplitterDistance = 42;
this.splitContainer.TabIndex = 0;
//
// columnWidthsButton
//
this.columnWidthsButton.Location = new System.Drawing.Point(126, 10);
this.columnWidthsButton.Name = "columnWidthsButton";
this.columnWidthsButton.Size = new System.Drawing.Size(120, 30);
this.columnWidthsButton.TabIndex = 1;
this.columnWidthsButton.Text = "Save column widths";
this.columnWidthsButton.UseVisualStyleBackColor = true;
this.columnWidthsButton.Click += new System.EventHandler(this.columnWidthsButton_Click);
//
// previousResultsButton
//
this.previousResultsButton.Location = new System.Drawing.Point(252, 10);
this.previousResultsButton.Name = "previousResultsButton";
this.previousResultsButton.Size = new System.Drawing.Size(147, 30);
this.previousResultsButton.TabIndex = 2;
this.previousResultsButton.Text = "Previous results";
this.previousResultsButton.UseVisualStyleBackColor = true;
this.previousResultsButton.Click += new System.EventHandler(this.previousResultsButton_Click);
//
// configureButton
//
this.configureButton.Location = new System.Drawing.Point(20, 10);
this.configureButton.Name = "configureButton";
this.configureButton.Size = new System.Drawing.Size(100, 30);
this.configureButton.TabIndex = 0;
this.configureButton.Text = "Configure";
this.configureButton.UseVisualStyleBackColor = true;
this.configureButton.Click += new System.EventHandler(this.configureButton_Click);
//
// batchResultsCtrl
//
this.batchResultsCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
this.batchResultsCtrl.Location = new System.Drawing.Point(0, 0);
this.batchResultsCtrl.Name = "batchResultsCtrl";
this.batchResultsCtrl.Size = new System.Drawing.Size(1057, 660);
this.batchResultsCtrl.TabIndex = 0;
//
// ResultsTabPageCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Silver;
this.Controls.Add(this.splitContainer);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.Name = "ResultsTabPageCtrl";
this.Size = new System.Drawing.Size(1057, 706);
this.Load += new System.EventHandler(this.ResultsTabPageCtrl_Load);
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
this.splitContainer.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer;
private System.Windows.Forms.Button configureButton;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel;
private System.Windows.Forms.Button configureButton;
private System.Windows.Forms.Button columnWidthsButton;
private System.Windows.Forms.Button previousResultsButton;
private Results.UiControls.BatchResultsCtrl batchResultsCtrl;
}
}

View File

@ -4,14 +4,12 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using log4net;
using Config;
using Config.Entities;
using TBF.Resources;
using TBF.UiBridge;
using Results.UiControls;
namespace TBF.Screens
{
@ -19,24 +17,8 @@ namespace TBF.Screens
{
static readonly ILog log = LogManager.GetLogger(typeof(ResultsTabPageCtrl));
public MetersArrangement MetersArrangement;
public TestsArrangement TestsArrangement;
public int NrMetersInOneGroup;
public IList<Results.ItemSpec> RsltItems_Screen_SingleWM;
public IList<Results.ItemSpec> RsltItems_Screen_CombinedWM;
public IList<Results.ItemSpec> RsltItems_Printer_SingleWM;
public IList<Results.ItemSpec> RsltItems_Printer_CombinedWM;
public IList<Results.ItemSpec> RsltItems_Disk_SingleWM;
public IList<Results.ItemSpec> RsltItems_Disk_CombinedWM;
Procedure procedure;
IList<TestResult> testResults;
bool compound;
ListView firstListView;
int lvWidth;
int lvHeight;
/// <summary>
/// Constructor
@ -68,12 +50,12 @@ namespace TBF.Screens
void OnProcedureSelected(object sender, ProcedureSelectedEventArgs args)
{
RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
batchResultsCtrl.Display(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
}
void OnTestCompleted(object sender, TestCompletedEventArgs args)
{
RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
batchResultsCtrl.Display(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
}
private void ResultsTabPageCtrl_Load(object sender, EventArgs e)
@ -83,15 +65,14 @@ namespace TBF.Screens
columnWidthsButton.Text = Strings.Save_column_widths;
previousResultsButton.Text = Strings.Previous_results;
MetersArrangement = Program.LocalSettings.ResultsConfigMeters;
TestsArrangement = Program.LocalSettings.ResultsConfigTests;
NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup);
RsltItems_Screen_SingleWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
RsltItems_Screen_CombinedWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
RsltItems_Printer_SingleWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM);
RsltItems_Printer_CombinedWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_CombinedWM);
RsltItems_Printer_SingleWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM);
RsltItems_Printer_CombinedWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_CombinedWM);
RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
batchResultsCtrl.MetersArrangement = Program.LocalSettings.ResultsConfigMeters;
batchResultsCtrl.TestsArrangement = Program.LocalSettings.ResultsConfigTests;
batchResultsCtrl.NrMetersInOneGroup = Math.Max(1, Program.LocalSettings.ResultsConfigMetersInOneGroup);
batchResultsCtrl.RsltItems_Screen_SingleWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_SingleWM);
batchResultsCtrl.RsltItems_Screen_CombinedWM = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Screen_CombinedWM);
}
/// <summary>
@ -99,39 +80,40 @@ namespace TBF.Screens
/// </summary>
private void configureButton_Click(object sender, EventArgs e)
{
TBF.Forms.ResultsConfig dlg = new TBF.Forms.ResultsConfig(compound);
TBF.Forms.ResultsConfig dlg = new TBF.Forms.ResultsConfig(batchResultsCtrl.Compound);
dlg.TestsArrangement = TestsArrangement;
dlg.MetersArrangement = MetersArrangement;
dlg.NrMetersInOneGroup = NrMetersInOneGroup;
dlg.TestsArrangement = batchResultsCtrl.TestsArrangement;
dlg.MetersArrangement = batchResultsCtrl.MetersArrangement;
dlg.NrMetersInOneGroup = batchResultsCtrl.NrMetersInOneGroup;
dlg.RsltItems_Screen_SingleWM = RsltItems_Screen_SingleWM;
dlg.RsltItems_Screen_CombinedWM = RsltItems_Screen_CombinedWM;
dlg.RsltItems_Screen_SingleWM = batchResultsCtrl.RsltItems_Screen_SingleWM;
dlg.RsltItems_Screen_CombinedWM = batchResultsCtrl.RsltItems_Screen_CombinedWM;
dlg.RsltItems_Printer_SingleWM = RsltItems_Printer_SingleWM;
dlg.RsltItems_Printer_CombinedWM = RsltItems_Printer_CombinedWM;
if (DialogResult.OK == dlg.ShowDialog())
{
MetersArrangement = dlg.MetersArrangement;
TestsArrangement = dlg.TestsArrangement;
NrMetersInOneGroup = dlg.NrMetersInOneGroup;
batchResultsCtrl.MetersArrangement = dlg.MetersArrangement;
batchResultsCtrl.TestsArrangement = dlg.TestsArrangement;
batchResultsCtrl.NrMetersInOneGroup = dlg.NrMetersInOneGroup;
RsltItems_Screen_SingleWM = dlg.RsltItems_Screen_SingleWM;
RsltItems_Screen_CombinedWM = dlg.RsltItems_Screen_CombinedWM;
batchResultsCtrl.RsltItems_Screen_SingleWM = dlg.RsltItems_Screen_SingleWM;
batchResultsCtrl.RsltItems_Screen_CombinedWM = dlg.RsltItems_Screen_CombinedWM;
RsltItems_Printer_SingleWM = dlg.RsltItems_Printer_SingleWM;
RsltItems_Printer_CombinedWM = dlg.RsltItems_Printer_CombinedWM;
Program.LocalSettings.ResultsConfigMeters = MetersArrangement;
Program.LocalSettings.ResultsConfigTests = TestsArrangement;
Program.LocalSettings.ResultsConfigMetersInOneGroup = NrMetersInOneGroup;
Program.LocalSettings.ResultsConfigMeters = batchResultsCtrl.MetersArrangement;
Program.LocalSettings.ResultsConfigTests = batchResultsCtrl.TestsArrangement;
Program.LocalSettings.ResultsConfigMetersInOneGroup = batchResultsCtrl.NrMetersInOneGroup;
Program.LocalSettings.RsltItems_Screen_SingleWM = Results.ItemSpec.ToStrArray(RsltItems_Screen_SingleWM);
Program.LocalSettings.RsltItems_Screen_CombinedWM = Results.ItemSpec.ToStrArray(RsltItems_Screen_CombinedWM);
Program.LocalSettings.RsltItems_Screen_SingleWM = Results.ItemSpec.ToStrArray(batchResultsCtrl.RsltItems_Screen_SingleWM);
Program.LocalSettings.RsltItems_Screen_CombinedWM = Results.ItemSpec.ToStrArray(batchResultsCtrl.RsltItems_Screen_CombinedWM);
Program.LocalSettings.RsltItems_Printer_SingleWM = Results.ItemSpec.ToStrArray(RsltItems_Printer_SingleWM);
Program.LocalSettings.RsltItems_Printer_CombinedWM = Results.ItemSpec.ToStrArray(RsltItems_Printer_CombinedWM);
Program.LocalSettings.Save();
}
RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
batchResultsCtrl.Redraw();
}
/// <summary>
@ -142,311 +124,15 @@ namespace TBF.Screens
new TBF.Forms.PreviousResultsDlg().ShowDialog();
}
#region Redraw
/// <summary>
/// Re-draw the results. Apply new settings if they changed.
/// </summary>
void RedrawAll(Results.BatchResults results)
private void columnWidthsButton_Click(object sender, EventArgs e)
{
this.SuspendLayout();
try
{
/// Determine how many water meters were enabled for result evaluation and printing
int enabledWMsCount = 0;
for (int i = 0; i < results.WMPositionsCount; i++)
{
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
{
enabledWMsCount++;
}
}
int metersInOneGroup = Math.Max(1, Math.Min(enabledWMsCount, NrMetersInOneGroup));
int nrGroups = Math.Max(1, (enabledWMsCount + NrMetersInOneGroup - 1) / metersInOneGroup);
if (MetersArrangement == MetersArrangement.Horizontally)
{
flowLayoutPanel.FlowDirection = FlowDirection.LeftToRight;
lvWidth = flowLayoutPanel.Width / metersInOneGroup - 6;
lvHeight = flowLayoutPanel.Height / nrGroups - 6;
}
else
{
flowLayoutPanel.FlowDirection = FlowDirection.TopDown;
lvWidth = flowLayoutPanel.Width / nrGroups - 6;
lvHeight = flowLayoutPanel.Height / metersInOneGroup - 6;
}
flowLayoutPanel.Controls.Clear();
flowLayoutPanel.WrapContents = true;
flowLayoutPanel.AutoScroll = true;
bool first = true;
for (int i = 0; i < results.WMPositionsCount; i++)
{
if (results.WaterMeters[i] != null && !results.WaterMeters[i].Disabled)
{
if (TestsArrangement == TestsArrangement.Rows)
{
ListView lview = GetResultsTestsAreRows(results.WaterMeters[i], i + 1);
if (first) { firstListView = lview; first = false; }
if (lview != null) flowLayoutPanel.Controls.Add(lview);
}
else
{
ListView lview = GetResultsTestsAreColumns(results.WaterMeters[i], i + 1);
if (first) { firstListView = lview; first = false; }
if (lview != null) flowLayoutPanel.Controls.Add(lview);
}
}
}
}
catch (Exception e)
{
log.FatalFormat("Redrawing results failed : {0}", e.Message);
if (e.InnerException != null)
{
log.FatalFormat("InnerMessage : {0}", e.InnerException.Message);
}
log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace);
}
this.ResumeLayout(false);
}
/// <summary>
/// Get an empty ListView control with appropriate parameters.
/// </summary>
/// <returns>ListView control</returns>
ListView GetListView()
{
ListView lview = new ListView();
lview.AllowColumnReorder = false;
lview.Dock = System.Windows.Forms.DockStyle.None;
lview.FullRowSelect = true;
lview.GridLines = true;
lview.Location = new System.Drawing.Point(0, 0);
lview.Size = new System.Drawing.Size(lvWidth, lvHeight);
lview.TabIndex = 0;
lview.UseCompatibleStateImageBehavior = false;
lview.View = System.Windows.Forms.View.Details;
return lview;
}
/// <summary>
/// Get decorated test names for a specified watermeter
/// </summary>
/// <param name="wMtr">Watermeter results entity</param>
/// <returns>A list of strings</returns>
IList<string> GetAllDecoratedTestNames(Results.Entities.WaterMeter wMtr)
{
IList<string> testNames = new List<string>();
foreach (var mtr in wMtr.MeterTestRslts)
{
if ( (mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound)
&& mtr.TestDone
&& (mtr.Publish() != Config.Entities.Publish.Never)
&& (mtr.Publish() != Config.Entities.Publish.Internal))
{
testNames.Add(mtr.Name());
}
}
return testNames;
}
/// <summary>
/// Get a ListView control filled with results of the meter 'mtr'
/// </summary>
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
/// <returns>ListView object</returns>
ListView GetResultsTestsAreRows(Results.Entities.WaterMeter wMtr, int printedWMNr)
{
compound = wMtr.Compound();
ListView lview = GetListView();
IList<Results.ItemSpec> items = (compound ? RsltItems_Screen_CombinedWM : RsltItems_Screen_SingleWM);
if (items == null || items.Count == 0) return lview;
// Header
TBF.LocalSettings ls = Program.LocalSettings;
lview.Columns.Add(printedWMNr.ToString(), (ls.RsltsClmnCount > 0) ? ls.RsltsClmnWidths[0] : 40);
int i = 1;
foreach (var item in items)
{
lview.Columns.Add(item.ClmnHeaderText, (ls.RsltsClmnCount > i) ? ls.RsltsClmnWidths[i] : 70);
i++;
}
IList<string> testNames = GetAllDecoratedTestNames(wMtr);
int ix = 0;
foreach (var mtr in wMtr.MeterTestRslts)
{
if ((mtr.CompoundMeterId == (byte)CompoundMeterId.Single || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound)
&& mtr.TestDone
&& (mtr.Publish() != Config.Entities.Publish.Never)
&& (mtr.Publish() != Config.Entities.Publish.Internal))
{
ListViewItem lvi = new ListViewItem(testNames[ix++]);
foreach (var item in items)
{
string str;
if (compound)
{
var main = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
var aux = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
str = (item.CanPrintCombined && main != null && aux != null)
? item.PrintCombined(main, aux, mtr)
: string.Empty;
}
else
{
str = item.CanPrintSingle ? item.Print(mtr) : string.Empty;
}
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
lview.Items.Add(lvi);
}
}
return lview;
}
/// <summary>
/// Get a ListView control filled with results of the meter 'mtr'
/// </summary>
/// <param name="mtr">Water meter number (1-based): 1 .. Config.Data.WMsCount</param>
/// <returns>ListView object</returns>
ListView GetResultsTestsAreColumns(Results.Entities.WaterMeter wMtr, int printedWMNr)
{
compound = wMtr.Compound();
ListView lview = GetListView();
IList<Results.ItemSpec> items = (compound ? RsltItems_Screen_CombinedWM : RsltItems_Screen_SingleWM);
if (items == null || items.Count == 0) return lview;
// Header
TBF.LocalSettings ls = Program.LocalSettings;
lview.Columns.Add(printedWMNr.ToString(), (ls.RsltsClmnCount > 0) ? ls.RsltsClmnWidths[0] : 40);
int i = 1;
foreach (var str in GetAllDecoratedTestNames(wMtr))
{
lview.Columns.Add(str, (ls.RsltsClmnCount > i) ? ls.RsltsClmnWidths[i] : 70);
i++;
}
foreach (var item in items)
{
ListViewItem lvi = new ListViewItem(item.ClmnHeaderText);
if (compound)
{
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr.CompoundMeterId == (byte)CompoundMeterId.Compound && mtr.TestDone
&& (mtr.Publish() != Config.Entities.Publish.Never)
&& (mtr.Publish() != Config.Entities.Publish.Internal))
{
var main = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
var aux = wMtr.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
string str = (item.CanPrintCombined && main != null && aux != null)
? item.PrintCombined(main, aux, mtr)
: string.Empty;
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
}
else
{
foreach (var mtr in wMtr.MeterTestRslts)
{
if (mtr.TestDone && (mtr.Publish() != Config.Entities.Publish.Never)
&& (mtr.Publish() != Config.Entities.Publish.Internal))
{
string str = !item.CanPrintSingle ? string.Empty : item.Print(mtr);
string[] texts = str.Split(new char[] { '|' });
if (texts.Length == 1)
{
lvi.SubItems.Add(str);
}
else if (texts.Length == 2)
{
Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
lvi.UseItemStyleForSubItems = false;
lvi.SubItems.Add(texts[0]);
lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
}
else
{
lvi.SubItems.Add(string.Empty);
}
}
}
}
lview.Items.Add(lvi);
}
return lview;
}
#endregion
private void columnWidthsButton_Click(object sender, EventArgs e)
{
if (firstListView == null) return;
/// Update the column widths
Program.LocalSettings.RsltsClmnWidths = new int[firstListView.Columns.Count];
for (int i = 0; i < firstListView.Columns.Count; i++)
{
Program.LocalSettings.RsltsClmnWidths[i] = firstListView.Columns[i].Width;
}
Program.LocalSettings.Save();
RedrawAll(TBF.BenchControl.Sequences.ProcessData.BatchRslts);
int[] columnWidths = batchResultsCtrl.RsltsClmnWidths;
if (columnWidths != null)
{
Program.LocalSettings.RsltsClmnWidths = columnWidths;
Program.LocalSettings.Save();
batchResultsCtrl.Redraw();
}
}
}
}