Statistics : (1) LocalSettings folder is optional, (2) LocalSettings changes, (3) New conn. strings/IP addr., (4) Flow ranges saved.
This commit is contained in:
parent
a75a7d0a4a
commit
5849984381
@ -18,31 +18,153 @@ namespace Statistics
|
||||
[XmlRootAttribute("Statistics")]
|
||||
public class LocalSettings
|
||||
{
|
||||
public const int BenchesCount = 6;
|
||||
public const int FlowsCount = 5;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// User interface language (used as CultureInfo(..) constructor argument).
|
||||
/// </summary>
|
||||
public string Language;
|
||||
|
||||
/// Names of servers.
|
||||
public string Bench1;
|
||||
public string Bench2;
|
||||
public string Bench3;
|
||||
public string Bench4;
|
||||
public string Bench5;
|
||||
public string Bench6;
|
||||
///
|
||||
/// Names of test benches
|
||||
///
|
||||
public string[] BenchNames;
|
||||
///
|
||||
public string GetBenchName(int i)
|
||||
{
|
||||
return ((BenchNames != null) && (i >= 0) && (i < BenchNames.Length)) ? BenchNames[i] : string.Empty;
|
||||
}
|
||||
|
||||
/// Database settings of servers.
|
||||
public string ConnectionString1;
|
||||
public string ConnectionString2;
|
||||
public string ConnectionString3;
|
||||
public string ConnectionString4;
|
||||
public string ConnectionString5;
|
||||
public string ConnectionString6;
|
||||
///
|
||||
/// Database settings of servers
|
||||
///
|
||||
public string[] ConnectionStrings;
|
||||
///
|
||||
public string GetConnectionString(int i)
|
||||
{
|
||||
return ((ConnectionStrings != null) && (i >= 0) && (i < ConnectionStrings.Length)) ? ConnectionStrings[i] : string.Empty;
|
||||
}
|
||||
|
||||
public string TimePeriodFormat;
|
||||
///
|
||||
/// Flow settings
|
||||
///
|
||||
public bool[] FlowEnabledWMs;
|
||||
public bool[] FlowEnabledI1;
|
||||
public bool[] FlowEnabledI2;
|
||||
public bool[] FlowEnabledI3;
|
||||
public bool[] FlowEnabledI4;
|
||||
///
|
||||
public bool GetFlowEnabled(UserControls.MidId midId, int i)
|
||||
{
|
||||
switch (midId)
|
||||
{
|
||||
case UserControls.MidId.WaterMeters:
|
||||
return ((FlowEnabledWMs != null) && (i >= 0) && (i < FlowEnabledWMs.Length)) ? FlowEnabledWMs[i] : false;
|
||||
case UserControls.MidId.I1: return ((FlowEnabledI1 != null) && (i >= 0) && (i < FlowEnabledI1.Length)) ? FlowEnabledI1[i] : false;
|
||||
case UserControls.MidId.I2: return ((FlowEnabledI2 != null) && (i >= 0) && (i < FlowEnabledI2.Length)) ? FlowEnabledI2[i] : false;
|
||||
case UserControls.MidId.I3: return ((FlowEnabledI3 != null) && (i >= 0) && (i < FlowEnabledI3.Length)) ? FlowEnabledI3[i] : false;
|
||||
case UserControls.MidId.I4: return ((FlowEnabledI4 != null) && (i >= 0) && (i < FlowEnabledI4.Length)) ? FlowEnabledI4[i] : false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
///
|
||||
public void SetFlowEnabled(UserControls.MidId midId, int i, bool value)
|
||||
{
|
||||
switch (midId)
|
||||
{
|
||||
case UserControls.MidId.WaterMeters:
|
||||
if ((FlowEnabledWMs != null) && (i >= 0) && (i < FlowEnabledWMs.Length)) { FlowEnabledWMs[i] = value; };
|
||||
break;
|
||||
case UserControls.MidId.I1: if ((FlowEnabledI1 != null) && (i >= 0) && (i < FlowEnabledI1.Length)) { FlowEnabledI1[i] = value; }; break;
|
||||
case UserControls.MidId.I2: if ((FlowEnabledI2 != null) && (i >= 0) && (i < FlowEnabledI2.Length)) { FlowEnabledI2[i] = value; }; break;
|
||||
case UserControls.MidId.I3: if ((FlowEnabledI3 != null) && (i >= 0) && (i < FlowEnabledI3.Length)) { FlowEnabledI3[i] = value; }; break;
|
||||
case UserControls.MidId.I4: if ((FlowEnabledI4 != null) && (i >= 0) && (i < FlowEnabledI4.Length)) { FlowEnabledI4[i] = value; }; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public double[] FlowFromWMs;
|
||||
public double[] FlowFromI1;
|
||||
public double[] FlowFromI2;
|
||||
public double[] FlowFromI3;
|
||||
public double[] FlowFromI4;
|
||||
///
|
||||
public double GetFlowFrom(UserControls.MidId midId, int i)
|
||||
{
|
||||
switch (midId)
|
||||
{
|
||||
case UserControls.MidId.WaterMeters:
|
||||
return ((FlowFromWMs != null) && (i >= 0) && (i < FlowFromWMs.Length)) ? FlowFromWMs[i] : 0;
|
||||
case UserControls.MidId.I1: return ((FlowFromI1 != null) && (i >= 0) && (i < FlowFromI1.Length)) ? FlowFromI1[i] : 0;
|
||||
case UserControls.MidId.I2: return ((FlowFromI2 != null) && (i >= 0) && (i < FlowFromI2.Length)) ? FlowFromI2[i] : 0;
|
||||
case UserControls.MidId.I3: return ((FlowFromI3 != null) && (i >= 0) && (i < FlowFromI3.Length)) ? FlowFromI3[i] : 0;
|
||||
case UserControls.MidId.I4: return ((FlowFromI4 != null) && (i >= 0) && (i < FlowFromI4.Length)) ? FlowFromI4[i] : 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
///
|
||||
public void SetFlowFrom(UserControls.MidId midId, int i, double value)
|
||||
{
|
||||
switch (midId)
|
||||
{
|
||||
case UserControls.MidId.WaterMeters:
|
||||
if ((FlowFromWMs != null) && (i >= 0) && (i < FlowFromWMs.Length)) { FlowFromWMs[i] = value; };
|
||||
break;
|
||||
case UserControls.MidId.I1: if ((FlowFromI1 != null) && (i >= 0) && (i < FlowFromI1.Length)) { FlowFromI1[i] = value; }; break;
|
||||
case UserControls.MidId.I2: if ((FlowFromI2 != null) && (i >= 0) && (i < FlowFromI2.Length)) { FlowFromI2[i] = value; }; break;
|
||||
case UserControls.MidId.I3: if ((FlowFromI3 != null) && (i >= 0) && (i < FlowFromI3.Length)) { FlowFromI3[i] = value; }; break;
|
||||
case UserControls.MidId.I4: if ((FlowFromI4 != null) && (i >= 0) && (i < FlowFromI4.Length)) { FlowFromI4[i] = value; }; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public double[] FlowToWMs;
|
||||
public double[] FlowToI1;
|
||||
public double[] FlowToI2;
|
||||
public double[] FlowToI3;
|
||||
public double[] FlowToI4;
|
||||
///
|
||||
public double GetFlowTo(UserControls.MidId midId, int i)
|
||||
{
|
||||
switch (midId)
|
||||
{
|
||||
case UserControls.MidId.WaterMeters:
|
||||
return ((FlowToWMs != null) && (i >= 0) && (i < FlowToWMs.Length)) ? FlowToWMs[i] : 0;
|
||||
case UserControls.MidId.I1: return ((FlowToI1 != null) && (i >= 0) && (i < FlowToI1.Length)) ? FlowToI1[i] : 0;
|
||||
case UserControls.MidId.I2: return ((FlowToI2 != null) && (i >= 0) && (i < FlowToI2.Length)) ? FlowToI2[i] : 0;
|
||||
case UserControls.MidId.I3: return ((FlowToI3 != null) && (i >= 0) && (i < FlowToI3.Length)) ? FlowToI3[i] : 0;
|
||||
case UserControls.MidId.I4: return ((FlowToI4 != null) && (i >= 0) && (i < FlowToI4.Length)) ? FlowToI4[i] : 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
///
|
||||
public void SetFlowTo(UserControls.MidId midId, int i, double value)
|
||||
{
|
||||
switch (midId)
|
||||
{
|
||||
case UserControls.MidId.WaterMeters:
|
||||
if ((FlowToWMs != null) && (i >= 0) && (i < FlowToWMs.Length)) { FlowToWMs[i] = value; };
|
||||
break;
|
||||
case UserControls.MidId.I1: if ((FlowToI1 != null) && (i >= 0) && (i < FlowToI1.Length)) { FlowToI1[i] = value; }; break;
|
||||
case UserControls.MidId.I2: if ((FlowToI2 != null) && (i >= 0) && (i < FlowToI2.Length)) { FlowToI2[i] = value; }; break;
|
||||
case UserControls.MidId.I3: if ((FlowToI3 != null) && (i >= 0) && (i < FlowToI3.Length)) { FlowToI3[i] = value; }; break;
|
||||
case UserControls.MidId.I4: if ((FlowToI4 != null) && (i >= 0) && (i < FlowToI4.Length)) { FlowToI4[i] = value; }; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// StatisticsDlg UI
|
||||
public int SelectedRadioButtonNumber;
|
||||
|
||||
/// Statistics options
|
||||
public bool TwoDim;
|
||||
|
||||
/// MainWnd
|
||||
public int MainWndLeft;
|
||||
@ -52,16 +174,49 @@ namespace Statistics
|
||||
public bool ManiWndMaximized;
|
||||
public int SplitterDistance;
|
||||
|
||||
/// Last configuration file name
|
||||
public string LastConfigFileName;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor which is used to create default settings
|
||||
/// </summary>
|
||||
public LocalSettings()
|
||||
{
|
||||
Language = "SK";
|
||||
|
||||
BenchNames = new string[] { "WR10", "WR11", "WR13", "WR14", "WR15", "PT7" };
|
||||
|
||||
ConnectionStrings = new string[]
|
||||
{
|
||||
"SERVER=10.42.128.93; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
|
||||
"SERVER=10.42.128.102; DATABASE=st-wr11-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
|
||||
"SERVER=10.42.128.89; DATABASE=st-wr13-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
|
||||
"SERVER=10.42.128.213; DATABASE=st-wr14-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
|
||||
"SERVER=10.42.128.214; DATABASE=st-wr15-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
|
||||
"SERVER=10.42.129.26; DATABASE=iperlspecial-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;",
|
||||
};
|
||||
|
||||
FlowEnabledWMs = new bool[FlowsCount];
|
||||
FlowEnabledI1 = new bool[FlowsCount];
|
||||
FlowEnabledI2 = new bool[FlowsCount];
|
||||
FlowEnabledI3 = new bool[FlowsCount];
|
||||
FlowEnabledI4 = new bool[FlowsCount];
|
||||
|
||||
FlowFromWMs = new double[FlowsCount];
|
||||
FlowFromI1 = new double[FlowsCount];
|
||||
FlowFromI2 = new double[FlowsCount];
|
||||
FlowFromI3 = new double[FlowsCount];
|
||||
FlowFromI4 = new double[FlowsCount];
|
||||
|
||||
FlowToWMs = new double[FlowsCount];
|
||||
FlowToI1 = new double[FlowsCount];
|
||||
FlowToI2 = new double[FlowsCount];
|
||||
FlowToI3 = new double[FlowsCount];
|
||||
FlowToI4 = new double[FlowsCount];
|
||||
|
||||
SelectedRadioButtonNumber = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load public fields of this class from the XML file.
|
||||
/// Load local settings (public fields of this class) from the XML file.
|
||||
/// </summary>
|
||||
public static LocalSettings Load(string fileName)
|
||||
{
|
||||
@ -82,7 +237,7 @@ namespace Statistics
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save public fields of this class to the XML file.
|
||||
/// Save local settings (public fields of this class) to the XML file.
|
||||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using Statistics.Resources;
|
||||
|
||||
@ -16,13 +15,17 @@ namespace Statistics
|
||||
public static DateTime BuildDateTime; /// date and time of program build
|
||||
|
||||
/// Local settings
|
||||
public static readonly string ExecutableDirectory;
|
||||
public static readonly string ConfigDirectory;
|
||||
public static readonly string LocalSettingsFileName;
|
||||
public static readonly string LocalSettingsBackupName;
|
||||
public static string ExecutableDirectory;
|
||||
public static string ConfigDirectory;
|
||||
public static string LocalSettingsFileName;
|
||||
public static string LocalSettingsBackupName;
|
||||
public static LocalSettings LocalSettings;
|
||||
|
||||
static Program()
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
/// Program version string
|
||||
System.Reflection.Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
@ -32,18 +35,17 @@ namespace Statistics
|
||||
|
||||
/// Local program configuration directory including the trailing backslash
|
||||
ExecutableDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
ConfigDirectory = Path.Combine(ExecutableDirectory, "..\\Cfg\\");
|
||||
LocalSettingsFileName = ConfigDirectory + "config.xml";
|
||||
LocalSettingsBackupName = ConfigDirectory + "config.backup.xml";
|
||||
}
|
||||
#if false
|
||||
/// Config directory is a sibling directory of the executable directory
|
||||
ConfigDirectory = Path.Combine(ExecutableDirectory, "..", string.Format("Cfg{0}", (args.Length >= 1) ? args[0] : string.Empty));
|
||||
#else
|
||||
/// Config directory is a directory in 'C:\Users\username\AppData\Local' folder
|
||||
ConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
string.Format("Statistics{0}", (args.Length >= 1) ? args[0] : string.Empty));
|
||||
#endif
|
||||
LocalSettingsFileName = Path.Combine(ConfigDirectory, "config.xml");
|
||||
LocalSettingsBackupName = Path.Combine(ConfigDirectory, "config.backup.xml");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
///
|
||||
/// Load the local settings
|
||||
///
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.18.1104.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1104.0")]
|
||||
[assembly: AssemblyVersion("2.18.1108.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1108.0")]
|
||||
|
||||
1
Statistics/StatisticsDlg.Designer.cs
generated
1
Statistics/StatisticsDlg.Designer.cs
generated
@ -292,6 +292,7 @@
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Name = "StatisticsDlg";
|
||||
this.Text = "Statistics";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.StatisticsDlg_FormClosing);
|
||||
this.Load += new System.EventHandler(this.StatisticsDlg_Load);
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel1.PerformLayout();
|
||||
|
||||
@ -24,30 +24,7 @@ namespace Statistics
|
||||
{
|
||||
public partial class StatisticsDlg : Form
|
||||
{
|
||||
static string[] testBenchNames = new string[] { "WR10", "WR11", "WR13", "WR14", "WR15", "PT7" };
|
||||
///
|
||||
#if true
|
||||
static string[] connectionStrings = new string[] {
|
||||
"SERVER=10.42.128.197; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", /// WR10
|
||||
"SERVER=10.42.128.98; DATABASE=st-wr11-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", /// WR11
|
||||
"SERVER=10.42.128.152; DATABASE=st-wr13-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", /// WR13
|
||||
"SERVER=10.42.128.143; DATABASE=st-wr14-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", /// WR14
|
||||
"SERVER=10.42.128.63; DATABASE=st-wr15-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", /// WR15
|
||||
"" /// PT7
|
||||
};
|
||||
#else
|
||||
static string[] connectionStrings = new string[] {
|
||||
"SERVER=localhost; DATABASE=st-wr10-r; UID=root; PASSWORD=; CHARSET=utf8;", /// WR10
|
||||
"SERVER=localhost; DATABASE=st-wr11-r; UID=root; PASSWORD=; CHARSET=utf8;", /// WR11
|
||||
"SERVER=localhost; DATABASE=st-wr13-r; UID=root; PASSWORD=; CHARSET=utf8;", /// WR13
|
||||
"SERVER=localhost; DATABASE=st-wr14-r; UID=root; PASSWORD=; CHARSET=utf8;", /// WR14
|
||||
"SERVER=localhost; DATABASE=st-wr15-r; UID=root; PASSWORD=; CHARSET=utf8;", /// WR15
|
||||
"" /// PT7
|
||||
};
|
||||
#endif
|
||||
///
|
||||
static ISessionFactory[] sessionFactories = new ISessionFactory[6];
|
||||
|
||||
static ISessionFactory[] sessionFactories = new ISessionFactory[LocalSettings.BenchesCount];
|
||||
|
||||
|
||||
public StatisticsDlg()
|
||||
@ -91,22 +68,35 @@ namespace Statistics
|
||||
Left = (ls.MainWndLeft != 0) ? ls.MainWndLeft : 50;
|
||||
Top = (ls.MainWndTop != 0) ? ls.MainWndTop : 50;
|
||||
|
||||
for (int i = 0; i < testBenchNames.Length; i++)
|
||||
switch (ls.SelectedRadioButtonNumber)
|
||||
{
|
||||
if ((i < connectionStrings.Length) && !string.IsNullOrEmpty(connectionStrings[i]))
|
||||
case 1: radioButton1.Checked = true; break;
|
||||
case 2: radioButton2.Checked = true; break;
|
||||
case 3: radioButton3.Checked = true; break;
|
||||
case 4: radioButton4.Checked = true; break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)MidId.Count; i++)
|
||||
{
|
||||
(midsTabControl.TabPages[i].Controls[0] as MidOrWaterMetersCtrl).Data2UI();
|
||||
}
|
||||
|
||||
for (int i = 0; i < LocalSettings.BenchesCount; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Program.LocalSettings.GetConnectionString(i)))
|
||||
{
|
||||
sessionFactories[i] = null;
|
||||
try
|
||||
{
|
||||
sessionFactories[i] = Fluently.Configure()
|
||||
.Database(MySQLConfiguration.Standard.ConnectionString(connectionStrings[i]))
|
||||
.Database(MySQLConfiguration.Standard.ConnectionString(Program.LocalSettings.GetConnectionString(i)))
|
||||
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Results.Entities.Batch>())
|
||||
.ExposeConfiguration(BuildSchema)
|
||||
.BuildSessionFactory();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show(string.Format("Cannot open one of database of {0}", testBenchNames[i]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
MessageBox.Show(string.Format("Cannot open one of database of {0}", Program.LocalSettings.GetBenchName(i)), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -140,7 +130,7 @@ namespace Statistics
|
||||
|
||||
public IList<TestRslt> UpdateRequest(int benchId, MidId midId)
|
||||
{
|
||||
if (benchId >= sessionFactories.Length || sessionFactories[benchId] == null || (midId == MidId.WaterMeters))
|
||||
if ((benchId < 0) || (benchId >= LocalSettings.BenchesCount) || (sessionFactories[benchId] == null) || (midId == MidId.WaterMeters))
|
||||
{
|
||||
if (midId == MidId.WaterMeters)
|
||||
{
|
||||
@ -148,7 +138,7 @@ namespace Statistics
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(string.Format("Cannot load statistics of {0}", (benchId < testBenchNames.Length) ? testBenchNames[benchId] : "XY"));
|
||||
MessageBox.Show(string.Format("Cannot load statistics of {0}", Program.LocalSettings.GetBenchName(benchId)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -193,7 +183,7 @@ namespace Statistics
|
||||
catch (Exception exc)
|
||||
{
|
||||
Forms.ModelessForm.CloseForm();
|
||||
MessageBox.Show(string.Format("Error loading statistics of {0}\r\n{1}", (benchId < testBenchNames.Length) ? testBenchNames[benchId] : "XY", exc.Message));
|
||||
MessageBox.Show(string.Format("Error loading statistics of {0}\r\n{1}", Program.LocalSettings.GetBenchName(benchId), exc.Message));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -230,5 +220,40 @@ namespace Statistics
|
||||
{
|
||||
timePeriodGroupBox.Enabled = radioButton4.Checked;
|
||||
}
|
||||
|
||||
private void StatisticsDlg_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
LocalSettings ls = Program.LocalSettings;
|
||||
|
||||
ls.ManiWndMaximized = (WindowState == FormWindowState.Maximized);
|
||||
if (WindowState == FormWindowState.Normal)
|
||||
{
|
||||
ls.MainWndLeft = Location.X;
|
||||
ls.MainWndTop = Location.Y;
|
||||
ls.MainWndWidth = Size.Width;
|
||||
ls.MainWndHeight = Size.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Maximized or minimized (when restarted, minimized window is restored as normal)
|
||||
ls.MainWndLeft = RestoreBounds.Left;
|
||||
ls.MainWndTop = RestoreBounds.Top;
|
||||
ls.MainWndWidth = RestoreBounds.Width;
|
||||
ls.MainWndHeight = RestoreBounds.Height;
|
||||
}
|
||||
|
||||
if (radioButton1.Checked) ls.SelectedRadioButtonNumber = 1;
|
||||
else if (radioButton2.Checked) ls.SelectedRadioButtonNumber = 2;
|
||||
else if (radioButton3.Checked) ls.SelectedRadioButtonNumber = 3;
|
||||
else if (radioButton4.Checked) ls.SelectedRadioButtonNumber = 4;
|
||||
else ls.SelectedRadioButtonNumber = 0;
|
||||
|
||||
for (int i = 0; i < (int)MidId.Count; i++)
|
||||
{
|
||||
(midsTabControl.TabPages[i].Controls[0] as MidOrWaterMetersCtrl).UI2Data();
|
||||
}
|
||||
|
||||
ls.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,14 +3,11 @@
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Results.Entities;
|
||||
using Statistics.Resources;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Statistics.UserControls
|
||||
{
|
||||
@ -129,6 +126,60 @@ namespace Statistics.UserControls
|
||||
toLabel6.Text = Strings.To;
|
||||
}
|
||||
|
||||
public void Data2UI()
|
||||
{
|
||||
LocalSettings ls = Program.LocalSettings;
|
||||
flow1CheckBox.Checked = ls.GetFlowEnabled(MidId, 0);
|
||||
flow2CheckBox.Checked = ls.GetFlowEnabled(MidId, 1);
|
||||
flow3CheckBox.Checked = ls.GetFlowEnabled(MidId, 2);
|
||||
flow4CheckBox.Checked = ls.GetFlowEnabled(MidId, 3);
|
||||
flow5CheckBox.Checked = ls.GetFlowEnabled(MidId, 4);
|
||||
flow1From = ls.GetFlowFrom(MidId, 0);
|
||||
flow2From = ls.GetFlowFrom(MidId, 1);
|
||||
flow3From = ls.GetFlowFrom(MidId, 2);
|
||||
flow4From = ls.GetFlowFrom(MidId, 3);
|
||||
flow5From = ls.GetFlowFrom(MidId, 4);
|
||||
flow1FromTextBox.Text = flow1From.ToString();
|
||||
flow2FromTextBox.Text = flow2From.ToString();
|
||||
flow3FromTextBox.Text = flow3From.ToString();
|
||||
flow4FromTextBox.Text = flow4From.ToString();
|
||||
flow5FromTextBox.Text = flow5From.ToString();
|
||||
flow1To = ls.GetFlowTo(MidId, 0);
|
||||
flow2To = ls.GetFlowTo(MidId, 1);
|
||||
flow3To = ls.GetFlowTo(MidId, 2);
|
||||
flow4To = ls.GetFlowTo(MidId, 3);
|
||||
flow5To = ls.GetFlowTo(MidId, 4);
|
||||
flow1ToTextBox.Text = flow1To.ToString();
|
||||
flow2ToTextBox.Text = flow2To.ToString();
|
||||
flow3ToTextBox.Text = flow3To.ToString();
|
||||
flow4ToTextBox.Text = flow4To.ToString();
|
||||
flow5ToTextBox.Text = flow5To.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>true when successful</returns>
|
||||
public void UI2Data()
|
||||
{
|
||||
LocalSettings ls = Program.LocalSettings;
|
||||
ls.SetFlowEnabled(MidId, 0, flow1CheckBox.Checked);
|
||||
ls.SetFlowEnabled(MidId, 1, flow2CheckBox.Checked);
|
||||
ls.SetFlowEnabled(MidId, 2, flow3CheckBox.Checked);
|
||||
ls.SetFlowEnabled(MidId, 3, flow4CheckBox.Checked);
|
||||
ls.SetFlowEnabled(MidId, 4, flow5CheckBox.Checked);
|
||||
ls.SetFlowFrom(MidId, 0, flow1From);
|
||||
ls.SetFlowFrom(MidId, 1, flow2From);
|
||||
ls.SetFlowFrom(MidId, 2, flow3From);
|
||||
ls.SetFlowFrom(MidId, 3, flow4From);
|
||||
ls.SetFlowFrom(MidId, 4, flow5From);
|
||||
ls.SetFlowTo(MidId, 0, flow1To);
|
||||
ls.SetFlowTo(MidId, 1, flow2To);
|
||||
ls.SetFlowTo(MidId, 2, flow3To);
|
||||
ls.SetFlowTo(MidId, 3, flow4To);
|
||||
ls.SetFlowTo(MidId, 4, flow5To);
|
||||
}
|
||||
|
||||
private void flow1CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow1CheckBox, flow1GroupBox); }
|
||||
private void flow2CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow2CheckBox, flow2GroupBox); }
|
||||
private void flow3CheckBox_CheckedChanged(object sender, EventArgs e) { ManageCheckGroupBox(flow3CheckBox, flow3GroupBox); }
|
||||
@ -157,7 +208,9 @@ namespace Statistics.UserControls
|
||||
flow1FromExclamation.Visible = false;
|
||||
}
|
||||
else
|
||||
flow1FromExclamation.Visible = !(double.TryParse(flow1FromTextBox.Text, out flow1From) && (flow1From >= 0));
|
||||
flow1FromExclamation.Visible = !((double.TryParse(flow1FromTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out flow1From) ||
|
||||
double.TryParse(flow1FromTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out flow1From)) &&
|
||||
(flow1From >= 0));
|
||||
}
|
||||
|
||||
private void flow1ToTextBox_TextChanged(object sender, EventArgs e)
|
||||
@ -168,7 +221,9 @@ namespace Statistics.UserControls
|
||||
flow1ToExclamation.Visible = false;
|
||||
}
|
||||
else
|
||||
flow1ToExclamation.Visible = !(double.TryParse(flow1ToTextBox.Text, out flow1To) && (flow1To >= 0));
|
||||
flow1ToExclamation.Visible = !((double.TryParse(flow1ToTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out flow1To) ||
|
||||
double.TryParse(flow1ToTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out flow1To)) &&
|
||||
(flow1To >= 0));
|
||||
}
|
||||
|
||||
private void flow2FromTextBox_TextChanged(object sender, EventArgs e)
|
||||
@ -179,7 +234,9 @@ namespace Statistics.UserControls
|
||||
flow2FromExclamation.Visible = false;
|
||||
}
|
||||
else
|
||||
flow2FromExclamation.Visible = !(double.TryParse(flow2FromTextBox.Text, out flow2From) && (flow2From >= 0));
|
||||
flow2FromExclamation.Visible = !((double.TryParse(flow2FromTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out flow2From) ||
|
||||
double.TryParse(flow2FromTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out flow2From)) &&
|
||||
(flow2From >= 0));
|
||||
}
|
||||
|
||||
private void flow2ToTextBox_TextChanged(object sender, EventArgs e)
|
||||
@ -190,7 +247,9 @@ namespace Statistics.UserControls
|
||||
flow2ToExclamation.Visible = false;
|
||||
}
|
||||
else
|
||||
flow2ToExclamation.Visible = !(double.TryParse(flow2ToTextBox.Text, out flow2To) && (flow2To >= 0));
|
||||
flow2ToExclamation.Visible = !((double.TryParse(flow2ToTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out flow2To) ||
|
||||
double.TryParse(flow2ToTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out flow2To)) &&
|
||||
(flow2To >= 0));
|
||||
}
|
||||
|
||||
private void flow3FromTextBox_TextChanged(object sender, EventArgs e)
|
||||
@ -201,7 +260,9 @@ namespace Statistics.UserControls
|
||||
flow3FromExclamation.Visible = false;
|
||||
}
|
||||
else
|
||||
flow3FromExclamation.Visible = !(double.TryParse(flow3FromTextBox.Text, out flow3From) && (flow3From >= 0));
|
||||
flow3FromExclamation.Visible = !((double.TryParse(flow3FromTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out flow3From) ||
|
||||
double.TryParse(flow3FromTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out flow3From)) &&
|
||||
(flow3From >= 0));
|
||||
}
|
||||
|
||||
private void flow3ToTextBox_TextChanged(object sender, EventArgs e)
|
||||
@ -212,7 +273,9 @@ namespace Statistics.UserControls
|
||||
flow3ToExclamation.Visible = false;
|
||||
}
|
||||
else
|
||||
flow3ToExclamation.Visible = !(double.TryParse(flow3ToTextBox.Text, out flow3To) && (flow3To >= 0));
|
||||
flow3ToExclamation.Visible = !((double.TryParse(flow3ToTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out flow3To) ||
|
||||
double.TryParse(flow3ToTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out flow3To)) &&
|
||||
(flow3To >= 0));
|
||||
}
|
||||
|
||||
private void flow4FromTextBox_TextChanged(object sender, EventArgs e)
|
||||
@ -223,7 +286,9 @@ namespace Statistics.UserControls
|
||||
flow4FromExclamation.Visible = false;
|
||||
}
|
||||
else
|
||||
flow4FromExclamation.Visible = !(double.TryParse(flow4FromTextBox.Text, out flow4From) && (flow4From >= 0));
|
||||
flow4FromExclamation.Visible = !((double.TryParse(flow4FromTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out flow4From) ||
|
||||
double.TryParse(flow4FromTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out flow4From)) &&
|
||||
(flow4From >= 0));
|
||||
}
|
||||
|
||||
private void flow4ToTextBox_TextChanged(object sender, EventArgs e)
|
||||
@ -234,7 +299,9 @@ namespace Statistics.UserControls
|
||||
flow4ToExclamation.Visible = false;
|
||||
}
|
||||
else
|
||||
flow4ToExclamation.Visible = !(double.TryParse(flow4ToTextBox.Text, out flow4To) && (flow4To >= 0));
|
||||
flow4ToExclamation.Visible = !((double.TryParse(flow4ToTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out flow4To) ||
|
||||
double.TryParse(flow4ToTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out flow4To)) &&
|
||||
(flow4To >= 0));
|
||||
}
|
||||
|
||||
private void flow5FromTextBox_TextChanged(object sender, EventArgs e)
|
||||
@ -245,7 +312,9 @@ namespace Statistics.UserControls
|
||||
flow5FromExclamation.Visible = false;
|
||||
}
|
||||
else
|
||||
flow5FromExclamation.Visible = !(double.TryParse(flow5FromTextBox.Text, out flow5From) && (flow5From >= 0));
|
||||
flow5FromExclamation.Visible = !((double.TryParse(flow5FromTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out flow5From) ||
|
||||
double.TryParse(flow5FromTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out flow5From)) &&
|
||||
(flow5From >= 0));
|
||||
}
|
||||
|
||||
private void flow5ToTextBox_TextChanged(object sender, EventArgs e)
|
||||
@ -256,7 +325,9 @@ namespace Statistics.UserControls
|
||||
flow5ToExclamation.Visible = false;
|
||||
}
|
||||
else
|
||||
flow5ToExclamation.Visible = !(double.TryParse(flow5ToTextBox.Text, out flow5To) && (flow5To >= 0));
|
||||
flow5ToExclamation.Visible = !((double.TryParse(flow5ToTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out flow5To) ||
|
||||
double.TryParse(flow5ToTextBox.Text, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out flow5To)) &&
|
||||
(flow5To >= 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
90
Statistics/UserControls/StatisticsCtrl.Designer.cs
generated
90
Statistics/UserControls/StatisticsCtrl.Designer.cs
generated
@ -28,13 +28,13 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
||||
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
||||
System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series6 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series7 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series8 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series9 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
this.updateButton = new System.Windows.Forms.Button();
|
||||
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
@ -51,7 +51,7 @@
|
||||
this.updateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.updateButton.Location = new System.Drawing.Point(3, 7);
|
||||
this.updateButton.Name = "updateButton";
|
||||
this.updateButton.Size = new System.Drawing.Size(101, 43);
|
||||
this.updateButton.Size = new System.Drawing.Size(90, 43);
|
||||
this.updateButton.TabIndex = 4;
|
||||
this.updateButton.Text = "Update data";
|
||||
this.updateButton.UseVisualStyleBackColor = true;
|
||||
@ -59,44 +59,44 @@
|
||||
//
|
||||
// chart1
|
||||
//
|
||||
chartArea1.Name = "ChartArea1";
|
||||
this.chart1.ChartAreas.Add(chartArea1);
|
||||
chartArea2.Name = "ChartArea1";
|
||||
this.chart1.ChartAreas.Add(chartArea2);
|
||||
this.chart1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
legend1.Name = "Legend1";
|
||||
this.chart1.Legends.Add(legend1);
|
||||
legend2.Name = "Legend1";
|
||||
this.chart1.Legends.Add(legend2);
|
||||
this.chart1.Location = new System.Drawing.Point(0, 0);
|
||||
this.chart1.Name = "chart1";
|
||||
series1.ChartArea = "ChartArea1";
|
||||
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
|
||||
series1.Color = System.Drawing.Color.ForestGreen;
|
||||
series1.Legend = "Legend1";
|
||||
series1.Name = "Flow 1";
|
||||
series2.ChartArea = "ChartArea1";
|
||||
series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
|
||||
series2.Color = System.Drawing.Color.Red;
|
||||
series2.Legend = "Legend1";
|
||||
series2.Name = "Flow 2";
|
||||
series3.ChartArea = "ChartArea1";
|
||||
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
|
||||
series3.Color = System.Drawing.Color.Blue;
|
||||
series3.Legend = "Legend1";
|
||||
series3.Name = "Flow 3";
|
||||
series4.ChartArea = "ChartArea1";
|
||||
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
|
||||
series4.Color = System.Drawing.Color.Yellow;
|
||||
series4.Legend = "Legend1";
|
||||
series4.Name = "Flow 4";
|
||||
series5.ChartArea = "ChartArea1";
|
||||
series5.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
|
||||
series5.Color = System.Drawing.Color.Fuchsia;
|
||||
series5.Legend = "Legend1";
|
||||
series5.Name = "Flow 5";
|
||||
this.chart1.Series.Add(series1);
|
||||
this.chart1.Series.Add(series2);
|
||||
this.chart1.Series.Add(series3);
|
||||
this.chart1.Series.Add(series4);
|
||||
this.chart1.Series.Add(series5);
|
||||
this.chart1.Size = new System.Drawing.Size(473, 381);
|
||||
series6.ChartArea = "ChartArea1";
|
||||
series6.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
|
||||
series6.Color = System.Drawing.Color.ForestGreen;
|
||||
series6.Legend = "Legend1";
|
||||
series6.Name = "Flow 1";
|
||||
series7.ChartArea = "ChartArea1";
|
||||
series7.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
|
||||
series7.Color = System.Drawing.Color.Red;
|
||||
series7.Legend = "Legend1";
|
||||
series7.Name = "Flow 2";
|
||||
series8.ChartArea = "ChartArea1";
|
||||
series8.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
|
||||
series8.Color = System.Drawing.Color.Blue;
|
||||
series8.Legend = "Legend1";
|
||||
series8.Name = "Flow 3";
|
||||
series9.ChartArea = "ChartArea1";
|
||||
series9.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
|
||||
series9.Color = System.Drawing.Color.DarkOrange;
|
||||
series9.Legend = "Legend1";
|
||||
series9.Name = "Flow 4";
|
||||
series10.ChartArea = "ChartArea1";
|
||||
series10.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
|
||||
series10.Color = System.Drawing.Color.Fuchsia;
|
||||
series10.Legend = "Legend1";
|
||||
series10.Name = "Flow 5";
|
||||
this.chart1.Series.Add(series6);
|
||||
this.chart1.Series.Add(series7);
|
||||
this.chart1.Series.Add(series8);
|
||||
this.chart1.Series.Add(series9);
|
||||
this.chart1.Series.Add(series10);
|
||||
this.chart1.Size = new System.Drawing.Size(476, 381);
|
||||
this.chart1.TabIndex = 5;
|
||||
this.chart1.Text = "chart1";
|
||||
//
|
||||
@ -117,7 +117,7 @@
|
||||
this.splitContainer1.Panel2.Controls.Add(this.exportButton);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.updateButton);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(577, 381);
|
||||
this.splitContainer1.SplitterDistance = 473;
|
||||
this.splitContainer1.SplitterDistance = 476;
|
||||
this.splitContainer1.SplitterWidth = 1;
|
||||
this.splitContainer1.TabIndex = 6;
|
||||
//
|
||||
@ -126,7 +126,7 @@
|
||||
this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.exportButton.Location = new System.Drawing.Point(3, 56);
|
||||
this.exportButton.Name = "exportButton";
|
||||
this.exportButton.Size = new System.Drawing.Size(101, 43);
|
||||
this.exportButton.Size = new System.Drawing.Size(90, 43);
|
||||
this.exportButton.TabIndex = 5;
|
||||
this.exportButton.Text = "Export";
|
||||
this.exportButton.UseVisualStyleBackColor = true;
|
||||
|
||||
@ -29,7 +29,7 @@ namespace Statistics.UserControls
|
||||
{
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
chart1.Series[string.Format("{0} {1}", Strings.Flow, i)].Points.Clear();
|
||||
chart1.Series[string.Format("Flow {0}", i)].Points.Clear();
|
||||
}
|
||||
|
||||
IList<TestRslt> results = MidCtrl.UpdateRequest(Id);
|
||||
@ -44,7 +44,7 @@ namespace Statistics.UserControls
|
||||
{
|
||||
if (MidCtrl.IsFlowEnabled(i) && (MidCtrl.FlowFrom(i) <= r.FlowMean) && (r.FlowMean <= MidCtrl.FlowTo(i)))
|
||||
{
|
||||
chart1.Series[string.Format("{0} {1}", Strings.Flow, i)].Points.AddXY(r.StartTime, r.ErrorMaster);
|
||||
chart1.Series[string.Format("Flow {0}", i)].Points.AddXY(r.StartTime, r.ErrorMaster);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user