diff --git a/EgwControlCenter.Core/ReleaseChecker.cs b/EgwControlCenter.Core/ReleaseChecker.cs index 77fbe34..4b395db 100644 --- a/EgwControlCenter.Core/ReleaseChecker.cs +++ b/EgwControlCenter.Core/ReleaseChecker.cs @@ -57,6 +57,45 @@ namespace EgwControlCenter.Core #region Public Properties + + /// + /// DataOra ultimo check locale + /// + public DateTime LastChecked() + { + DateTime answ = new DateTime(DateTime.Today.Year, 1, 1); + //se ho record locali cerco il + recente + if (ListStatus != null && ListStatus.Count > 0) + { + var primo = ListStatus + .OrderByDescending(x => x.LastUpdateLoc) + .FirstOrDefault(); + if (primo != null) + { + answ = primo.LastUpdateLoc; + } + } + return answ; + } + + public bool HasUpdate() + { + bool answ = false; + //se ho record locali cerco il + recente + if (ListStatus != null && ListStatus.Count > 0) + { + foreach (var item in ListStatus) + { + answ = item.HasUpdate(); + if(answ) + { + break; + } + } + } + return answ; + } + /// /// Elenco degli oggetti stato dei programmi monitorati /// diff --git a/EgwControlCenter/App.config b/EgwControlCenter/App.config index 246180f..9e682e6 100644 --- a/EgwControlCenter/App.config +++ b/EgwControlCenter/App.config @@ -46,7 +46,7 @@ - + diff --git a/EgwControlCenter/ControlCenter.Designer.cs b/EgwControlCenter/ControlCenter.Designer.cs index eb9c876..14b07da 100644 --- a/EgwControlCenter/ControlCenter.Designer.cs +++ b/EgwControlCenter/ControlCenter.Designer.cs @@ -31,34 +31,29 @@ components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ControlCenter)); label1 = new Label(); - label2 = new Label(); trayMenu = new ContextMenuStrip(components); notifyIcon1 = new NotifyIcon(components); btnSetup = new Button(); btnUpdate = new Button(); lblOut = new Label(); timerCheck = new System.Windows.Forms.Timer(components); + statusStrip1 = new StatusStrip(); + tsLabelOut = new ToolStripStatusLabel(); + dgView = new DataGridView(); + statusStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dgView).BeginInit(); SuspendLayout(); // // label1 // label1.AutoSize = true; - label1.Font = new Font("Roboto", 24F, FontStyle.Regular, GraphicsUnit.Point, 0); - label1.Location = new Point(193, 9); + label1.Font = new Font("Roboto", 16F, FontStyle.Regular, GraphicsUnit.Point, 0); + label1.Location = new Point(34, 9); label1.Name = "label1"; - label1.Size = new Size(429, 38); + label1.Size = new Size(293, 27); label1.TabIndex = 0; label1.Text = "EgalWare App Control Center"; // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(53, 83); - label2.Name = "label2"; - label2.Size = new Size(152, 15); - label2.TabIndex = 1; - label2.Text = "Elenco App (list? webview?)"; - // // trayMenu // trayMenu.Name = "trayMenu"; @@ -75,7 +70,7 @@ // // btnSetup // - btnSetup.Location = new Point(761, 23); + btnSetup.Location = new Point(352, 13); btnSetup.Name = "btnSetup"; btnSetup.Size = new Size(27, 23); btnSetup.TabIndex = 3; @@ -85,11 +80,11 @@ // // btnUpdate // - btnUpdate.Location = new Point(577, 77); + btnUpdate.Location = new Point(281, 267); btnUpdate.Name = "btnUpdate"; - btnUpdate.Size = new Size(75, 23); + btnUpdate.Size = new Size(98, 23); btnUpdate.TabIndex = 4; - btnUpdate.Text = "Update"; + btnUpdate.Text = "Check Now"; btnUpdate.UseVisualStyleBackColor = true; btnUpdate.Click += btnUpdate_Click; // @@ -107,22 +102,51 @@ timerCheck.Interval = 1000; timerCheck.Tick += timerCheck_Tick; // + // statusStrip1 + // + statusStrip1.Items.AddRange(new ToolStripItem[] { tsLabelOut }); + statusStrip1.Location = new Point(0, 293); + statusStrip1.Name = "statusStrip1"; + statusStrip1.Size = new Size(388, 22); + statusStrip1.TabIndex = 6; + statusStrip1.Text = "statusStrip1"; + // + // tsLabelOut + // + tsLabelOut.Name = "tsLabelOut"; + tsLabelOut.Size = new Size(49, 17); + tsLabelOut.Text = "v.0.0.0.0"; + tsLabelOut.TextImageRelation = TextImageRelation.Overlay; + // + // dgView + // + dgView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgView.Location = new Point(12, 56); + dgView.Name = "dgView"; + dgView.Size = new Size(364, 205); + dgView.TabIndex = 7; + // // ControlCenter // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); + ClientSize = new Size(388, 315); + Controls.Add(dgView); + Controls.Add(statusStrip1); Controls.Add(lblOut); Controls.Add(btnUpdate); Controls.Add(btnSetup); - Controls.Add(label2); Controls.Add(label1); Icon = (Icon)resources.GetObject("$this.Icon"); Name = "ControlCenter"; Text = "Egalware Control Center"; FormClosing += ControlCenter_FormClosing; + Load += ControlCenter_Load; Shown += ControlCenter_Shown; Resize += ControlCenter_Resize; + statusStrip1.ResumeLayout(false); + statusStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dgView).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -130,12 +154,14 @@ #endregion private Label label1; - private Label label2; private ContextMenuStrip trayMenu; private NotifyIcon notifyIcon1; private Button btnSetup; private Button btnUpdate; private Label lblOut; private System.Windows.Forms.Timer timerCheck; + private StatusStrip statusStrip1; + private ToolStripStatusLabel tsLabelOut; + private DataGridView dgView; } } diff --git a/EgwControlCenter/ControlCenter.cs b/EgwControlCenter/ControlCenter.cs index 2b4b44c..00c50d9 100644 --- a/EgwControlCenter/ControlCenter.cs +++ b/EgwControlCenter/ControlCenter.cs @@ -15,8 +15,6 @@ namespace EgwControlCenter public ControlCenter() { InitializeComponent(); - SetupTrayIcon(); - CreateTrayMenu(); InitObjects(); } @@ -117,6 +115,13 @@ namespace EgwControlCenter timerCheck.Dispose(); } + private void ControlCenter_Load(object sender, EventArgs e) + { + // posiziono in basso a sx... + Rectangle workArea = Screen.GetWorkingArea(this); + this.Location = new Point(workArea.Right - Size.Width, workArea.Bottom - Size.Height); + } + /// /// evento resize /// @@ -165,6 +170,7 @@ namespace EgwControlCenter /// private void DisplayCheckResult(TimeSpan elapsed) { +#if false StringBuilder sb = new StringBuilder(); sb.AppendLine("---------------------"); sb.AppendLine($"{DateTime.Now:HH:mm:ss}"); @@ -178,13 +184,27 @@ namespace EgwControlCenter sb.AppendLine(); sb.AppendLine("---------------------"); sb.AppendLine($"Eseguito refresh | Loc: {locCheckOk} | Rem: {remCheckOk} | {elapsed.TotalMilliseconds:N0} ms"); - lblOut.Text = sb.ToString(); + lblOut.Text = sb.ToString(); +#endif + tsLabelOut.Text = $"Last Check: {CurrCheck.LastChecked():yyyy-MM-dd HH:mm:ss}"; + // notifica ballontip se ho aggiornamenti... + if(CurrCheck.HasUpdate()) + { + + notifyIcon1.BalloonTipTitle = "EgalWare's App Control Center"; + notifyIcon1.BalloonTipText = "Update found!"; + notifyIcon1.BalloonTipIcon = ToolTipIcon.Warning; + notifyIcon1.ShowBalloonTip(1000); + } } private void InitObjects() { + SetupTrayIcon(); + CreateTrayMenu(); // init obj gestione check... CurrCheck = new ReleaseChecker(AccUtils.confDir, "ConfPatrol.json"); + tsLabelOut.Text = $"Last Check: {CurrCheck.LastChecked():yyyy-MM-dd HH:mm:ss}"; timerCheck.Start(); } @@ -238,7 +258,10 @@ namespace EgwControlCenter remCheckOk = CurrCheck.CheckCurrReleases(); } sw.Stop(); - DisplayCheckResult(sw.Elapsed); + if (locCheckOk) + { + DisplayCheckResult(sw.Elapsed); + } } /// diff --git a/EgwControlCenter/ControlCenter.resx b/EgwControlCenter/ControlCenter.resx index fdb3f2b..7072d7c 100644 --- a/EgwControlCenter/ControlCenter.resx +++ b/EgwControlCenter/ControlCenter.resx @@ -293,6 +293,9 @@ 236, 17 + + 351, 17 + AAABAAEAMDAAAAEAIACoJQAAFgAAACgAAAAwAAAAYAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA