ResultsBrowser: Serialization works fine.

This commit is contained in:
Milan Hanajik 2016-06-02 20:35:04 +02:00
parent b0137f9384
commit ebffe9b1cb
23 changed files with 403 additions and 285 deletions

View File

@ -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;
}
/// <summary>
/// Save public fields of this class to the XML string.
/// </summary>
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;
}
}
}
}
}

View File

@ -1,6 +1,6 @@
namespace ResultsBrowser.Filters
{
partial class DateFilter
partial class DateFilterUI
{
/// <summary>
/// Required designer variable.

View File

@ -0,0 +1,43 @@
using System.Windows.Forms;
namespace ResultsBrowser.Filters
{
public partial class DateFilterUI : UserControl
{
DateFilter data;
/// <summary> Used only by Designer </summary>
public DateFilterUI()
{
InitializeComponent();
Localize();
}
/// <summary> Used to create the control aby a filter </summary>
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;
}
}
}

View File

@ -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;
}
}

View File

@ -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
}
}

View File

@ -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;
}
/// <summary>
/// Save public fields of this class to the XML string.
/// </summary>
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;
}
}
}
}
}

View File

@ -1,6 +1,6 @@
namespace ResultsBrowser.Filters
{
partial class ProcedureFilter
partial class ProcedureFilterUI
{
/// <summary>
/// Required designer variable.

View File

@ -0,0 +1,39 @@
using System.Windows.Forms;
namespace ResultsBrowser.Filters
{
public partial class ProcedureFilterUI : UserControl
{
ProcedureFilter data;
/// <summary> Used only by Designer </summary>
public ProcedureFilterUI()
{
InitializeComponent();
Localize();
}
/// <summary> Used to create the control aby a filter </summary>
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;
}
}
}

View File

@ -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;
}
/// <summary>
/// Save public fields of this class to the XML string.
/// </summary>
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;
}
}
}
}

View File

@ -1,6 +1,6 @@
namespace ResultsBrowser.Filters
{
partial class SerialNrFilter
partial class SerialNrFilterUI
{
/// <summary>
/// Required designer variable.

View File

@ -0,0 +1,39 @@
using System.Windows.Forms;
namespace ResultsBrowser.Filters
{
public partial class SerialNrFilterUI : UserControl
{
SerialNrFilter data;
/// <summary> Used only by Designer </summary>
public SerialNrFilterUI()
{
InitializeComponent();
Localize();
}
/// <summary> Used to create the control aby a filter </summary>
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;
}
}
}

View File

@ -13,42 +13,39 @@ namespace ResultsBrowser
/// Public members are filters / parts of a query.
/// </summary>
[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];
}
}
/// <summary>
/// Load public fields of this class from the XML file.
/// </summary>
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)

View File

@ -1,6 +1,6 @@
namespace ResultsBrowser.Forms
{
partial class DatabaseSettings
partial class DatabaseSettingsDlg
{
/// <summary>
/// Required designer variable.

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -73,25 +73,28 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Filters\DateFilter.cs">
<Compile Include="Filters\DateFilterUI.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Filters\DateFilter.Designer.cs">
<DependentUpon>DateFilter.cs</DependentUpon>
<Compile Include="Filters\DateFilterUI.Designer.cs">
<DependentUpon>DateFilterUI.cs</DependentUpon>
</Compile>
<Compile Include="Filters\DateFilter.cs" />
<Compile Include="Filters\Factory.cs" />
<Compile Include="Filters\IFilter.cs" />
<Compile Include="Filters\ProcedureFilter.cs">
<Compile Include="Filters\ProcedureFilter.cs" />
<Compile Include="Filters\ProcedureFilterUI.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Filters\ProcedureFilter.Designer.cs">
<DependentUpon>ProcedureFilter.cs</DependentUpon>
<Compile Include="Filters\ProcedureFilterUI.Designer.cs">
<DependentUpon>ProcedureFilterUI.cs</DependentUpon>
</Compile>
<Compile Include="Filters\SerialNrFilter.cs">
<Compile Include="Filters\SerialNrFilter.cs" />
<Compile Include="Filters\SerialNrFilterUI.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Filters\SerialNrFilter.Designer.cs">
<DependentUpon>SerialNrFilter.cs</DependentUpon>
<Compile Include="Filters\SerialNrFilterUI.Designer.cs">
<DependentUpon>SerialNrFilterUI.cs</DependentUpon>
</Compile>
<Compile Include="Forms\AddFilterDlg.cs">
<SubType>Form</SubType>
@ -99,11 +102,11 @@
<Compile Include="Forms\AddFilterDlg.Designer.cs">
<DependentUpon>AddFilterDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\DatabaseSettings.cs">
<Compile Include="Forms\DatabaseSettingsDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\DatabaseSettings.Designer.cs">
<DependentUpon>DatabaseSettings.cs</DependentUpon>
<Compile Include="Forms\DatabaseSettingsDlg.Designer.cs">
<DependentUpon>DatabaseSettingsDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\NoBenchOrDatabaseDlg.cs">
<SubType>Form</SubType>
@ -126,7 +129,7 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QueryFilters.cs" />
<Compile Include="FiltersConfig.cs" />
<Compile Include="RBrowserWnd.cs">
<SubType>Form</SubType>
</Compile>
@ -140,20 +143,20 @@
<Compile Include="ResultsBrowserWnd.Designer.cs">
<DependentUpon>ResultsBrowserWnd.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Filters\DateFilter.resx">
<DependentUpon>DateFilter.cs</DependentUpon>
<EmbeddedResource Include="Filters\DateFilterUI.resx">
<DependentUpon>DateFilterUI.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Filters\ProcedureFilter.resx">
<DependentUpon>ProcedureFilter.cs</DependentUpon>
<EmbeddedResource Include="Filters\ProcedureFilterUI.resx">
<DependentUpon>ProcedureFilterUI.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Filters\SerialNrFilter.resx">
<DependentUpon>SerialNrFilter.cs</DependentUpon>
<EmbeddedResource Include="Filters\SerialNrFilterUI.resx">
<DependentUpon>SerialNrFilterUI.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\AddFilterDlg.resx">
<DependentUpon>AddFilterDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\DatabaseSettings.resx">
<DependentUpon>DatabaseSettings.cs</DependentUpon>
<EmbeddedResource Include="Forms\DatabaseSettingsDlg.resx">
<DependentUpon>DatabaseSettingsDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\NoBenchOrDatabaseDlg.resx">
<DependentUpon>NoBenchOrDatabaseDlg.cs</DependentUpon>

View File

@ -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;
}
}

View File

@ -13,25 +13,50 @@ namespace ResultsBrowser
{
public partial class ResultsBrowserWnd : Form
{
QueryFilters queryFilters;
IList<IFilter> filters;
public ResultsBrowserWnd()
{
InitializeComponent();
filters = new List<IFilter>();
}
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)
{
}