diff --git a/Statistics/Forms/ModelessForm.Designer.cs b/Statistics/Forms/ModelessForm.Designer.cs new file mode 100644 index 000000000..9c2026e5b --- /dev/null +++ b/Statistics/Forms/ModelessForm.Designer.cs @@ -0,0 +1,64 @@ +namespace Statistics.Forms +{ + partial class ModelessForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(47, 29); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(35, 13); + this.label1.TabIndex = 0; + this.label1.Text = "label1"; + // + // ModelessForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(191, 56); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "ModelessForm"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "ModelessForm"; + this.Load += new System.EventHandler(this.ModelessForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/Statistics/Forms/ModelessForm.cs b/Statistics/Forms/ModelessForm.cs new file mode 100644 index 000000000..2a327f8de --- /dev/null +++ b/Statistics/Forms/ModelessForm.cs @@ -0,0 +1,68 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace Statistics.Forms +{ + public partial class ModelessForm : Form + { + /// + /// Called from the state machine when an operation forces a modeless dialog close. + /// + public static void CloseForm() + { + if (CloseFormHandler == null) return; + try { CloseFormHandler(null, null); } + catch (Exception) { } + } + public static event EventHandler CloseFormHandler; + + void OnCloseForm(object sender, EventArgs args) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + + public string Title; + public string Message; + public Color BackgroundColor; + public Color TextColor; + public Font TextFont; + public string FontFamily; + public int FontSize; + public FontStyle FontStyle; + + + /// + /// Constructor to be used by the application + /// + /// Window title + /// Displayed message + public ModelessForm() + { + InitializeComponent(); + ControlBox = false; + + CloseFormHandler += delegate(object sender, EventArgs args) + { + if (InvokeRequired) { Invoke(new EventHandler(OnCloseForm), sender, args); } + else OnCloseForm(sender, args); + }; + } + + private void ModelessForm_Load(object sender, EventArgs e) + { + if (Title != null) Text = Title; + if (Message != null) label1.Text = Message; + if (BackgroundColor != null) BackColor = BackgroundColor; + if (TextColor != null) ForeColor = TextColor; + if (FontFamily != null) label1.Font = new Font(FontFamily, FontSize, FontStyle); + + float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Width; + float textHeight = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Height; + Width = (int)textWidth + 120; /// Form width calculated from the text width + Height += (int)textHeight; /// Form height calculated from the text height + } + } +} diff --git a/Statistics/Forms/ModelessForm.resx b/Statistics/Forms/ModelessForm.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/Statistics/Forms/ModelessForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Statistics/Properties/AssemblyInfo.cs b/Statistics/Properties/AssemblyInfo.cs index 83d980846..059a5d80b 100644 --- a/Statistics/Properties/AssemblyInfo.cs +++ b/Statistics/Properties/AssemblyInfo.cs @@ -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.1088.0")] -[assembly: AssemblyFileVersion("2.18.1088.0")] +[assembly: AssemblyVersion("2.18.1104.0")] +[assembly: AssemblyFileVersion("2.18.1104.0")] diff --git a/Statistics/Resources/Strings.Designer.cs b/Statistics/Resources/Strings.Designer.cs index 97bc318c9..60465cc20 100644 --- a/Statistics/Resources/Strings.Designer.cs +++ b/Statistics/Resources/Strings.Designer.cs @@ -78,6 +78,15 @@ namespace Statistics.Resources { } } + /// + /// Looks up a localized string similar to searching.... + /// + internal static string searching_ { + get { + return ResourceManager.GetString("searching_", resourceCulture); + } + } + /// /// Looks up a localized string similar to Statistics. /// diff --git a/Statistics/Resources/Strings.resx b/Statistics/Resources/Strings.resx index e96134330..fea310568 100644 --- a/Statistics/Resources/Strings.resx +++ b/Statistics/Resources/Strings.resx @@ -123,6 +123,9 @@ From + + searching... + Statistics diff --git a/Statistics/Resources/Strings.sk.resx b/Statistics/Resources/Strings.sk.resx index c2c26104c..6196e8b7b 100644 --- a/Statistics/Resources/Strings.sk.resx +++ b/Statistics/Resources/Strings.sk.resx @@ -123,6 +123,9 @@ Od + + hľadám... + Štatistiky diff --git a/Statistics/Statistics.csproj b/Statistics/Statistics.csproj index 269a1da18..6effcae82 100644 --- a/Statistics/Statistics.csproj +++ b/Statistics/Statistics.csproj @@ -49,6 +49,7 @@ + @@ -59,6 +60,12 @@ + + Form + + + ModelessForm.cs + True True @@ -85,6 +92,9 @@ StatisticsCtrl.cs + + ModelessForm.cs + ResXFileCodeGenerator Strings.Designer.cs diff --git a/Statistics/StatisticsDlg.cs b/Statistics/StatisticsDlg.cs index d82359f61..9223b4fad 100644 --- a/Statistics/StatisticsDlg.cs +++ b/Statistics/StatisticsDlg.cs @@ -14,6 +14,8 @@ using Results; using Results.Entities; using Statistics.Resources; using Statistics.UserControls; +using System.Threading; +using System.Globalization; namespace Statistics { @@ -21,7 +23,7 @@ namespace Statistics { static string[] testBenchNames = new string[] { "WR10", "WR11", "WR13", "WR14", "WR15", "PT7" }; /// -#if false +#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 @@ -120,7 +122,7 @@ namespace Statistics } - public void UpdateRequest(int benchId, MidId midId) + public IList UpdateRequest(int benchId, MidId midId) { if (benchId >= sessionFactories.Length || sessionFactories[benchId] == null || (midId == MidId.WaterMeters)) { @@ -132,9 +134,22 @@ namespace Statistics { MessageBox.Show(string.Format("Cannot load statistics of {0}", (benchId < testBenchNames.Length) ? testBenchNames[benchId] : "XY")); } - return; + return null; } + Thread thread = new Thread(() => Application.Run(new Forms.ModelessForm() + { + Title = string.Empty, + Message = Strings.searching_, + BackgroundColor = Color.LightGreen, + FontFamily = "Arial", + FontSize = 14, + FontStyle = FontStyle.Regular, + })); + thread.CurrentCulture = CultureInfo.CurrentCulture; + thread.CurrentUICulture = CultureInfo.CurrentUICulture; + thread.Start(); + try { ISession session = sessionFactories[benchId].OpenSession(); @@ -151,11 +166,15 @@ namespace Statistics foreach (var tr in listOfRslts) testRslts.Add(tr); } + Forms.ModelessForm.CloseForm(); session.Close(); + return testRslts; } 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)); + return null; } } } diff --git a/Statistics/UserControls/MidOrWaterMetersCtrl.cs b/Statistics/UserControls/MidOrWaterMetersCtrl.cs index 863bb75ee..e402744ff 100644 --- a/Statistics/UserControls/MidOrWaterMetersCtrl.cs +++ b/Statistics/UserControls/MidOrWaterMetersCtrl.cs @@ -6,6 +6,7 @@ using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; +using Results.Entities; using Statistics.Resources; namespace Statistics.UserControls @@ -46,9 +47,9 @@ namespace Statistics.UserControls } - public void UpdateRequest(int benchId) + public IList UpdateRequest(int benchId) { - Parent.UpdateRequest(benchId, MidId); + return Parent.UpdateRequest(benchId, MidId); } diff --git a/Statistics/UserControls/StatisticsCtrl.Designer.cs b/Statistics/UserControls/StatisticsCtrl.Designer.cs index f58153ea1..760d21cb2 100644 --- a/Statistics/UserControls/StatisticsCtrl.Designer.cs +++ b/Statistics/UserControls/StatisticsCtrl.Designer.cs @@ -28,27 +28,94 @@ /// 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(); this.updateButton = new System.Windows.Forms.Button(); + this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.exportButton = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); this.SuspendLayout(); // // updateButton // this.updateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.updateButton.Location = new System.Drawing.Point(255, 11); + this.updateButton.Location = new System.Drawing.Point(3, 7); this.updateButton.Name = "updateButton"; - this.updateButton.Size = new System.Drawing.Size(122, 43); + this.updateButton.Size = new System.Drawing.Size(101, 43); this.updateButton.TabIndex = 4; - this.updateButton.Text = "Update"; + this.updateButton.Text = "Update data"; this.updateButton.UseVisualStyleBackColor = true; this.updateButton.Click += new System.EventHandler(this.updateButton_Click); // + // chart1 + // + chartArea1.Name = "ChartArea1"; + this.chart1.ChartAreas.Add(chartArea1); + this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; + legend1.Name = "Legend1"; + this.chart1.Legends.Add(legend1); + 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 = "Error"; + this.chart1.Series.Add(series1); + this.chart1.Size = new System.Drawing.Size(470, 381); + this.chart1.TabIndex = 5; + this.chart1.Text = "chart1"; + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.splitContainer1.IsSplitterFixed = true; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.chart1); + // + // splitContainer1.Panel2 + // + 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 = 470; + this.splitContainer1.SplitterWidth = 1; + this.splitContainer1.TabIndex = 6; + // + // exportButton + // + 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.TabIndex = 5; + this.exportButton.Text = "Export"; + this.exportButton.UseVisualStyleBackColor = true; + this.exportButton.Click += new System.EventHandler(this.exportButton_Click); + // // StatisticsCtrl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.updateButton); + this.Controls.Add(this.splitContainer1); this.Name = "StatisticsCtrl"; - this.Size = new System.Drawing.Size(388, 242); + this.Size = new System.Drawing.Size(577, 381); + ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); this.ResumeLayout(false); } @@ -56,5 +123,8 @@ #endregion private System.Windows.Forms.Button updateButton; + private System.Windows.Forms.DataVisualization.Charting.Chart chart1; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.Button exportButton; } } diff --git a/Statistics/UserControls/StatisticsCtrl.cs b/Statistics/UserControls/StatisticsCtrl.cs index d50a09909..8b04afce8 100644 --- a/Statistics/UserControls/StatisticsCtrl.cs +++ b/Statistics/UserControls/StatisticsCtrl.cs @@ -6,6 +6,8 @@ using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; +using System.Windows.Forms.DataVisualization.Charting; +using Results.Entities; namespace Statistics.UserControls { @@ -17,11 +19,33 @@ namespace Statistics.UserControls public StatisticsCtrl() { InitializeComponent(); + chart1.ChartAreas[0].AxisX.LabelStyle.Format = "dd.MM.yy"; + chart1.ChartAreas[0].AxisX.Interval = 1; + chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Days; } private void updateButton_Click(object sender, EventArgs e) { - if (BenchesCtrl != null) BenchesCtrl.UpdateRequest(Id); + if (BenchesCtrl != null) + { + IList results = BenchesCtrl.UpdateRequest(Id); + + if (results != null) + { + foreach (var r in results) + { + chart1.Series["Error"].Points.AddXY(r.StartTime, r.ErrorMaster); + } + return; + } + } + + chart1.Series["Error"].Points.Clear(); + } + + private void exportButton_Click(object sender, EventArgs e) + { + } } } diff --git a/TBF/Properties/AssemblyInfo.cs b/TBF/Properties/AssemblyInfo.cs index 5d3d7fdeb..113033aa8 100644 --- a/TBF/Properties/AssemblyInfo.cs +++ b/TBF/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.18.1103.0")] -[assembly: AssemblyFileVersion("2.18.1103.0")] +[assembly: AssemblyVersion("2.18.1104.0")] +[assembly: AssemblyFileVersion("2.18.1104.0")]