diff --git a/ResultsBrowser/Filters/DateFilter.cs b/ResultsBrowser/Filters/DateFilter.cs index 41f717489..500aa1806 100644 --- a/ResultsBrowser/Filters/DateFilter.cs +++ b/ResultsBrowser/Filters/DateFilter.cs @@ -1,60 +1,38 @@ using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using System.Windows.Forms; using System.Xml.Serialization; namespace ResultsBrowser.Filters { - public partial class DateFilter : UserControl, IFilter + public class DateFilter : IFilter { - public static string GetFilterName() { return "Date"; } - public string GetThisFilterName() { return "Date"; } + public static string GetFilterName() { return "Date"; } - public DateTime From; - public DateTime To; + /// + /// Obligatory wrappers + /// + public string GetThisFilterName() { return GetFilterName(); } + public void Save(StringBuilder sb) { (new XmlSerializer(this.GetType())).Serialize(new StringWriter(sb), this); } + public void Data2UI() { userIface.Data2UI(); } + public void UI2Data() { userIface.UI2Data(); } + public UserControl GetFilterUI() { return userIface as UserControl; } + + /// + /// Serialized filter data + /// + public DateTime From; + public DateTime To; + + + private DateFilterUI userIface; public DateFilter() { - InitializeComponent(); - Localize(); + userIface = new DateFilterUI(this); } - - void Localize() - { - groupBox1.Text = "Date"; - fromLabel.Text = "From"; - toLabel.Text = "To"; - } - - public void Data2UI() - { - fromDateTimePicker.Value = From; - toDateTimePicker.Value = To; - } - - public void UI2Data() - { - From = fromDateTimePicker.Value; - To = toDateTimePicker.Value; - } - - /// - /// Save public fields of this class to the XML string. - /// - public void Save(StringBuilder sb) - { - try - { - using (TextWriter writer = new StringWriter(sb)) - { - (new XmlSerializer(typeof(DateFilter))).Serialize(writer, this); - } - } - catch (Exception e) - { - string msg = e.Message; - } - } } -} +} \ No newline at end of file diff --git a/ResultsBrowser/Filters/DateFilter.Designer.cs b/ResultsBrowser/Filters/DateFilterUI.Designer.cs similarity index 99% rename from ResultsBrowser/Filters/DateFilter.Designer.cs rename to ResultsBrowser/Filters/DateFilterUI.Designer.cs index bcc6d0ec5..959ad7116 100644 --- a/ResultsBrowser/Filters/DateFilter.Designer.cs +++ b/ResultsBrowser/Filters/DateFilterUI.Designer.cs @@ -1,6 +1,6 @@ namespace ResultsBrowser.Filters { - partial class DateFilter + partial class DateFilterUI { /// /// Required designer variable. diff --git a/ResultsBrowser/Filters/DateFilterUI.cs b/ResultsBrowser/Filters/DateFilterUI.cs new file mode 100644 index 000000000..db440885a --- /dev/null +++ b/ResultsBrowser/Filters/DateFilterUI.cs @@ -0,0 +1,43 @@ +using System.Windows.Forms; + +namespace ResultsBrowser.Filters +{ + public partial class DateFilterUI : UserControl + { + DateFilter data; + + /// Used only by Designer + public DateFilterUI() + { + InitializeComponent(); + Localize(); + } + + /// Used to create the control aby a filter + public DateFilterUI(DateFilter data) + { + this.data = data; + InitializeComponent(); + Localize(); + } + + void Localize() + { + groupBox1.Text = "Date"; + fromLabel.Text = "From"; + toLabel.Text = "To"; + } + + public void Data2UI() + { + fromDateTimePicker.Value = data.From; + toDateTimePicker.Value = data.To; + } + + public void UI2Data() + { + data.From = fromDateTimePicker.Value; + data.To = toDateTimePicker.Value; + } + } +} diff --git a/ResultsBrowser/Filters/DateFilter.resx b/ResultsBrowser/Filters/DateFilterUI.resx similarity index 100% rename from ResultsBrowser/Filters/DateFilter.resx rename to ResultsBrowser/Filters/DateFilterUI.resx diff --git a/ResultsBrowser/Filters/Factory.cs b/ResultsBrowser/Filters/Factory.cs index 7178dc4cf..17fe36ef6 100644 --- a/ResultsBrowser/Filters/Factory.cs +++ b/ResultsBrowser/Filters/Factory.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Text; +using System.Windows.Forms; using System.Xml.Serialization; namespace ResultsBrowser.Filters @@ -33,27 +34,24 @@ namespace ResultsBrowser.Filters } - public static IFilter LoadFilter(string filterName, string serialized) + public static IFilter LoadFilter(string filterName, string serializedText) { - Type filterType; - - if (filterName == DateFilter.GetFilterName()) filterType = Type.GetType("DateFilter"); - else if (filterName == ProcedureFilter.GetFilterName()) filterType = Type.GetType("ProcedureFilter"); - else if (filterName == SerialNrFilter.GetFilterName()) filterType = Type.GetType("SerialNrFilter"); - else return null; - try { - using (TextReader reader = new StringReader(serialized)) - { - IFilter filter = (new XmlSerializer(filterType)).Deserialize(reader) as IFilter; - filter.Data2UI(); - return filter; - } + Type type; + if (filterName == DateFilter.GetFilterName()) type = typeof(DateFilter); + else if (filterName == ProcedureFilter.GetFilterName()) type = typeof(ProcedureFilter); + else if (filterName == SerialNrFilter.GetFilterName()) type = typeof(SerialNrFilter); + else return null; + + IFilter filter = (new XmlSerializer(type)).Deserialize(new StringReader(serializedText)) as IFilter; + filter.Data2UI(); + return filter; } catch (Exception e) { string msg = e.Message; + MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return null; } } diff --git a/ResultsBrowser/Filters/IFilter.cs b/ResultsBrowser/Filters/IFilter.cs index 6e99d5a46..62e63dd72 100644 --- a/ResultsBrowser/Filters/IFilter.cs +++ b/ResultsBrowser/Filters/IFilter.cs @@ -2,14 +2,20 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Windows.Forms; namespace ResultsBrowser.Filters { public interface IFilter { - string GetThisFilterName(); - void Data2UI(); - void UI2Data(); /// Throws an exception with appropriate message if UI data are invalid - void Save(StringBuilder sb); - } + string GetThisFilterName(); /// Returns string identifying filter type + + void Save(StringBuilder sb); /// Saves filter parameters into a string + + void Data2UI(); + + void UI2Data(); /// Throws an exception with appropriate message if UI data are invalid + + UserControl GetFilterUI(); /// Returns filter's UI control to be added to the FlowLayoutPanel + } } diff --git a/ResultsBrowser/Filters/ProcedureFilter.cs b/ResultsBrowser/Filters/ProcedureFilter.cs index fa7c42e44..b4a244dd6 100644 --- a/ResultsBrowser/Filters/ProcedureFilter.cs +++ b/ResultsBrowser/Filters/ProcedureFilter.cs @@ -1,55 +1,37 @@ using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using System.Windows.Forms; using System.Xml.Serialization; namespace ResultsBrowser.Filters { - public partial class ProcedureFilter : UserControl, IFilter + public class ProcedureFilter : IFilter { - public static string GetFilterName() { return "Procedure"; } - public string GetThisFilterName() { return "Procedure"; } + public static string GetFilterName() { return "Procedure"; } - public string Procedure; + /// + /// Obligatory wrappers + /// + public string GetThisFilterName() { return GetFilterName(); } + public void Save(StringBuilder sb) { (new XmlSerializer(this.GetType())).Serialize(new StringWriter(sb), this); } + public void Data2UI() { userIface.Data2UI(); } + public void UI2Data() { userIface.UI2Data(); } + public UserControl GetFilterUI() { return userIface as UserControl; } + + /// + /// Serialized filter data + /// + public string Procedure; + + + private ProcedureFilterUI userIface; public ProcedureFilter() { - InitializeComponent(); - Localize(); + userIface = new ProcedureFilterUI(this); } - - void Localize() - { - groupBox1.Text = "Procedure"; - } - - public void Data2UI() - { - procedureTextBox.Text = (Procedure != null) ? Procedure : string.Empty; - } - - public void UI2Data() - { - Procedure = procedureTextBox.Text; - } - - /// - /// Save public fields of this class to the XML string. - /// - public void Save(StringBuilder sb) - { - try - { - using (TextWriter writer = new StringWriter(sb)) - { - (new XmlSerializer(typeof(ProcedureFilter))).Serialize(writer, this); - } - } - catch (Exception e) - { - string msg = e.Message; - } - } - } + } } diff --git a/ResultsBrowser/Filters/ProcedureFilter.Designer.cs b/ResultsBrowser/Filters/ProcedureFilterUI.Designer.cs similarity index 98% rename from ResultsBrowser/Filters/ProcedureFilter.Designer.cs rename to ResultsBrowser/Filters/ProcedureFilterUI.Designer.cs index c2f180de4..33811547a 100644 --- a/ResultsBrowser/Filters/ProcedureFilter.Designer.cs +++ b/ResultsBrowser/Filters/ProcedureFilterUI.Designer.cs @@ -1,6 +1,6 @@ namespace ResultsBrowser.Filters { - partial class ProcedureFilter + partial class ProcedureFilterUI { /// /// Required designer variable. diff --git a/ResultsBrowser/Filters/ProcedureFilterUI.cs b/ResultsBrowser/Filters/ProcedureFilterUI.cs new file mode 100644 index 000000000..c20ef64f5 --- /dev/null +++ b/ResultsBrowser/Filters/ProcedureFilterUI.cs @@ -0,0 +1,39 @@ +using System.Windows.Forms; + +namespace ResultsBrowser.Filters +{ + public partial class ProcedureFilterUI : UserControl + { + ProcedureFilter data; + + /// Used only by Designer + public ProcedureFilterUI() + { + InitializeComponent(); + Localize(); + } + + /// Used to create the control aby a filter + public ProcedureFilterUI(ProcedureFilter data) + { + this.data = data; + InitializeComponent(); + Localize(); + } + + void Localize() + { + groupBox1.Text = "Procedure"; + } + + public void Data2UI() + { + procedureTextBox.Text = (data.Procedure != null) ? data.Procedure : string.Empty; + } + + public void UI2Data() + { + data.Procedure = procedureTextBox.Text; + } + } +} diff --git a/ResultsBrowser/Filters/ProcedureFilter.resx b/ResultsBrowser/Filters/ProcedureFilterUI.resx similarity index 100% rename from ResultsBrowser/Filters/ProcedureFilter.resx rename to ResultsBrowser/Filters/ProcedureFilterUI.resx diff --git a/ResultsBrowser/Filters/SerialNrFilter.cs b/ResultsBrowser/Filters/SerialNrFilter.cs index 3282b9cdb..2f4f2f24f 100644 --- a/ResultsBrowser/Filters/SerialNrFilter.cs +++ b/ResultsBrowser/Filters/SerialNrFilter.cs @@ -1,56 +1,37 @@ using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using System.Windows.Forms; using System.Xml.Serialization; namespace ResultsBrowser.Filters { - public partial class SerialNrFilter : UserControl, IFilter + public class SerialNrFilter : IFilter { - public static string GetFilterName() { return "SerialNr"; } - public string GetThisFilterName() { return "SerialNr"; } + public static string GetFilterName() { return "SerialNr"; } - public string SerialNr; + /// + /// Obligatory wrappers + /// + public string GetThisFilterName() { return GetFilterName(); } + public void Save(StringBuilder sb) { (new XmlSerializer(this.GetType())).Serialize(new StringWriter(sb), this); } + public void Data2UI() { userIface.Data2UI(); } + public void UI2Data() { userIface.UI2Data(); } + public UserControl GetFilterUI() { return userIface as UserControl; } + + /// + /// Serialized filter data + /// + public string SerialNr; + + + private SerialNrFilterUI userIface; public SerialNrFilter() { - InitializeComponent(); - Localize(); + userIface = new SerialNrFilterUI(this); } - - void Localize() - { - groupBox1.Text = "Serial number"; - } - - - public void Data2UI() - { - serialNrTextBox.Text = (SerialNr != null) ? SerialNr : string.Empty; - } - - public void UI2Data() - { - SerialNr = serialNrTextBox.Text; - } - - /// - /// Save public fields of this class to the XML string. - /// - public void Save(StringBuilder sb) - { - try - { - using (TextWriter writer = new StringWriter(sb)) - { - (new XmlSerializer(typeof(SerialNrFilter))).Serialize(writer, this); - } - } - catch (Exception e) - { - string msg = e.Message; - } - } } } diff --git a/ResultsBrowser/Filters/SerialNrFilter.Designer.cs b/ResultsBrowser/Filters/SerialNrFilterUI.Designer.cs similarity index 98% rename from ResultsBrowser/Filters/SerialNrFilter.Designer.cs rename to ResultsBrowser/Filters/SerialNrFilterUI.Designer.cs index a8edec376..06c98f1fb 100644 --- a/ResultsBrowser/Filters/SerialNrFilter.Designer.cs +++ b/ResultsBrowser/Filters/SerialNrFilterUI.Designer.cs @@ -1,6 +1,6 @@ namespace ResultsBrowser.Filters { - partial class SerialNrFilter + partial class SerialNrFilterUI { /// /// Required designer variable. diff --git a/ResultsBrowser/Filters/SerialNrFilterUI.cs b/ResultsBrowser/Filters/SerialNrFilterUI.cs new file mode 100644 index 000000000..d075cce95 --- /dev/null +++ b/ResultsBrowser/Filters/SerialNrFilterUI.cs @@ -0,0 +1,39 @@ +using System.Windows.Forms; + +namespace ResultsBrowser.Filters +{ + public partial class SerialNrFilterUI : UserControl + { + SerialNrFilter data; + + /// Used only by Designer + public SerialNrFilterUI() + { + InitializeComponent(); + Localize(); + } + + /// Used to create the control aby a filter + public SerialNrFilterUI(SerialNrFilter data) + { + this.data = data; + InitializeComponent(); + Localize(); + } + + void Localize() + { + groupBox1.Text = "Serial number"; + } + + public void Data2UI() + { + serialNrTextBox.Text = (data.SerialNr != null) ? data.SerialNr : string.Empty; + } + + public void UI2Data() + { + data.SerialNr = serialNrTextBox.Text; + } + } +} diff --git a/ResultsBrowser/Filters/SerialNrFilter.resx b/ResultsBrowser/Filters/SerialNrFilterUI.resx similarity index 100% rename from ResultsBrowser/Filters/SerialNrFilter.resx rename to ResultsBrowser/Filters/SerialNrFilterUI.resx diff --git a/ResultsBrowser/QueryFilters.cs b/ResultsBrowser/FiltersConfig.cs similarity index 64% rename from ResultsBrowser/QueryFilters.cs rename to ResultsBrowser/FiltersConfig.cs index c1fcdffbb..685930cc1 100644 --- a/ResultsBrowser/QueryFilters.cs +++ b/ResultsBrowser/FiltersConfig.cs @@ -13,42 +13,39 @@ namespace ResultsBrowser /// Public members are filters / parts of a query. /// [XmlRootAttribute("Query")] - public class QueryFilters + public class FiltersConfig { - public string[] FilterNames; + public string[] FilterName; + public string[] FilterData; [XmlIgnore] - public int FilterNamesCount { get { return (FilterNames != null) ? FilterNames.Length : 0; } } - - public string[] FilterSettings; - - [XmlIgnore] - public int FilterSettingsCount { get { return (FilterSettings != null) ? FilterSettings.Length : 0; } } + public int FiltersCount { get { return Math.Min((FilterName != null) ? FilterName.Length : 0, + (FilterData != null) ? FilterData.Length : 0); } } - public QueryFilters() + public FiltersConfig() { } - public QueryFilters(int count) + public FiltersConfig(int count) { if (count > 0) { - FilterNames = new string[count]; - FilterSettings = new string[count]; + FilterName = new string[count]; + FilterData = new string[count]; } } /// /// Load public fields of this class from the XML file. /// - public static QueryFilters Load(string fileName) + public static FiltersConfig Load(string fileName) { try { using (TextReader reader = new StreamReader(fileName)) { - QueryFilters ls = (new XmlSerializer(typeof(QueryFilters))).Deserialize(reader) as QueryFilters; + FiltersConfig ls = (new XmlSerializer(typeof(FiltersConfig))).Deserialize(reader) as FiltersConfig; // Copy the settings just in case De-serialize() completes OK return ls; } @@ -69,7 +66,7 @@ namespace ResultsBrowser { using (TextWriter writer = new StreamWriter(fileName)) { - (new XmlSerializer(typeof(QueryFilters))).Serialize(writer, this); + (new XmlSerializer(typeof(FiltersConfig))).Serialize(writer, this); } } catch (Exception e) diff --git a/ResultsBrowser/Forms/DatabaseSettings.Designer.cs b/ResultsBrowser/Forms/DatabaseSettingsDlg.Designer.cs similarity index 99% rename from ResultsBrowser/Forms/DatabaseSettings.Designer.cs rename to ResultsBrowser/Forms/DatabaseSettingsDlg.Designer.cs index eb572005a..84fb81adc 100644 --- a/ResultsBrowser/Forms/DatabaseSettings.Designer.cs +++ b/ResultsBrowser/Forms/DatabaseSettingsDlg.Designer.cs @@ -1,6 +1,6 @@ namespace ResultsBrowser.Forms { - partial class DatabaseSettings + partial class DatabaseSettingsDlg { /// /// Required designer variable. diff --git a/ResultsBrowser/Forms/DatabaseSettings.cs b/ResultsBrowser/Forms/DatabaseSettingsDlg.cs similarity index 95% rename from ResultsBrowser/Forms/DatabaseSettings.cs rename to ResultsBrowser/Forms/DatabaseSettingsDlg.cs index 3155e4372..e1c88d431 100644 --- a/ResultsBrowser/Forms/DatabaseSettings.cs +++ b/ResultsBrowser/Forms/DatabaseSettingsDlg.cs @@ -9,9 +9,9 @@ using System.Windows.Forms; namespace ResultsBrowser.Forms { - public partial class DatabaseSettings : Form + public partial class DatabaseSettingsDlg : Form { - public DatabaseSettings() + public DatabaseSettingsDlg() { InitializeComponent(); } @@ -23,6 +23,7 @@ namespace ResultsBrowser.Forms benchNameTextBox1.Text = Program.LocalSettings.Bench1; benchNameTextBox2.Text = Program.LocalSettings.Bench2; benchNameTextBox3.Text = Program.LocalSettings.Bench3; + connectionStringTextBox1.Text = Program.LocalSettings.ConnectionString1; connectionStringTextBox2.Text = Program.LocalSettings.ConnectionString2; connectionStringTextBox3.Text = Program.LocalSettings.ConnectionString3; diff --git a/ResultsBrowser/Forms/DatabaseSettings.resx b/ResultsBrowser/Forms/DatabaseSettingsDlg.resx similarity index 100% rename from ResultsBrowser/Forms/DatabaseSettings.resx rename to ResultsBrowser/Forms/DatabaseSettingsDlg.resx diff --git a/ResultsBrowser/MainWnd.cs b/ResultsBrowser/MainWnd.cs index 4aa36f81a..6b48952dd 100644 --- a/ResultsBrowser/MainWnd.cs +++ b/ResultsBrowser/MainWnd.cs @@ -421,7 +421,7 @@ namespace ResultsBrowser private void configButton_Click(object sender, EventArgs e) { - if ((new Forms.DatabaseSettings()).ShowDialog() == DialogResult.OK) + if ((new Forms.DatabaseSettingsDlg()).ShowDialog() == DialogResult.OK) { Results.DB.ConnectionString = Program.LocalSettings.ConnectionString1; } diff --git a/ResultsBrowser/RBrowserWnd.cs b/ResultsBrowser/RBrowserWnd.cs index 57cfdc8ca..718022abb 100644 --- a/ResultsBrowser/RBrowserWnd.cs +++ b/ResultsBrowser/RBrowserWnd.cs @@ -418,7 +418,7 @@ namespace ResultsBrowser private void configButton_Click(object sender, EventArgs e) { - if ((new Forms.DatabaseSettings()).ShowDialog() == DialogResult.OK) + if ((new Forms.DatabaseSettingsDlg()).ShowDialog() == DialogResult.OK) { Results.DB.ConnectionString = Program.LocalSettings.ConnectionString1; radioButton1.Text = Program.LocalSettings.Bench1; diff --git a/ResultsBrowser/ResultsBrowser.csproj b/ResultsBrowser/ResultsBrowser.csproj index ef8951c03..a24b1e058 100644 --- a/ResultsBrowser/ResultsBrowser.csproj +++ b/ResultsBrowser/ResultsBrowser.csproj @@ -73,25 +73,28 @@ - + UserControl - - DateFilter.cs + + DateFilterUI.cs + - + + UserControl - - ProcedureFilter.cs + + ProcedureFilterUI.cs - + + UserControl - - SerialNrFilter.cs + + SerialNrFilterUI.cs Form @@ -99,11 +102,11 @@ AddFilterDlg.cs - + Form - - DatabaseSettings.cs + + DatabaseSettingsDlg.cs Form @@ -126,7 +129,7 @@ - + Form @@ -140,20 +143,20 @@ ResultsBrowserWnd.cs - - DateFilter.cs + + DateFilterUI.cs - - ProcedureFilter.cs + + ProcedureFilterUI.cs - - SerialNrFilter.cs + + SerialNrFilterUI.cs AddFilterDlg.cs - - DatabaseSettings.cs + + DatabaseSettingsDlg.cs NoBenchOrDatabaseDlg.cs diff --git a/ResultsBrowser/ResultsBrowserWnd.Designer.cs b/ResultsBrowser/ResultsBrowserWnd.Designer.cs index b437049a2..7711bb354 100644 --- a/ResultsBrowser/ResultsBrowserWnd.Designer.cs +++ b/ResultsBrowser/ResultsBrowserWnd.Designer.cs @@ -30,17 +30,19 @@ { this.vSplitContainer = new System.Windows.Forms.SplitContainer(); this.hSplitContainer = new System.Windows.Forms.SplitContainer(); + this.filtersGroupBox = new System.Windows.Forms.GroupBox(); this.filtersFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); - this.listBox1 = new System.Windows.Forms.ListBox(); + this.resultsGroupBox = new System.Windows.Forms.GroupBox(); + this.resultsListBox = new System.Windows.Forms.ListBox(); this.settingsBtn = new System.Windows.Forms.Button(); this.saveQueryBtn = new System.Windows.Forms.Button(); this.loadQueryBtn = new System.Windows.Forms.Button(); - this.execQueryBtn = new System.Windows.Forms.Button(); + this.executeQueryBtn = new System.Windows.Forms.Button(); this.addFilterBtn = new System.Windows.Forms.Button(); - this.benchesGroupBox = new System.Windows.Forms.GroupBox(); - this.radioButton2 = new System.Windows.Forms.RadioButton(); - this.radioButton3 = new System.Windows.Forms.RadioButton(); - this.radioButton1 = new System.Windows.Forms.RadioButton(); + this.testBenchesGroupBox = new System.Windows.Forms.GroupBox(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.checkBox3 = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.vSplitContainer)).BeginInit(); this.vSplitContainer.Panel1.SuspendLayout(); this.vSplitContainer.Panel2.SuspendLayout(); @@ -49,7 +51,9 @@ this.hSplitContainer.Panel1.SuspendLayout(); this.hSplitContainer.Panel2.SuspendLayout(); this.hSplitContainer.SuspendLayout(); - this.benchesGroupBox.SuspendLayout(); + this.filtersGroupBox.SuspendLayout(); + this.resultsGroupBox.SuspendLayout(); + this.testBenchesGroupBox.SuspendLayout(); this.SuspendLayout(); // // vSplitContainer @@ -69,9 +73,9 @@ this.vSplitContainer.Panel2.Controls.Add(this.settingsBtn); this.vSplitContainer.Panel2.Controls.Add(this.saveQueryBtn); this.vSplitContainer.Panel2.Controls.Add(this.loadQueryBtn); - this.vSplitContainer.Panel2.Controls.Add(this.execQueryBtn); + this.vSplitContainer.Panel2.Controls.Add(this.executeQueryBtn); this.vSplitContainer.Panel2.Controls.Add(this.addFilterBtn); - this.vSplitContainer.Panel2.Controls.Add(this.benchesGroupBox); + this.vSplitContainer.Panel2.Controls.Add(this.testBenchesGroupBox); this.vSplitContainer.Panel2MinSize = 100; this.vSplitContainer.Size = new System.Drawing.Size(984, 712); this.vSplitContainer.SplitterDistance = 840; @@ -86,31 +90,53 @@ // // hSplitContainer.Panel1 // - this.hSplitContainer.Panel1.Controls.Add(this.filtersFlowLayoutPanel); + this.hSplitContainer.Panel1.Controls.Add(this.filtersGroupBox); // // hSplitContainer.Panel2 // - this.hSplitContainer.Panel2.Controls.Add(this.listBox1); + this.hSplitContainer.Panel2.Controls.Add(this.resultsGroupBox); this.hSplitContainer.Size = new System.Drawing.Size(840, 712); this.hSplitContainer.SplitterDistance = 280; this.hSplitContainer.TabIndex = 0; // + // filtersGroupBox + // + this.filtersGroupBox.Controls.Add(this.filtersFlowLayoutPanel); + this.filtersGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.filtersGroupBox.Location = new System.Drawing.Point(0, 0); + this.filtersGroupBox.Name = "filtersGroupBox"; + this.filtersGroupBox.Size = new System.Drawing.Size(840, 280); + this.filtersGroupBox.TabIndex = 1; + this.filtersGroupBox.TabStop = false; + this.filtersGroupBox.Text = "Filters"; + // // filtersFlowLayoutPanel // this.filtersFlowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.filtersFlowLayoutPanel.Location = new System.Drawing.Point(0, 0); + this.filtersFlowLayoutPanel.Location = new System.Drawing.Point(3, 16); this.filtersFlowLayoutPanel.Name = "filtersFlowLayoutPanel"; - this.filtersFlowLayoutPanel.Size = new System.Drawing.Size(840, 280); + this.filtersFlowLayoutPanel.Size = new System.Drawing.Size(834, 261); this.filtersFlowLayoutPanel.TabIndex = 0; // - // listBox1 + // resultsGroupBox // - this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.listBox1.FormattingEnabled = true; - this.listBox1.Location = new System.Drawing.Point(0, 0); - this.listBox1.Name = "listBox1"; - this.listBox1.Size = new System.Drawing.Size(840, 428); - this.listBox1.TabIndex = 0; + this.resultsGroupBox.Controls.Add(this.resultsListBox); + this.resultsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.resultsGroupBox.Location = new System.Drawing.Point(0, 0); + this.resultsGroupBox.Name = "resultsGroupBox"; + this.resultsGroupBox.Size = new System.Drawing.Size(840, 428); + this.resultsGroupBox.TabIndex = 1; + 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; // // settingsBtn // @@ -142,15 +168,15 @@ this.loadQueryBtn.UseVisualStyleBackColor = true; this.loadQueryBtn.Click += new System.EventHandler(this.loadQueryBtn_Click); // - // execQueryBtn + // executeQueryBtn // - this.execQueryBtn.Location = new System.Drawing.Point(8, 280); - this.execQueryBtn.Name = "execQueryBtn"; - this.execQueryBtn.Size = new System.Drawing.Size(125, 33); - this.execQueryBtn.TabIndex = 5; - this.execQueryBtn.Text = "Execute query"; - this.execQueryBtn.UseVisualStyleBackColor = true; - this.execQueryBtn.Click += new System.EventHandler(this.execQueryBtn_Click); + this.executeQueryBtn.Location = new System.Drawing.Point(8, 280); + this.executeQueryBtn.Name = "executeQueryBtn"; + this.executeQueryBtn.Size = new System.Drawing.Size(125, 33); + this.executeQueryBtn.TabIndex = 5; + this.executeQueryBtn.Text = "Execute query"; + this.executeQueryBtn.UseVisualStyleBackColor = true; + this.executeQueryBtn.Click += new System.EventHandler(this.executeQueryBtn_Click); // // addFilterBtn // @@ -162,53 +188,47 @@ this.addFilterBtn.UseVisualStyleBackColor = true; this.addFilterBtn.Click += new System.EventHandler(this.addFilterBtn_Click); // - // benchesGroupBox + // testBenchesGroupBox // - this.benchesGroupBox.Controls.Add(this.radioButton2); - this.benchesGroupBox.Controls.Add(this.radioButton3); - this.benchesGroupBox.Controls.Add(this.radioButton1); - this.benchesGroupBox.Location = new System.Drawing.Point(8, 173); - this.benchesGroupBox.Name = "benchesGroupBox"; - this.benchesGroupBox.Size = new System.Drawing.Size(125, 99); - this.benchesGroupBox.TabIndex = 4; - this.benchesGroupBox.TabStop = false; - this.benchesGroupBox.Text = "Test benches"; + this.testBenchesGroupBox.Controls.Add(this.checkBox3); + this.testBenchesGroupBox.Controls.Add(this.checkBox2); + this.testBenchesGroupBox.Controls.Add(this.checkBox1); + this.testBenchesGroupBox.Location = new System.Drawing.Point(8, 173); + this.testBenchesGroupBox.Name = "testBenchesGroupBox"; + this.testBenchesGroupBox.Size = new System.Drawing.Size(125, 99); + this.testBenchesGroupBox.TabIndex = 4; + this.testBenchesGroupBox.TabStop = false; + this.testBenchesGroupBox.Text = "Test benches"; // - // radioButton2 + // checkBox1 // - this.radioButton2.AutoSize = true; - this.radioButton2.Location = new System.Drawing.Point(15, 44); - this.radioButton2.Name = "radioButton2"; - this.radioButton2.Size = new System.Drawing.Size(85, 17); - this.radioButton2.TabIndex = 1; - this.radioButton2.TabStop = true; - this.radioButton2.Text = "radioButton2"; - this.radioButton2.UseVisualStyleBackColor = true; - this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged); + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(20, 24); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(80, 17); + this.checkBox1.TabIndex = 0; + this.checkBox1.Text = "checkBox1"; + this.checkBox1.UseVisualStyleBackColor = true; // - // radioButton3 + // checkBox2 // - this.radioButton3.AutoSize = true; - this.radioButton3.Location = new System.Drawing.Point(15, 67); - this.radioButton3.Name = "radioButton3"; - this.radioButton3.Size = new System.Drawing.Size(85, 17); - this.radioButton3.TabIndex = 2; - this.radioButton3.TabStop = true; - this.radioButton3.Text = "radioButton3"; - this.radioButton3.UseVisualStyleBackColor = true; - this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged); + this.checkBox2.AutoSize = true; + this.checkBox2.Location = new System.Drawing.Point(20, 47); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(80, 17); + this.checkBox2.TabIndex = 1; + this.checkBox2.Text = "checkBox2"; + this.checkBox2.UseVisualStyleBackColor = true; // - // radioButton1 + // checkBox3 // - this.radioButton1.AutoSize = true; - this.radioButton1.Location = new System.Drawing.Point(15, 21); - this.radioButton1.Name = "radioButton1"; - this.radioButton1.Size = new System.Drawing.Size(85, 17); - this.radioButton1.TabIndex = 0; - this.radioButton1.TabStop = true; - this.radioButton1.Text = "radioButton1"; - this.radioButton1.UseVisualStyleBackColor = true; - this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); + this.checkBox3.AutoSize = true; + this.checkBox3.Location = new System.Drawing.Point(20, 70); + this.checkBox3.Name = "checkBox3"; + this.checkBox3.Size = new System.Drawing.Size(80, 17); + this.checkBox3.TabIndex = 2; + this.checkBox3.Text = "checkBox3"; + this.checkBox3.UseVisualStyleBackColor = true; // // ResultsBrowserWnd // @@ -217,7 +237,7 @@ this.ClientSize = new System.Drawing.Size(984, 712); this.Controls.Add(this.vSplitContainer); this.Name = "ResultsBrowserWnd"; - this.Text = "ResultsBrowserWnd"; + this.Text = "Results Browser"; this.Load += new System.EventHandler(this.ResultsBrowserWnd_Load); this.vSplitContainer.Panel1.ResumeLayout(false); this.vSplitContainer.Panel2.ResumeLayout(false); @@ -227,8 +247,10 @@ this.hSplitContainer.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.hSplitContainer)).EndInit(); this.hSplitContainer.ResumeLayout(false); - this.benchesGroupBox.ResumeLayout(false); - this.benchesGroupBox.PerformLayout(); + this.filtersGroupBox.ResumeLayout(false); + this.resultsGroupBox.ResumeLayout(false); + this.testBenchesGroupBox.ResumeLayout(false); + this.testBenchesGroupBox.PerformLayout(); this.ResumeLayout(false); } @@ -238,15 +260,17 @@ private System.Windows.Forms.SplitContainer vSplitContainer; private System.Windows.Forms.SplitContainer hSplitContainer; private System.Windows.Forms.FlowLayoutPanel filtersFlowLayoutPanel; - private System.Windows.Forms.ListBox listBox1; - private System.Windows.Forms.GroupBox benchesGroupBox; - private System.Windows.Forms.RadioButton radioButton3; - private System.Windows.Forms.RadioButton radioButton2; - private System.Windows.Forms.RadioButton radioButton1; + private System.Windows.Forms.ListBox resultsListBox; + private System.Windows.Forms.GroupBox testBenchesGroupBox; private System.Windows.Forms.Button saveQueryBtn; private System.Windows.Forms.Button loadQueryBtn; - private System.Windows.Forms.Button execQueryBtn; + private System.Windows.Forms.Button executeQueryBtn; private System.Windows.Forms.Button addFilterBtn; private System.Windows.Forms.Button settingsBtn; + private System.Windows.Forms.GroupBox filtersGroupBox; + private System.Windows.Forms.GroupBox resultsGroupBox; + private System.Windows.Forms.CheckBox checkBox3; + private System.Windows.Forms.CheckBox checkBox2; + private System.Windows.Forms.CheckBox checkBox1; } } \ No newline at end of file diff --git a/ResultsBrowser/ResultsBrowserWnd.cs b/ResultsBrowser/ResultsBrowserWnd.cs index 3b2ba5fb9..35746f9af 100644 --- a/ResultsBrowser/ResultsBrowserWnd.cs +++ b/ResultsBrowser/ResultsBrowserWnd.cs @@ -13,25 +13,50 @@ namespace ResultsBrowser { public partial class ResultsBrowserWnd : Form { - QueryFilters queryFilters; + IList filters; public ResultsBrowserWnd() { InitializeComponent(); + filters = new List(); } private void ResultsBrowserWnd_Load(object sender, EventArgs e) { Localize(); + RedrawTestBenches(); + } + + void RedrawTestBenches() + { + checkBox1.Text = Program.LocalSettings.Bench1; + checkBox2.Text = Program.LocalSettings.Bench2; + checkBox3.Text = Program.LocalSettings.Bench3; + + checkBox1.Visible = !string.IsNullOrEmpty(checkBox1.Text); + checkBox2.Visible = !string.IsNullOrEmpty(checkBox2.Text); + checkBox3.Visible = !string.IsNullOrEmpty(checkBox3.Text); } void Localize() { + Text = "Results Browser"; /// or Statistics + filtersGroupBox.Text = "Filters"; + resultsGroupBox.Text = "Query results"; + settingsBtn.Text = "Settings"; + addFilterBtn.Text = "Add filter"; + loadQueryBtn.Text = "Load query"; + saveQueryBtn.Text = "Save query"; + testBenchesGroupBox.Text = "Test benches"; + executeQueryBtn.Text = "Execute query"; } private void settingsBtn_Click(object sender, EventArgs e) { - + if (new Forms.DatabaseSettingsDlg().ShowDialog() == DialogResult.OK) + { + RedrawTestBenches(); + } } private void addFilterBtn_Click(object sender, EventArgs e) @@ -40,7 +65,8 @@ namespace ResultsBrowser if (dlg.ShowDialog() == DialogResult.OK && dlg.SelectedFilterName != null) { IFilter filter = Factory.GetFilter(dlg.SelectedFilterName); - filtersFlowLayoutPanel.Controls.Add(filter as UserControl); + filters.Add(filter); + filtersFlowLayoutPanel.Controls.Add(filter.GetFilterUI()); } } @@ -49,13 +75,16 @@ namespace ResultsBrowser OpenFileDialog dlg = new OpenFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { - QueryFilters queryFilters = QueryFilters.Load(dlg.FileName); + FiltersConfig filtersConfig = FiltersConfig.Load(dlg.FileName); + filters.Clear(); filtersFlowLayoutPanel.Controls.Clear(); - for (int i = 0; i < queryFilters.FilterNamesCount; i++) + /// + for (int i = 0; i < filtersConfig.FiltersCount; i++) { - IFilter filter = Factory.LoadFilter(queryFilters.FilterNames[i], queryFilters.FilterSettings[i]); - filtersFlowLayoutPanel.Controls.Add(filter as Control); + IFilter filter = Factory.LoadFilter(filtersConfig.FilterName[i], filtersConfig.FilterData[i]); + filters.Add(filter); + filtersFlowLayoutPanel.Controls.Add(filter.GetFilterUI()); } } } @@ -64,19 +93,17 @@ namespace ResultsBrowser { StringBuilder sb = new StringBuilder(); - int count = filtersFlowLayoutPanel.Controls.Count; - QueryFilters queryFilters = new QueryFilters(count); + FiltersConfig filtersConfig = new FiltersConfig(filters.Count); try { - for (int i = 0; i < count; i++) + for (int i = 0; i < filters.Count; i++) { - IFilter filter = (filtersFlowLayoutPanel.Controls[i] as IFilter); - queryFilters.FilterNames[i] = filter.GetThisFilterName(); + filtersConfig.FilterName[i] = filters[i].GetThisFilterName(); sb.Clear(); - filter.UI2Data(); - filter.Save(sb); - queryFilters.FilterSettings[i] = sb.ToString(); + filters[i].UI2Data(); + filters[i].Save(sb); + filtersConfig.FilterData[i] = sb.ToString(); } } catch (Exception exc) @@ -88,26 +115,26 @@ namespace ResultsBrowser SaveFileDialog dlg = new SaveFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { - queryFilters.Save(dlg.FileName); + filtersConfig.Save(dlg.FileName); } } - private void radioButton1_CheckedChanged(object sender, EventArgs e) + private void checkBox1_CheckedChanged(object sender, EventArgs e) { } - private void radioButton2_CheckedChanged(object sender, EventArgs e) + private void checkBox2_CheckedChanged(object sender, EventArgs e) { } - private void radioButton3_CheckedChanged(object sender, EventArgs e) + private void checkBox3_CheckedChanged(object sender, EventArgs e) { } - private void execQueryBtn_Click(object sender, EventArgs e) + private void executeQueryBtn_Click(object sender, EventArgs e) { }