ResultsBrowser: Serialization works fine.

This commit is contained in:
Milan Hanajik
2016-06-02 23:10:13 +02:00
parent b0137f9384
commit ebffe9b1cb
23 changed files with 403 additions and 285 deletions
+23 -45
View File
@@ -1,60 +1,38 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml.Serialization; using System.Xml.Serialization;
namespace ResultsBrowser.Filters namespace ResultsBrowser.Filters
{ {
public partial class DateFilter : UserControl, IFilter public class DateFilter : IFilter
{ {
public static string GetFilterName() { return "Date"; } public static string GetFilterName() { return "Date"; }
public string GetThisFilterName() { 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() public DateFilter()
{ {
InitializeComponent(); userIface = new DateFilterUI(this);
Localize();
} }
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;
}
}
} }
} }
@@ -1,6 +1,6 @@
namespace ResultsBrowser.Filters namespace ResultsBrowser.Filters
{ {
partial class DateFilter partial class DateFilterUI
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
+43
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;
}
}
}
+12 -14
View File
@@ -1,6 +1,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization; using System.Xml.Serialization;
namespace ResultsBrowser.Filters 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 try
{ {
using (TextReader reader = new StringReader(serialized)) Type type;
{ if (filterName == DateFilter.GetFilterName()) type = typeof(DateFilter);
IFilter filter = (new XmlSerializer(filterType)).Deserialize(reader) as IFilter; else if (filterName == ProcedureFilter.GetFilterName()) type = typeof(ProcedureFilter);
filter.Data2UI(); else if (filterName == SerialNrFilter.GetFilterName()) type = typeof(SerialNrFilter);
return filter; else return null;
}
IFilter filter = (new XmlSerializer(type)).Deserialize(new StringReader(serializedText)) as IFilter;
filter.Data2UI();
return filter;
} }
catch (Exception e) catch (Exception e)
{ {
string msg = e.Message; string msg = e.Message;
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return null; return null;
} }
} }
+11 -5
View File
@@ -2,14 +2,20 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms;
namespace ResultsBrowser.Filters namespace ResultsBrowser.Filters
{ {
public interface IFilter public interface IFilter
{ {
string GetThisFilterName(); string GetThisFilterName(); /// Returns string identifying filter type
void Data2UI();
void UI2Data(); /// Throws an exception with appropriate message if UI data are invalid void Save(StringBuilder sb); /// Saves filter parameters into a string
void Save(StringBuilder sb);
} 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
}
} }
+22 -40
View File
@@ -1,55 +1,37 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml.Serialization; using System.Xml.Serialization;
namespace ResultsBrowser.Filters namespace ResultsBrowser.Filters
{ {
public partial class ProcedureFilter : UserControl, IFilter public class ProcedureFilter : IFilter
{ {
public static string GetFilterName() { return "Procedure"; } public static string GetFilterName() { return "Procedure"; }
public string GetThisFilterName() { 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() public ProcedureFilter()
{ {
InitializeComponent(); userIface = new ProcedureFilterUI(this);
Localize();
} }
}
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;
}
}
}
} }
@@ -1,6 +1,6 @@
namespace ResultsBrowser.Filters namespace ResultsBrowser.Filters
{ {
partial class ProcedureFilter partial class ProcedureFilterUI
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -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;
}
}
}
+21 -40
View File
@@ -1,56 +1,37 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml.Serialization; using System.Xml.Serialization;
namespace ResultsBrowser.Filters namespace ResultsBrowser.Filters
{ {
public partial class SerialNrFilter : UserControl, IFilter public class SerialNrFilter : IFilter
{ {
public static string GetFilterName() { return "SerialNr"; } public static string GetFilterName() { return "SerialNr"; }
public string GetThisFilterName() { 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() public SerialNrFilter()
{ {
InitializeComponent(); userIface = new SerialNrFilterUI(this);
Localize();
} }
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;
}
}
} }
} }
@@ -1,6 +1,6 @@
namespace ResultsBrowser.Filters namespace ResultsBrowser.Filters
{ {
partial class SerialNrFilter partial class SerialNrFilterUI
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -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;
}
}
}
@@ -13,42 +13,39 @@ namespace ResultsBrowser
/// Public members are filters / parts of a query. /// Public members are filters / parts of a query.
/// </summary> /// </summary>
[XmlRootAttribute("Query")] [XmlRootAttribute("Query")]
public class QueryFilters public class FiltersConfig
{ {
public string[] FilterNames; public string[] FilterName;
public string[] FilterData;
[XmlIgnore] [XmlIgnore]
public int FilterNamesCount { get { return (FilterNames != null) ? FilterNames.Length : 0; } } public int FiltersCount { get { return Math.Min((FilterName != null) ? FilterName.Length : 0,
(FilterData != null) ? FilterData.Length : 0); } }
public string[] FilterSettings;
[XmlIgnore]
public int FilterSettingsCount { get { return (FilterSettings != null) ? FilterSettings.Length : 0; } }
public QueryFilters() public FiltersConfig()
{ {
} }
public QueryFilters(int count) public FiltersConfig(int count)
{ {
if (count > 0) if (count > 0)
{ {
FilterNames = new string[count]; FilterName = new string[count];
FilterSettings = new string[count]; FilterData = new string[count];
} }
} }
/// <summary> /// <summary>
/// Load public fields of this class from the XML file. /// Load public fields of this class from the XML file.
/// </summary> /// </summary>
public static QueryFilters Load(string fileName) public static FiltersConfig Load(string fileName)
{ {
try try
{ {
using (TextReader reader = new StreamReader(fileName)) 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 // Copy the settings just in case De-serialize() completes OK
return ls; return ls;
} }
@@ -69,7 +66,7 @@ namespace ResultsBrowser
{ {
using (TextWriter writer = new StreamWriter(fileName)) using (TextWriter writer = new StreamWriter(fileName))
{ {
(new XmlSerializer(typeof(QueryFilters))).Serialize(writer, this); (new XmlSerializer(typeof(FiltersConfig))).Serialize(writer, this);
} }
} }
catch (Exception e) catch (Exception e)
@@ -1,6 +1,6 @@
namespace ResultsBrowser.Forms namespace ResultsBrowser.Forms
{ {
partial class DatabaseSettings partial class DatabaseSettingsDlg
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -9,9 +9,9 @@ using System.Windows.Forms;
namespace ResultsBrowser.Forms namespace ResultsBrowser.Forms
{ {
public partial class DatabaseSettings : Form public partial class DatabaseSettingsDlg : Form
{ {
public DatabaseSettings() public DatabaseSettingsDlg()
{ {
InitializeComponent(); InitializeComponent();
} }
@@ -23,6 +23,7 @@ namespace ResultsBrowser.Forms
benchNameTextBox1.Text = Program.LocalSettings.Bench1; benchNameTextBox1.Text = Program.LocalSettings.Bench1;
benchNameTextBox2.Text = Program.LocalSettings.Bench2; benchNameTextBox2.Text = Program.LocalSettings.Bench2;
benchNameTextBox3.Text = Program.LocalSettings.Bench3; benchNameTextBox3.Text = Program.LocalSettings.Bench3;
connectionStringTextBox1.Text = Program.LocalSettings.ConnectionString1; connectionStringTextBox1.Text = Program.LocalSettings.ConnectionString1;
connectionStringTextBox2.Text = Program.LocalSettings.ConnectionString2; connectionStringTextBox2.Text = Program.LocalSettings.ConnectionString2;
connectionStringTextBox3.Text = Program.LocalSettings.ConnectionString3; connectionStringTextBox3.Text = Program.LocalSettings.ConnectionString3;
+1 -1
View File
@@ -421,7 +421,7 @@ namespace ResultsBrowser
private void configButton_Click(object sender, EventArgs e) 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; Results.DB.ConnectionString = Program.LocalSettings.ConnectionString1;
} }
+1 -1
View File
@@ -418,7 +418,7 @@ namespace ResultsBrowser
private void configButton_Click(object sender, EventArgs e) 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; Results.DB.ConnectionString = Program.LocalSettings.ConnectionString1;
radioButton1.Text = Program.LocalSettings.Bench1; radioButton1.Text = Program.LocalSettings.Bench1;
+24 -21
View File
@@ -73,25 +73,28 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Filters\DateFilter.cs"> <Compile Include="Filters\DateFilterUI.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Filters\DateFilter.Designer.cs"> <Compile Include="Filters\DateFilterUI.Designer.cs">
<DependentUpon>DateFilter.cs</DependentUpon> <DependentUpon>DateFilterUI.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Filters\DateFilter.cs" />
<Compile Include="Filters\Factory.cs" /> <Compile Include="Filters\Factory.cs" />
<Compile Include="Filters\IFilter.cs" /> <Compile Include="Filters\IFilter.cs" />
<Compile Include="Filters\ProcedureFilter.cs"> <Compile Include="Filters\ProcedureFilter.cs" />
<Compile Include="Filters\ProcedureFilterUI.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Filters\ProcedureFilter.Designer.cs"> <Compile Include="Filters\ProcedureFilterUI.Designer.cs">
<DependentUpon>ProcedureFilter.cs</DependentUpon> <DependentUpon>ProcedureFilterUI.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Filters\SerialNrFilter.cs"> <Compile Include="Filters\SerialNrFilter.cs" />
<Compile Include="Filters\SerialNrFilterUI.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Filters\SerialNrFilter.Designer.cs"> <Compile Include="Filters\SerialNrFilterUI.Designer.cs">
<DependentUpon>SerialNrFilter.cs</DependentUpon> <DependentUpon>SerialNrFilterUI.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Forms\AddFilterDlg.cs"> <Compile Include="Forms\AddFilterDlg.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
@@ -99,11 +102,11 @@
<Compile Include="Forms\AddFilterDlg.Designer.cs"> <Compile Include="Forms\AddFilterDlg.Designer.cs">
<DependentUpon>AddFilterDlg.cs</DependentUpon> <DependentUpon>AddFilterDlg.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Forms\DatabaseSettings.cs"> <Compile Include="Forms\DatabaseSettingsDlg.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Forms\DatabaseSettings.Designer.cs"> <Compile Include="Forms\DatabaseSettingsDlg.Designer.cs">
<DependentUpon>DatabaseSettings.cs</DependentUpon> <DependentUpon>DatabaseSettingsDlg.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Forms\NoBenchOrDatabaseDlg.cs"> <Compile Include="Forms\NoBenchOrDatabaseDlg.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
@@ -126,7 +129,7 @@
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QueryFilters.cs" /> <Compile Include="FiltersConfig.cs" />
<Compile Include="RBrowserWnd.cs"> <Compile Include="RBrowserWnd.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@@ -140,20 +143,20 @@
<Compile Include="ResultsBrowserWnd.Designer.cs"> <Compile Include="ResultsBrowserWnd.Designer.cs">
<DependentUpon>ResultsBrowserWnd.cs</DependentUpon> <DependentUpon>ResultsBrowserWnd.cs</DependentUpon>
</Compile> </Compile>
<EmbeddedResource Include="Filters\DateFilter.resx"> <EmbeddedResource Include="Filters\DateFilterUI.resx">
<DependentUpon>DateFilter.cs</DependentUpon> <DependentUpon>DateFilterUI.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Filters\ProcedureFilter.resx"> <EmbeddedResource Include="Filters\ProcedureFilterUI.resx">
<DependentUpon>ProcedureFilter.cs</DependentUpon> <DependentUpon>ProcedureFilterUI.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Filters\SerialNrFilter.resx"> <EmbeddedResource Include="Filters\SerialNrFilterUI.resx">
<DependentUpon>SerialNrFilter.cs</DependentUpon> <DependentUpon>SerialNrFilterUI.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Forms\AddFilterDlg.resx"> <EmbeddedResource Include="Forms\AddFilterDlg.resx">
<DependentUpon>AddFilterDlg.cs</DependentUpon> <DependentUpon>AddFilterDlg.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Forms\DatabaseSettings.resx"> <EmbeddedResource Include="Forms\DatabaseSettingsDlg.resx">
<DependentUpon>DatabaseSettings.cs</DependentUpon> <DependentUpon>DatabaseSettingsDlg.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Forms\NoBenchOrDatabaseDlg.resx"> <EmbeddedResource Include="Forms\NoBenchOrDatabaseDlg.resx">
<DependentUpon>NoBenchOrDatabaseDlg.cs</DependentUpon> <DependentUpon>NoBenchOrDatabaseDlg.cs</DependentUpon>
+101 -77
View File
@@ -30,17 +30,19 @@
{ {
this.vSplitContainer = new System.Windows.Forms.SplitContainer(); this.vSplitContainer = new System.Windows.Forms.SplitContainer();
this.hSplitContainer = 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.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.settingsBtn = new System.Windows.Forms.Button();
this.saveQueryBtn = new System.Windows.Forms.Button(); this.saveQueryBtn = new System.Windows.Forms.Button();
this.loadQueryBtn = 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.addFilterBtn = new System.Windows.Forms.Button();
this.benchesGroupBox = new System.Windows.Forms.GroupBox(); this.testBenchesGroupBox = new System.Windows.Forms.GroupBox();
this.radioButton2 = new System.Windows.Forms.RadioButton(); this.checkBox1 = new System.Windows.Forms.CheckBox();
this.radioButton3 = new System.Windows.Forms.RadioButton(); this.checkBox2 = new System.Windows.Forms.CheckBox();
this.radioButton1 = new System.Windows.Forms.RadioButton(); this.checkBox3 = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.vSplitContainer)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.vSplitContainer)).BeginInit();
this.vSplitContainer.Panel1.SuspendLayout(); this.vSplitContainer.Panel1.SuspendLayout();
this.vSplitContainer.Panel2.SuspendLayout(); this.vSplitContainer.Panel2.SuspendLayout();
@@ -49,7 +51,9 @@
this.hSplitContainer.Panel1.SuspendLayout(); this.hSplitContainer.Panel1.SuspendLayout();
this.hSplitContainer.Panel2.SuspendLayout(); this.hSplitContainer.Panel2.SuspendLayout();
this.hSplitContainer.SuspendLayout(); this.hSplitContainer.SuspendLayout();
this.benchesGroupBox.SuspendLayout(); this.filtersGroupBox.SuspendLayout();
this.resultsGroupBox.SuspendLayout();
this.testBenchesGroupBox.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// vSplitContainer // vSplitContainer
@@ -69,9 +73,9 @@
this.vSplitContainer.Panel2.Controls.Add(this.settingsBtn); this.vSplitContainer.Panel2.Controls.Add(this.settingsBtn);
this.vSplitContainer.Panel2.Controls.Add(this.saveQueryBtn); this.vSplitContainer.Panel2.Controls.Add(this.saveQueryBtn);
this.vSplitContainer.Panel2.Controls.Add(this.loadQueryBtn); 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.addFilterBtn);
this.vSplitContainer.Panel2.Controls.Add(this.benchesGroupBox); this.vSplitContainer.Panel2.Controls.Add(this.testBenchesGroupBox);
this.vSplitContainer.Panel2MinSize = 100; this.vSplitContainer.Panel2MinSize = 100;
this.vSplitContainer.Size = new System.Drawing.Size(984, 712); this.vSplitContainer.Size = new System.Drawing.Size(984, 712);
this.vSplitContainer.SplitterDistance = 840; this.vSplitContainer.SplitterDistance = 840;
@@ -86,31 +90,53 @@
// //
// hSplitContainer.Panel1 // hSplitContainer.Panel1
// //
this.hSplitContainer.Panel1.Controls.Add(this.filtersFlowLayoutPanel); this.hSplitContainer.Panel1.Controls.Add(this.filtersGroupBox);
// //
// hSplitContainer.Panel2 // 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.Size = new System.Drawing.Size(840, 712);
this.hSplitContainer.SplitterDistance = 280; this.hSplitContainer.SplitterDistance = 280;
this.hSplitContainer.TabIndex = 0; 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 // filtersFlowLayoutPanel
// //
this.filtersFlowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; 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.Name = "filtersFlowLayoutPanel";
this.filtersFlowLayoutPanel.Size = new System.Drawing.Size(840, 280); this.filtersFlowLayoutPanel.Size = new System.Drawing.Size(834, 261);
this.filtersFlowLayoutPanel.TabIndex = 0; this.filtersFlowLayoutPanel.TabIndex = 0;
// //
// listBox1 // resultsGroupBox
// //
this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.resultsGroupBox.Controls.Add(this.resultsListBox);
this.listBox1.FormattingEnabled = true; this.resultsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox1.Location = new System.Drawing.Point(0, 0); this.resultsGroupBox.Location = new System.Drawing.Point(0, 0);
this.listBox1.Name = "listBox1"; this.resultsGroupBox.Name = "resultsGroupBox";
this.listBox1.Size = new System.Drawing.Size(840, 428); this.resultsGroupBox.Size = new System.Drawing.Size(840, 428);
this.listBox1.TabIndex = 0; 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 // settingsBtn
// //
@@ -142,15 +168,15 @@
this.loadQueryBtn.UseVisualStyleBackColor = true; this.loadQueryBtn.UseVisualStyleBackColor = true;
this.loadQueryBtn.Click += new System.EventHandler(this.loadQueryBtn_Click); this.loadQueryBtn.Click += new System.EventHandler(this.loadQueryBtn_Click);
// //
// execQueryBtn // executeQueryBtn
// //
this.execQueryBtn.Location = new System.Drawing.Point(8, 280); this.executeQueryBtn.Location = new System.Drawing.Point(8, 280);
this.execQueryBtn.Name = "execQueryBtn"; this.executeQueryBtn.Name = "executeQueryBtn";
this.execQueryBtn.Size = new System.Drawing.Size(125, 33); this.executeQueryBtn.Size = new System.Drawing.Size(125, 33);
this.execQueryBtn.TabIndex = 5; this.executeQueryBtn.TabIndex = 5;
this.execQueryBtn.Text = "Execute query"; this.executeQueryBtn.Text = "Execute query";
this.execQueryBtn.UseVisualStyleBackColor = true; this.executeQueryBtn.UseVisualStyleBackColor = true;
this.execQueryBtn.Click += new System.EventHandler(this.execQueryBtn_Click); this.executeQueryBtn.Click += new System.EventHandler(this.executeQueryBtn_Click);
// //
// addFilterBtn // addFilterBtn
// //
@@ -162,53 +188,47 @@
this.addFilterBtn.UseVisualStyleBackColor = true; this.addFilterBtn.UseVisualStyleBackColor = true;
this.addFilterBtn.Click += new System.EventHandler(this.addFilterBtn_Click); this.addFilterBtn.Click += new System.EventHandler(this.addFilterBtn_Click);
// //
// benchesGroupBox // testBenchesGroupBox
// //
this.benchesGroupBox.Controls.Add(this.radioButton2); this.testBenchesGroupBox.Controls.Add(this.checkBox3);
this.benchesGroupBox.Controls.Add(this.radioButton3); this.testBenchesGroupBox.Controls.Add(this.checkBox2);
this.benchesGroupBox.Controls.Add(this.radioButton1); this.testBenchesGroupBox.Controls.Add(this.checkBox1);
this.benchesGroupBox.Location = new System.Drawing.Point(8, 173); this.testBenchesGroupBox.Location = new System.Drawing.Point(8, 173);
this.benchesGroupBox.Name = "benchesGroupBox"; this.testBenchesGroupBox.Name = "testBenchesGroupBox";
this.benchesGroupBox.Size = new System.Drawing.Size(125, 99); this.testBenchesGroupBox.Size = new System.Drawing.Size(125, 99);
this.benchesGroupBox.TabIndex = 4; this.testBenchesGroupBox.TabIndex = 4;
this.benchesGroupBox.TabStop = false; this.testBenchesGroupBox.TabStop = false;
this.benchesGroupBox.Text = "Test benches"; this.testBenchesGroupBox.Text = "Test benches";
// //
// radioButton2 // checkBox1
// //
this.radioButton2.AutoSize = true; this.checkBox1.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(15, 44); this.checkBox1.Location = new System.Drawing.Point(20, 24);
this.radioButton2.Name = "radioButton2"; this.checkBox1.Name = "checkBox1";
this.radioButton2.Size = new System.Drawing.Size(85, 17); this.checkBox1.Size = new System.Drawing.Size(80, 17);
this.radioButton2.TabIndex = 1; this.checkBox1.TabIndex = 0;
this.radioButton2.TabStop = true; this.checkBox1.Text = "checkBox1";
this.radioButton2.Text = "radioButton2"; this.checkBox1.UseVisualStyleBackColor = true;
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
// //
// radioButton3 // checkBox2
// //
this.radioButton3.AutoSize = true; this.checkBox2.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(15, 67); this.checkBox2.Location = new System.Drawing.Point(20, 47);
this.radioButton3.Name = "radioButton3"; this.checkBox2.Name = "checkBox2";
this.radioButton3.Size = new System.Drawing.Size(85, 17); this.checkBox2.Size = new System.Drawing.Size(80, 17);
this.radioButton3.TabIndex = 2; this.checkBox2.TabIndex = 1;
this.radioButton3.TabStop = true; this.checkBox2.Text = "checkBox2";
this.radioButton3.Text = "radioButton3"; this.checkBox2.UseVisualStyleBackColor = true;
this.radioButton3.UseVisualStyleBackColor = true;
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
// //
// radioButton1 // checkBox3
// //
this.radioButton1.AutoSize = true; this.checkBox3.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(15, 21); this.checkBox3.Location = new System.Drawing.Point(20, 70);
this.radioButton1.Name = "radioButton1"; this.checkBox3.Name = "checkBox3";
this.radioButton1.Size = new System.Drawing.Size(85, 17); this.checkBox3.Size = new System.Drawing.Size(80, 17);
this.radioButton1.TabIndex = 0; this.checkBox3.TabIndex = 2;
this.radioButton1.TabStop = true; this.checkBox3.Text = "checkBox3";
this.radioButton1.Text = "radioButton1"; this.checkBox3.UseVisualStyleBackColor = true;
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
// //
// ResultsBrowserWnd // ResultsBrowserWnd
// //
@@ -217,7 +237,7 @@
this.ClientSize = new System.Drawing.Size(984, 712); this.ClientSize = new System.Drawing.Size(984, 712);
this.Controls.Add(this.vSplitContainer); this.Controls.Add(this.vSplitContainer);
this.Name = "ResultsBrowserWnd"; this.Name = "ResultsBrowserWnd";
this.Text = "ResultsBrowserWnd"; this.Text = "Results Browser";
this.Load += new System.EventHandler(this.ResultsBrowserWnd_Load); this.Load += new System.EventHandler(this.ResultsBrowserWnd_Load);
this.vSplitContainer.Panel1.ResumeLayout(false); this.vSplitContainer.Panel1.ResumeLayout(false);
this.vSplitContainer.Panel2.ResumeLayout(false); this.vSplitContainer.Panel2.ResumeLayout(false);
@@ -227,8 +247,10 @@
this.hSplitContainer.Panel2.ResumeLayout(false); this.hSplitContainer.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.hSplitContainer)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.hSplitContainer)).EndInit();
this.hSplitContainer.ResumeLayout(false); this.hSplitContainer.ResumeLayout(false);
this.benchesGroupBox.ResumeLayout(false); this.filtersGroupBox.ResumeLayout(false);
this.benchesGroupBox.PerformLayout(); this.resultsGroupBox.ResumeLayout(false);
this.testBenchesGroupBox.ResumeLayout(false);
this.testBenchesGroupBox.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -238,15 +260,17 @@
private System.Windows.Forms.SplitContainer vSplitContainer; private System.Windows.Forms.SplitContainer vSplitContainer;
private System.Windows.Forms.SplitContainer hSplitContainer; private System.Windows.Forms.SplitContainer hSplitContainer;
private System.Windows.Forms.FlowLayoutPanel filtersFlowLayoutPanel; private System.Windows.Forms.FlowLayoutPanel filtersFlowLayoutPanel;
private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.ListBox resultsListBox;
private System.Windows.Forms.GroupBox benchesGroupBox; private System.Windows.Forms.GroupBox testBenchesGroupBox;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.Button saveQueryBtn; private System.Windows.Forms.Button saveQueryBtn;
private System.Windows.Forms.Button loadQueryBtn; 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 addFilterBtn;
private System.Windows.Forms.Button settingsBtn; 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;
} }
} }
+47 -20
View File
@@ -13,25 +13,50 @@ namespace ResultsBrowser
{ {
public partial class ResultsBrowserWnd : Form public partial class ResultsBrowserWnd : Form
{ {
QueryFilters queryFilters; IList<IFilter> filters;
public ResultsBrowserWnd() public ResultsBrowserWnd()
{ {
InitializeComponent(); InitializeComponent();
filters = new List<IFilter>();
} }
private void ResultsBrowserWnd_Load(object sender, EventArgs e) private void ResultsBrowserWnd_Load(object sender, EventArgs e)
{ {
Localize(); 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() 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) private void settingsBtn_Click(object sender, EventArgs e)
{ {
if (new Forms.DatabaseSettingsDlg().ShowDialog() == DialogResult.OK)
{
RedrawTestBenches();
}
} }
private void addFilterBtn_Click(object sender, EventArgs e) private void addFilterBtn_Click(object sender, EventArgs e)
@@ -40,7 +65,8 @@ namespace ResultsBrowser
if (dlg.ShowDialog() == DialogResult.OK && dlg.SelectedFilterName != null) if (dlg.ShowDialog() == DialogResult.OK && dlg.SelectedFilterName != null)
{ {
IFilter filter = Factory.GetFilter(dlg.SelectedFilterName); 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(); OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog() == DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
QueryFilters queryFilters = QueryFilters.Load(dlg.FileName); FiltersConfig filtersConfig = FiltersConfig.Load(dlg.FileName);
filters.Clear();
filtersFlowLayoutPanel.Controls.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]); IFilter filter = Factory.LoadFilter(filtersConfig.FilterName[i], filtersConfig.FilterData[i]);
filtersFlowLayoutPanel.Controls.Add(filter as Control); filters.Add(filter);
filtersFlowLayoutPanel.Controls.Add(filter.GetFilterUI());
} }
} }
} }
@@ -64,19 +93,17 @@ namespace ResultsBrowser
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int count = filtersFlowLayoutPanel.Controls.Count; FiltersConfig filtersConfig = new FiltersConfig(filters.Count);
QueryFilters queryFilters = new QueryFilters(count);
try try
{ {
for (int i = 0; i < count; i++) for (int i = 0; i < filters.Count; i++)
{ {
IFilter filter = (filtersFlowLayoutPanel.Controls[i] as IFilter); filtersConfig.FilterName[i] = filters[i].GetThisFilterName();
queryFilters.FilterNames[i] = filter.GetThisFilterName();
sb.Clear(); sb.Clear();
filter.UI2Data(); filters[i].UI2Data();
filter.Save(sb); filters[i].Save(sb);
queryFilters.FilterSettings[i] = sb.ToString(); filtersConfig.FilterData[i] = sb.ToString();
} }
} }
catch (Exception exc) catch (Exception exc)
@@ -88,26 +115,26 @@ namespace ResultsBrowser
SaveFileDialog dlg = new SaveFileDialog(); SaveFileDialog dlg = new SaveFileDialog();
if (dlg.ShowDialog() == DialogResult.OK) 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)
{ {
} }