From 6b62e101cb30c5754d3449ad0e5df3e337e33ef5 Mon Sep 17 00:00:00 2001 From: klavirshik Date: Tue, 13 Aug 2024 19:03:30 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=B1=D0=B0=D0=B3=D0=B8=20=D0=B2=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B4=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B5=20=D0=B2=20=D1=81?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BA=D0=BD=D0=B8=D0=BA?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D0=BB=D0=B8?= =?UTF-8?q?=20=D1=83=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reseter2/CompName.cs | 10 ++- Reseter2/Form1.Designer.cs | 120 ++++++++++--------------------- Reseter2/Form1.cs | 97 ++++++++++++++++++++----- Reseter2/Form1.resx | 7 +- Reseter2/Pinger.cs | 1 + Reseter2/ReseteTask.cs | 25 ++++++- Reseter2/StatusRebootSucces.cs | 1 + Reseter2/TaskControl.Designer.cs | 49 +++++++------ Reseter2/TaskControl.cs | 8 ++- Reseter2/TaskControl.resx | 2 +- Reseter2/Words/BilderWords.cs | 93 ++++++++++++++++++------ Reseter2/reseter.cs | 8 +++ 12 files changed, 263 insertions(+), 158 deletions(-) diff --git a/Reseter2/CompName.cs b/Reseter2/CompName.cs index 871af9f..81467b1 100644 --- a/Reseter2/CompName.cs +++ b/Reseter2/CompName.cs @@ -19,9 +19,12 @@ namespace Reseter2 public CompId(string netname) { this.netName = netname; - this.Name = netname; + //this.Name = netname; + } + + public CompId(IPAddress ip) @@ -99,14 +102,15 @@ namespace Reseter2 public string GetResetName() { if (netName != null) return netName; - return Ip.ToString(); + return GetIPStr(); } public string GetDescription() { return Description; } - + + } } diff --git a/Reseter2/Form1.Designer.cs b/Reseter2/Form1.Designer.cs index 92f7018..64ae275 100644 --- a/Reseter2/Form1.Designer.cs +++ b/Reseter2/Form1.Designer.cs @@ -38,13 +38,7 @@ this.tabPage1 = new System.Windows.Forms.TabPage(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.tabPage2 = new System.Windows.Forms.TabPage(); - this.button2 = new System.Windows.Forms.Button(); - this.treeView1 = new Reseter2.NewTreeView(); - this.cm_words = new System.Windows.Forms.ContextMenuStrip(this.components); - this.mi_newitem = new System.Windows.Forms.ToolStripMenuItem(); - this.mi_edit = new System.Windows.Forms.ToolStripMenuItem(); - this.mi_delete = new System.Windows.Forms.ToolStripMenuItem(); - this.перезагрузитьОдинToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.bt_resetAll = new System.Windows.Forms.Button(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.imageList2 = new System.Windows.Forms.ImageList(this.components); this.tabPage3 = new System.Windows.Forms.TabPage(); @@ -59,10 +53,10 @@ this.sm_SaveItem = new System.Windows.Forms.ToolStripMenuItem(); this.tabPage4 = new System.Windows.Forms.TabPage(); this.bt_wordsBilder = new System.Windows.Forms.Button(); + this.treeView1 = new Reseter2.NewTreeView(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); - this.cm_words.SuspendLayout(); this.tabPage3.SuspendLayout(); this.cm_history.SuspendLayout(); this.tabPage4.SuspendLayout(); @@ -110,7 +104,7 @@ this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Controls.Add(this.tabPage4); - this.tabControl1.Location = new System.Drawing.Point(2, 39); + this.tabControl1.Location = new System.Drawing.Point(2, 38); this.tabControl1.Multiline = true; this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; @@ -142,7 +136,7 @@ // // tabPage2 // - this.tabPage2.Controls.Add(this.button2); + this.tabPage2.Controls.Add(this.bt_resetAll); this.tabPage2.Controls.Add(this.treeView1); this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; @@ -152,73 +146,15 @@ this.tabPage2.Text = "Справочник"; this.tabPage2.UseVisualStyleBackColor = true; // - // button2 + // bt_resetAll // - this.button2.Location = new System.Drawing.Point(224, 662); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(168, 23); - this.button2.TabIndex = 1; - this.button2.Text = "Перезагрузить выделенное"; - this.button2.UseVisualStyleBackColor = true; - // - // treeView1 - // - this.treeView1.ContextMenuStrip = this.cm_words; - this.treeView1.Dock = System.Windows.Forms.DockStyle.Top; - this.treeView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); - this.treeView1.HideSelection = false; - this.treeView1.ImageIndex = 0; - this.treeView1.ImageList = this.imageList1; - this.treeView1.ImeMode = System.Windows.Forms.ImeMode.Close; - this.treeView1.Indent = 22; - this.treeView1.ItemHeight = 24; - this.treeView1.Location = new System.Drawing.Point(3, 3); - this.treeView1.Name = "treeView1"; - this.treeView1.SelectedImageIndex = 0; - this.treeView1.ShowLines = false; - this.treeView1.ShowNodeToolTips = true; - this.treeView1.Size = new System.Drawing.Size(396, 653); - this.treeView1.StateImageList = this.imageList2; - this.treeView1.TabIndex = 0; - this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck); - this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick); - this.treeView1.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick); - this.treeView1.MouseCaptureChanged += new System.EventHandler(this.treeView1_MouseCaptureChanged); - // - // cm_words - // - this.cm_words.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mi_newitem, - this.mi_edit, - this.mi_delete, - this.перезагрузитьОдинToolStripMenuItem}); - this.cm_words.Name = "cm_words"; - this.cm_words.Size = new System.Drawing.Size(185, 92); - // - // mi_newitem - // - this.mi_newitem.Name = "mi_newitem"; - this.mi_newitem.Size = new System.Drawing.Size(184, 22); - this.mi_newitem.Text = "Новый элемент"; - this.mi_newitem.Click += new System.EventHandler(this.mi_newitem_Click); - // - // mi_edit - // - this.mi_edit.Name = "mi_edit"; - this.mi_edit.Size = new System.Drawing.Size(184, 22); - this.mi_edit.Text = "Изменить"; - // - // mi_delete - // - this.mi_delete.Name = "mi_delete"; - this.mi_delete.Size = new System.Drawing.Size(184, 22); - this.mi_delete.Text = "Удалить"; - // - // перезагрузитьОдинToolStripMenuItem - // - this.перезагрузитьОдинToolStripMenuItem.Name = "перезагрузитьОдинToolStripMenuItem"; - this.перезагрузитьОдинToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.перезагрузитьОдинToolStripMenuItem.Text = "Перезагрузить один"; + this.bt_resetAll.Location = new System.Drawing.Point(224, 662); + this.bt_resetAll.Name = "bt_resetAll"; + this.bt_resetAll.Size = new System.Drawing.Size(168, 23); + this.bt_resetAll.TabIndex = 1; + this.bt_resetAll.Text = "Перезагрузить выделенное"; + this.bt_resetAll.UseVisualStyleBackColor = true; + this.bt_resetAll.Click += new System.EventHandler(this.bt_resetAll_Click); // // imageList1 // @@ -348,6 +284,7 @@ this.sm_SaveItem.Name = "sm_SaveItem"; this.sm_SaveItem.Size = new System.Drawing.Size(176, 22); this.sm_SaveItem.Text = "Сохранить"; + this.sm_SaveItem.Click += new System.EventHandler(this.sm_SaveItem_Click); // // tabPage4 // @@ -370,6 +307,29 @@ this.bt_wordsBilder.UseVisualStyleBackColor = true; this.bt_wordsBilder.Click += new System.EventHandler(this.bt_wordsBilder_Click); // + // treeView1 + // + this.treeView1.Dock = System.Windows.Forms.DockStyle.Top; + this.treeView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); + this.treeView1.HideSelection = false; + this.treeView1.ImageIndex = 0; + this.treeView1.ImageList = this.imageList1; + this.treeView1.ImeMode = System.Windows.Forms.ImeMode.Close; + this.treeView1.Indent = 22; + this.treeView1.ItemHeight = 24; + this.treeView1.Location = new System.Drawing.Point(3, 3); + this.treeView1.Name = "treeView1"; + this.treeView1.SelectedImageIndex = 0; + this.treeView1.ShowLines = false; + this.treeView1.ShowNodeToolTips = true; + this.treeView1.Size = new System.Drawing.Size(396, 653); + this.treeView1.StateImageList = this.imageList2; + this.treeView1.TabIndex = 0; + this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck); + this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick); + this.treeView1.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick); + this.treeView1.MouseCaptureChanged += new System.EventHandler(this.treeView1_MouseCaptureChanged); + // // Form1 // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -387,7 +347,6 @@ this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.tabPage2.ResumeLayout(false); - this.cm_words.ResumeLayout(false); this.tabPage3.ResumeLayout(false); this.tabPage3.PerformLayout(); this.cm_history.ResumeLayout(false); @@ -418,13 +377,8 @@ private System.Windows.Forms.ContextMenuStrip cm_history; private System.Windows.Forms.ToolStripMenuItem sm_RebootItem; private System.Windows.Forms.ToolStripMenuItem sm_SaveItem; - private System.Windows.Forms.ContextMenuStrip cm_words; - private System.Windows.Forms.ToolStripMenuItem mi_newitem; - private System.Windows.Forms.ToolStripMenuItem mi_edit; - private System.Windows.Forms.ToolStripMenuItem mi_delete; - private System.Windows.Forms.ToolStripMenuItem перезагрузитьОдинToolStripMenuItem; private System.Windows.Forms.Button bt_wordsBilder; - private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button bt_resetAll; public System.Windows.Forms.ImageList imageList1; private System.Windows.Forms.ImageList imageList2; private NewTreeView treeView1; diff --git a/Reseter2/Form1.cs b/Reseter2/Form1.cs index cec843f..b54e4fa 100644 --- a/Reseter2/Form1.cs +++ b/Reseter2/Form1.cs @@ -24,23 +24,28 @@ namespace Reseter2 public Form1() { - try - { BinaryFormatter binaryFormatter = new BinaryFormatter(); FileStream file = new FileStream("res.dat", FileMode.OpenOrCreate); + try + { + HistoryList.Hitem = (List)binaryFormatter.Deserialize(file); - file.Dispose(); file.Close(); - + file.Dispose(); binaryFormatter = new BinaryFormatter(); - file = new FileStream("base.dat", FileMode.OpenOrCreate); + file = new FileStream("base.dat", FileMode.OpenOrCreate); WordsList.MainCategory = (WordsCategory)binaryFormatter.Deserialize(file); - file.Dispose(); file.Close(); + file.Dispose(); + } catch { - + + file.Close(); + file.Dispose(); + MessageBox.Show("Ошибка чтения конфигурационных файлов.\n Перезапустите программу.", "Критическая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + this.Close(); } @@ -161,9 +166,21 @@ namespace Reseter2 private void Form1_FormClosing(object sender, FormClosingEventArgs e) { BinaryFormatter binaryFormatter = new BinaryFormatter(); - FileStream file = new FileStream("res.dat", FileMode.OpenOrCreate); - binaryFormatter.Serialize(file, HistoryList.Hitem); - file.Close(); + FileStream file = null; + try + { + file = new FileStream("res.dat", FileMode.OpenOrCreate); + binaryFormatter.Serialize(file, HistoryList.Hitem); + file.Close(); + file.Dispose(); + } + catch + { + file.Close(); + file.Dispose(); + MessageBox.Show("Ошибка записи конфигурационных файлов.\n Текущие данные будут потерянны.", "Критическая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } private void treeView1_AfterCheck(object sender, TreeViewEventArgs e) @@ -266,7 +283,7 @@ namespace Reseter2 tree.SelectedNode = e.Node; } //tree.BeginUpdate(); - Rectangle BoundsIcon = new Rectangle(e.Node.Bounds.X -48, e.Node.Bounds.Y, 24, 24); + Rectangle BoundsIcon = new Rectangle(e.Node.Bounds.X -43, e.Node.Bounds.Y + 2, 17, 18); if (BoundsIcon.Contains(e.Location)) { e.Node.Checked = !e.Node.Checked; @@ -277,17 +294,18 @@ namespace Reseter2 else { e.Node.StateImageIndex = 0; - } + } + treeView1_treeViewChangeCheckBox(e.Node); + treeView1_ChangePrentRootCheckBox(e.Node); } - treeView1_treeViewChangeCheckBox(e.Node); - treeView1_ChangePrentRootCheckBox(e.Node); - + + bool k = false; // for (int i = 0; i < tree.Nodes.Count; i++) // { // treeView1_treeViewChangeRootCheckBox(tree.Nodes[i]); // } - tree.EndUpdate(); + } @@ -301,5 +319,52 @@ namespace Reseter2 //treeView1_treeViewChangeCheckBox(tree.Nodes[0]); } + + private List treeViewCheckOn(TreeNode node) + { + List comps = new List(); + if (node.Checked && node.Tag is WordsComp) + { + WordsComp comp = (WordsComp)node.Tag; + comps.Add(comp.GetComp()); + } + for (int i = 0; i < node.Nodes.Count; i++) + { + comps.AddRange(treeViewCheckOn(node.Nodes[i])); + + } + return comps; + } + + private void bt_resetAll_Click(object sender, EventArgs e) + { + List comps = new List(); + for (int i = 0; i < treeView1.Nodes.Count; i++) + { + comps.AddRange(treeViewCheckOn(treeView1.Nodes[i])); + } + + DialogResult result = MessageBox.Show("Будет перезагруженно " + comps.Count() + " компьютеров.\nПродолжить?", + "Запуск многопоточной перезагрузки.", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (result == DialogResult.Yes) { + Reseter.AddTask(comps); + tabControl1.SelectedIndex = 0; + } + } + + private void sm_SaveItem_Click(object sender, EventArgs e) + { + + if (selectItem is HistoryItem historyItem) + { + BilderWords bilderWords = new BilderWords(historyItem.GetComp()); + DialogResult result = bilderWords.ShowDialog(); + if (result == DialogResult.OK) + { + treeView1.Nodes.Clear(); + treeView1.Nodes.AddRange(WordsList.ListNodes()); + } + } + } } } diff --git a/Reseter2/Form1.resx b/Reseter2/Form1.resx index 2992d83..46788bf 100644 --- a/Reseter2/Form1.resx +++ b/Reseter2/Form1.resx @@ -120,9 +120,6 @@ 122, 17 - - 319, 17 - 425, 17 @@ -131,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACk - UQAAAk1TRnQBSQFMAgEBCQEAATABAAEwAQABGAEAARgBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFg + UQAAAk1TRnQBSQFMAgEBCQEAAWgBAAFoAQABGAEAARgBAAT/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/ @@ -490,7 +487,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAu - CQAAAk1TRnQBSQFMAgEBAwEAARgBAAEYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CQAAAk1TRnQBSQFMAgEBAwEAAVABAAFQAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/Reseter2/Pinger.cs b/Reseter2/Pinger.cs index be69678..e8913ed 100644 --- a/Reseter2/Pinger.cs +++ b/Reseter2/Pinger.cs @@ -41,6 +41,7 @@ namespace Reseter2 { // Discard PingExceptions and return false; } + finally { if (pinger != null) diff --git a/Reseter2/ReseteTask.cs b/Reseter2/ReseteTask.cs index 0c374f4..f396c3e 100644 --- a/Reseter2/ReseteTask.cs +++ b/Reseter2/ReseteTask.cs @@ -22,13 +22,32 @@ namespace Reseter2 public HistoryItem historyItem; + public ReseterTask(IComp comp, TaskControl taskCntrl) { + Comp = comp; taskControl = taskCntrl; - StatusTask = new StatusPreReboot(this); - Pingers = new Pinger(Comp.GetResetName()); - historyItem = HistoryList.Add(this); + System.Diagnostics.Debug.WriteLine(comp.GetResetName()); + if (comp.GetResetName() == null || comp.GetResetName().Length == 0) + { + //Pingers = new Pinger(""); + Comp.SetName("Не заданно"); + Comp.SetNetName("Не заданно"); + Pingers = new Pinger(Comp.GetResetName()); + StatusTask = new StatusPreReboot(this); + historyItem = HistoryList.Add(this); + StatusTask = new StatusRebootError(this); + + } + else + { + Pingers = new Pinger(Comp.GetResetName()); + StatusTask = new StatusPreReboot(this); + historyItem = HistoryList.Add(this); + + } + } public async Task Tick() diff --git a/Reseter2/StatusRebootSucces.cs b/Reseter2/StatusRebootSucces.cs index eb5d844..324fd6f 100644 --- a/Reseter2/StatusRebootSucces.cs +++ b/Reseter2/StatusRebootSucces.cs @@ -14,6 +14,7 @@ namespace Reseter2 resetertask.SetNameStage("Успешно перезагруженно", 7); resetertask.historyItem.SetEndTime(DateTime.Now); PingResult = resetertask.Ping(); + resetertask.Comp.SetIP(PingResult.Ip); reseterTask.sw.Stop(); } diff --git a/Reseter2/TaskControl.Designer.cs b/Reseter2/TaskControl.Designer.cs index 9d841da..4fcd246 100644 --- a/Reseter2/TaskControl.Designer.cs +++ b/Reseter2/TaskControl.Designer.cs @@ -52,26 +52,26 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(87, 23); + this.label1.Location = new System.Drawing.Point(85, 16); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(47, 13); + this.label1.Size = new System.Drawing.Size(50, 13); this.label1.TabIndex = 0; - this.label1.Text = "Имя ПК"; + this.label1.Text = "Имя ПК:"; this.label1.Click += new System.EventHandler(this.label1_Click); // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(87, 36); + this.label2.Location = new System.Drawing.Point(85, 30); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(17, 13); + this.label2.Size = new System.Drawing.Size(75, 13); this.label2.TabIndex = 1; - this.label2.Text = "IP"; + this.label2.Text = "Сетевое имя:"; // // lb_name // this.lb_name.AutoSize = true; - this.lb_name.Location = new System.Drawing.Point(134, 23); + this.lb_name.Location = new System.Drawing.Point(132, 16); this.lb_name.Name = "lb_name"; this.lb_name.Size = new System.Drawing.Size(64, 13); this.lb_name.TabIndex = 2; @@ -80,7 +80,7 @@ // lb_ip // this.lb_ip.AutoSize = true; - this.lb_ip.Location = new System.Drawing.Point(103, 36); + this.lb_ip.Location = new System.Drawing.Point(156, 30); this.lb_ip.Name = "lb_ip"; this.lb_ip.Size = new System.Drawing.Size(70, 13); this.lb_ip.TabIndex = 3; @@ -89,25 +89,24 @@ // lb_stage // this.lb_stage.AutoSize = true; - this.lb_stage.Location = new System.Drawing.Point(87, 10); + this.lb_stage.Location = new System.Drawing.Point(85, 2); this.lb_stage.Name = "lb_stage"; - this.lb_stage.Size = new System.Drawing.Size(104, 13); + this.lb_stage.Size = new System.Drawing.Size(0, 13); this.lb_stage.TabIndex = 4; - this.lb_stage.Text = "Перезагружаеться"; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(186, 36); + this.label4.Location = new System.Drawing.Point(85, 43); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(28, 13); + this.label4.Size = new System.Drawing.Size(31, 13); this.label4.TabIndex = 5; - this.label4.Text = "Ping"; + this.label4.Text = "Ping:"; // // lb_ping // this.lb_ping.AutoSize = true; - this.lb_ping.Location = new System.Drawing.Point(220, 36); + this.lb_ping.Location = new System.Drawing.Point(119, 43); this.lb_ping.Name = "lb_ping"; this.lb_ping.Size = new System.Drawing.Size(0, 13); this.lb_ping.TabIndex = 6; @@ -115,23 +114,23 @@ // Timeout // this.Timeout.AutoSize = true; - this.Timeout.Location = new System.Drawing.Point(186, 52); + this.Timeout.Location = new System.Drawing.Point(159, 43); this.Timeout.Name = "Timeout"; - this.Timeout.Size = new System.Drawing.Size(45, 13); + this.Timeout.Size = new System.Drawing.Size(48, 13); this.Timeout.TabIndex = 7; - this.Timeout.Text = "Timeout"; + this.Timeout.Text = "Timeout:"; // // lb_timeout // this.lb_timeout.AutoSize = true; - this.lb_timeout.Location = new System.Drawing.Point(237, 52); + this.lb_timeout.Location = new System.Drawing.Point(210, 43); this.lb_timeout.Name = "lb_timeout"; this.lb_timeout.Size = new System.Drawing.Size(0, 13); this.lb_timeout.TabIndex = 8; // // button1 // - this.button1.Location = new System.Drawing.Point(270, 3); + this.button1.Location = new System.Drawing.Point(270, 1); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(96, 23); this.button1.TabIndex = 9; @@ -141,7 +140,7 @@ // // button2 // - this.button2.Location = new System.Drawing.Point(270, 49); + this.button2.Location = new System.Drawing.Point(270, 51); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(96, 23); this.button2.TabIndex = 10; @@ -170,16 +169,16 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(86, 52); + this.label3.Location = new System.Drawing.Point(85, 58); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(46, 13); + this.label3.Size = new System.Drawing.Size(49, 13); this.label3.TabIndex = 13; - this.label3.Text = "Таймер"; + this.label3.Text = "Таймер:"; // // lb_time // this.lb_time.AutoSize = true; - this.lb_time.Location = new System.Drawing.Point(131, 52); + this.lb_time.Location = new System.Drawing.Point(130, 58); this.lb_time.Name = "lb_time"; this.lb_time.Size = new System.Drawing.Size(34, 13); this.lb_time.TabIndex = 14; diff --git a/Reseter2/TaskControl.cs b/Reseter2/TaskControl.cs index 86929de..0afa960 100644 --- a/Reseter2/TaskControl.cs +++ b/Reseter2/TaskControl.cs @@ -25,7 +25,13 @@ namespace Reseter2 { reseterTask = res; if (reseterTask.GetName() != null) lb_name.Text = reseterTask.GetName(); - if (reseterTask.Comp.GetIP() != null) lb_ip.Text = reseterTask.Comp.GetIP().ToString(); + if (reseterTask.Comp.GetNetNameStr() != null) + { + lb_ip.Text = reseterTask.Comp.GetNetNameStr(); + if (reseterTask.Comp.GetIP() != null && reseterTask.Comp.GetNetName() != null) lb_ip.Text = lb_ip.Text+"(" +reseterTask.Comp.GetIP().ToString()+")"; + } + + } public void DataContrl(string ping, string timeout, IPAddress ip, TimeSpan time) diff --git a/Reseter2/TaskControl.resx b/Reseter2/TaskControl.resx index 39c7ce1..4e7533e 100644 --- a/Reseter2/TaskControl.resx +++ b/Reseter2/TaskControl.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABk - lAIAAk1TRnQBSQFMAgEBCAEAARABAAEQAQABQAEAAUABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgEAAEB + lAIAAk1TRnQBSQFMAgEBCAEAASABAAEgAQABQAEAAUABAAT/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 diff --git a/Reseter2/Words/BilderWords.cs b/Reseter2/Words/BilderWords.cs index c10774c..a1aba76 100644 --- a/Reseter2/Words/BilderWords.cs +++ b/Reseter2/Words/BilderWords.cs @@ -7,6 +7,7 @@ using System.Data.Odbc; using System.Drawing; using System.IO; using System.Linq; +using System.Reflection; using System.Runtime.Serialization.Formatters.Binary; using System.Security.Cryptography; using System.Security.Policy; @@ -26,10 +27,36 @@ namespace Reseter2.Words MD5 Hash = MD5.Create(); public BilderWords() { + LoadForm(); + treeView1.Nodes.AddRange(WordsList.ListNodes(ChangeCategory)); + } - + public BilderWords(IComp comp) + { + LoadForm(); + BinaryFormatter binaryFormatter = new BinaryFormatter(); + MemoryStream memory = new MemoryStream(); + binaryFormatter.Serialize(memory, comp); + memory.Position = 0; + CompId compId = (CompId)binaryFormatter.Deserialize(memory); + memory.Close(); + memory.Dispose(); + //TreeNode treeNode = new TreeNode(); + WordsComp item = new WordsComp(compId); + WordsList.AddItem(item, ChangeCategory); + + + treeView1.Nodes.AddRange(WordsList.ListNodes(ChangeCategory)); + //treeNode.ImageIndex = 1; + //treeNode.Text = item.NameNode(); + //treeNode.Tag = item; + //treeView1.Nodes.Add(treeNode); + } + + private void LoadForm() + { BinaryFormatter binaryFormatter = new BinaryFormatter(); MemoryStream Memory = new MemoryStream(); binaryFormatter.Serialize(Memory, WordsList.MainCategory); @@ -39,16 +66,9 @@ namespace Reseter2.Words ChangeCategory = (WordsCategory)binaryFormatter.Deserialize(Memory); Memory.Dispose(); Memory.Close(); - + InitializeComponent(); - //WordsList.MainCategory. - - - //// TreeNode trno = new TreeNode("main"); - - - treeView1.Nodes.AddRange(WordsList.ListNodes(ChangeCategory)); - //trno.ImageIndex = 1; + cb_create.Items.Add("Категория"); cb_create.Items.Add("Компьютер"); cb_create.SelectedIndex = 0; @@ -57,11 +77,9 @@ namespace Reseter2.Words treeView1.DragOver += new DragEventHandler(TreeView1_DragOver); treeView1.DragDrop += new DragEventHandler(TreeView1_DragDrop); - + this.DialogResult = DialogResult.Abort; - } - private void TreeView1_ItemDrag(object sender, ItemDragEventArgs e) { DragOn = true; @@ -160,11 +178,22 @@ namespace Reseter2.Words } if(SrcCategory == DstCategory) { - if(selectNode == null) + if (selectNode == null) { if (targetPoint.Y > 5) index--; } - else if (moveNode.Index < selectNode.Index) index--; + else if(selectNode.Tag == DstCategory) + { + index = 0; + } + else if(selectNode.Tag == moveNode.Tag) + { + return; + } + else if(moveNode.Index < selectNode.Index) + { + index--; + } } IWordsItem MoveItem = (IWordsItem)moveNode.Tag; @@ -313,10 +342,18 @@ namespace Reseter2.Words if (selectNode.Tag == null) return; IWordsItem wordsItem = (IWordsItem)selectNode.Tag; + + if(selectNode.NextNode != null) + { + treeView1.SelectedNode = selectNode.NextNode; + }else if(selectNode.PrevNode != null) + { + treeView1.SelectedNode = selectNode.PrevNode; + }else if(selectNode.Parent != null) treeView1.SelectedNode = selectNode.Parent ; ParentCategory.DeleteItem(wordsItem); ParentNodes.Remove(selectNode); - + } @@ -362,12 +399,17 @@ namespace Reseter2.Words private void bt_saveClose_Click(object sender, EventArgs e) { - control.Visible = false; - control.Dispose(); + if (control != null) + { + control.Visible = false; + control.Dispose(); + } + BinaryFormatter binaryFormatter = new BinaryFormatter(); FileStream file = new FileStream("base.dat", FileMode.OpenOrCreate); binaryFormatter.Serialize(file, ChangeCategory); file.Close(); + file.Dispose(); WordsList.MainCategory = ChangeCategory; this.DialogResult = DialogResult.OK; this.Close(); @@ -375,18 +417,27 @@ namespace Reseter2.Words private void bt_save_Click(object sender, EventArgs e) { - control.Visible = false; - control.Visible = true; + if (control != null) + { + control.Visible = false; + control.Visible = true; + } BinaryFormatter binaryFormatter = new BinaryFormatter(); FileStream file = new FileStream("base.dat", FileMode.OpenOrCreate); binaryFormatter.Serialize(file, ChangeCategory); file.Close(); + file.Dispose(); WordsList.MainCategory = ChangeCategory; - this.DialogResult = DialogResult.OK; + } private void bt_close_Click(object sender, EventArgs e) { + if (control != null) + { + control.Visible = false; + control.Dispose(); + } BinaryFormatter binaryFormatter = new BinaryFormatter(); MemoryStream Memory = new MemoryStream(); binaryFormatter.Serialize(Memory, ChangeCategory); diff --git a/Reseter2/reseter.cs b/Reseter2/reseter.cs index 15db81b..b702f06 100644 --- a/Reseter2/reseter.cs +++ b/Reseter2/reseter.cs @@ -40,6 +40,14 @@ namespace Reseter2 } } + + public static void AddTask(List comps) + { + foreach (var item in comps) + { + AddTask(item); + } + } public static void AddTask(IComp compName) {