Output.Printers.OnePerMeter can print water meter images.

This commit is contained in:
Milan Hanajik 2017-12-06 14:54:45 +03:00
parent 6b6098164a
commit f6e44914fa
6 changed files with 224 additions and 30 deletions

View File

@ -148,18 +148,25 @@ namespace Results.Output.Printers.OnePerMeter
if (pageNr == 1)
{
///
/// Print water meter picture
///
if (cfg.ImgWid != 0 && cfg.ImgHgh != 0 && cfg.ImgFullPathName != null)
{
try
{
e.Graphics.DrawImage(new Bitmap(Image.FromFile(cfg.ImgFullPathName), cfg.ImgWid, cfg.ImgHgh),
new Rectangle(cfg.ImgLeft, cfg.ImgTop, cfg.ImgWid, cfg.ImgHgh));
}
catch (Exception) { } /// Cope with situations when file is missing or is not correct
}
titleHeight = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Height;
commonTop = TitleY + titleHeight + spacingOne4Header;
commonHeight = commonItems.Count * spacingOne;
bodyTop = commonTop + commonHeight + spacingOne4Header;
}
/// Use the StringFormat class for the text layout of our document
StringFormat format = new StringFormat(StringFormatFlags.LineLimit);
if (pageNr == 1)
{
///
/// Title
///

View File

@ -33,5 +33,10 @@ namespace Results.Output.Printers.OnePerMeter
public string Footer;
public bool TestsAreRows;
public bool TestsAreRows2;
public string ImgFullPathName;
public int ImgLeft;
public int ImgTop;
public int ImgWid;
public int ImgHgh;
}
}

View File

@ -101,6 +101,11 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
printerCfg.TestsAreRows = newCfg.TestsAreRows;
printerCfg.TestsAreRows2 = newCfg.TestsAreRows2;
printerCfg.DocName = newCfg.DocName;
printerCfg.ImgName = newCfg.ImgName;
printerCfg.ImgLeft = newCfg.ImgLeft;
printerCfg.ImgTop = newCfg.ImgTop;
printerCfg.ImgWid = newCfg.ImgWid;
printerCfg.ImgHgh = newCfg.ImgHgh;
ApplyConfig();
}
@ -199,6 +204,11 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
Footer = printerCfg.Footer,
TestsAreRows = printerCfg.TestsAreRows,
TestsAreRows2 = printerCfg.TestsAreRows2,
ImgFullPathName = (wm.ArchivePath != null) ? System.IO.Path.Combine(wm.ArchivePath, printerCfg.ImgName) : null,
ImgLeft = printerCfg.ImgLeft,
ImgTop = printerCfg.ImgTop,
ImgWid = printerCfg.ImgWid,
ImgHgh = printerCfg.ImgHgh,
};
new Results.Output.Printers.OnePerMeter.OnePerMeterPrintDocument(batch, cfg, wm, documentName).Print();

View File

