add class

This commit is contained in:
klavirshik 2024-07-15 18:09:09 +02:00
parent 7333f919a0
commit f4c5232547
12 changed files with 122 additions and 9 deletions

View File

@ -11,6 +11,11 @@ namespace Reseter2
private string Name { get; set; }
private string Description { get; set; }
private string Ip { get; set; }
public CompId(string name)
{
this.Name = name;
}
public CompId(string name, string description)
{
this.Name = name;

View File

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.tb_comp = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
@ -36,6 +37,7 @@
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
//
@ -64,6 +66,7 @@
this.bt_reset.TabIndex = 2;
this.bt_reset.Text = "Перезагрузить";
this.bt_reset.UseVisualStyleBackColor = true;
this.bt_reset.Click += new System.EventHandler(this.bt_reset_Click);
//
// toolStrip1
//
@ -106,6 +109,13 @@
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(394, 380);
this.flowLayoutPanel1.TabIndex = 4;
this.flowLayoutPanel1.WrapContents = false;
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Form1
//
@ -134,6 +144,7 @@
private System.Windows.Forms.ToolStripButton toolStripButton1;
private System.Windows.Forms.ToolStripButton toolStripButton2;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Timer timer1;
}
}

View File

@ -14,12 +14,24 @@ namespace Reseter2
{
public Form1()
{
InitializeComponent();
Reseter.SetForm(flowLayoutPanel1);
}
private void label1_Click(object sender, EventArgs e)
{
}
private void bt_reset_Click(object sender, EventArgs e)
{
Reseter.AddTask(tb_comp.Text) ;
}
private void timer1_Tick(object sender, EventArgs e)
{
Reseter.Tick();
}
}
}

View File

@ -151,4 +151,7 @@
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>122, 17</value>
</metadata>
</root>

View File

@ -13,6 +13,7 @@ namespace Reseter2
{
resetertask = reseterTask;
}
public abstract void Tick();
public abstract void Stop();
public abstract void Next();
}

12
Reseter2/Pinger.cs Normal file
View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Reseter2
{
internal class Pinger
{
}
}

View File

@ -6,21 +6,37 @@ using System.Threading.Tasks;
namespace Reseter2
{
internal class ReseterTask
class ReseterTask
{
private IComp Comp;
private AStatusTask StatusTask;
private TaskControl taskControl;
public ReseterTask(IComp comp)
public ReseterTask(IComp comp, TaskControl taskCntrl)
{
Comp = comp;
taskControl = taskCntrl;
StatusTask = new StatusPreReboot(this);
}
public string GetName()
{
return Comp.GetName();
}
public void Tick()
{
StatusTask.Tick();
}
public void DataContrl(string srt)
{
taskControl.DataContrl(srt);
}
private void Clear()
{
Reseter.Clear(this);
Reseter.Clear(this, taskControl);
}
}
}

View File

@ -55,6 +55,7 @@
</Compile>
<Compile Include="IComp.cs" />
<Compile Include="IStatusTask.cs" />
<Compile Include="Pinger.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="reseter.cs" />

View File

@ -8,10 +8,16 @@ namespace Reseter2
{
internal class StatusPreReboot : AStatusTask
{
private int time;
public StatusPreReboot(ReseterTask reseterTask) : base(reseterTask)
{
}
public override void Tick()
{
time++;
resetertask.DataContrl(time.ToString());
}
public override void Next()
{

View File

@ -133,6 +133,7 @@
this.button1.TabIndex = 9;
this.button1.Text = "Остановить";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//

View File

@ -11,16 +11,34 @@ using System.Windows.Forms;
namespace Reseter2
{
[DefaultEvent(nameof(TaskControl))]
public partial class TaskControl : UserControl
partial class TaskControl : UserControl
{
ReseterTask reseterTask;
public TaskControl()
{
reseterTask = null;
InitializeComponent();
}
public void Intit(ReseterTask res)
{
reseterTask = res;
lb_name.Text = reseterTask.GetName();
}
public void DataContrl(string ping)
{
label5.Text = ping;
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Reseter.Clear(reseterTask, this);
}
}
}

View File

@ -1,24 +1,51 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection.Emit;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Reseter2
{
internal static class Reseter
{
private static List<ReseterTask> list_task;
private static List<ReseterTask> list_task = new List<ReseterTask>();
private static Panel flow_conteiner;
public static void SetForm(Panel flow_cntr)
{
flow_conteiner = flow_cntr;
}
public static void AddTask(String name)
{
CompId compid = new CompId(name);
AddTask(compid);
}
public static void AddTask(IComp compName)
{
list_task.Add(new ReseterTask(compName));
TaskControl taskControl = new TaskControl();
ReseterTask reseterTask = new ReseterTask(compName, taskControl);
taskControl.Intit(reseterTask);
flow_conteiner.Controls.Add(taskControl);
list_task.Add(reseterTask);
}
public static void Clear(ReseterTask reseterTask)
public static void Clear(ReseterTask reseterTask, TaskControl taskControl)
{
flow_conteiner.Controls.Remove(taskControl);
list_task.Remove(reseterTask);
}
public static void Tick()
{
foreach (var item in list_task)
{
item.Tick();
}
}
}
}