ResultsBrowser : UI for printer component OK, ver. 2.18.847

This commit is contained in:
Milan Hanajik 2018-03-19 02:41:20 +01:00
parent 5e50056f4a
commit 9f9883ac3e
14 changed files with 992 additions and 934 deletions

View File

@ -68,10 +68,10 @@ namespace DeviceTest
public DeviceTestDlg()
{
InitializeComponent();
compClasses = new List<string>();
radioButton0.Checked = true;
stopButton.Enabled = false;
compClasses = new List<string>();
foreach (var componentFactory in TbfComponents.Factories)
{
compClasses.Add(componentFactory.ClassName);

View File

@ -27,6 +27,9 @@ namespace ResultsBrowser
public string[] ResultItems;
public string PrinterClass;
public string PrinterCfg;
[XmlArrayAttribute("ResultsClmnWidths")]
public int[] ResultsClmnWidths;
[XmlIgnore]

View File

@ -93,7 +93,7 @@
this.okButton.Location = new System.Drawing.Point(506, 250);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(95, 38);
this.okButton.TabIndex = 16;
this.okButton.TabIndex = 18;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
@ -105,7 +105,7 @@
this.cancelButton.Location = new System.Drawing.Point(617, 250);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(95, 38);
this.cancelButton.TabIndex = 17;
this.cancelButton.TabIndex = 19;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
@ -155,9 +155,9 @@
this.formatLabel.AutoSize = true;
this.formatLabel.Location = new System.Drawing.Point(26, 185);
this.formatLabel.Name = "formatLabel";
this.formatLabel.Size = new System.Drawing.Size(39, 13);
this.formatLabel.Size = new System.Drawing.Size(94, 13);
this.formatLabel.TabIndex = 12;
this.formatLabel.Text = "Format";
this.formatLabel.Text = "Time period format";
//
// timePeriodFormatTextBox
//
@ -222,7 +222,7 @@
this.Controls.Add(this.connectionStringTextBox1);
this.Name = "DatabaseSettingsDlg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Database Settings";
this.Text = "Settings";
this.Load += new System.EventHandler(this.DatabaseSettings_Load);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ResultsBrowser.Resources;
using TBF.BenchControl;
namespace ResultsBrowser.Forms
{

View File

@ -0,0 +1,112 @@
namespace ResultsBrowser.Forms
{
partial class PrinterConfigDlg
{
/// <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.printerClassComboBox = new System.Windows.Forms.ComboBox();
this.changePrinterClassButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.configureButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// printerClassComboBox
//
this.printerClassComboBox.Enabled = false;
this.printerClassComboBox.FormattingEnabled = true;
this.printerClassComboBox.Location = new System.Drawing.Point(12, 29);
this.printerClassComboBox.Name = "printerClassComboBox";
this.printerClassComboBox.Size = new System.Drawing.Size(389, 21);
this.printerClassComboBox.TabIndex = 0;
//
// changePrinterClassButton
//
this.changePrinterClassButton.Location = new System.Drawing.Point(15, 67);
this.changePrinterClassButton.Name = "changePrinterClassButton";
this.changePrinterClassButton.Size = new System.Drawing.Size(161, 43);
this.changePrinterClassButton.TabIndex = 1;
this.changePrinterClassButton.Text = "Change printer type (configuration will be deleted)";
this.changePrinterClassButton.UseVisualStyleBackColor = true;
this.changePrinterClassButton.Click += new System.EventHandler(this.changePrinterClassButton_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Printer type";
//
// configureButton
//
this.configureButton.Location = new System.Drawing.Point(196, 67);
this.configureButton.Name = "configureButton";
this.configureButton.Size = new System.Drawing.Size(95, 43);
this.configureButton.TabIndex = 3;
this.configureButton.Text = "Configure";
this.configureButton.UseVisualStyleBackColor = true;
this.configureButton.Click += new System.EventHandler(this.configureButton_Click);
//
// cancelButton
//
this.cancelButton.Location = new System.Drawing.Point(306, 67);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(95, 43);
this.cancelButton.TabIndex = 4;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// PrinterConfigDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(416, 122);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.configureButton);
this.Controls.Add(this.label1);
this.Controls.Add(this.changePrinterClassButton);
this.Controls.Add(this.printerClassComboBox);
this.Name = "PrinterConfigDlg";
this.Text = "Printer configuration";
this.Load += new System.EventHandler(this.PrinterClassDlg_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox printerClassComboBox;
private System.Windows.Forms.Button changePrinterClassButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button configureButton;
private System.Windows.Forms.Button cancelButton;
}
}

View File

@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using TBF.BenchControl;
using TBF.BenchControl.Generic;
namespace ResultsBrowser.Forms
{
public partial class PrinterConfigDlg : Form
{
public string PrinterClass; /// To be initialized in the constructor
public string PrinterCfg;
IList<IComponentFactory> printerFactories; /// Printer components classes
IComponentFactory printerFactory;
public PrinterConfigDlg()
{
InitializeComponent();
printerFactories = new List<IComponentFactory>();
foreach (var fctry in TbfComponents.Factories)
{
if (fctry.ClassName.Contains("Output.Printers.")) printerFactories.Add(fctry);
}
}
private void PrinterClassDlg_Load(object sender, EventArgs e)
{
printerClassComboBox.Items.Add("---");
foreach (var fctry in printerFactories)
{
printerClassComboBox.Items.Add(fctry.ClassName);
}
printerClassComboBox.Text = string.IsNullOrEmpty(PrinterClass) ? "---" : PrinterClass;
}
private void changePrinterClassButton_Click(object sender, EventArgs e)
{
printerClassComboBox.Enabled = true;
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void configureButton_Click(object sender, EventArgs e)
{
string oriClassName = PrinterClass;
PrinterClass = string.Empty;
if (printerClassComboBox.Text != "---")
{
foreach (var pc in printerFactories)
{
if (printerClassComboBox.Text == pc.ClassName) PrinterClass = pc.ClassName;
}
}
printerFactory = GetFactory(PrinterClass);
if (printerFactory == null)
{
MessageBox.Show("Invalid printer");
return;
}
IComponentCfg printerCfg;
if ((oriClassName != printerFactory.ClassName) || string.IsNullOrEmpty(PrinterCfg))
{
printerCfg = printerFactory.DefaultConfig();
}
else
{
Config.Entities.Component cmpnt = new Config.Entities.Component();
cmpnt.Name = "printer";
cmpnt.ClassName = PrinterClass;
cmpnt.Parameters = PrinterCfg;
printerCfg = printerFactory.CmpntCfgFromCmpntEntity(cmpnt);
}
IComponentCfgCtrl cfgControl = printerCfg.GetControl();
cfgControl.Config = printerCfg;
cfgControl.Config.ItemNr = 0;
TBF.ComponentParametersDlg cfgForm = new TBF.ComponentParametersDlg();
cfgForm.TbfComponents = new List<Config.Entities.Component>();
cfgForm.ComponentCfgCtrl = cfgControl;
cfgForm.UnlockAfterStart = true;
DialogResult dr = cfgForm.ShowDialog();
if (dr != DialogResult.OK) return;
PrinterCfg = (printerCfg != null) ? printerCfg.CreateDbEntity().Parameters : string.Empty;
DialogResult = DialogResult.OK;
Close();
}
/// <summary>
/// Updates component factory
/// </summary>
/// <param name="className">Component class name</param>
/// <param name="factory">Reference to a factory</param>
/// <returns>true when factory changed</returns>
IComponentFactory GetFactory(string className)
{
if (!string.IsNullOrEmpty(className))
{
foreach (var fac in TbfComponents.Factories)
{
if (fac.ClassName == className) return fac;
}
}
return null;
}
}
}

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

@ -1,386 +0,0 @@
///
/// Copyright (c) 2016 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using Config.Entities;
namespace ResultsBrowser.Output.Printers.QueryResults
{
public class QueryResultsPrintDocument : PrintDocument
{
const string FontFamilyName = "Arial"; //"Times New Roman";
const int SpacingOne = 18;
const int SpacingOneAndHalf = (3 * SpacingOne) / 2;
const int TitleX = 240;
const int TitleY = 180; /// Depends on the size of the header
const int FirstLineNr = 14; /// Depends on the size of the header
const int Tab1 = 80; /// Positions of columns above the table
const int Tab2 = 240;
const int Tab3 = 430;
const int Tab4 = 590;
const int BorderW = 1; /// Table border line width
const int MarginTop = 7; /// Margins of the text from table lines
const int MarginLeft = 4; /// Margins of the text from table lines
///
/// Data to print
///
readonly string docVersion;
readonly Results.Entities.WaterMeter wm;
string zaehlertyp;
string pruefvorlage;
readonly IList<Results.Entities.MeterTestRslt> results;
readonly int resultsCount;
readonly bool compound; /// true when MetersKind is MetersKind.Combined
readonly int secondTableOffset; /// Calculated in the constructor
/// Top coordinate of the table
int top;
/// <summary>
/// Property variable for the Font the user wishes to use
/// </summary>
Font font;
Font boldFont;
Font fontTitle;
/// <summary>
/// Constructor
/// </summary>
/// <param name="textToPrint">Text to be printed</param>
public QueryResultsPrintDocument(string docVersion,
Results.Entities.WaterMeter wm,
PageOrientation pageOrientation)
{
this.docVersion = docVersion;
this.wm = wm;
compound = wm.Compound();
string[] info = wm.ProductName().Split(new char[] { ';' });
if (info.Length >= 2)
{
pruefvorlage = info[0];
zaehlertyp = info[1];
}
else if (info.Length == 1)
{
pruefvorlage = info[0];
zaehlertyp = compound ? "Verbundzähler" : "Einzelzähler";
}
else
{
pruefvorlage = wm.ProcedureName();
zaehlertyp = compound ? "Verbundzähler" : "Einzelzähler";
}
results = wm.MeterTestRslts;
this.resultsCount = compound ? (results.Count / 3) : results.Count;
int resultsCount = wm.MeterTestRslts.Count;
if (compound) resultsCount /= 3;
secondTableOffset = (resultsCount + 2) * SpacingOneAndHalf;
DefaultPageSettings.Landscape = (pageOrientation == PageOrientation.Landscape);
}
/// <summary>
/// Override the default onbeginPrint method of the PrintDocument Object.
/// </summary>
/// <param name=e></param>
/// <remarks></remarks>
protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
{
base.OnBeginPrint(e);
if (font == null) { font = new Font(FontFamilyName, 10, FontStyle.Regular); }
if (boldFont == null) { boldFont = new Font(FontFamilyName, 10, FontStyle.Bold); }
if (fontTitle == null) { fontTitle = new Font(FontFamilyName, 24, FontStyle.Bold); }
}
/// <summary>
/// Override the default OnPrintPage method of the PrintDocument.
/// </summary>
/// <param name=e></param>
/// <remarks>This provides the print logic for our document</remarks>
protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
{
// Run base code
base.OnPrintPage(e);
/// Set print area size and margins (in dots using 80 dpi)
int printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
int printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
int leftMargin = base.DefaultPageSettings.Margins.Left; /// X
int topMargin = base.DefaultPageSettings.Margins.Top; /// Y
/// Check if the user selected to print in Landscape mode
/// if they did then we need to swap height/width parameters
if (base.DefaultPageSettings.Landscape)
{
int tmp = printHeight;
printHeight = printWidth;
printWidth = tmp;
}
int x = leftMargin;
int y = topMargin;
/// Use the StringFormat class for the text layout of our document
StringFormat format = new StringFormat(StringFormatFlags.LineLimit);
RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 50);
e.Graphics.DrawString(wm.Batch.ProtocolTitle, this.fontTitle, Brushes.Black, printArea);
int lineNr = FirstLineNr;
PrintAt(e, Tab1, lineNr * SpacingOne, docVersion);
lineNr++;
PrintBoldAt(e, Tab1, lineNr * SpacingOne, "Prüfstand Nr :");
PrintBoldAt(e, Tab2, lineNr * SpacingOne, wm.BenchId().ToString());
PrintBoldAt(e, Tab3, lineNr * SpacingOne, "Datum :");
PrintBoldAt(e, Tab4, lineNr * SpacingOne, wm.Batch.EndTime.Date.ToString("d"));
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Zählertyp :");
PrintAt(e, Tab2, lineNr * SpacingOne, zaehlertyp);
PrintAt(e, Tab3, lineNr * SpacingOne, "Eichjahr :");
PrintAt(e, Tab4, lineNr * SpacingOne, wm.YearOfProduction.ToString());
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Prüfvorlage :");
PrintAt(e, Tab2, lineNr * SpacingOne, pruefvorlage);
lineNr += 2;
if (compound)
{
PrintBoldAt(e, Tab1, lineNr * SpacingOne, "Hauptzahler");
PrintBoldAt(e, Tab3, lineNr * SpacingOne, "Nebenzahler");
lineNr++;
}
PrintAt(e, Tab1, lineNr * SpacingOne, "Hersteller :");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Producer());
if (compound)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Hersteller :");
PrintAt(e, Tab4, lineNr * SpacingOne, wm.ProducerAux());
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Seriennummer :");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.SerialNr);
if (compound)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Seriennummer :");
PrintAt(e, Tab4, lineNr * SpacingOne, wm.SerialNrAux);
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Qn :");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Q3_Qn().ToString());
if (compound)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Qn :");
PrintAt(e, Tab4, lineNr * SpacingOne, wm.Q3_Qn_Aux().ToString());
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Zulassungszeichen :");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.ApprovalInfo());
if (compound)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Zulassungszeichen :");
PrintAt(e, Tab4, lineNr * SpacingOne, wm.ApprovalInfoAux());
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Metr. klasse :");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.MetrologicalClass());
if (compound)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Metr. klasse :");
PrintAt(e, Tab4, lineNr * SpacingOne, wm.MetrologicalClassAux());
}
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Stand :");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.EndState);
if (compound)
{
PrintAt(e, Tab3, lineNr * SpacingOne, "Stand :");
PrintAt(e, Tab4, lineNr * SpacingOne, wm.EndStateAux);
lineNr += 2;
PrintAt(e, Tab1, lineNr * SpacingOne, "Umschaltpunkte :");
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Qsteig");
PrintAt(e, Tab2, lineNr * SpacingOne, (1000.0 * wm.QRise).ToString("F1") + " l/h");
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Qfall");
PrintAt(e, Tab2, lineNr * SpacingOne, (1000.0 * wm.QFall).ToString("F1") + " l/h");
}
lineNr += 2;
top = SpacingOne * lineNr;
PrintTable(e);
DrawTable(e);
lineNr += (secondTableOffset * 2) / SpacingOne;
PrintAt(e, Tab1, lineNr * SpacingOne, "Temperatur");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Batch.AmbTempMean().ToString("F1") + " \x00b0C");
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Feuchtigkeit");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Batch.AmbHumiMean().ToString("F0") + " %");
lineNr++;
PrintAt(e, Tab1, lineNr * SpacingOne, "Luftdruck");
PrintAt(e, Tab2, lineNr * SpacingOne, wm.Batch.AmbPressMean().ToString("F0") + " mbar");
lineNr++;
PrintAt(e, Tab3, lineNr * SpacingOne, wm.Batch.EndTime.Date.ToString("d"));
lineNr ++;
PrintAt(e, Tab3, lineNr * SpacingOne, "Datum");
PrintAt(e, Tab4, lineNr * SpacingOne, "Unterschrift");
}
/// <summary>
/// Print table texts.
/// </summary>
void PrintTable(System.Drawing.Printing.PrintPageEventArgs e)
{
PrintAt(e, FromTest(-1, -1), "Prüflauf");
PrintAt(e, FromTest(-1, 0), "Q [l/h]");
PrintAt(e, FromTest(-1, 1), "Prüf-Vol.[l]");
PrintAt(e, FromTest(-1, 2), compound ? "HZ-Vol.[l]" : "Z-Vol.[l]");
PrintAt(e, FromTest(-1, 3), compound ? "NZ-Vol.[l]" : "-");
PrintAt(e, FromTest(-1, 4), "Fehler [%]");
PrintAt(e, FromTest(-1, 5), "Ergebnis");
PrintAt(e, FromTest(-1, 6), "Q [l/h]");
PrintAt(e, FromTest(-1, 7), "Temperatur");
PrintAt(e, FromTest(-1, 8), "Dichte");
PrintAt(e, FromTest(-1, 9), "Prüfzeit");
PrintAt(e, FromTest(-1, 10), "Druck Eing.");
PrintAt(e, FromTest(-1, 11), "Druck Ausg.");
int rowCnt = 0;
foreach (var mtr in wm.MeterTestRslts)
{
if (!compound || mtr.CompoundMeterId == (byte)CompoundMeterId.Compound)
{
Point p = FromTest(rowCnt, -1);
PrintAt(e, p.X, p.Y, mtr.Name());
PrintAt(e, p.X, p.Y + (resultsCount + 2) * SpacingOneAndHalf, mtr.Name());
PrintAt(e, FromTest(rowCnt, 0), mtr.TestRslt.FlowMass.ToString("F1"));
PrintAt(e, FromTest(rowCnt, 1), mtr.TestRslt.VolumeCTV.ToString("F2"));
if (compound)
{
Results.Entities.MeterTestRslt mainMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundMain);
Results.Entities.MeterTestRslt auxMtr = wm.GetMeterTestRslt(mtr.Name(), CompoundMeterId.CompoundAux);
PrintAt(e, FromTest(rowCnt, 2), mainMtr.VolumeMeter.ToString("F2"));
PrintAt(e, FromTest(rowCnt, 3), auxMtr.VolumeMeter.ToString("F2"));
PrintAt(e, FromTest(rowCnt, 4), mtr.Error.ToString("F2"));
PrintAt(e, FromTest(rowCnt, 5), mtr.Passed ? "iO" : "NiO");
}
else
{
PrintAt(e, FromTest(rowCnt, 2), mtr.VolumeMeter.ToString("F2"));
PrintAt(e, FromTest(rowCnt, 3), "-");
PrintAt(e, FromTest(rowCnt, 4), mtr.Error.ToString("F2"));
PrintAt(e, FromTest(rowCnt, 5), mtr.Passed ? "iO" : "NiO");
}
PrintAt(e, FromTest(rowCnt, 6), mtr.TestRslt.FlowMass.ToString("F1"));
PrintAt(e, FromTest(rowCnt, 7), mtr.TestRslt.TempDownMean.ToString("F2"));
PrintAt(e, FromTest(rowCnt, 8), mtr.TestRslt.DensityDiv.ToString("F2"));
PrintAt(e, FromTest(rowCnt, 9), mtr.TestTime.ToString("F1"));
PrintAt(e, FromTest(rowCnt, 10), Config.Units.ConvertTo(Config.Unit.bar, mtr.TestRslt.PressUpMean).ToString("F3"));
PrintAt(e, FromTest(rowCnt, 11), Config.Units.ConvertTo(Config.Unit.bar, mtr.TestRslt.PressDownMean).ToString("F3"));
rowCnt++;
}
}
}
/// <summary>
/// Draw table lines.
/// </summary>
void DrawTable(System.Drawing.Printing.PrintPageEventArgs e)
{
int mid = top + SpacingOneAndHalf;
int bot = top + (resultsCount + 1) * SpacingOneAndHalf;
int top2 = top + secondTableOffset;
int mid2 = mid + secondTableOffset;
int bot2 = bot + secondTableOffset;
// Horizontal lines
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, top), new Point(747, top));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, mid), new Point(747, mid));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, bot), new Point(747, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, top2), new Point(747, top2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, mid2), new Point(747, mid2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(80, bot2), new Point(747, bot2));
// Vertical lines
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point( 80, top), new Point( 80, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(267, top), new Point(267, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(347, top), new Point(347, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(427, top), new Point(427, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(507, top), new Point(507, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(587, top), new Point(587, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(667, top), new Point(667, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(747, top), new Point(747, bot));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point( 80, top2), new Point( 80, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(267, top2), new Point(267, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(347, top2), new Point(347, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(427, top2), new Point(427, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(507, top2), new Point(507, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(587, top2), new Point(587, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(667, top2), new Point(667, bot2));
e.Graphics.DrawLine(new Pen(Color.Black, BorderW), new Point(747, top2), new Point(747, bot2));
}
void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string text)
{
PrintAt(e, p.X, p.Y, text);
}
void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text)
{
RectangleF printArea = new RectangleF(x, y, 667, SpacingOne);
e.Graphics.DrawString(text, this.font, Brushes.Black, printArea);
}
void PrintBoldAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string text)
{
PrintBoldAt(e, p.X, p.Y, text);
}
void PrintBoldAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string text)
{
RectangleF printArea = new RectangleF(x, y, 667, SpacingOne);
e.Graphics.DrawString(text, this.boldFont, Brushes.Black, printArea);
}
Point FromTest(int testNr, int parNr)
{
const int NrParamsInOneTableRow = 6;
int x = 267 + (parNr % NrParamsInOneTableRow) * 80 + MarginLeft;
int y = top + SpacingOneAndHalf + MarginTop + testNr * SpacingOneAndHalf
+ ((parNr >= NrParamsInOneTableRow) ? secondTableOffset : 0);
if (parNr < 0) x = 80 + MarginLeft; /// When parNr == -1 return the left column x coordinate
return new Point(x, y);
}
}
}

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.18.844.0")]
[assembly: AssemblyFileVersion("2.18.844.0")]
[assembly: AssemblyVersion("2.18.847.0")]
[assembly: AssemblyFileVersion("2.18.847.0")]

View File

@ -706,7 +706,7 @@
<value>Filters</value>
</data>
<data name="Format_of_results" xml:space="preserve">
<value>Format of results</value>
<value>Configure output</value>
</data>
<data name="Load_filters" xml:space="preserve">
<value>Load filters</value>
@ -810,4 +810,7 @@
<data name="Print" xml:space="preserve">
<value>Print</value>
</data>
<data name="Configure_printer" xml:space="preserve">
<value>Configure printer</value>
</data>
</root>

View File

@ -555,6 +555,15 @@ namespace ResultsBrowser.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Configure printer.
/// </summary>
internal static string Configure_printer {
get {
return ResourceManager.GetString("Configure_printer", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Configure test benches (password required).
/// </summary>
@ -1186,7 +1195,7 @@ namespace ResultsBrowser.Resources {
}
/// <summary>
/// Looks up a localized string similar to Format of results.
/// Looks up a localized string similar to Configure output.
/// </summary>
internal static string Format_of_results {
get {

View File

@ -125,6 +125,12 @@
<Compile Include="Forms\NoBenchOrDatabaseDlg.designer.cs">
<DependentUpon>NoBenchOrDatabaseDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\PrinterConfigDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\PrinterConfigDlg.Designer.cs">
<DependentUpon>PrinterConfigDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\StatisticsDlg.cs">
<SubType>Form</SubType>
</Compile>
@ -138,9 +144,6 @@
<DependentUpon>StatisticsOptionsDlg.cs</DependentUpon>
</Compile>
<Compile Include="LocalSettings.cs" />
<Compile Include="Output\Printers\QueryResults\QueryResultsPrintDocument.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Output\Printers\Statistics\StatisticsPrintDocument.cs">
<SubType>Component</SubType>
</Compile>
@ -182,6 +185,9 @@
<EmbeddedResource Include="Forms\NoBenchOrDatabaseDlg.resx">
<DependentUpon>NoBenchOrDatabaseDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\PrinterConfigDlg.resx">
<DependentUpon>PrinterConfigDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\StatisticsDlg.resx">
<DependentUpon>StatisticsDlg.cs</DependentUpon>
</EmbeddedResource>
@ -230,6 +236,10 @@
<Project>{9D0DCC88-DC81-47EB-9FDD-4C3907871BFB}</Project>
<Name>Results</Name>
</ProjectReference>
<ProjectReference Include="..\TBF\TBF.csproj">
<Project>{8648FD92-CDA1-4C3A-B5F9-FE547CE1FA48}</Project>
<Name>TBF</Name>
</ProjectReference>
<ProjectReference Include="..\Users\Users.csproj">
<Project>{6E5CB0E9-E1B6-4E5D-AC6E-B1049E180F2B}</Project>
<Name>Users</Name>

View File

@ -34,6 +34,7 @@
this.filtersFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.resultsGroupBox = new System.Windows.Forms.GroupBox();
this.resultsListView = new System.Windows.Forms.ListView();
this.printerConfigBtn = new System.Windows.Forms.Button();
this.statisticsBtn = new System.Windows.Forms.Button();
this.printQueryResultsBtn = new System.Windows.Forms.Button();
this.exportQueryResultsBtn = new System.Windows.Forms.Button();
@ -77,6 +78,7 @@
//
// vSplitContainer.Panel2
//
this.vSplitContainer.Panel2.Controls.Add(this.printerConfigBtn);
this.vSplitContainer.Panel2.Controls.Add(this.statisticsBtn);
this.vSplitContainer.Panel2.Controls.Add(this.printQueryResultsBtn);
this.vSplitContainer.Panel2.Controls.Add(this.exportQueryResultsBtn);
@ -151,11 +153,21 @@
this.resultsListView.UseCompatibleStateImageBehavior = false;
this.resultsListView.View = System.Windows.Forms.View.Details;
//
// printerConfigBtn
//
this.printerConfigBtn.Location = new System.Drawing.Point(8, 316);
this.printerConfigBtn.Name = "printerConfigBtn";
this.printerConfigBtn.Size = new System.Drawing.Size(125, 35);
this.printerConfigBtn.TabIndex = 11;
this.printerConfigBtn.Text = "Configure printer";
this.printerConfigBtn.UseVisualStyleBackColor = true;
this.printerConfigBtn.Click += new System.EventHandler(this.printerConfigBtn_Click);
//
// statisticsBtn
//
this.statisticsBtn.Location = new System.Drawing.Point(8, 581);
this.statisticsBtn.Location = new System.Drawing.Point(8, 621);
this.statisticsBtn.Name = "statisticsBtn";
this.statisticsBtn.Size = new System.Drawing.Size(125, 33);
this.statisticsBtn.Size = new System.Drawing.Size(125, 35);
this.statisticsBtn.TabIndex = 10;
this.statisticsBtn.Text = "Statistics";
this.statisticsBtn.UseVisualStyleBackColor = true;
@ -163,9 +175,9 @@
//
// printQueryResultsBtn
//
this.printQueryResultsBtn.Location = new System.Drawing.Point(8, 506);
this.printQueryResultsBtn.Location = new System.Drawing.Point(8, 548);
this.printQueryResultsBtn.Name = "printQueryResultsBtn";
this.printQueryResultsBtn.Size = new System.Drawing.Size(125, 33);
this.printQueryResultsBtn.Size = new System.Drawing.Size(125, 35);
this.printQueryResultsBtn.TabIndex = 9;
this.printQueryResultsBtn.Text = "Print query results";
this.printQueryResultsBtn.UseVisualStyleBackColor = true;
@ -173,9 +185,9 @@
//
// exportQueryResultsBtn
//
this.exportQueryResultsBtn.Location = new System.Drawing.Point(8, 467);
this.exportQueryResultsBtn.Location = new System.Drawing.Point(8, 508);
this.exportQueryResultsBtn.Name = "exportQueryResultsBtn";
this.exportQueryResultsBtn.Size = new System.Drawing.Size(125, 33);
this.exportQueryResultsBtn.Size = new System.Drawing.Size(125, 35);
this.exportQueryResultsBtn.TabIndex = 8;
this.exportQueryResultsBtn.Text = "Export query results";
this.exportQueryResultsBtn.UseVisualStyleBackColor = true;
@ -183,11 +195,11 @@
//
// formatOfResultsBtn
//
this.formatOfResultsBtn.Location = new System.Drawing.Point(8, 274);
this.formatOfResultsBtn.Location = new System.Drawing.Point(8, 276);
this.formatOfResultsBtn.Name = "formatOfResultsBtn";
this.formatOfResultsBtn.Size = new System.Drawing.Size(125, 33);
this.formatOfResultsBtn.Size = new System.Drawing.Size(125, 35);
this.formatOfResultsBtn.TabIndex = 7;
this.formatOfResultsBtn.Text = "Format of results";
this.formatOfResultsBtn.Text = "Configure output";
this.formatOfResultsBtn.UseVisualStyleBackColor = true;
this.formatOfResultsBtn.Click += new System.EventHandler(this.formatOfResultsBtn_Click);
//
@ -195,7 +207,7 @@
//
this.clearFiltersBtn.Location = new System.Drawing.Point(8, 196);
this.clearFiltersBtn.Name = "clearFiltersBtn";
this.clearFiltersBtn.Size = new System.Drawing.Size(125, 33);
this.clearFiltersBtn.Size = new System.Drawing.Size(125, 35);
this.clearFiltersBtn.TabIndex = 2;
this.clearFiltersBtn.Text = "Clear filters";
this.clearFiltersBtn.UseVisualStyleBackColor = true;
@ -213,9 +225,9 @@
//
// saveConfigBtn
//
this.saveConfigBtn.Location = new System.Drawing.Point(8, 313);
this.saveConfigBtn.Location = new System.Drawing.Point(8, 356);
this.saveConfigBtn.Name = "saveConfigBtn";
this.saveConfigBtn.Size = new System.Drawing.Size(125, 33);
this.saveConfigBtn.Size = new System.Drawing.Size(125, 35);
this.saveConfigBtn.TabIndex = 5;
this.saveConfigBtn.Text = "Save configuration";
this.saveConfigBtn.UseVisualStyleBackColor = true;
@ -223,9 +235,9 @@
//
// loadConfigBtn
//
this.loadConfigBtn.Location = new System.Drawing.Point(8, 352);
this.loadConfigBtn.Location = new System.Drawing.Point(8, 396);
this.loadConfigBtn.Name = "loadConfigBtn";
this.loadConfigBtn.Size = new System.Drawing.Size(125, 33);
this.loadConfigBtn.Size = new System.Drawing.Size(125, 35);
this.loadConfigBtn.TabIndex = 4;
this.loadConfigBtn.Text = "Load configuration";
this.loadConfigBtn.UseVisualStyleBackColor = true;
@ -233,9 +245,9 @@
//
// executeQueryBtn
//
this.executeQueryBtn.Location = new System.Drawing.Point(8, 428);
this.executeQueryBtn.Location = new System.Drawing.Point(8, 468);
this.executeQueryBtn.Name = "executeQueryBtn";
this.executeQueryBtn.Size = new System.Drawing.Size(125, 33);
this.executeQueryBtn.Size = new System.Drawing.Size(125, 35);
this.executeQueryBtn.TabIndex = 6;
this.executeQueryBtn.Text = "Execute query";
this.executeQueryBtn.UseVisualStyleBackColor = true;
@ -243,9 +255,9 @@
//
// addFilterBtn
//
this.addFilterBtn.Location = new System.Drawing.Point(8, 235);
this.addFilterBtn.Location = new System.Drawing.Point(8, 236);
this.addFilterBtn.Name = "addFilterBtn";
this.addFilterBtn.Size = new System.Drawing.Size(125, 33);
this.addFilterBtn.Size = new System.Drawing.Size(125, 35);
this.addFilterBtn.TabIndex = 3;
this.addFilterBtn.Text = "Add filter";
this.addFilterBtn.UseVisualStyleBackColor = true;
@ -374,5 +386,6 @@
private System.Windows.Forms.ListView resultsListView;
private System.Windows.Forms.RadioButton checkBox5;
private System.Windows.Forms.RadioButton checkBox4;
private System.Windows.Forms.Button printerConfigBtn;
}
}

View File

@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using NHibernate;
using Results.Entities;
using TBF.BenchControl;
using TBF.BenchControl.Generic;
using ResultsBrowser.Filters;
using ResultsBrowser.Resources;
using System.IO;
namespace ResultsBrowser
{
@ -13,7 +15,7 @@ namespace ResultsBrowser
{
const string OpenFileDlg_SaveFileDlg_Filter = "{0} (*.qry)|*.qry|{1} (*.*)|*.*";
string[] args;
string[] args; /// Comand line argument
IList<Filters.IFilter> filters; /// Filters and the UI of filters
FiltersConfig filtersConfig; /// Serializable configuration of filters and displayed results
@ -26,6 +28,7 @@ namespace ResultsBrowser
public ResultsBrowserWnd(string[] args)
{
InitializeComponent();
filters = new List<Filters.IFilter>();
filtersConfig = new FiltersConfig();
this.args = args;
@ -95,14 +98,18 @@ namespace ResultsBrowser
resultsGroupBox.Text = Strings.Query_results;
settingsBtn.Text = Strings.Settings;
testBenchesGroupBox.Text = Strings.Test_benches;
clearFiltersBtn.Text = Strings.Clear_filters;
addFilterBtn.Text = Strings.Add_filter;
formatOfResultsBtn.Text = Strings.Format_of_results;
printerConfigBtn.Text = Strings.Configure_printer;
loadConfigBtn.Text = Strings.Load_filters;
saveConfigBtn.Text = Strings.Save_filters;
executeQueryBtn.Text = Strings.Execute_query;
formatOfResultsBtn.Text = Strings.Format_of_results;
exportQueryResultsBtn.Text = Strings.Export_query_results;
printQueryResultsBtn.Text = Strings.Print_query_results;
statisticsBtn.Text = Strings.Statistics;
}
@ -147,6 +154,34 @@ namespace ResultsBrowser
}
}
private void formatOfResultsBtn_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg();
dlg.MetersKind = Config.Entities.MetersKind.Single;
dlg.SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(filtersConfig.ResultItems);
if (dlg.ShowDialog() == DialogResult.OK)
{
filtersConfig.ResultItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
RedrawResults();
}
}
private void printerConfigBtn_Click(object sender, EventArgs e)
{
Forms.PrinterConfigDlg dlg = new Forms.PrinterConfigDlg
{
PrinterClass = filtersConfig.PrinterClass,
PrinterCfg = filtersConfig.PrinterCfg
};
if (dlg.ShowDialog() == DialogResult.OK)
{
filtersConfig.PrinterClass = dlg.PrinterClass;
filtersConfig.PrinterCfg = dlg.PrinterCfg;
}
}
private void loadConfigBtn_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
@ -295,19 +330,6 @@ namespace ResultsBrowser
}
}
private void formatOfResultsBtn_Click(object sender, EventArgs e)
{
Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg();
dlg.MetersKind = Config.Entities.MetersKind.Single;
dlg.SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(filtersConfig.ResultItems);
if (dlg.ShowDialog() == DialogResult.OK)
{
filtersConfig.ResultItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
RedrawResults();
}
}
private void exportQueryResultsBtn_Click(object sender, EventArgs e)
{
IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.FromStrArray(filtersConfig.ResultItems);
@ -382,6 +404,11 @@ namespace ResultsBrowser
"PT40 Z/E-35-A",
"0111-OOP-C035-13").Print();
}
#else
foreach (var wm in waterMeters)
{
new Results.Output.Printers.Munich.MunichPrintDocument(string.Format("4/13 - {0}", BenchName()), wm, Config.Entities.PageOrientation.Portrait).Print();
}
#endif
}
@ -408,5 +435,24 @@ namespace ResultsBrowser
timePeriodStart, timePeriodEnd);
statisticsDlg.ShowDialog();
}
/// <summary>
/// Updates component factory
/// </summary>
/// <param name="className">Component class name</param>
/// <param name="factory">Reference to a factory</param>
/// <returns>true when factory changed</returns>
IComponentFactory GetFactory(string className)
{
if (!string.IsNullOrEmpty(className))
{
foreach (var fac in TbfComponents.Factories)
{
if (fac.ClassName == className) return fac;
}
}
return null;
}
}
}