@ -45,6 +45,11 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
public bool TestsAreRows; /// true = Tests are rows
public bool TestsAreRows2; /// true = Tests are rows
public string DocName;
public string ImgName;
public int ImgLeft;
public int ImgTop;
public int ImgWid;
public int ImgHgh;
[XmlIgnore]
public Config.Entities.MetersKind MetersKind;
@ -84,7 +89,8 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
Header = string.Empty;
Footer = string.Empty;
DocName = string.Empty;
}
ImgName = string.Empty;
}
public string ToString(int i)
{

View File

@ -77,6 +77,17 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
this.footerFontSizeTextBox = new System.Windows.Forms.TextBox();
this.footerFontFamilyComboBox = new System.Windows.Forms.ComboBox();
this.footerFontLabel = new System.Windows.Forms.Label();
this.imageNameTextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.imageLeftTextBox = new System.Windows.Forms.TextBox();
this.imageTopTextBox = new System.Windows.Forms.TextBox();
this.imageWidthTextBox = new System.Windows.Forms.TextBox();
this.imageHeightTextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
@ -84,7 +95,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(142, 24);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(218, 20);
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
this.nameTextBox.TabIndex = 2;
//
// nameLabel
@ -109,7 +120,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
//
this.supressPrintingCheckBox.AutoSize = true;
this.supressPrintingCheckBox.Enabled = false;
this.supressPrintingCheckBox.Location = new System.Drawing.Point(19, 230);
this.supressPrintingCheckBox.Location = new System.Drawing.Point(192, 227);
this.supressPrintingCheckBox.Name = "supressPrintingCheckBox";
this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17);
this.supressPrintingCheckBox.TabIndex = 33;
@ -131,7 +142,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
this.orientationComboBox.FormattingEnabled = true;
this.orientationComboBox.Location = new System.Drawing.Point(142, 66);
this.orientationComboBox.Name = "orientationComboBox";
this.orientationComboBox.Size = new System.Drawing.Size(218, 21);
this.orientationComboBox.Size = new System.Drawing.Size(146, 21);
this.orientationComboBox.TabIndex = 6;
//
// topMarginTextBox
@ -173,7 +184,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
this.cultureComboBox.FormattingEnabled = true;
this.cultureComboBox.Location = new System.Drawing.Point(142, 194);
this.cultureComboBox.Name = "cultureComboBox";
this.cultureComboBox.Size = new System.Drawing.Size(218, 21);
this.cultureComboBox.Size = new System.Drawing.Size(110, 21);
this.cultureComboBox.TabIndex = 32;
//
// cultureLabel
@ -188,9 +199,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
// commonItemsButton
//
this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(142, 238);
this.commonItemsButton.Location = new System.Drawing.Point(19, 238);
this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(218, 23);
this.commonItemsButton.Size = new System.Drawing.Size(167, 23);
this.commonItemsButton.TabIndex = 38;
this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true;
@ -199,9 +210,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
// footerButton
//
this.footerButton.Enabled = false;
this.footerButton.Location = new System.Drawing.Point(142, 304);
this.footerButton.Location = new System.Drawing.Point(19, 304);
this.footerButton.Name = "footerButton";
this.footerButton.Size = new System.Drawing.Size(218, 23);
this.footerButton.Size = new System.Drawing.Size(167, 23);
this.footerButton.TabIndex = 41;
this.footerButton.Text = "Footer";
this.footerButton.UseVisualStyleBackColor = true;
@ -210,9 +221,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
// headerButton
//
this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(142, 216);
this.headerButton.Location = new System.Drawing.Point(19, 216);
this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(218, 23);
this.headerButton.Size = new System.Drawing.Size(167, 23);
this.headerButton.TabIndex = 37;
this.headerButton.Text = "Title";
this.headerButton.UseVisualStyleBackColor = true;
@ -221,9 +232,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
// testItemsButton
//
this.testItemsButton.Enabled = false;
this.testItemsButton.Location = new System.Drawing.Point(142, 260);
this.testItemsButton.Location = new System.Drawing.Point(19, 260);
this.testItemsButton.Name = "testItemsButton";
this.testItemsButton.Size = new System.Drawing.Size(218, 23);
this.testItemsButton.Size = new System.Drawing.Size(167, 23);
this.testItemsButton.TabIndex = 39;
this.testItemsButton.Text = "Test items - 1st table";
this.testItemsButton.UseVisualStyleBackColor = true;
@ -391,7 +402,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
//
this.testsAreRowsCheckBox.AutoSize = true;
this.testsAreRowsCheckBox.Enabled = false;
this.testsAreRowsCheckBox.Location = new System.Drawing.Point(19, 266);
this.testsAreRowsCheckBox.Location = new System.Drawing.Point(192, 263);
this.testsAreRowsCheckBox.Name = "testsAreRowsCheckBox";
this.testsAreRowsCheckBox.Size = new System.Drawing.Size(95, 17);
this.testsAreRowsCheckBox.TabIndex = 35;
@ -402,7 +413,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
//
this.tests2AreRowsCheckBox.AutoSize = true;
this.tests2AreRowsCheckBox.Enabled = false;
this.tests2AreRowsCheckBox.Location = new System.Drawing.Point(19, 284);
this.tests2AreRowsCheckBox.Location = new System.Drawing.Point(192, 281);
this.tests2AreRowsCheckBox.Name = "tests2AreRowsCheckBox";
this.tests2AreRowsCheckBox.Size = new System.Drawing.Size(104, 17);
this.tests2AreRowsCheckBox.TabIndex = 36;
@ -412,9 +423,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
// testItems2Button
//
this.testItems2Button.Enabled = false;
this.testItems2Button.Location = new System.Drawing.Point(142, 282);
this.testItems2Button.Location = new System.Drawing.Point(19, 282);
this.testItems2Button.Name = "testItems2Button";
this.testItems2Button.Size = new System.Drawing.Size(218, 23);
this.testItems2Button.Size = new System.Drawing.Size(167, 23);
this.testItems2Button.TabIndex = 40;
this.testItems2Button.Text = "Test items - 2nd table";
this.testItems2Button.UseVisualStyleBackColor = true;
@ -424,7 +435,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
//
this.goodOnlyCheckBox.AutoSize = true;
this.goodOnlyCheckBox.Enabled = false;
this.goodOnlyCheckBox.Location = new System.Drawing.Point(19, 248);
this.goodOnlyCheckBox.Location = new System.Drawing.Point(192, 245);
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox";
this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17);
this.goodOnlyCheckBox.TabIndex = 34;
@ -436,7 +447,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
this.templateTextBox.Enabled = false;
this.templateTextBox.Location = new System.Drawing.Point(142, 45);
this.templateTextBox.Name = "templateTextBox";
this.templateTextBox.Size = new System.Drawing.Size(218, 20);
this.templateTextBox.Size = new System.Drawing.Size(146, 20);
this.templateTextBox.TabIndex = 4;
//
// templateLabel
@ -451,7 +462,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
// docNameLabel
//
this.docNameLabel.AutoSize = true;
this.docNameLabel.Location = new System.Drawing.Point(16, 331);
this.docNameLabel.Location = new System.Drawing.Point(58, 331);
this.docNameLabel.Name = "docNameLabel";
this.docNameLabel.Size = new System.Drawing.Size(243, 13);
this.docNameLabel.TabIndex = 42;
@ -460,9 +471,9 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
// docNameTextBox
//
this.docNameTextBox.Enabled = false;
this.docNameTextBox.Location = new System.Drawing.Point(258, 328);
this.docNameTextBox.Location = new System.Drawing.Point(302, 328);
this.docNameTextBox.Name = "docNameTextBox";
this.docNameTextBox.Size = new System.Drawing.Size(102, 20);
this.docNameTextBox.Size = new System.Drawing.Size(126, 20);
this.docNameTextBox.TabIndex = 43;
//
// footerItalicCheckBox
@ -511,10 +522,115 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
this.footerFontLabel.TabIndex = 26;
this.footerFontLabel.Text = "Footer font/size/style";
//
// imageNameTextBox
//
this.imageNameTextBox.Enabled = false;
this.imageNameTextBox.Location = new System.Drawing.Point(302, 306);
this.imageNameTextBox.Name = "imageNameTextBox";
this.imageNameTextBox.Size = new System.Drawing.Size(126, 20);
this.imageNameTextBox.TabIndex = 44;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(217, 309);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(84, 13);
this.label3.TabIndex = 45;
this.label3.Text = "Image file name:";
//
// imageLeftTextBox
//
this.imageLeftTextBox.Enabled = false;
this.imageLeftTextBox.Location = new System.Drawing.Point(388, 218);
this.imageLeftTextBox.Name = "imageLeftTextBox";
this.imageLeftTextBox.Size = new System.Drawing.Size(40, 20);
this.imageLeftTextBox.TabIndex = 46;
//
// imageTopTextBox
//
this.imageTopTextBox.Enabled = false;
this.imageTopTextBox.Location = new System.Drawing.Point(388, 240);
this.imageTopTextBox.Name = "imageTopTextBox";
this.imageTopTextBox.Size = new System.Drawing.Size(40, 20);
this.imageTopTextBox.TabIndex = 47;
//
// imageWidthTextBox
//
this.imageWidthTextBox.Enabled = false;
this.imageWidthTextBox.Location = new System.Drawing.Point(388, 262);
this.imageWidthTextBox.Name = "imageWidthTextBox";
this.imageWidthTextBox.Size = new System.Drawing.Size(40, 20);
this.imageWidthTextBox.TabIndex = 48;
//
// imageHeightTextBox
//
this.imageHeightTextBox.Enabled = false;
this.imageHeightTextBox.Location = new System.Drawing.Point(388, 284);
this.imageHeightTextBox.Name = "imageHeightTextBox";
this.imageHeightTextBox.Size = new System.Drawing.Size(40, 20);
this.imageHeightTextBox.TabIndex = 49;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(311, 222);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(53, 13);
this.label4.TabIndex = 50;
this.label4.Text = "Image left";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(311, 244);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(54, 13);
this.label5.TabIndex = 52;
this.label5.Text = "Image top";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(311, 266);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(64, 13);
this.label6.TabIndex = 54;
this.label6.Text = "Image width";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(311, 288);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(68, 13);
this.label7.TabIndex = 56;
this.label7.Text = "Image height";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(277, 202);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(172, 13);
this.label8.TabIndex = 57;
this.label8.Text = "Image coordinates are in 0.254 mm";
//
// PrinterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.imageHeightTextBox);
this.Controls.Add(this.imageWidthTextBox);
this.Controls.Add(this.imageTopTextBox);
this.Controls.Add(this.imageLeftTextBox);
this.Controls.Add(this.label3);
this.Controls.Add(this.imageNameTextBox);
this.Controls.Add(this.footerItalicCheckBox);
this.Controls.Add(this.footerBoldCheckBox);
this.Controls.Add(this.footerFontSizeTextBox);
@ -562,7 +678,7 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "PrinterCfgCtrl";
this.Size = new System.Drawing.Size(400, 350);
this.Size = new System.Drawing.Size(455, 350);
this.Load += new System.EventHandler(this.PrinterCfgCtrl_Load);
this.ResumeLayout(false);
this.PerformLayout();
@ -617,5 +733,16 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
private System.Windows.Forms.TextBox footerFontSizeTextBox;
private System.Windows.Forms.ComboBox footerFontFamilyComboBox;
private System.Windows.Forms.Label footerFontLabel;
private System.Windows.Forms.TextBox imageNameTextBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox imageLeftTextBox;
private System.Windows.Forms.TextBox imageTopTextBox;
private System.Windows.Forms.TextBox imageWidthTextBox;
private System.Windows.Forms.TextBox imageHeightTextBox;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
}
}

