diff --git a/Results/WMeterRsltItemSpec.cs b/Results/WMeterRsltItemSpec.cs
index 3b230ae45..46efc9c3e 100644
--- a/Results/WMeterRsltItemSpec.cs
+++ b/Results/WMeterRsltItemSpec.cs
@@ -136,7 +136,7 @@ namespace Results
AllItems.Add(new WMeterRsltItemSpec(29, "Volume", Strings.Volume_l + "()", (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : Config.Units.ConvertTo(u, w.GetMeterTestRslt(t).VolumeMeter).ToString(string.IsNullOrEmpty(p) ? "F3" : p)));
AllItems.Add(new WMeterRsltItemSpec(30, "Reference volume", Strings.VolRef_l + "()", (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : Config.Units.ConvertTo(u, w.GetMeterTestRslt(t).VolumeRef).ToString(string.IsNullOrEmpty(p) ? "F3" : p)));
#if IPERLST || IPERLST_SPECIAL
- AllItems.Add(new WMeterRsltItemSpec(31, "Error", "Error()", (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "0" : Config.Units.ConvertTo(u, w.GetMeterTestRslt(t).Error).ToString(string.IsNullOrEmpty(p) ? "F2" : p)));
+ AllItems.Add(new WMeterRsltItemSpec(31, "Error", Strings.Error_pct + "()", (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "0" : Config.Units.ConvertTo(u, w.GetMeterTestRslt(t).Error).ToString(string.IsNullOrEmpty(p) ? "F2" : p)));
#else
AllItems.Add(new WMeterRsltItemSpec(31, "Error", Strings.Error_pct + "()", (w, t, u, f, p) => (w.GetMeterTestRslt(t) == null) ? "" : Config.Units.ConvertTo(u, w.GetMeterTestRslt(t).Error).ToString(string.IsNullOrEmpty(p) ? "F2" : p)));
#endif
diff --git a/ResultsBrowser/FiltersConfig.cs b/ResultsBrowser/FiltersConfig.cs
index d504d3ec7..65013654f 100644
--- a/ResultsBrowser/FiltersConfig.cs
+++ b/ResultsBrowser/FiltersConfig.cs
@@ -2,9 +2,12 @@
/// Copyright (c) 2016 Sensus Metering Systems
///
using System;
+using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.Serialization;
+using System.Windows.Forms;
+using ResultsBrowser.Resources;
namespace ResultsBrowser
{
@@ -22,6 +25,13 @@ namespace ResultsBrowser
public int FiltersCount { get { return Math.Min((FilterID != null) ? FilterID.Length : 0,
(FilterData != null) ? FilterData.Length : 0); } }
+ public string[] ResultItems;
+
+ [XmlArrayAttribute("ResultsClmnWidths")]
+ public int[] ResultsClmnWidths;
+ [XmlIgnore]
+ public int ResultsClmnCount { get { return (ResultsClmnWidths != null) ? ResultsClmnWidths.Length : 0; } }
+
public FiltersConfig()
{
@@ -57,10 +67,42 @@ namespace ResultsBrowser
}
}
+ ///
+ /// Updates public arrays FilterID[] and FilterData[] of this serializable class.
+ ///
+ ///
+ ///
+ public bool UpdateFromFilters(IList filters)
+ {
+ try
+ {
+ int cnt = filters.Count;
+ FilterID = new string[cnt];
+ FilterData = new string[cnt];
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < cnt; i++)
+ {
+ FilterID[i] = filters[i].GetThisFilterID();
+ filters[i].UI2Data();
+ sb.Clear();
+ filters[i].Save(sb);
+ FilterData[i] = sb.ToString();
+ }
+
+ return true; /// All OK
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show(exc.Message, Strings.Error_serializing_filters, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+ return false;
+ }
+ }
+
///
/// Save public fields of this class to the XML file.
///
- public void Save(string fileName)
+ public bool Save(string fileName)
{
try
{
@@ -68,10 +110,12 @@ namespace ResultsBrowser
{
(new XmlSerializer(typeof(FiltersConfig))).Serialize(writer, this);
}
+ return true;
}
- catch (Exception e)
+ catch (Exception exc)
{
- string msg = e.Message;
+ MessageBox.Show(exc.Message, Strings.Error_saving_file, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+ return false;
}
}
}
diff --git a/ResultsBrowser/Forms/AddFilterDlg.Designer.cs b/ResultsBrowser/Forms/AddFilterDlg.Designer.cs
index b3d5b89ba..f20ae0167 100644
--- a/ResultsBrowser/Forms/AddFilterDlg.Designer.cs
+++ b/ResultsBrowser/Forms/AddFilterDlg.Designer.cs
@@ -85,6 +85,7 @@
this.Controls.Add(this.label1);
this.Controls.Add(this.availFiltersListBox);
this.Name = "AddFilterDlg";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Select a filter";
this.Load += new System.EventHandler(this.AddFilterDlg_Load);
this.ResumeLayout(false);
diff --git a/ResultsBrowser/Forms/DatabaseSettingsDlg.Designer.cs b/ResultsBrowser/Forms/DatabaseSettingsDlg.Designer.cs
index 4360f6d83..0fec74ada 100644
--- a/ResultsBrowser/Forms/DatabaseSettingsDlg.Designer.cs
+++ b/ResultsBrowser/Forms/DatabaseSettingsDlg.Designer.cs
@@ -159,6 +159,7 @@
this.Controls.Add(this.benchNameLabel);
this.Controls.Add(this.connectionStringTextBox1);
this.Name = "DatabaseSettingsDlg";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Database Settings";
this.Load += new System.EventHandler(this.DatabaseSettings_Load);
this.ResumeLayout(false);
diff --git a/ResultsBrowser/Forms/StatisticsOptionsDlg.Designer.cs b/ResultsBrowser/Forms/StatisticsOptionsDlg.Designer.cs
index e22c432cf..c59f90876 100644
--- a/ResultsBrowser/Forms/StatisticsOptionsDlg.Designer.cs
+++ b/ResultsBrowser/Forms/StatisticsOptionsDlg.Designer.cs
@@ -160,6 +160,7 @@
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);
diff --git a/ResultsBrowser/LocalSettings.cs b/ResultsBrowser/LocalSettings.cs
index a284d208b..d716f055a 100644
--- a/ResultsBrowser/LocalSettings.cs
+++ b/ResultsBrowser/LocalSettings.cs
@@ -38,7 +38,6 @@ namespace ResultsBrowser
public bool Bench2Selected;
public bool Bench3Selected;
-
public bool TwoDim;
public int RowItemID;
public int ColumnItemID;
diff --git a/ResultsBrowser/Program.cs b/ResultsBrowser/Program.cs
index cabb4f3a2..1ab346a4a 100644
--- a/ResultsBrowser/Program.cs
+++ b/ResultsBrowser/Program.cs
@@ -139,7 +139,7 @@ namespace ResultsBrowser
{
/// Open the main application window
log.Info("Creating the main window");
-#if IPERLST || IPERLST_SPECIAL
+#if false //IPERLST || IPERLST_SPECIAL
MainWnd = new MainWnd();
log.Info("Opening the main window");
Application.Run(MainWnd);
diff --git a/ResultsBrowser/Resources/Strings.de.resx b/ResultsBrowser/Resources/Strings.de.resx
index 13f2e6699..c2487292e 100644
--- a/ResultsBrowser/Resources/Strings.de.resx
+++ b/ResultsBrowser/Resources/Strings.de.resx
@@ -222,4 +222,13 @@
Wasserzähler
+
+ Fehler beim Anzeigen der Ergebnisse
+
+
+ Fehler beim Speichern der Datei
+
+
+ Fehler Serialisierung Filter
+
\ No newline at end of file
diff --git a/ResultsBrowser/Resources/Strings.resx b/ResultsBrowser/Resources/Strings.resx
index 41a3bfaae..eeee5c99b 100644
--- a/ResultsBrowser/Resources/Strings.resx
+++ b/ResultsBrowser/Resources/Strings.resx
@@ -765,4 +765,19 @@
Select a filter
+
+ Error displaying results
+
+
+ All files
+
+
+ Error saving file
+
+
+ Error serializing filters
+
+
+ Query files
+
\ No newline at end of file
diff --git a/ResultsBrowser/Resources/Strings1.Designer.cs b/ResultsBrowser/Resources/Strings1.Designer.cs
index 32b90e179..b6b91ea8e 100644
--- a/ResultsBrowser/Resources/Strings1.Designer.cs
+++ b/ResultsBrowser/Resources/Strings1.Designer.cs
@@ -150,6 +150,15 @@ namespace ResultsBrowser.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to All files.
+ ///
+ internal static string All_files {
+ get {
+ return ResourceManager.GetString("All_files", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Ambient humidity: .
///
@@ -978,6 +987,15 @@ namespace ResultsBrowser.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Error displaying results.
+ ///
+ internal static string Error_displaying_results {
+ get {
+ return ResourceManager.GetString("Error_displaying_results", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Error loading users from the database:.
///
@@ -996,6 +1014,24 @@ namespace ResultsBrowser.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Error saving file.
+ ///
+ internal static string Error_saving_file {
+ get {
+ return ResourceManager.GetString("Error_saving_file", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Error serializing filters.
+ ///
+ internal static string Error_serializing_filters {
+ get {
+ return ResourceManager.GetString("Error_serializing_filters", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Error while creating the database. Reason: .
///
@@ -1725,6 +1761,15 @@ namespace ResultsBrowser.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Query files.
+ ///
+ internal static string Query_files {
+ get {
+ return ResourceManager.GetString("Query_files", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Query results.
///
diff --git a/ResultsBrowser/ResultsBrowserWnd.Designer.cs b/ResultsBrowser/ResultsBrowserWnd.Designer.cs
index 5f753b7ae..2c04e8295 100644
--- a/ResultsBrowser/ResultsBrowserWnd.Designer.cs
+++ b/ResultsBrowser/ResultsBrowserWnd.Designer.cs
@@ -33,7 +33,6 @@
this.filtersGroupBox = new System.Windows.Forms.GroupBox();
this.filtersFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.resultsGroupBox = new System.Windows.Forms.GroupBox();
- this.resultsListBox = new System.Windows.Forms.ListBox();
this.statisticsBtn = new System.Windows.Forms.Button();
this.printQueryResultsBtn = new System.Windows.Forms.Button();
this.exportQueryResultsBtn = new System.Windows.Forms.Button();
@@ -48,6 +47,7 @@
this.checkBox3 = new System.Windows.Forms.RadioButton();
this.checkBox2 = new System.Windows.Forms.RadioButton();
this.checkBox1 = new System.Windows.Forms.RadioButton();
+ this.resultsListView = new System.Windows.Forms.ListView();
((System.ComponentModel.ISupportInitialize)(this.vSplitContainer)).BeginInit();
this.vSplitContainer.Panel1.SuspendLayout();
this.vSplitContainer.Panel2.SuspendLayout();
@@ -130,7 +130,7 @@
//
// resultsGroupBox
//
- this.resultsGroupBox.Controls.Add(this.resultsListBox);
+ this.resultsGroupBox.Controls.Add(this.resultsListView);
this.resultsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.resultsGroupBox.Location = new System.Drawing.Point(0, 0);
this.resultsGroupBox.Name = "resultsGroupBox";
@@ -139,15 +139,6 @@
this.resultsGroupBox.TabStop = false;
this.resultsGroupBox.Text = "Query results";
//
- // resultsListBox
- //
- this.resultsListBox.Dock = System.Windows.Forms.DockStyle.Fill;
- this.resultsListBox.FormattingEnabled = true;
- this.resultsListBox.Location = new System.Drawing.Point(3, 16);
- this.resultsListBox.Name = "resultsListBox";
- this.resultsListBox.Size = new System.Drawing.Size(834, 409);
- this.resultsListBox.TabIndex = 0;
- //
// statisticsBtn
//
this.statisticsBtn.Location = new System.Drawing.Point(8, 521);
@@ -296,6 +287,16 @@
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
+ // resultsListView
+ //
+ this.resultsListView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.resultsListView.Location = new System.Drawing.Point(3, 16);
+ this.resultsListView.Name = "resultsListView";
+ this.resultsListView.Size = new System.Drawing.Size(834, 409);
+ this.resultsListView.TabIndex = 0;
+ this.resultsListView.UseCompatibleStateImageBehavior = false;
+ this.resultsListView.View = System.Windows.Forms.View.Details;
+ //
// ResultsBrowserWnd
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -326,7 +327,6 @@
private System.Windows.Forms.SplitContainer vSplitContainer;
private System.Windows.Forms.SplitContainer hSplitContainer;
private System.Windows.Forms.FlowLayoutPanel filtersFlowLayoutPanel;
- private System.Windows.Forms.ListBox resultsListBox;
private System.Windows.Forms.GroupBox testBenchesGroupBox;
private System.Windows.Forms.Button saveFiltersBtn;
private System.Windows.Forms.Button loadFiltersBtn;
@@ -343,5 +343,6 @@
private System.Windows.Forms.Button formatOfResultsBtn;
private System.Windows.Forms.Button printQueryResultsBtn;
private System.Windows.Forms.Button statisticsBtn;
+ private System.Windows.Forms.ListView resultsListView;
}
}
\ No newline at end of file
diff --git a/ResultsBrowser/ResultsBrowserWnd.cs b/ResultsBrowser/ResultsBrowserWnd.cs
index 243693586..6eac13a1e 100644
--- a/ResultsBrowser/ResultsBrowserWnd.cs
+++ b/ResultsBrowser/ResultsBrowserWnd.cs
@@ -15,7 +15,8 @@ namespace ResultsBrowser
{
public partial class ResultsBrowserWnd : Form
{
- IList filters;
+ IList filters; /// Filters and the UI of filters
+ FiltersConfig filtersConfig; /// Serializable configuration of filters and displayed results
IList waterMeters;
@@ -23,6 +24,7 @@ namespace ResultsBrowser
{
InitializeComponent();
filters = new List();
+ filtersConfig = new FiltersConfig();
}
private void ResultsBrowserWnd_Load(object sender, EventArgs e)
@@ -104,50 +106,49 @@ namespace ResultsBrowser
private void loadFiltersBtn_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
+ dlg.Filter = string.Format("{0} (*.qry)|*.qry|{1} (*.*)|*.*", Strings.Query_files, Strings.All_files);
if (dlg.ShowDialog() == DialogResult.OK)
{
- FiltersConfig filtersConfig = FiltersConfig.Load(dlg.FileName);
+ FiltersConfig localFiltersConfig = FiltersConfig.Load(dlg.FileName);
+ if (localFiltersConfig != null)
+ {
+ filtersConfig = localFiltersConfig;
- filters.Clear();
- filtersFlowLayoutPanel.Controls.Clear();
- ///
- for (int i = 0; i < filtersConfig.FiltersCount; i++)
- {
- Filters.IFilter filter = Factory.LoadFilter(filtersConfig.FilterID[i], filtersConfig.FilterData[i]);
- filters.Add(filter);
- filtersFlowLayoutPanel.Controls.Add(filter.GetFilterUI());
- }
+ filters.Clear();
+ filtersFlowLayoutPanel.Controls.Clear();
+ ///
+ for (int i = 0; i < filtersConfig.FiltersCount; i++)
+ {
+ Filters.IFilter filter = Factory.LoadFilter(filtersConfig.FilterID[i], filtersConfig.FilterData[i]);
+ filters.Add(filter);
+ filtersFlowLayoutPanel.Controls.Add(filter.GetFilterUI());
+ }
+ }
}
}
private void saveFiltersBtn_Click(object sender, EventArgs e)
{
- StringBuilder sb = new StringBuilder();
+ if (filtersConfig.UpdateFromFilters(filters)) /// filtersConfig members related to filters
+ {
+ /// Save column widths of the ListView into filtersConfig members
+ if (resultsListView.Columns.Count > 0)
+ {
+ filtersConfig.ResultsClmnWidths = new int[resultsListView.Columns.Count];
+ for (int i = 0; i < resultsListView.Columns.Count; i++)
+ {
+ filtersConfig.ResultsClmnWidths[i] = resultsListView.Columns[i].Width;
+ }
+ }
- FiltersConfig filtersConfig = new FiltersConfig(filters.Count);
-
- try
- {
- for (int i = 0; i < filters.Count; i++)
- {
- filtersConfig.FilterID[i] = filters[i].GetThisFilterID();
- sb.Clear();
- filters[i].UI2Data();
- filters[i].Save(sb);
- filtersConfig.FilterData[i] = sb.ToString();
- }
- }
- catch (Exception exc)
- {
- MessageBox.Show(exc.Message, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
-
- SaveFileDialog dlg = new SaveFileDialog();
- if (dlg.ShowDialog() == DialogResult.OK)
- {
- filtersConfig.Save(dlg.FileName);
- }
+ /// Save the file
+ SaveFileDialog dlg = new SaveFileDialog();
+ dlg.Filter = string.Format("{0} (*.qry)|*.qry|{1} (*.*)|*.*", Strings.Query_files, Strings.All_files);
+ if (dlg.ShowDialog() == DialogResult.OK)
+ {
+ filtersConfig.Save(dlg.FileName);
+ }
+ }
}
private void executeQueryBtn_Click(object sender, EventArgs e)
@@ -171,21 +172,62 @@ namespace ResultsBrowser
waterMeters2 = filter.ExecuteQuery(sessions, waterMeters);
waterMeters = waterMeters2;
}
-
- resultsListBox.Items.Clear();
-
- foreach (var wm in waterMeters) resultsListBox.Items.Add(wm.ToString());
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
+
+ RedrawResults();
+ }
+
+ ///
+ /// Displays obtained results as configured by result items in the ListView
+ ///
+ void RedrawResults()
+ {
+ IList items = Results.WMeterRsltItemSpec.FromStrArray(filtersConfig.ResultItems);
+
+ resultsListView.Clear();
+ if (waterMeters == null || waterMeters.Count == 0 || items.Count == 0) return;
+
+ try
+ {
+ for (int i = 0; i < items.Count; i++)
+ {
+ resultsListView.Columns.Add(items[i].Caption, (filtersConfig.ResultsClmnCount > i) ? filtersConfig.ResultsClmnWidths[i] : 70);
+ }
+ foreach (var wm in waterMeters)
+ {
+ ListViewItem lvi = null;
+ foreach (var item in items)
+ {
+ if (lvi == null) lvi = new ListViewItem(item.Print(wm));
+ else lvi.SubItems.Add(item.Print(wm));
+ }
+ if (lvi != null) resultsListView.Items.Add(lvi);
+ }
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show(exc.Message, Strings.Error_displaying_results, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+ }
}
private void formatOfResultsBtn_Click(object sender, EventArgs e)
{
+ Results.Forms.ResultsConfigDlg dlg = new Results.Forms.ResultsConfigDlg();
+ dlg.Compound = false; /// config.Factory.ClassName.Contains("Compound");
+ dlg.SelectedItems = Results.WMeterRsltItemSpec.FromStrArray(filtersConfig.ResultItems);
+ dlg.AvailableItems = new List();
+ foreach (var v in Results.WMeterRsltItemSpec.AllItems) dlg.AvailableItems.Add(v);
+ if (dlg.ShowDialog() == DialogResult.OK)
+ {
+ filtersConfig.ResultItems = Results.WMeterRsltItemSpec.ToStrArray(dlg.SelectedItems);
+ RedrawResults();
+ }
}
private void exportQueryResultsBtn_Click(object sender, EventArgs e)