Printing from PreviousResultsDlg, ver. 2.32.2027

This commit is contained in:
Milan Hanajik 2023-03-10 10:32:45 +01:00
parent c8a5640ddc
commit f0e57554f2
19 changed files with 428 additions and 41 deletions

View File

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

View File

@ -3823,11 +3823,11 @@ namespace TBF.Resources {
}
/// <summary>
/// Looks up a localized string similar to Print again.
/// Looks up a localized string similar to Print.
/// </summary>
internal static string Print_again {
internal static string Print {
get {
return ResourceManager.GetString("Print_again", resourceCulture);
return ResourceManager.GetString("Print", resourceCulture);
}
}
@ -3885,6 +3885,15 @@ namespace TBF.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Printer selection.
/// </summary>
internal static string Printer_selection {
get {
return ResourceManager.GetString("Printer_selection", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Printer.
/// </summary>

View File

@ -1683,4 +1683,10 @@
<data name="Test_0_config_error_1_is_missing" xml:space="preserve">
<value>Konfigurace testu {0} : chybí {1}</value>
</data>
<data name="Print" xml:space="preserve">
<value>Vytisknout</value>
</data>
<data name="Printer_selection" xml:space="preserve">
<value>Výběr tiskárny</value>
</data>
</root>

View File

@ -1278,8 +1278,8 @@
<data name="Volume" xml:space="preserve">
<value>Volumen</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>Druck wiederholen</value>
<data name="Print" xml:space="preserve">
<value>Drucken</value>
</data>
<data name="Show" xml:space="preserve">
<value>Anzeigen</value>

View File

@ -2010,4 +2010,7 @@
<data name="Fill" xml:space="preserve">
<value>Inonder</value>
</data>
<data name="Print" xml:space="preserve">
<value>Imprimer</value>
</data>
</root>

View File

@ -1533,9 +1533,6 @@
<data name="P_delta" xml:space="preserve">
<value>P delta</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>stampa ancora</value>
</data>
<data name="Show" xml:space="preserve">
<value>mostrare</value>
</data>
@ -1779,4 +1776,7 @@
<data name="Start_cycle" xml:space="preserve">
<value>Avviare il ciclo</value>
</data>
<data name="Print" xml:space="preserve">
<value>Stampa</value>
</data>
</root>

View File

@ -1543,9 +1543,6 @@
<data name="P_delta" xml:space="preserve">
<value>P delta</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>Wydrukuj jeszcze raz</value>
</data>
<data name="Show" xml:space="preserve">
<value>Pokaż</value>
</data>
@ -1627,4 +1624,7 @@
<data name="Start_cycle" xml:space="preserve">
<value>Start cyklu</value>
</data>
<data name="Print" xml:space="preserve">
<value>Wydruk</value>
</data>
</root>

View File

@ -1531,8 +1531,8 @@
<data name="P_delta" xml:space="preserve">
<value>P delta</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>Print again</value>
<data name="Print" xml:space="preserve">
<value>Print</value>
</data>
<data name="Show" xml:space="preserve">
<value>Show</value>
@ -2320,4 +2320,7 @@
<data name="no_profile" xml:space="preserve">
<value>no profile</value>
</data>
<data name="Printer_selection" xml:space="preserve">
<value>Printer selection</value>
</data>
</root>

View File

@ -831,4 +831,7 @@
<data name="Evaporation" xml:space="preserve">
<value>Evaporare</value>
</data>
<data name="Print" xml:space="preserve">
<value>Imprimanta</value>
</data>
</root>

View File

@ -1518,9 +1518,6 @@
<data name="P_delta" xml:space="preserve">
<value>P дельта</value>
</data>
<data name="Print_again" xml:space="preserve">
<value>Печатать снова</value>
</data>
<data name="Show" xml:space="preserve">
<value>Показать</value>
</data>
@ -1599,4 +1596,7 @@
<data name="Evaporation" xml:space="preserve">
<value>испарение</value>
</data>
<data name="Print" xml:space="preserve">
<value>Печатать</value>
</data>
</root>

View File

@ -1191,4 +1191,7 @@
<data name="Evaporation" xml:space="preserve">
<value>蒸发</value>
</data>
<data name="Print" xml:space="preserve">
<value>打印机</value>
</data>
</root>

View File

@ -2611,6 +2611,12 @@
<Compile Include="UI\ResultsMI\PreviousResultsDlg.designer.cs">
<DependentUpon>PreviousResultsDlg.cs</DependentUpon>
</Compile>
<Compile Include="UI\ResultsMI\PrintResultsSelectionDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\ResultsMI\PrintResultsSelectionDlg.Designer.cs">
<DependentUpon>PrintResultsSelectionDlg.cs</DependentUpon>
</Compile>
<Compile Include="UI\ResultsMI\ResultsArrangementDlg.cs">
<SubType>Form</SubType>
</Compile>
@ -3591,6 +3597,9 @@
<EmbeddedResource Include="UI\ResultsMI\PreviousResultsDlg.resx">
<DependentUpon>PreviousResultsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\ResultsMI\PrintResultsSelectionDlg.resx">
<DependentUpon>PrintResultsSelectionDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\ResultsMI\ResultsArrangementDlg.resx">
<DependentUpon>ResultsArrangementDlg.cs</DependentUpon>
</EmbeddedResource>

View File

@ -278,7 +278,7 @@
<value>62, 20</value>
</data>
<data name="proceduresToolStripMenuItem.Text" xml:space="preserve">
<value>Postupy</value>
<value>Procedury</value>
</data>
<data name="processToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>54, 20</value>

View File

@ -62,6 +62,7 @@
this.sentCheckBox.TabIndex = 14;
this.sentCheckBox.Text = "Sent";
this.sentCheckBox.UseVisualStyleBackColor = true;
this.sentCheckBox.Visible = false;
//
// failedCountLabel
//

View File

@ -13,7 +13,8 @@ namespace TBF.UI.ResultsMI
{
readonly PreviousResultsDlg parent;
readonly PreviousResultsMode mode;
readonly bool sendBtnIsPrint;
public int BatchNr;
public DateTime StarTime;
public DateTime EndTime;
@ -58,27 +59,39 @@ namespace TBF.UI.ResultsMI
passedCountLabel.Text = string.Format("{0}: {1}", Strings.Passed, PassedCount);
failedCountLabel.Text = string.Format("{0}: {1}", Strings.Failed, FailedCount);
switch (mode)
{
case PreviousResultsMode.Show: sendReloadButton.Text = Strings.Save_again; break;
case PreviousResultsMode.Reload: sendReloadButton.Text = Strings.Restore; break;
case PreviousResultsMode.Fix: sendReloadButton.Text = Strings.Fix; break;
}
showButton.Text = Strings.Show;
#if MUNICH
if (mode == PreviousResultsMode.Show) sendReloadButton.Text = Strings.Print_again;
sentCheckBox.Text = Strings.Printed;
sentCheckBox.Checked = Sent;
sendReloadButton.Enabled = true; /// 'Print again' function always available
#elif ORACLE_DB
/// 'Sent' check box
#if ORACLE_DB
sentCheckBox.Visible = (mode == PreviousResultsMode.Show);
sentCheckBox.Text = Strings.Sent;
sentCheckBox.Checked = Sent;
sendReloadButton.Enabled = (mode != PreviousResultsMode.Show) || !Sent;
#else
sentCheckBox.Visible = false;
sendReloadButton.Enabled = (mode != PreviousResultsMode.Show);
sendReloadButton.Visible = (mode != PreviousResultsMode.Show);
#endif
/// 'Send again'/'Print' button
sendBtnIsPrint = false;
switch (mode)
{
case PreviousResultsMode.Show:
#if ORACLE_DB
sendReloadButton.Enabled = !Sent;
sendReloadButton.Text = Strings.Save_again;
#else
sendReloadButton.Enabled = true; /// 'Print' function always available
sendReloadButton.Text = Strings.Print;
sendBtnIsPrint = true;
#endif
break;
case PreviousResultsMode.Reload:
sendReloadButton.Enabled = true;
sendReloadButton.Text = Strings.Restore;
break;
case PreviousResultsMode.Fix:
sendReloadButton.Enabled = true;
sendReloadButton.Text = Strings.Fix;
break;
}
/// 'Show' button
showButton.Text = Strings.Show;
}
public void UpdateSentState(bool sent)
@ -100,7 +113,11 @@ namespace TBF.UI.ResultsMI
private void sendReloadButton_MouseClick(object sender, MouseEventArgs e)
{
if (mode == PreviousResultsMode.Show)
if (sendBtnIsPrint)
{
parent.OnPrint(this, new PreviousResultIdEventArgs(BatchNr, SerialNrs));
}
else if (mode == PreviousResultsMode.Show)
{
parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr, SerialNrs));
}

View File

@ -14,6 +14,8 @@ using Oracle.DataAccess.Client;
using Common;
using Results;
using Results.Entities;
using TBF.Rig.Generic;
using TBF.Rig.GenericDevices;
using TBF.Rig.Output.DB.SensusOracle;
using TBF.Rig.Sequences;
using TBF.Resources;
@ -48,6 +50,12 @@ namespace TBF.UI.ResultsMI
this.mode = mode;
currentBatchNr = Program.LocalSettings.BatchNr;
PrintHandler += delegate(object sndr, PreviousResultIdEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<PreviousResultIdEventArgs>(DoPrint), sndr, args); }
else DoPrint(sndr, args);
};
SendAgainHandler += delegate(object sndr, PreviousResultIdEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<PreviousResultIdEventArgs>(DoSendAgain), sndr, args); }
@ -208,9 +216,52 @@ namespace TBF.UI.ResultsMI
public event EventHandler<PreviousResultIdEventArgs> SendAgainHandler;
public event EventHandler<PreviousResultIdEventArgs> PrintHandler;
/// <summary>
/// <summary>
/// Called from PreviousResultCtrl when 'Print' button pressed.
/// </summary>
public void OnPrint(object sender, PreviousResultIdEventArgs data)
{
if (PrintHandler == null) return;
try
{
PrintHandler(sender, data);
}
catch (Exception e)
{
log.Error("PrintHandler(...) failed", e);
}
}
public void DoPrint(object sender, PreviousResultIdEventArgs data)
{
foreach (var b in batches)
{
if (b.BatchNr == data.BatchNr)
{
IList<IResultsPrinter> printers = new List<IResultsPrinter>();
foreach (var c in TBF.Rig.StateMachine.Components)
{
if (c is IResultsPrinter) printers.Add(c as IResultsPrinter);
}
var dlg = new PrintResultsSelectionDlg(printers);
if (dlg.ShowDialog() != DialogResult.OK) return;
TBF.Rig.IOperation printResultsOp = dlg.SelectedPrinter.ProcessResultsOp(b);
printResultsOp.Start();
TBF.Rig.Event e;
do { e = printResultsOp.Run(); }
while (e != TBF.Rig.Event.ResultsPrinted && e != TBF.Rig.Event.ErrorProcessingResults);
printResultsOp.Stop();
}
}
}
public event EventHandler<PreviousResultIdEventArgs> SendAgainHandler;
/// <summary>
/// Called from PreviousResultCtrl when 'Send again' button pressed.
/// </summary>
public void OnSendAgain(object sender, PreviousResultIdEventArgs data)

