From f493dc1e7a0723ae10bb9eb5e1dea94ffab8fd61 Mon Sep 17 00:00:00 2001 From: klavirshik Date: Fri, 23 Aug 2024 07:47:51 +0200 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BB=D1=8E=D1=88=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reseter2/Form1.Designer.cs | 97 +++++++++++++++++++++++-- Reseter2/Form1.cs | 83 +++++++++++++++++---- Reseter2/Form1.resx | 10 ++- Reseter2/IStatusTask.cs | 2 +- Reseter2/ReseteTask.cs | 2 +- Reseter2/Setting/SettingWordsControl.cs | 10 +-- Reseter2/StatusCanceled.cs | 4 + Reseter2/StatusReboot.cs | 4 + Reseter2/StatusRebootError.cs | 4 + Reseter2/StatusRebootStop.cs | 4 + Reseter2/StatusRebootSucces.cs | 4 + Reseter2/StatusRebooting.cs | 4 + Reseter2/StausPreReboot.cs | 5 ++ Reseter2/TaskControl.Designer.cs | 23 ++++++ Reseter2/TaskControl.cs | 16 +++- Reseter2/TaskControl.resx | 5 +- Reseter2/Words/BilderWords.cs | 1 + Reseter2/reseter.cs | 42 +++++++++-- 18 files changed, 282 insertions(+), 38 deletions(-) diff --git a/Reseter2/Form1.Designer.cs b/Reseter2/Form1.Designer.cs index 51f5d0e..6c38e5d 100644 --- a/Reseter2/Form1.Designer.cs +++ b/Reseter2/Form1.Designer.cs @@ -35,6 +35,11 @@ this.timer1 = new System.Windows.Forms.Timer(this.components); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); + this.button2 = new System.Windows.Forms.Button(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.ss_activ = new System.Windows.Forms.ToolStripStatusLabel(); + this.ss_close = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.label2 = new System.Windows.Forms.Label(); @@ -56,6 +61,8 @@ this.tabPage5 = new System.Windows.Forms.TabPage(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label16 = new System.Windows.Forms.Label(); + this.cm_words = new System.Windows.Forms.ContextMenuStrip(this.components); + this.WordsReboot = new System.Windows.Forms.ToolStripMenuItem(); this.cb_comp = new System.Windows.Forms.ComboBox(); this.checkControl1 = new Reseter2.CheckControl(); this.treeView1 = new Reseter2.NewTreeView(); @@ -64,12 +71,14 @@ this.settingWordsControl1 = new Reseter2.Setting.SettingWordsControl(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); + this.statusStrip1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.tabPage3.SuspendLayout(); this.cm_history.SuspendLayout(); this.tabPage4.SuspendLayout(); this.tabPage5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.cm_words.SuspendLayout(); this.SuspendLayout(); // // label1 @@ -120,7 +129,9 @@ // // tabPage1 // - this.tabPage1.BackColor = System.Drawing.SystemColors.Window; + this.tabPage1.BackColor = System.Drawing.SystemColors.Control; + this.tabPage1.Controls.Add(this.button2); + this.tabPage1.Controls.Add(this.statusStrip1); this.tabPage1.Controls.Add(this.flowLayoutPanel1); this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; @@ -129,15 +140,59 @@ this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Задания"; // + // button2 + // + this.button2.Location = new System.Drawing.Point(236, 665); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(165, 23); + this.button2.TabIndex = 2; + this.button2.Text = "Очистить все завершенные"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // statusStrip1 + // + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.ss_activ, + this.ss_close, + this.toolStripStatusLabel1}); + this.statusStrip1.Location = new System.Drawing.Point(3, 663); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(396, 22); + this.statusStrip1.TabIndex = 1; + this.statusStrip1.Text = "statusStrip1"; + // + // ss_activ + // + this.ss_activ.Name = "ss_activ"; + this.ss_activ.Size = new System.Drawing.Size(61, 17); + this.ss_activ.Text = "Активные"; + this.ss_activ.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + // + // ss_close + // + this.ss_close.Name = "ss_close"; + this.ss_close.Size = new System.Drawing.Size(85, 17); + this.ss_close.Text = "Завершенные"; + this.ss_close.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + // + // toolStripStatusLabel1 + // + this.toolStripStatusLabel1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 17); + this.toolStripStatusLabel1.Text = "toolStripStatusLabel1"; + // // flowLayoutPanel1 // + this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.flowLayoutPanel1.AutoScroll = true; this.flowLayoutPanel1.BackColor = System.Drawing.SystemColors.Window; - 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.Size = new System.Drawing.Size(396, 657); this.flowLayoutPanel1.TabIndex = 0; this.flowLayoutPanel1.WrapContents = false; // @@ -283,27 +338,28 @@ // // cm_history // + this.cm_history.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.cm_history.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.sm_RebootItem, this.sm_SaveItem}); this.cm_history.Name = "cm_history"; this.cm_history.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.cm_history.ShowCheckMargin = true; - this.cm_history.Size = new System.Drawing.Size(177, 48); + this.cm_history.ShowImageMargin = false; + this.cm_history.Size = new System.Drawing.Size(156, 70); this.cm_history.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.cm_history_Closed); this.cm_history.Opening += new System.ComponentModel.CancelEventHandler(this.cm_history_Opening); // // sm_RebootItem // this.sm_RebootItem.Name = "sm_RebootItem"; - this.sm_RebootItem.Size = new System.Drawing.Size(176, 22); + this.sm_RebootItem.Size = new System.Drawing.Size(155, 22); this.sm_RebootItem.Text = "Перезагрузить"; this.sm_RebootItem.Click += new System.EventHandler(this.sm_RebootItem_Click); // // sm_SaveItem // this.sm_SaveItem.Name = "sm_SaveItem"; - this.sm_SaveItem.Size = new System.Drawing.Size(176, 22); + this.sm_SaveItem.Size = new System.Drawing.Size(155, 22); this.sm_SaveItem.Text = "Сохранить"; this.sm_SaveItem.Click += new System.EventHandler(this.sm_SaveItem_Click); // @@ -360,12 +416,28 @@ this.label16.TabIndex = 0; this.label16.Text = "Reseter2"; // + // cm_words + // + this.cm_words.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.WordsReboot}); + this.cm_words.Name = "cm_words"; + this.cm_words.ShowImageMargin = false; + this.cm_words.Size = new System.Drawing.Size(125, 26); + // + // WordsReboot + // + this.WordsReboot.Name = "WordsReboot"; + this.WordsReboot.Size = new System.Drawing.Size(124, 22); + this.WordsReboot.Text = "Перезарузить"; + this.WordsReboot.Click += new System.EventHandler(this.WordsReboot_Click); + // // cb_comp // this.cb_comp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.cb_comp.DropDownHeight = 1; this.cb_comp.FormattingEnabled = true; + this.cb_comp.IntegralHeight = false; this.cb_comp.Items.AddRange(new object[] { "889", "fdfd"}); @@ -443,6 +515,9 @@ this.Load += new System.EventHandler(this.Form1_Load); this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); + this.tabPage1.PerformLayout(); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); this.tabPage2.ResumeLayout(false); this.tabPage2.PerformLayout(); this.tabPage3.ResumeLayout(false); @@ -452,6 +527,7 @@ this.tabPage5.ResumeLayout(false); this.tabPage5.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.cm_words.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -490,6 +566,13 @@ private Setting.SettingRebootControl settingRebootControl1; private Setting.SettingSCCMControl settingSCCMControl1; private System.Windows.Forms.ComboBox cb_comp; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel ss_activ; + private System.Windows.Forms.ToolStripStatusLabel ss_close; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.ContextMenuStrip cm_words; + private System.Windows.Forms.ToolStripMenuItem WordsReboot; } } diff --git a/Reseter2/Form1.cs b/Reseter2/Form1.cs index ddd81c9..6c954d8 100644 --- a/Reseter2/Form1.cs +++ b/Reseter2/Form1.cs @@ -14,6 +14,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; + namespace Reseter2 { public partial class Form1 : Form @@ -56,7 +57,6 @@ namespace Reseter2 InitializeComponent(); - settingWordsControl1.treeView = treeView1; this.Save += settingWordsControl1.Save; this.Save += settingSCCMControl1.Save; this.Save += settingRebootControl1.Save; @@ -64,14 +64,14 @@ namespace Reseter2 this.UpdateSetting += settingWordsControl1.UpdateSetting; this.UpdateSetting += settingSCCMControl1.UpdateSetting; this.UpdateSetting += settingRebootControl1.UpdateSetting; - + this.settingWordsControl1.UpdateTree = UpdateTree; // cb_comp.DropDownStyle = ComboBoxStyle.DropDown; checkControl1.updateCheck += CheckControl1_updateCheck; - flowLayoutPanel1.AutoScrollMinSize = new Size(0, 683) ; + flowLayoutPanel1.AutoScrollMinSize = new Size(0, 658) ; flowLayoutPanel1.VerticalScroll.Visible = true; - Reseter.SetForm(flowLayoutPanel1); + Reseter.SetForm(flowLayoutPanel1, this); HistoryList.Update += Update_lb; lb_history.DataSource = HistoryList.Hitem; lb_history.DisplayMember = "ToStr"; @@ -82,13 +82,15 @@ namespace Reseter2 //treeView1.SelectedNode. //treeView1.MouseCaptureChanged.; tabControl1.SelectedIndex = 1; - - } - + public void UpdateTree() + { + treeView1.Nodes.Clear(); + treeView1.Nodes.AddRange(WordsList.ListNodes()); + } private void bt_reset_Click(object sender, EventArgs e) { @@ -98,7 +100,25 @@ namespace Reseter2 private void timer1_Tick(object sender, EventArgs e) { - Reseter.Tick(); + int Act; + int Cls; + Reseter.Tick(out Act,out Cls) ; + if (Act>0) + { + ss_activ.Text = "Активно:" + Act; + } + else + { + ss_activ.Text = ""; + } + if (Cls > 0) + { + ss_close.Text = "Завершено:" + Cls; + } + else + { + ss_close.Text = ""; + } } public void Update_lb() { @@ -276,7 +296,7 @@ namespace Reseter2 private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { - if (e.Node.Tag is WordsComp) + if (e.Button == MouseButtons.Left && e.Node.Tag is WordsComp) { WordsComp wordsComp = (WordsComp)e.Node.Tag; @@ -294,13 +314,23 @@ namespace Reseter2 TreeView tree = (TreeView)sender; - if(e.Button == MouseButtons.Right) + Rectangle BoundsNode = new(e.Node.Bounds.X - 43, e.Node.Bounds.Y, e.Node.Bounds.Width + 43, e.Node.Bounds.Height); + if (e.Button == MouseButtons.Right) { - tree.SelectedNode = e.Node; + if (BoundsNode.Contains(e.Location) && e.Node.Tag is WordsComp) + { + tree.SelectedNode = e.Node; + cm_words.Show(tree.PointToScreen(e.Location)); + } + else + { + tree.SelectedNode = null; + } + } //tree.BeginUpdate(); - Rectangle BoundsIcon = new Rectangle(e.Node.Bounds.X -43, e.Node.Bounds.Y + 2, 17, 18); - if (BoundsIcon.Contains(e.Location)) + Rectangle BoundsIcon = new(e.Node.Bounds.X -43, e.Node.Bounds.Y + 2, 17, 18); + if (e.Button == MouseButtons.Left && BoundsIcon.Contains(e.Location)) { e.Node.Checked = !e.Node.Checked; if (e.Node.Checked) @@ -360,7 +390,11 @@ namespace Reseter2 { comps.AddRange(treeViewCheckOn(treeView1.Nodes[i])); } - + if(comps.Count == 0) + { + MessageBox.Show("Не выбранно ни одного ПК"); + return; + } DialogResult result = MessageBox.Show("Будет перезагруженно " + comps.Count() + " компьютеров.\nПродолжить?", "Запуск многопоточной перезагрузки.", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { @@ -442,6 +476,27 @@ namespace Reseter2 UpdateSetting(); } } + + private void button2_Click(object sender, EventArgs e) + { + Reseter.ClearCanceled(); + } + + private void WordsReboot_Click(object sender, EventArgs e) + { + if(treeView1.SelectedNode.Tag is WordsComp) + { + WordsComp wordsComp = (WordsComp)treeView1.SelectedNode.Tag; + + DialogResult result = MessageBox.Show("Перезагрузить ПК: " + wordsComp.NameNode(), "Создание новой задачи", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (result == DialogResult.Yes) + { + Reseter.AddTask(wordsComp.GetComp()); + tabControl1.SelectedIndex = 0; + } + } + + } } } diff --git a/Reseter2/Form1.resx b/Reseter2/Form1.resx index 81ae244..4d48960 100644 --- a/Reseter2/Form1.resx +++ b/Reseter2/Form1.resx @@ -120,6 +120,9 @@ 122, 17 + + 645, 17 + 425, 17 @@ -128,7 +131,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACk - UQAAAk1TRnQBSQFMAgEBCQEAAUABAgFAAQIBGAEAARgBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFg + UQAAAk1TRnQBSQFMAgEBCQEAAcgBAgHIAQIBGAEAARgBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFg AwABSAMAAQEBAAEQBgABNhIAAf8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/ AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/kAAB/wF/ Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/ @@ -487,7 +490,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABQ - CgAAAk1TRnQBSQFMAgEBAwEAAeABAAHgAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CgAAAk1TRnQBSQFMAgEBAwEAAWgBAQFoAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -537,6 +540,9 @@ 209, 17 + + 761, 17 + diff --git a/Reseter2/IStatusTask.cs b/Reseter2/IStatusTask.cs index b24a7cb..c3e614b 100644 --- a/Reseter2/IStatusTask.cs +++ b/Reseter2/IStatusTask.cs @@ -29,6 +29,6 @@ namespace Reseter2 resetertask.historyItem = HistoryList.Add(resetertask); HistoryList.Updated(); } - + public abstract int ActionIs(); } } diff --git a/Reseter2/ReseteTask.cs b/Reseter2/ReseteTask.cs index 252f0ed..88fe8f2 100644 --- a/Reseter2/ReseteTask.cs +++ b/Reseter2/ReseteTask.cs @@ -15,7 +15,7 @@ namespace Reseter2 public DateTime StartTime = DateTime.Now; public IComp Comp { get; } public AStatusTask StatusTask { get; set; } - private TaskControl taskControl; + public TaskControl taskControl; private Pinger Pingers; public Stopwatch sw = new Stopwatch(); public PingResult pingResult; diff --git a/Reseter2/Setting/SettingWordsControl.cs b/Reseter2/Setting/SettingWordsControl.cs index 30fc780..a18e547 100644 --- a/Reseter2/Setting/SettingWordsControl.cs +++ b/Reseter2/Setting/SettingWordsControl.cs @@ -16,7 +16,9 @@ namespace Reseter2.Setting partial class SettingWordsControl : UserControl { - public NewTreeView treeView; + + public delegate void DUpdateTree(); + public DUpdateTree UpdateTree; public SettingWordsControl() { InitializeComponent(); @@ -37,11 +39,7 @@ namespace Reseter2.Setting DialogResult result = bilderWords.ShowDialog(); if (result == DialogResult.OK) { - if (treeView != null) - { - treeView.Nodes.Clear(); - treeView.Nodes.AddRange(WordsList.ListNodes()); - } + UpdateTree(); } } diff --git a/Reseter2/StatusCanceled.cs b/Reseter2/StatusCanceled.cs index d19cafc..314a4c3 100644 --- a/Reseter2/StatusCanceled.cs +++ b/Reseter2/StatusCanceled.cs @@ -28,5 +28,9 @@ namespace Reseter2 { return "Canceled"; } + public override int ActionIs() + { + return 0; + } } } \ No newline at end of file diff --git a/Reseter2/StatusReboot.cs b/Reseter2/StatusReboot.cs index 188d618..d93b472 100644 --- a/Reseter2/StatusReboot.cs +++ b/Reseter2/StatusReboot.cs @@ -50,5 +50,9 @@ namespace Reseter2 { return "Send RST"; } + public override int ActionIs() + { + return 1; + } } } diff --git a/Reseter2/StatusRebootError.cs b/Reseter2/StatusRebootError.cs index a0382ab..9c29f64 100644 --- a/Reseter2/StatusRebootError.cs +++ b/Reseter2/StatusRebootError.cs @@ -32,5 +32,9 @@ namespace Reseter2 return _error; } + public override int ActionIs() + { + return 0; + } } } diff --git a/Reseter2/StatusRebootStop.cs b/Reseter2/StatusRebootStop.cs index 5c4eb0f..ceb4f28 100644 --- a/Reseter2/StatusRebootStop.cs +++ b/Reseter2/StatusRebootStop.cs @@ -28,5 +28,9 @@ namespace Reseter2 { return "Stop"; } + public override int ActionIs() + { + return 0; + } } } diff --git a/Reseter2/StatusRebootSucces.cs b/Reseter2/StatusRebootSucces.cs index cca6572..f8fedbd 100644 --- a/Reseter2/StatusRebootSucces.cs +++ b/Reseter2/StatusRebootSucces.cs @@ -29,5 +29,9 @@ namespace Reseter2 { return "Succes"; } + public override int ActionIs() + { + return 0; + } } } diff --git a/Reseter2/StatusRebooting.cs b/Reseter2/StatusRebooting.cs index cedf65e..623d1c8 100644 --- a/Reseter2/StatusRebooting.cs +++ b/Reseter2/StatusRebooting.cs @@ -50,5 +50,9 @@ namespace Reseter2 { return "Rebooting"; } + public override int ActionIs() + { + return 1; + } } } diff --git a/Reseter2/StausPreReboot.cs b/Reseter2/StausPreReboot.cs index 1064de2..d387138 100644 --- a/Reseter2/StausPreReboot.cs +++ b/Reseter2/StausPreReboot.cs @@ -50,5 +50,10 @@ namespace Reseter2 return "Check NET"; } + public override int ActionIs() + { + return 1; + } + } } \ No newline at end of file diff --git a/Reseter2/TaskControl.Designer.cs b/Reseter2/TaskControl.Designer.cs index 8c7c312..a6a79cd 100644 --- a/Reseter2/TaskControl.Designer.cs +++ b/Reseter2/TaskControl.Designer.cs @@ -46,7 +46,10 @@ this.label3 = new System.Windows.Forms.Label(); this.lb_time = new System.Windows.Forms.Label(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); + this.cm_task = new System.Windows.Forms.ContextMenuStrip(this.components); + this.cm_taskSave = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.cm_task.SuspendLayout(); this.SuspendLayout(); // // label1 @@ -197,11 +200,28 @@ this.imageList1.Images.SetKeyName(6, "5icon-64.png"); this.imageList1.Images.SetKeyName(7, "7icon-64.png"); // + // cm_task + // + this.cm_task.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.cm_taskSave}); + this.cm_task.Name = "cm_task"; + this.cm_task.ShowImageMargin = false; + this.cm_task.Size = new System.Drawing.Size(109, 26); + this.cm_task.Text = "Сохранить"; + // + // cm_taskSave + // + this.cm_taskSave.Name = "cm_taskSave"; + this.cm_taskSave.Size = new System.Drawing.Size(108, 22); + this.cm_taskSave.Text = "Сохранить"; + this.cm_taskSave.Click += new System.EventHandler(this.cm_taskSave_Click); + // // TaskControl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.ContextMenuStrip = this.cm_task; this.Controls.Add(this.lb_time); this.Controls.Add(this.label3); this.Controls.Add(this.button3); @@ -220,6 +240,7 @@ this.Name = "TaskControl"; this.Size = new System.Drawing.Size(371, 77); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.cm_task.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -243,5 +264,7 @@ private System.Windows.Forms.Label label3; private System.Windows.Forms.Label lb_time; private System.Windows.Forms.ImageList imageList1; + private System.Windows.Forms.ContextMenuStrip cm_task; + private System.Windows.Forms.ToolStripMenuItem cm_taskSave; } } diff --git a/Reseter2/TaskControl.cs b/Reseter2/TaskControl.cs index a4299ef..c98bbe9 100644 --- a/Reseter2/TaskControl.cs +++ b/Reseter2/TaskControl.cs @@ -1,4 +1,5 @@ -using System; +using Reseter2.Words; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -8,6 +9,7 @@ using System.Net; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; namespace Reseter2 { @@ -15,6 +17,8 @@ namespace Reseter2 partial class TaskControl : UserControl { ReseterTask reseterTask; + public delegate void DUpdateTree(); + public DUpdateTree UpdateTree; public TaskControl() { reseterTask = null; @@ -76,5 +80,15 @@ namespace Reseter2 { reseterTask.RebootReturn(); } + + private void cm_taskSave_Click(object sender, EventArgs e) + { + BilderWords bilderWords = new BilderWords(reseterTask.Comp); + DialogResult result = bilderWords.ShowDialog(); + if (result == DialogResult.OK) + { + UpdateTree(); + } + } } } diff --git a/Reseter2/TaskControl.resx b/Reseter2/TaskControl.resx index ad3c453..fe7580c 100644 --- a/Reseter2/TaskControl.resx +++ b/Reseter2/TaskControl.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABk - lAIAAk1TRnQBSQFMAgEBCAEAASgBAAEoAQABQAEAAUABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgEAAEB + lAIAAk1TRnQBSQFMAgEBCAEAATgBAAE4AQABQAEAAUABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgEAAEB AgABwAMAAQEBAAEYBgABQAEC/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A /wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A @@ -2945,4 +2945,7 @@ AQ8C/wHwBAABDwL/Af4EAAF/Av8B/gQAAX8C/wH+BAABfwL/Af4EAAF/Af8L + + 127, 17 + \ No newline at end of file diff --git a/Reseter2/Words/BilderWords.cs b/Reseter2/Words/BilderWords.cs index 9fb9df0..2975219 100644 --- a/Reseter2/Words/BilderWords.cs +++ b/Reseter2/Words/BilderWords.cs @@ -41,6 +41,7 @@ namespace Reseter2.Words WordsComp item = new WordsComp(compId); WordsList.AddItem(item, ChangeCategory); treeView1.Nodes.AddRange(WordsList.ListNodes(ChangeCategory)); + treeView1.SelectedNode = treeView1.Nodes[treeView1.Nodes.Count-1]; } private void LoadForm() diff --git a/Reseter2/reseter.cs b/Reseter2/reseter.cs index 20e2d20..4f846f1 100644 --- a/Reseter2/reseter.cs +++ b/Reseter2/reseter.cs @@ -5,10 +5,12 @@ using System.ComponentModel; using System.Linq; using System.Net; using System.Reflection.Emit; +using System.Runtime.CompilerServices; using System.Runtime.Remoting.Metadata.W3cXsd2001; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip; namespace Reseter2 { @@ -16,10 +18,12 @@ namespace Reseter2 { private static List list_task = new List(); private static Panel flow_conteiner; - - public static void SetForm(Panel flow_cntr) + private static Form1 Main; + + public static void SetForm(Panel flow_cntr, Form1 main) { flow_conteiner = flow_cntr; + Main = main; } public static void AddTask(String name) { @@ -52,13 +56,29 @@ namespace Reseter2 { TaskControl taskControl = new TaskControl(); + taskControl.UpdateTree = Main.UpdateTree; ReseterTask reseterTask = new ReseterTask(compName, taskControl); taskControl.Intit(reseterTask); flow_conteiner.Controls.Add(taskControl); list_task.Add(reseterTask); } - public static async void Clear(ReseterTask reseterTask, TaskControl taskControl) + public static void ClearCanceled() + { + foreach (var item in list_task) + { + if (item.StatusTask.ActionIs() == 0) + { + flow_conteiner.Controls.Remove(item.taskControl); + list_task.Remove(item); + ClearCanceled(); + return; + } + + } + } + + public static async void Clear(ReseterTask reseterTask, TaskControl taskControl) { if(!(reseterTask.StatusTask is StatusRebootError || reseterTask.StatusTask is StatusRebootStop || @@ -73,21 +93,33 @@ namespace Reseter2 list_task.Remove(reseterTask); } - public static async void Tick() + public static void Tick(out int Action, out int Close) { + Action = 0; + Close = 0; + try { foreach (var item in list_task) { item.Tick(); - + if(item.StatusTask.ActionIs() == 1) + { + Action++; + } + else + { + Close++; + } } } catch { } + + } } }