View File

@ -127,7 +127,12 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
cultureComboBox.Text = config.Culture.ToString();
docNameTextBox.Text = config.DocName;
}
imageNameTextBox.Text = config.ImgName;
imageLeftTextBox.Text = config.ImgLeft.ToString();
imageTopTextBox.Text = config.ImgTop.ToString();
imageWidthTextBox.Text = config.ImgWid.ToString();
imageHeightTextBox.Text = config.ImgHgh.ToString();
}
public void Unlock()
{
@ -164,6 +169,11 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
testsAreRowsCheckBox.Enabled = true;
tests2AreRowsCheckBox.Enabled = true;
docNameTextBox.Enabled = true;
imageNameTextBox.Enabled = true;
imageLeftTextBox.Enabled = true;
imageTopTextBox.Enabled = true;
imageWidthTextBox.Enabled = true;
imageHeightTextBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
@ -225,6 +235,30 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
message += Environment.NewLine + "Invalid culture";
}
if (!int.TryParse(imageLeftTextBox.Text, out dummy) || dummy < 0 || dummy > 1100)
{
message += Environment.NewLine + "Image left' should be between 0 and 1100";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(imageTopTextBox.Text, out dummy) || dummy < 0 || dummy > 1100)
{
message += Environment.NewLine + "Image top' should be between 0 and 1100";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(imageWidthTextBox.Text, out dummy) || dummy < 0 || dummy > 1100)
{
message += Environment.NewLine + "Image width' should be between 0 and 1100";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(imageHeightTextBox.Text, out dummy) || dummy < 0 || dummy > 1100)
{
message += Environment.NewLine + "Image height' should be between 0 and 1100";
flags |= CfgUpdateFlags.Error;
}
return flags;
}
@ -304,6 +338,11 @@ namespace TBF.BenchControl.Output.Printers.OnePerMeter
}
flags |= UpdateDifferent(ref config.DocName, docNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.ImgName, imageNameTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.ImgLeft, imageLeftTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.ImgTop, imageTopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.ImgWid, imageWidthTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
flags |= UpdateDifferent(ref config.ImgHgh, imageHeightTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
{