From eb5f3465c831bca8334389764dca0493f836b16c Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 18 Nov 2016 14:09:12 +0100 Subject: [PATCH] ResultsBrowser : Statistics : rows and columns are combinations of two items, ver. 2.12.390 --- Results/Results.csproj | 1 - .../Forms/StatisticsDlg.Designer.cs | 185 +++++---- ResultsBrowser/Forms/StatisticsDlg.cs | 66 ++- .../Forms/StatisticsOptionsDlg.Designer.cs | 348 +++++++++------- ResultsBrowser/Forms/StatisticsOptionsDlg.cs | 45 +- ResultsBrowser/LocalSettings.cs | 6 +- .../QueryResults/QueryResultsPrintDocument.cs | 386 ++++++++++++++++++ .../Statistics/StatisticsPrintDocument.cs | 275 +++++++++++++ ResultsBrowser/Properties/AssemblyInfo.cs | 4 +- ResultsBrowser/ResultsBrowser.csproj | 10 +- ResultsBrowser/ResultsBrowserWnd.cs | 5 +- 11 files changed, 1065 insertions(+), 266 deletions(-) create mode 100644 ResultsBrowser/Output/Printers/QueryResults/QueryResultsPrintDocument.cs create mode 100644 ResultsBrowser/Output/Printers/Statistics/StatisticsPrintDocument.cs diff --git a/Results/Results.csproj b/Results/Results.csproj index ddaeae3d8..e20f58f03 100644 --- a/Results/Results.csproj +++ b/Results/Results.csproj @@ -124,7 +124,6 @@ - diff --git a/ResultsBrowser/Forms/StatisticsDlg.Designer.cs b/ResultsBrowser/Forms/StatisticsDlg.Designer.cs index abc52a051..dbc37736a 100644 --- a/ResultsBrowser/Forms/StatisticsDlg.Designer.cs +++ b/ResultsBrowser/Forms/StatisticsDlg.Designer.cs @@ -28,91 +28,103 @@ /// private void InitializeComponent() { - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.statisticsListView = new System.Windows.Forms.ListView(); - this.splitContainer2 = new System.Windows.Forms.SplitContainer(); - this.okButton = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); - this.splitContainer2.Panel2.SuspendLayout(); - this.splitContainer2.SuspendLayout(); - this.SuspendLayout(); - // - // splitContainer1 - // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; - this.splitContainer1.Location = new System.Drawing.Point(0, 0); - this.splitContainer1.Name = "splitContainer1"; - this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.statisticsListView); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); - this.splitContainer1.Size = new System.Drawing.Size(572, 409); - this.splitContainer1.SplitterDistance = 320; - this.splitContainer1.TabIndex = 0; - // - // statisticsListView - // - this.statisticsListView.Dock = System.Windows.Forms.DockStyle.Fill; - this.statisticsListView.GridLines = true; - this.statisticsListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.statisticsListView.Location = new System.Drawing.Point(0, 0); - this.statisticsListView.Name = "statisticsListView"; - this.statisticsListView.Size = new System.Drawing.Size(572, 320); - this.statisticsListView.TabIndex = 0; - this.statisticsListView.UseCompatibleStateImageBehavior = false; - // - // splitContainer2 - // - this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; - this.splitContainer2.Location = new System.Drawing.Point(0, 0); - this.splitContainer2.Name = "splitContainer2"; - // - // splitContainer2.Panel2 - // - this.splitContainer2.Panel2.Controls.Add(this.okButton); - this.splitContainer2.Size = new System.Drawing.Size(572, 85); - this.splitContainer2.SplitterDistance = 390; - this.splitContainer2.TabIndex = 0; - // - // okButton - // - this.okButton.Location = new System.Drawing.Point(45, 20); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(108, 41); - this.okButton.TabIndex = 0; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.okButton_Click); - // - // StatisticsDlg - // - this.AcceptButton = this.okButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(572, 409); - this.Controls.Add(this.splitContainer1); - this.Name = "StatisticsDlg"; - this.Text = "StatisticsDlg"; - this.Load += new System.EventHandler(this.StatisticsDlg_Load); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - this.splitContainer2.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); - this.splitContainer2.ResumeLayout(false); - this.ResumeLayout(false); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.statisticsListView = new System.Windows.Forms.ListView(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.printButton = new System.Windows.Forms.Button(); + this.closeButton = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); + this.splitContainer2.Panel2.SuspendLayout(); + this.splitContainer2.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.statisticsListView); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); + this.splitContainer1.Size = new System.Drawing.Size(572, 409); + this.splitContainer1.SplitterDistance = 320; + this.splitContainer1.TabIndex = 0; + // + // statisticsListView + // + this.statisticsListView.Dock = System.Windows.Forms.DockStyle.Fill; + this.statisticsListView.GridLines = true; + this.statisticsListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.statisticsListView.Location = new System.Drawing.Point(0, 0); + this.statisticsListView.Name = "statisticsListView"; + this.statisticsListView.Size = new System.Drawing.Size(572, 320); + this.statisticsListView.TabIndex = 0; + this.statisticsListView.UseCompatibleStateImageBehavior = false; + // + // splitContainer2 + // + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.Controls.Add(this.printButton); + this.splitContainer2.Panel2.Controls.Add(this.closeButton); + this.splitContainer2.Size = new System.Drawing.Size(572, 85); + this.splitContainer2.SplitterDistance = 249; + this.splitContainer2.TabIndex = 0; + // + // printButton + // + this.printButton.Location = new System.Drawing.Point(38, 22); + this.printButton.Name = "printButton"; + this.printButton.Size = new System.Drawing.Size(108, 41); + this.printButton.TabIndex = 0; + this.printButton.Text = "Print"; + this.printButton.UseVisualStyleBackColor = true; + this.printButton.Click += new System.EventHandler(this.printButton_Click); + // + // closeButton + // + this.closeButton.Location = new System.Drawing.Point(176, 22); + this.closeButton.Name = "closeButton"; + this.closeButton.Size = new System.Drawing.Size(108, 41); + this.closeButton.TabIndex = 1; + this.closeButton.Text = "Close"; + this.closeButton.UseVisualStyleBackColor = true; + this.closeButton.Click += new System.EventHandler(this.closeButton_Click); + // + // StatisticsDlg + // + this.AcceptButton = this.closeButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(572, 409); + this.Controls.Add(this.splitContainer1); + this.Name = "StatisticsDlg"; + this.Text = "StatisticsDlg"; + this.Load += new System.EventHandler(this.StatisticsDlg_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.splitContainer2.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); + this.splitContainer2.ResumeLayout(false); + this.ResumeLayout(false); } @@ -121,6 +133,7 @@ private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.ListView statisticsListView; private System.Windows.Forms.SplitContainer splitContainer2; - private System.Windows.Forms.Button okButton; + private System.Windows.Forms.Button closeButton; + private System.Windows.Forms.Button printButton; } } \ No newline at end of file diff --git a/ResultsBrowser/Forms/StatisticsDlg.cs b/ResultsBrowser/Forms/StatisticsDlg.cs index 55f11c8c6..6b821f918 100644 --- a/ResultsBrowser/Forms/StatisticsDlg.cs +++ b/ResultsBrowser/Forms/StatisticsDlg.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Windows.Forms; using Results.Entities; using ResultsBrowser.Resources; +using ResultsBrowser.Output.Printers.Statistics; namespace ResultsBrowser.Forms { @@ -13,28 +14,48 @@ namespace ResultsBrowser.Forms bool twoDim; Results.WMeterRsltItemSpec rowItem; - Results.WMeterRsltItemSpec columnItem; + Results.WMeterRsltItemSpec rowItemExt; + Results.WMeterRsltItemSpec columnItem; + Results.WMeterRsltItemSpec columnItemExt; string rowTestSpec; + string rowExtTestSpec; string columnTestSpec; + string columnExtTestSpec; IList rowValues; IList columnValues; - public StatisticsDlg(IList waterMeters, bool twoDim, Results.WMeterRsltItemSpec rowItem, Results.WMeterRsltItemSpec columnItem, string rowTestSpec, string columnTestSpec) + int[,] occurances; + + + public StatisticsDlg(IList waterMeters, bool twoDim, + Results.WMeterRsltItemSpec rowItem, + Results.WMeterRsltItemSpec rowItemExt, + Results.WMeterRsltItemSpec columnItem, + Results.WMeterRsltItemSpec columnItemExt, + string rowTestSpec, + string rowExtTestSpec, + string columnTestSpec, + string columnExtTestSpec) { InitializeComponent(); Text = Strings.Statistics; - okButton.Text = Strings.OkBtnText; + closeButton.Text = Strings.OkBtnText; this.waterMeters = waterMeters; this.twoDim = twoDim; + this.rowItem = rowItem; + this.rowItemExt = rowItemExt; this.columnItem = columnItem; + this.columnItemExt = columnItemExt; this.rowTestSpec = rowTestSpec; - this.columnTestSpec = columnTestSpec; + this.rowExtTestSpec = rowExtTestSpec; + this.columnTestSpec = columnTestSpec; + this.columnExtTestSpec = columnExtTestSpec; } private void StatisticsDlg_Load(object sender, EventArgs e) @@ -55,38 +76,46 @@ namespace ResultsBrowser.Forms foreach (var wm in waterMeters) { string value = rowItem.Print(wm); + if (rowItemExt != null) value = value + " | " + rowItemExt.Print(wm); if (!rowValues.Contains(value)) rowValues.Add(value); if (twoDim) { value = columnItem.Print(wm); - if (!columnValues.Contains(value)) columnValues.Add(value); + if (columnItemExt != null) value = value + " | " + columnItemExt.Print(wm); + if (!columnValues.Contains(value)) columnValues.Add(value); } } /// /// Calculate occurances /// - int columns = Math.Max(1, columnValues.Count); - int[,] occurances = new int[rowValues.Count, columns]; + int columnsCount = Math.Max(1, columnValues.Count); + occurances = new int[rowValues.Count, columnsCount]; foreach (var wm in waterMeters) { for (int row = 0; row < rowValues.Count; row++) { + string rowValue = rowItem.Print(wm); + if (rowItemExt != null) rowValue = rowValue + " | " + rowItemExt.Print(wm); + if (twoDim) { - for (int column = 0; column < columns; column++) + for (int column = 0; column < columnsCount; column++) { - if (rowItem.Print(wm).Equals(rowValues[row]) && columnItem.Print(wm).Equals(columnValues[column])) - { - occurances[row, column]++; - } + string columnValue = columnItem.Print(wm); + if (columnItemExt != null) columnValue = columnValue + " | " + columnItemExt.Print(wm); + + if (rowValue == rowValues[row] && columnValue == columnValues[column]) + { + occurances[row, column]++; + } } } else { - if (rowItem.Print(wm).Equals(rowValues[row])) occurances[row, 0]++; + if (rowValue == rowValues[row]) occurances[row, 0]++; } } } @@ -99,7 +128,7 @@ namespace ResultsBrowser.Forms statisticsListView.FullRowSelect = true; statisticsListView.Columns.Add(" ", 200); - for (int column = 0; column < columns; column++) + for (int column = 0; column < columnsCount; column++) { statisticsListView.Columns.Add((twoDim ? columnValues[column] : Strings.Count), 70); } @@ -107,7 +136,7 @@ namespace ResultsBrowser.Forms for (int row = 0; row < rowValues.Count; row++) { ListViewItem lvi = new ListViewItem(rowValues[row]); - for (int column = 0; column < columns; column++) lvi.SubItems.Add(occurances[row, column].ToString()); + for (int column = 0; column < columnsCount; column++) lvi.SubItems.Add(occurances[row, column].ToString()); statisticsListView.Items.Add(lvi); } @@ -120,10 +149,15 @@ namespace ResultsBrowser.Forms } } - private void okButton_Click(object sender, EventArgs e) + private void closeButton_Click(object sender, EventArgs e) { DialogResult = DialogResult.OK; Close(); } + + private void printButton_Click(object sender, EventArgs e) + { + new StatisticsPrintDocument("", rowValues, columnValues, occurances, Config.Entities.PageOrientation.Portrait).Print(); + } } } diff --git a/ResultsBrowser/Forms/StatisticsOptionsDlg.Designer.cs b/ResultsBrowser/Forms/StatisticsOptionsDlg.Designer.cs index c59f90876..31b859171 100644 --- a/ResultsBrowser/Forms/StatisticsOptionsDlg.Designer.cs +++ b/ResultsBrowser/Forms/StatisticsOptionsDlg.Designer.cs @@ -28,147 +28,207 @@ /// private void InitializeComponent() { - this.cancelButton = new System.Windows.Forms.Button(); - this.okButton = new System.Windows.Forms.Button(); - this.rowsGroupBox = new System.Windows.Forms.GroupBox(); - this.rowTestSpecTextBox = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.rowsComboBox = new System.Windows.Forms.ComboBox(); - this.columnsGroupBox = new System.Windows.Forms.GroupBox(); - this.columnTestSpecTextBox = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.columnsComboBox = new System.Windows.Forms.ComboBox(); - this.twoDimCheckBox = new System.Windows.Forms.CheckBox(); - this.rowsGroupBox.SuspendLayout(); - this.columnsGroupBox.SuspendLayout(); - this.SuspendLayout(); - // - // cancelButton - // - this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(368, 196); - this.cancelButton.Name = "cancelButton"; - this.cancelButton.Size = new System.Drawing.Size(95, 38); - this.cancelButton.TabIndex = 9; - this.cancelButton.Text = "Cancel"; - this.cancelButton.UseVisualStyleBackColor = true; - this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); - // - // okButton - // - this.okButton.Location = new System.Drawing.Point(257, 196); - this.okButton.Name = "okButton"; - this.okButton.Size = new System.Drawing.Size(95, 38); - this.okButton.TabIndex = 8; - this.okButton.Text = "OK"; - this.okButton.UseVisualStyleBackColor = true; - this.okButton.Click += new System.EventHandler(this.okButton_Click); - // - // rowsGroupBox - // - this.rowsGroupBox.Controls.Add(this.rowTestSpecTextBox); - this.rowsGroupBox.Controls.Add(this.label1); - this.rowsGroupBox.Controls.Add(this.rowsComboBox); - this.rowsGroupBox.Location = new System.Drawing.Point(38, 50); - this.rowsGroupBox.Name = "rowsGroupBox"; - this.rowsGroupBox.Size = new System.Drawing.Size(427, 56); - this.rowsGroupBox.TabIndex = 10; - this.rowsGroupBox.TabStop = false; - this.rowsGroupBox.Text = "Rows"; - // - // rowTestSpecTextBox - // - this.rowTestSpecTextBox.Location = new System.Drawing.Point(326, 22); - this.rowTestSpecTextBox.Name = "rowTestSpecTextBox"; - this.rowTestSpecTextBox.Size = new System.Drawing.Size(61, 20); - this.rowTestSpecTextBox.TabIndex = 2; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(242, 24); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(35, 13); - this.label1.TabIndex = 1; - this.label1.Text = "label1"; - // - // rowsComboBox - // - this.rowsComboBox.FormattingEnabled = true; - this.rowsComboBox.Location = new System.Drawing.Point(32, 21); - this.rowsComboBox.Name = "rowsComboBox"; - this.rowsComboBox.Size = new System.Drawing.Size(185, 21); - this.rowsComboBox.TabIndex = 0; - // - // columnsGroupBox - // - this.columnsGroupBox.Controls.Add(this.columnTestSpecTextBox); - this.columnsGroupBox.Controls.Add(this.label2); - this.columnsGroupBox.Controls.Add(this.columnsComboBox); - this.columnsGroupBox.Location = new System.Drawing.Point(38, 112); - this.columnsGroupBox.Name = "columnsGroupBox"; - this.columnsGroupBox.Size = new System.Drawing.Size(427, 56); - this.columnsGroupBox.TabIndex = 11; - this.columnsGroupBox.TabStop = false; - this.columnsGroupBox.Text = "Columns"; - // - // columnTestSpecTextBox - // - this.columnTestSpecTextBox.Location = new System.Drawing.Point(326, 21); - this.columnTestSpecTextBox.Name = "columnTestSpecTextBox"; - this.columnTestSpecTextBox.Size = new System.Drawing.Size(61, 20); - this.columnTestSpecTextBox.TabIndex = 3; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(242, 23); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(35, 13); - this.label2.TabIndex = 2; - this.label2.Text = "label2"; - // - // columnsComboBox - // - this.columnsComboBox.FormattingEnabled = true; - this.columnsComboBox.Location = new System.Drawing.Point(32, 20); - this.columnsComboBox.Name = "columnsComboBox"; - this.columnsComboBox.Size = new System.Drawing.Size(185, 21); - this.columnsComboBox.TabIndex = 1; - // - // twoDimCheckBox - // - this.twoDimCheckBox.AutoSize = true; - this.twoDimCheckBox.Location = new System.Drawing.Point(39, 21); - this.twoDimCheckBox.Name = "twoDimCheckBox"; - this.twoDimCheckBox.Size = new System.Drawing.Size(40, 17); - this.twoDimCheckBox.TabIndex = 12; - this.twoDimCheckBox.Text = "2D"; - this.twoDimCheckBox.UseVisualStyleBackColor = true; - this.twoDimCheckBox.CheckedChanged += new System.EventHandler(this.twoDimCheckBox_CheckedChanged); - // - // StatisticsOptionsDlg - // - this.AcceptButton = this.okButton; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.cancelButton; - this.ClientSize = new System.Drawing.Size(503, 262); - this.Controls.Add(this.columnsGroupBox); - this.Controls.Add(this.twoDimCheckBox); - this.Controls.Add(this.rowsGroupBox); - this.Controls.Add(this.cancelButton); - this.Controls.Add(this.okButton); - this.Name = "StatisticsOptionsDlg"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "StatisticsOptionsDlg"; - this.Load += new System.EventHandler(this.StatisticsOptionsDlg_Load); - this.rowsGroupBox.ResumeLayout(false); - this.rowsGroupBox.PerformLayout(); - this.columnsGroupBox.ResumeLayout(false); - this.columnsGroupBox.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + this.cancelButton = new System.Windows.Forms.Button(); + this.okButton = new System.Windows.Forms.Button(); + this.rowsGroupBox = new System.Windows.Forms.GroupBox(); + this.rowTestSpecTextBox = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.rowsComboBox = new System.Windows.Forms.ComboBox(); + this.columnsGroupBox = new System.Windows.Forms.GroupBox(); + this.columnTestSpecTextBox = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.columnsComboBox = new System.Windows.Forms.ComboBox(); + this.twoDimCheckBox = new System.Windows.Forms.CheckBox(); + this.columnsExtComboBox = new System.Windows.Forms.ComboBox(); + this.label3 = new System.Windows.Forms.Label(); + this.columnExtTestSpecTextBox = new System.Windows.Forms.TextBox(); + this.rowExtTestSpecTextBox = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.rowsExtComboBox = new System.Windows.Forms.ComboBox(); + this.rowsGroupBox.SuspendLayout(); + this.columnsGroupBox.SuspendLayout(); + this.SuspendLayout(); + // + // cancelButton + // + this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelButton.Location = new System.Drawing.Point(368, 251); + this.cancelButton.Name = "cancelButton"; + this.cancelButton.Size = new System.Drawing.Size(95, 38); + this.cancelButton.TabIndex = 9; + this.cancelButton.Text = "Cancel"; + this.cancelButton.UseVisualStyleBackColor = true; + this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); + // + // okButton + // + this.okButton.Location = new System.Drawing.Point(257, 251); + this.okButton.Name = "okButton"; + this.okButton.Size = new System.Drawing.Size(95, 38); + this.okButton.TabIndex = 8; + this.okButton.Text = "OK"; + this.okButton.UseVisualStyleBackColor = true; + this.okButton.Click += new System.EventHandler(this.okButton_Click); + // + // rowsGroupBox + // + this.rowsGroupBox.Controls.Add(this.rowExtTestSpecTextBox); + this.rowsGroupBox.Controls.Add(this.label4); + this.rowsGroupBox.Controls.Add(this.rowsExtComboBox); + this.rowsGroupBox.Controls.Add(this.rowTestSpecTextBox); + this.rowsGroupBox.Controls.Add(this.label1); + this.rowsGroupBox.Controls.Add(this.rowsComboBox); + this.rowsGroupBox.Location = new System.Drawing.Point(38, 50); + this.rowsGroupBox.Name = "rowsGroupBox"; + this.rowsGroupBox.Size = new System.Drawing.Size(427, 84); + this.rowsGroupBox.TabIndex = 10; + this.rowsGroupBox.TabStop = false; + this.rowsGroupBox.Text = "Rows"; + // + // rowTestSpecTextBox + // + this.rowTestSpecTextBox.Location = new System.Drawing.Point(326, 24); + this.rowTestSpecTextBox.Name = "rowTestSpecTextBox"; + this.rowTestSpecTextBox.Size = new System.Drawing.Size(61, 20); + this.rowTestSpecTextBox.TabIndex = 2; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(242, 27); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(35, 13); + this.label1.TabIndex = 1; + this.label1.Text = "label1"; + // + // rowsComboBox + // + this.rowsComboBox.FormattingEnabled = true; + this.rowsComboBox.Location = new System.Drawing.Point(32, 24); + this.rowsComboBox.Name = "rowsComboBox"; + this.rowsComboBox.Size = new System.Drawing.Size(185, 21); + this.rowsComboBox.TabIndex = 0; + // + // columnsGroupBox + // + this.columnsGroupBox.Controls.Add(this.columnExtTestSpecTextBox); + this.columnsGroupBox.Controls.Add(this.label3); + this.columnsGroupBox.Controls.Add(this.columnsExtComboBox); + this.columnsGroupBox.Controls.Add(this.columnTestSpecTextBox); + this.columnsGroupBox.Controls.Add(this.label2); + this.columnsGroupBox.Controls.Add(this.columnsComboBox); + this.columnsGroupBox.Location = new System.Drawing.Point(38, 147); + this.columnsGroupBox.Name = "columnsGroupBox"; + this.columnsGroupBox.Size = new System.Drawing.Size(427, 84); + this.columnsGroupBox.TabIndex = 11; + this.columnsGroupBox.TabStop = false; + this.columnsGroupBox.Text = "Columns"; + // + // columnTestSpecTextBox + // + this.columnTestSpecTextBox.Location = new System.Drawing.Point(326, 23); + this.columnTestSpecTextBox.Name = "columnTestSpecTextBox"; + this.columnTestSpecTextBox.Size = new System.Drawing.Size(61, 20); + this.columnTestSpecTextBox.TabIndex = 3; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(242, 26); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(35, 13); + this.label2.TabIndex = 2; + this.label2.Text = "label2"; + // + // columnsComboBox + // + this.columnsComboBox.FormattingEnabled = true; + this.columnsComboBox.Location = new System.Drawing.Point(32, 23); + this.columnsComboBox.Name = "columnsComboBox"; + this.columnsComboBox.Size = new System.Drawing.Size(185, 21); + this.columnsComboBox.TabIndex = 1; + // + // twoDimCheckBox + // + this.twoDimCheckBox.AutoSize = true; + this.twoDimCheckBox.Location = new System.Drawing.Point(39, 21); + this.twoDimCheckBox.Name = "twoDimCheckBox"; + this.twoDimCheckBox.Size = new System.Drawing.Size(40, 17); + this.twoDimCheckBox.TabIndex = 12; + this.twoDimCheckBox.Text = "2D"; + this.twoDimCheckBox.UseVisualStyleBackColor = true; + this.twoDimCheckBox.CheckedChanged += new System.EventHandler(this.twoDimCheckBox_CheckedChanged); + // + // columnsExtComboBox + // + this.columnsExtComboBox.FormattingEnabled = true; + this.columnsExtComboBox.Location = new System.Drawing.Point(32, 51); + this.columnsExtComboBox.Name = "columnsExtComboBox"; + this.columnsExtComboBox.Size = new System.Drawing.Size(185, 21); + this.columnsExtComboBox.TabIndex = 4; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(242, 54); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(35, 13); + this.label3.TabIndex = 5; + this.label3.Text = "label3"; + // + // columnExtTestSpecTextBox + // + this.columnExtTestSpecTextBox.Location = new System.Drawing.Point(326, 51); + this.columnExtTestSpecTextBox.Name = "columnExtTestSpecTextBox"; + this.columnExtTestSpecTextBox.Size = new System.Drawing.Size(61, 20); + this.columnExtTestSpecTextBox.TabIndex = 6; + // + // rowExtTestSpecTextBox + // + this.rowExtTestSpecTextBox.Location = new System.Drawing.Point(326, 52); + this.rowExtTestSpecTextBox.Name = "rowExtTestSpecTextBox"; + this.rowExtTestSpecTextBox.Size = new System.Drawing.Size(61, 20); + this.rowExtTestSpecTextBox.TabIndex = 5; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(242, 55); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(35, 13); + this.label4.TabIndex = 4; + this.label4.Text = "label4"; + // + // rowsExtComboBox + // + this.rowsExtComboBox.FormattingEnabled = true; + this.rowsExtComboBox.Location = new System.Drawing.Point(32, 52); + this.rowsExtComboBox.Name = "rowsExtComboBox"; + this.rowsExtComboBox.Size = new System.Drawing.Size(185, 21); + this.rowsExtComboBox.TabIndex = 3; + // + // StatisticsOptionsDlg + // + this.AcceptButton = this.okButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelButton; + this.ClientSize = new System.Drawing.Size(503, 307); + this.Controls.Add(this.columnsGroupBox); + this.Controls.Add(this.twoDimCheckBox); + this.Controls.Add(this.rowsGroupBox); + this.Controls.Add(this.cancelButton); + this.Controls.Add(this.okButton); + this.Name = "StatisticsOptionsDlg"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "StatisticsOptionsDlg"; + this.Load += new System.EventHandler(this.StatisticsOptionsDlg_Load); + this.rowsGroupBox.ResumeLayout(false); + this.rowsGroupBox.PerformLayout(); + this.columnsGroupBox.ResumeLayout(false); + this.columnsGroupBox.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -185,5 +245,11 @@ private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox columnTestSpecTextBox; private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox columnExtTestSpecTextBox; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ComboBox columnsExtComboBox; + private System.Windows.Forms.TextBox rowExtTestSpecTextBox; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.ComboBox rowsExtComboBox; } } \ No newline at end of file diff --git a/ResultsBrowser/Forms/StatisticsOptionsDlg.cs b/ResultsBrowser/Forms/StatisticsOptionsDlg.cs index 76aa24ea2..9b822efa2 100644 --- a/ResultsBrowser/Forms/StatisticsOptionsDlg.cs +++ b/ResultsBrowser/Forms/StatisticsOptionsDlg.cs @@ -16,9 +16,13 @@ namespace ResultsBrowser.Forms public bool TwoDim; public Results.WMeterRsltItemSpec RowItem; + public Results.WMeterRsltItemSpec RowItemExt; public Results.WMeterRsltItemSpec ColumnItem; - public string RowTestSpecifier; - public string ColumnTestSpecifier; + public Results.WMeterRsltItemSpec ColumnItemExt; + public string RowTestSpecifier; + public string RowExtTestSpecifier; + public string ColumnTestSpecifier; + public string ColumnExtTestSpecifier; public StatisticsOptionsDlg(IList items) { @@ -34,16 +38,22 @@ namespace ResultsBrowser.Forms columnsComboBox.Enabled = twoDimCheckBox.Checked = TwoDim = Program.LocalSettings.TwoDim; rowsComboBox.Text = Program.LocalSettings.RowItemCaption; + rowsExtComboBox.Text = Program.LocalSettings.RowExtItemCaption; columnsComboBox.Text = Program.LocalSettings.ColumnItemCaption; + columnsExtComboBox.Text = Program.LocalSettings.ColumnExtItemCaption; /// foreach (var item in items) { rowsComboBox.Items.Add(item.Caption); - columnsComboBox.Items.Add(item.Caption); + rowsExtComboBox.Items.Add(item.Caption); + columnsComboBox.Items.Add(item.Caption); + columnsExtComboBox.Items.Add(item.Caption); } rowTestSpecTextBox.Text = RowTestSpecifier = Program.LocalSettings.RowTestSpecifier; + rowExtTestSpecTextBox.Text = RowExtTestSpecifier = Program.LocalSettings.RowExtTestSpecifier; columnTestSpecTextBox.Text = ColumnTestSpecifier = Program.LocalSettings.ColumnTestSpecifier; + columnExtTestSpecTextBox.Text = ColumnExtTestSpecifier = Program.LocalSettings.ColumnExtTestSpecifier; } void Localize() @@ -55,7 +65,9 @@ namespace ResultsBrowser.Forms columnsGroupBox.Text = Strings.Columns; label1.Text = Strings.Test; label2.Text = Strings.Test; - } + label3.Text = Strings.Test; + label4.Text = Strings.Test; + } private void twoDimCheckBox_CheckedChanged(object sender, EventArgs e) { @@ -66,22 +78,21 @@ namespace ResultsBrowser.Forms { TwoDim = twoDimCheckBox.Checked; RowTestSpecifier = rowTestSpecTextBox.Text; - ColumnTestSpecifier = columnTestSpecTextBox.Text; + RowExtTestSpecifier = rowExtTestSpecTextBox.Text; + ColumnTestSpecifier = columnTestSpecTextBox.Text; + ColumnExtTestSpecifier = columnExtTestSpecTextBox.Text; RowItem = null; + RowItemExt = null; ColumnItem = null; + ColumnItemExt = null; foreach (var item in items) { - if (rowsComboBox.Text.Equals(item.Caption)) - { - RowItem = item; - } - - if (TwoDim && columnsComboBox.Text.Equals(item.Caption)) - { - ColumnItem = item; - } + if (!string.IsNullOrEmpty(rowsComboBox.Text) && rowsComboBox.Text.Equals(item.Caption)) RowItem = item; + if (!string.IsNullOrEmpty(rowsExtComboBox.Text) && rowsExtComboBox.Text.Equals(item.Caption)) RowItemExt = item; + if (!string.IsNullOrEmpty(columnsComboBox.Text) && TwoDim && columnsComboBox.Text.Equals(item.Caption)) ColumnItem = item; + if (!string.IsNullOrEmpty(columnsExtComboBox.Text) && TwoDim && columnsExtComboBox.Text.Equals(item.Caption)) ColumnItemExt = item; } @@ -93,9 +104,13 @@ namespace ResultsBrowser.Forms Program.LocalSettings.TwoDim = TwoDim; Program.LocalSettings.RowItemCaption = RowItem.Caption; + Program.LocalSettings.RowExtItemCaption = (RowItemExt != null) ? RowItemExt.Caption : string.Empty; Program.LocalSettings.ColumnItemCaption = (ColumnItem != null) ? ColumnItem.Caption : string.Empty; + Program.LocalSettings.ColumnExtItemCaption = (ColumnItemExt != null) ? ColumnItemExt.Caption : string.Empty; Program.LocalSettings.RowTestSpecifier = RowTestSpecifier; - Program.LocalSettings.ColumnTestSpecifier = ColumnTestSpecifier; + Program.LocalSettings.RowExtTestSpecifier = RowExtTestSpecifier; + Program.LocalSettings.ColumnTestSpecifier = ColumnTestSpecifier; + Program.LocalSettings.ColumnExtTestSpecifier = ColumnExtTestSpecifier; Program.LocalSettings.Save(); DialogResult = DialogResult.OK; diff --git a/ResultsBrowser/LocalSettings.cs b/ResultsBrowser/LocalSettings.cs index 06935a2a6..2e0675c6f 100644 --- a/ResultsBrowser/LocalSettings.cs +++ b/ResultsBrowser/LocalSettings.cs @@ -40,9 +40,13 @@ namespace ResultsBrowser /// Statistics options public bool TwoDim; public string RowItemCaption; + public string RowExtItemCaption; public string ColumnItemCaption; + public string ColumnExtItemCaption; public string RowTestSpecifier; - public string ColumnTestSpecifier; + public string RowExtTestSpecifier; + public string ColumnTestSpecifier; + public string ColumnExtTestSpecifier; public bool FilterPurchaseOrder; diff --git a/ResultsBrowser/Output/Printers/QueryResults/QueryResultsPrintDocument.cs b/ResultsBrowser/Output/Printers/QueryResults/QueryResultsPrintDocument.cs new file mode 100644 index 000000000..9abf1a810 --- /dev/null +++ b/ResultsBrowser/Output/Printers/QueryResults/QueryResultsPrintDocument.cs @@ -0,0 +1,386 @@ +/// +/// 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; + 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; + + /// + /// Property variable for the Font the user wishes to use + /// + Font font; + Font boldFont; + Font fontTitle; + + /// + /// Constructor + /// + /// Text to be printed + 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); + } + + /// + /// Override the default onbeginPrint method of the PrintDocument Object. + /// + /// + /// + 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); } + } + + /// + /// Override the default OnPrintPage method of the PrintDocument. + /// + /// + /// This provides the print logic for our document + 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.AmbientTempAve().ToString("F1") + " \x00b0C"); + lineNr++; + PrintAt(e, Tab1, lineNr * SpacingOne, "Feuchtigkeit"); + PrintAt(e, Tab2, lineNr * SpacingOne, wm.Batch.AmbientHumiAve().ToString("F0") + " %"); + lineNr++; + PrintAt(e, Tab1, lineNr * SpacingOne, "Luftdruck"); + PrintAt(e, Tab2, lineNr * SpacingOne, wm.Batch.AmbientPressAve().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"); + } + + /// + /// Print table texts. + /// + 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++; + } + } + } + + /// + /// Draw table lines. + /// + 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); + } + } +} diff --git a/ResultsBrowser/Output/Printers/Statistics/StatisticsPrintDocument.cs b/ResultsBrowser/Output/Printers/Statistics/StatisticsPrintDocument.cs new file mode 100644 index 000000000..5cb934c32 --- /dev/null +++ b/ResultsBrowser/Output/Printers/Statistics/StatisticsPrintDocument.cs @@ -0,0 +1,275 @@ +/// +/// 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.Statistics +{ + public class StatisticsPrintDocument : 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 IList rowValues; + readonly IList columnValues; + readonly int[,] occurances; + readonly int columnsCount; + + /// Top coordinate of the table + int top; + + /// + /// Property variable for the Font the user wishes to use + /// + Font font; + Font boldFont; + Font fontTitle; + + /// + /// Constructor + /// + /// Text to be printed + public StatisticsPrintDocument(string docVersion, + IList rowValues, IList columnValues, int[,] occurances, + PageOrientation pageOrientation) + { + this.docVersion = docVersion; + this.rowValues = rowValues; + this.columnValues = columnValues; + this.occurances = occurances; + columnsCount = Math.Max(1, columnValues.Count); + + DefaultPageSettings.Landscape = (pageOrientation == PageOrientation.Landscape); + } + + /// + /// Override the default onbeginPrint method of the PrintDocument Object. + /// + /// + /// + 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); } + } + + /// + /// Override the default OnPrintPage method of the PrintDocument. + /// + /// + /// This provides the print logic for our document + 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("ABCDEF", 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; + + PrintAt(e, Tab1, lineNr * SpacingOne, "Hersteller :"); + PrintAt(e, Tab2, lineNr * SpacingOne, wm.Producer()); + lineNr++; + + PrintAt(e, Tab1, lineNr * SpacingOne, "Seriennummer :"); + PrintAt(e, Tab2, lineNr * SpacingOne, wm.SerialNr); + lineNr++; + + PrintAt(e, Tab1, lineNr * SpacingOne, "Qn :"); + PrintAt(e, Tab2, lineNr * SpacingOne, wm.Q3_Qn().ToString()); + lineNr++; + + PrintAt(e, Tab1, lineNr * SpacingOne, "Zulassungszeichen :"); + PrintAt(e, Tab2, lineNr * SpacingOne, wm.ApprovalInfo()); + lineNr++; + + PrintAt(e, Tab1, lineNr * SpacingOne, "Metr. klasse :"); + PrintAt(e, Tab2, lineNr * SpacingOne, wm.MetrologicalClass()); + lineNr++; + + PrintAt(e, Tab1, lineNr * SpacingOne, "Stand :"); + PrintAt(e, Tab2, lineNr * SpacingOne, wm.EndState); + + lineNr += 2; + top = SpacingOne * lineNr; +*/ + PrintTable(e); + DrawTable(e); + } + + /// + /// Print table texts. + /// + 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, 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) + { + 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++; + } +*/ + } + + /// + /// Draw table lines. + /// + void DrawTable(System.Drawing.Printing.PrintPageEventArgs e) + { + int mid = top + SpacingOneAndHalf; + int bot = top + (rowValues.Count + 1) * SpacingOneAndHalf; + + // 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)); + + // 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)); + } + + 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; + + if (parNr < 0) x = 80 + MarginLeft; /// When parNr == -1 return the left column x coordinate + + return new Point(x, y); + } + } +} diff --git a/ResultsBrowser/Properties/AssemblyInfo.cs b/ResultsBrowser/Properties/AssemblyInfo.cs index 270a3b353..fd31ef3f3 100644 --- a/ResultsBrowser/Properties/AssemblyInfo.cs +++ b/ResultsBrowser/Properties/AssemblyInfo.cs @@ -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.12.389.0")] -[assembly: AssemblyFileVersion("2.12.389.0")] +[assembly: AssemblyVersion("2.12.390.0")] +[assembly: AssemblyFileVersion("2.12.390.0")] diff --git a/ResultsBrowser/ResultsBrowser.csproj b/ResultsBrowser/ResultsBrowser.csproj index 69a913883..f630c7a34 100644 --- a/ResultsBrowser/ResultsBrowser.csproj +++ b/ResultsBrowser/ResultsBrowser.csproj @@ -144,6 +144,12 @@ StatisticsOptionsDlg.cs + + Component + + + Component + @@ -231,9 +237,7 @@ Results - - - +