diff --git a/Reseter2/Form1.Designer.cs b/Reseter2/Form1.Designer.cs index 6b49b9f..88dd25e 100644 --- a/Reseter2/Form1.Designer.cs +++ b/Reseter2/Form1.Designer.cs @@ -35,11 +35,16 @@ this.timer1 = new System.Windows.Forms.Timer(this.components); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage3 = new System.Windows.Forms.TabPage(); - this.tabPage4 = new System.Windows.Forms.TabPage(); + this.button1 = new System.Windows.Forms.Button(); + this.label6 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); this.lb_history = new System.Windows.Forms.ListBox(); + this.tabPage4 = new System.Windows.Forms.TabPage(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage3.SuspendLayout(); @@ -90,7 +95,7 @@ this.tabControl1.Location = new System.Drawing.Point(2, 39); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(410, 697); + this.tabControl1.Size = new System.Drawing.Size(410, 714); this.tabControl1.TabIndex = 4; // // tabPage1 @@ -100,62 +105,118 @@ this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(402, 671); + this.tabPage1.Size = new System.Drawing.Size(402, 688); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Задания"; // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.flowLayoutPanel1.AutoScroll = true; - this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; - this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 3); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(396, 665); - this.flowLayoutPanel1.TabIndex = 0; - this.flowLayoutPanel1.WrapContents = false; - // // tabPage2 // this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(392, 671); + this.tabPage2.Size = new System.Drawing.Size(402, 688); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Справочник"; this.tabPage2.UseVisualStyleBackColor = true; // // tabPage3 // + this.tabPage3.Controls.Add(this.button1); + this.tabPage3.Controls.Add(this.label6); + this.tabPage3.Controls.Add(this.label5); + this.tabPage3.Controls.Add(this.label4); + this.tabPage3.Controls.Add(this.label3); this.tabPage3.Controls.Add(this.lb_history); this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Name = "tabPage3"; this.tabPage3.Padding = new System.Windows.Forms.Padding(3); - this.tabPage3.Size = new System.Drawing.Size(402, 671); + this.tabPage3.Size = new System.Drawing.Size(402, 688); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "История"; this.tabPage3.UseVisualStyleBackColor = true; // + // button1 + // + this.button1.Location = new System.Drawing.Point(321, 661); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 6; + this.button1.Text = "Очистить"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("Cascadia Code", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label6.Location = new System.Drawing.Point(327, 3); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(37, 15); + this.label6.TabIndex = 5; + this.label6.Text = "Конец"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("Cascadia Code", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label5.Location = new System.Drawing.Point(185, 3); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(43, 15); + this.label5.TabIndex = 4; + this.label5.Text = "Статус"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Cascadia Code", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label4.Location = new System.Drawing.Point(112, 3); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(25, 15); + this.label4.TabIndex = 3; + this.label4.Text = "Имя"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Cascadia Code", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.label3.Location = new System.Drawing.Point(3, 3); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(79, 15); + this.label3.TabIndex = 2; + this.label3.Text = "Время старта"; + // + // lb_history + // + this.lb_history.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lb_history.Font = new System.Drawing.Font("Cascadia Code", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lb_history.FormattingEnabled = true; + this.lb_history.ItemHeight = 15; + this.lb_history.Location = new System.Drawing.Point(3, 21); + this.lb_history.Name = "lb_history"; + this.lb_history.Size = new System.Drawing.Size(396, 634); + this.lb_history.TabIndex = 0; + // // tabPage4 // this.tabPage4.Location = new System.Drawing.Point(4, 22); this.tabPage4.Name = "tabPage4"; this.tabPage4.Padding = new System.Windows.Forms.Padding(3); - this.tabPage4.Size = new System.Drawing.Size(392, 671); + this.tabPage4.Size = new System.Drawing.Size(402, 688); this.tabPage4.TabIndex = 3; this.tabPage4.Text = "Настройки"; this.tabPage4.UseVisualStyleBackColor = true; // - // lb_history + // flowLayoutPanel1 // - this.lb_history.Dock = System.Windows.Forms.DockStyle.Fill; - this.lb_history.FormattingEnabled = true; - this.lb_history.Location = new System.Drawing.Point(3, 3); - this.lb_history.Name = "lb_history"; - this.lb_history.Size = new System.Drawing.Size(396, 665); - this.lb_history.TabIndex = 0; + this.flowLayoutPanel1.AutoScroll = true; + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 3); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(396, 682); + this.flowLayoutPanel1.TabIndex = 0; + this.flowLayoutPanel1.WrapContents = false; // // Form1 // @@ -168,10 +229,10 @@ this.Controls.Add(this.tb_comp); this.Name = "Form1"; this.Text = "Reseter2"; - this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.tabPage3.ResumeLayout(false); + this.tabPage3.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -185,11 +246,16 @@ private System.Windows.Forms.Timer timer1; private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TabPage tabPage3; private System.Windows.Forms.TabPage tabPage4; private System.Windows.Forms.ListBox lb_history; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; } } diff --git a/Reseter2/Form1.cs b/Reseter2/Form1.cs index 6f01666..52cb7bf 100644 --- a/Reseter2/Form1.cs +++ b/Reseter2/Form1.cs @@ -14,14 +14,14 @@ namespace Reseter2 public partial class Form1 : Form { //private FormHistory formHistory; - public bool Focus; + //public bool Focus; public Form1() { InitializeComponent(); - flowLayoutPanel1.AutoScrollMinSize = new Size(0, 666) ; + flowLayoutPanel1.AutoScrollMinSize = new Size(0, 683) ; flowLayoutPanel1.VerticalScroll.Visible = true; Reseter.SetForm(flowLayoutPanel1); HistoryList.Update += Update_lb; @@ -49,6 +49,13 @@ namespace Reseter2 lb_history.DataSource = HistoryList.Hitem; lb_history.DisplayMember = "ToStr"; } - + + private void button1_Click(object sender, EventArgs e) + { + HistoryList.Clear(); + lb_history.DataSource = null; + lb_history.DataSource = HistoryList.Hitem; + lb_history.DisplayMember = "ToStr"; + } } } diff --git a/Reseter2/History/HistoryItem.cs b/Reseter2/History/HistoryItem.cs index 576aa20..ea37ba2 100644 --- a/Reseter2/History/HistoryItem.cs +++ b/Reseter2/History/HistoryItem.cs @@ -16,6 +16,7 @@ namespace Reseter2.History private AStatusTask statusTask; private DateTime startTime; private string statusName; + private DateTime endTime; public HistoryItem(IComp comp, AStatusTask statusTask, DateTime startTime) { this.comp = comp; @@ -35,6 +36,11 @@ namespace Reseter2.History } + public void SetEndTime(DateTime endTime) + { + this.endTime = endTime; + } + public void ClearTask() { this.task = null; @@ -49,7 +55,7 @@ namespace Reseter2.History this.statusTask = this.task.StatusTask; this.statusName = this.statusTask.GetName(); } - string output = string.Format("{0,5}|{1,10}|{2,10}", startTime.ToString(), comp.GetResetName(), this.statusName, startTime.ToString()); + string output = string.Format("{0,17:dd.MM.yy HH:mm:ss} {1,-12}{2,-22} {3,8:HH:mm:ss}", startTime, comp.GetResetName().ToString(), this.statusName, endTime); return output; } } diff --git a/Reseter2/History/HistoryList.cs b/Reseter2/History/HistoryList.cs index 20b6e05..09e4fdb 100644 --- a/Reseter2/History/HistoryList.cs +++ b/Reseter2/History/HistoryList.cs @@ -21,7 +21,7 @@ namespace Reseter2.History { HistoryItem historyItem = new HistoryItem(reseterTask); - Hitem.Add(historyItem); + Hitem.Insert(0, historyItem); Update(); return historyItem; @@ -31,6 +31,9 @@ namespace Reseter2.History { Update(); } - + static public void Clear() + { + Hitem.Clear(); + } } } diff --git a/Reseter2/IStatusTask.cs b/Reseter2/IStatusTask.cs index 3d45be3..b24a7cb 100644 --- a/Reseter2/IStatusTask.cs +++ b/Reseter2/IStatusTask.cs @@ -23,6 +23,7 @@ namespace Reseter2 } public void RebootReturn() { + resetertask.historyItem.SetEndTime(DateTime.Now); resetertask.historyItem.ClearTask(); resetertask.StatusTask = new StatusPreReboot(resetertask); resetertask.historyItem = HistoryList.Add(resetertask); diff --git a/Reseter2/StatusRebootStop.cs b/Reseter2/StatusRebootStop.cs index e9d9f42..fc1ac02 100644 --- a/Reseter2/StatusRebootStop.cs +++ b/Reseter2/StatusRebootStop.cs @@ -13,6 +13,7 @@ namespace Reseter2 { resetertask.SetNameStage("Остановленно"); PingResult = resetertask.pingResult; + resetertask.historyItem.SetEndTime(DateTime.Now); reseterTask.sw.Stop(); } diff --git a/Reseter2/StatusRebootSucces.cs b/Reseter2/StatusRebootSucces.cs index 84a7210..3315911 100644 --- a/Reseter2/StatusRebootSucces.cs +++ b/Reseter2/StatusRebootSucces.cs @@ -12,6 +12,7 @@ namespace Reseter2 public StatusRebootSucces(ReseterTask reseterTask) : base(reseterTask) { resetertask.SetNameStage("Успешно перезагруженно"); + resetertask.historyItem.SetEndTime(DateTime.Now); PingResult = resetertask.Ping(); reseterTask.sw.Stop(); } diff --git a/Reseter2/reseter.cs b/Reseter2/reseter.cs index 44b70ee..646b386 100644 --- a/Reseter2/reseter.cs +++ b/Reseter2/reseter.cs @@ -1,4 +1,5 @@ -using System; +using Reseter2.History; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -51,6 +52,8 @@ namespace Reseter2 public static async void Clear(ReseterTask reseterTask, TaskControl taskControl) { + reseterTask.historyItem.SetEndTime(DateTime.Now); + HistoryList.Updated(); flow_conteiner.Controls.Remove(taskControl); list_task.Remove(reseterTask);