View File

@ -0,0 +1,100 @@
namespace TBF.UI.ResultsMI
{
partial class PrintResultsSelectionDlg
{
/// <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.printersComboBox = new System.Windows.Forms.ComboBox();
this.printerLabel = new System.Windows.Forms.Label();
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// printersComboBox
//
this.printersComboBox.FormattingEnabled = true;
this.printersComboBox.Location = new System.Drawing.Point(121, 27);
this.printersComboBox.Name = "printersComboBox";
this.printersComboBox.Size = new System.Drawing.Size(392, 21);
this.printersComboBox.TabIndex = 0;
//
// printerLabel
//
this.printerLabel.AutoSize = true;
this.printerLabel.Location = new System.Drawing.Point(36, 30);
this.printerLabel.Name = "printerLabel";
this.printerLabel.Size = new System.Drawing.Size(37, 13);
this.printerLabel.TabIndex = 1;
this.printerLabel.Text = "Printer";
//
// okButton
//
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.okButton.Location = new System.Drawing.Point(305, 68);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(92, 40);
this.okButton.TabIndex = 4;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// cancelButton
//
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancelButton.Location = new System.Drawing.Point(421, 68);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(92, 40);
this.cancelButton.TabIndex = 5;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// PrintResultsSelectionDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(546, 127);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.printerLabel);
this.Controls.Add(this.printersComboBox);
this.Name = "PrintResultsSelectionDlg";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Database and water meter selection";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox printersComboBox;
private System.Windows.Forms.Label printerLabel;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
}
}

View File

@ -0,0 +1,62 @@
///
/// Copyright (c) 2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using TBF.Resources;
using TBF.Rig.GenericDevices;
namespace TBF.UI.ResultsMI
{
public partial class PrintResultsSelectionDlg : Form
{
readonly IList<IResultsPrinter> printers;
public IResultsPrinter SelectedPrinter;
public PrintResultsSelectionDlg(IList<IResultsPrinter> printers)
{
this.printers = printers;
InitializeComponent();
Localize();
if (printers != null)
foreach (var p in printers)
printersComboBox.Items.Add(p.Name);
}
void Localize()
{
Text = Strings.Printer_selection;
printerLabel.Text = Strings.Printer;
okButton.Text = Strings.OkBtnText;
cancelButton.Text = Strings.CancelBtnText;
}
private void okButton_Click(object sender, EventArgs e)
{
if (printersComboBox.SelectedItem != null)
{
SelectedPrinter = printers.FirstOrDefault(x => x.Name == printersComboBox.SelectedItem.ToString());
}
if (SelectedPrinter == null)
{
MessageBox.Show("Invalid selection");
return;
}
DialogResult = DialogResult.OK;
Close();
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

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>