From a0742c8c433353b10939ab446dc0c42bc741340f Mon Sep 17 00:00:00 2001 From: szporowolik Date: Sat, 19 Oct 2019 13:34:50 +0200 Subject: [PATCH] Performance upgrade - icons reloading will not affect performance --- 02_Windows_App/Perun_v1/01_Classes/Globals.cs | 1 + .../Perun_v1/02_Forms/form_Main.Designer.cs | 56 +++++++++++++++++-- 02_Windows_App/Perun_v1/02_Forms/form_Main.cs | 23 ++++++-- 3 files changed, 70 insertions(+), 10 deletions(-) diff --git a/02_Windows_App/Perun_v1/01_Classes/Globals.cs b/02_Windows_App/Perun_v1/01_Classes/Globals.cs index 3b461e0..27b4bac 100644 --- a/02_Windows_App/Perun_v1/01_Classes/Globals.cs +++ b/02_Windows_App/Perun_v1/01_Classes/Globals.cs @@ -8,6 +8,7 @@ internal class Globals public static bool bLogHistoryUpdate = true; // Mark if log control require update public static string strPerunTitleText = ""; + public static bool bStatusIconsForce = true; // Force icons reload public static bool bdcConnection = false; // Historic db connection status public static bool btcpcServer = false; // Historic tcp connection status public static bool bSRSStatus = false; // Historic srs connection status diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs index 36951ba..fc3a6bf 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs @@ -69,6 +69,10 @@ this.con_img_srs = new System.Windows.Forms.PictureBox(); this.con_img_dcs = new System.Windows.Forms.PictureBox(); this.con_img_db = new System.Windows.Forms.PictureBox(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.label11 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); this.con_GroupBox_1.SuspendLayout(); this.con_GroupBox_2.SuspendLayout(); this.con_GroupBox_3.SuspendLayout(); @@ -384,7 +388,7 @@ // // con_img_lotATC // - this.con_img_lotATC.Location = new System.Drawing.Point(307, 335); + this.con_img_lotATC.Location = new System.Drawing.Point(292, 335); this.con_img_lotATC.Name = "con_img_lotATC"; this.con_img_lotATC.Size = new System.Drawing.Size(29, 28); this.con_img_lotATC.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -393,7 +397,7 @@ // // con_img_srs // - this.con_img_srs.Location = new System.Drawing.Point(272, 335); + this.con_img_srs.Location = new System.Drawing.Point(208, 335); this.con_img_srs.Name = "con_img_srs"; this.con_img_srs.Size = new System.Drawing.Size(29, 28); this.con_img_srs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -402,7 +406,7 @@ // // con_img_dcs // - this.con_img_dcs.Location = new System.Drawing.Point(237, 335); + this.con_img_dcs.Location = new System.Drawing.Point(135, 335); this.con_img_dcs.Name = "con_img_dcs"; this.con_img_dcs.Size = new System.Drawing.Size(29, 28); this.con_img_dcs.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -412,18 +416,58 @@ // con_img_db // this.con_img_db.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.con_img_db.Location = new System.Drawing.Point(202, 335); + this.con_img_db.Location = new System.Drawing.Point(69, 335); this.con_img_db.Name = "con_img_db"; this.con_img_db.Size = new System.Drawing.Size(29, 28); this.con_img_db.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.con_img_db.TabIndex = 10; this.con_img_db.TabStop = false; // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(15, 335); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(56, 13); + this.label9.TabIndex = 1; + this.label9.Text = "Database:"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(101, 335); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(38, 13); + this.label10.TabIndex = 14; + this.label10.Text = "Game:"; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(170, 335); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(32, 13); + this.label11.TabIndex = 15; + this.label11.Text = "SRS:"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(243, 335); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(46, 13); + this.label12.TabIndex = 16; + this.label12.Text = "LotATC:"; + // // form_Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(349, 604); + this.Controls.Add(this.label12); + this.Controls.Add(this.label11); + this.Controls.Add(this.label10); + this.Controls.Add(this.label9); this.Controls.Add(this.con_img_lotATC); this.Controls.Add(this.con_img_srs); this.Controls.Add(this.con_img_dcs); @@ -503,6 +547,10 @@ private System.Windows.Forms.PictureBox con_img_dcs; private System.Windows.Forms.PictureBox con_img_srs; private System.Windows.Forms.PictureBox con_img_lotATC; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label12; } } diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs index 076329a..cbcd6ea 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs @@ -166,6 +166,9 @@ namespace Perun_v1 // Prepare connection string dcConnection.strMySQLConnectionString = "server=" + con_txt_mysql_server.Text + ";user=" + con_txt_mysql_username.Text + ";database=" + con_txt_mysql_database.Text + ";port=" + con_txt_mysql_port.Text + ";password=" + con_txt_mysql_password.Text; + // Force icons update + Globals.bStatusIconsForce = true; + // Start timmers tim_200ms.Enabled = true; tim_1000ms.Enabled = true; @@ -221,7 +224,14 @@ namespace Perun_v1 // Set title bar this.Text = Globals.strPerunTitleText; - } + + // Set helpers for updates + Globals.bLogHistoryUpdate = false; + Globals.bdcConnection = false; + Globals.btcpcServer = false; + Globals.bSRSStatus = false; + Globals.bLotATCStatus = false; + } private void con_lab_github_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { @@ -367,7 +377,7 @@ namespace Perun_v1 } // Update status icons at main form - if (dcConnection.bStatus != Globals.bdcConnection) { + if ((dcConnection.bStatus != Globals.bdcConnection) || Globals.bStatusIconsForce) { if (dcConnection.bStatus) { con_img_db.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_db"); @@ -378,7 +388,7 @@ namespace Perun_v1 Globals.bdcConnection = dcConnection.bStatus; } - if (tcpcServer.bStatus != Globals.btcpcServer) { + if ((tcpcServer.bStatus != Globals.btcpcServer) || Globals.bStatusIconsForce) { if (tcpcServer.bStatus) { con_img_dcs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_game"); @@ -389,7 +399,7 @@ namespace Perun_v1 } Globals.btcpcServer = tcpcServer.bStatus; } - if (bSRSStatus != Globals.bSRSStatus) { + if ((bSRSStatus != Globals.bSRSStatus) || Globals.bStatusIconsForce) { if (bSRSStatus) { con_img_srs.Image = (Image)Properties.Resources.ResourceManager.GetObject("ico_srs"); @@ -400,7 +410,7 @@ namespace Perun_v1 } Globals.bSRSStatus = bSRSStatus; } - if (bLotATCStatus != Globals.bLotATCStatus) + if ((bLotATCStatus != Globals.bLotATCStatus) || Globals.bStatusIconsForce) { if (bLotATCStatus) { @@ -412,7 +422,7 @@ namespace Perun_v1 } Globals.bLotATCStatus = bLotATCStatus; } - + Globals.bStatusIconsForce = false; } private void tim_10000ms_Tick(object sender, EventArgs e) @@ -517,5 +527,6 @@ namespace Perun_v1 } dcConnection.SendToMySql(strLotATCJson); } + } }