From 7551ca5dcf4d07bd00d629499fc0163e4b3ea621 Mon Sep 17 00:00:00 2001 From: klavirshik Date: Tue, 13 Aug 2024 03:15:12 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=20=D1=84=D0=BE=D1=80=D0=BC=D1=83=20=D0=B4?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B2=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reseter2/CompName.cs | 33 +++++- Reseter2/Form1.Designer.cs | 105 +++++++++--------- Reseter2/Form1.cs | 86 +++++++++++--- Reseter2/Form1.resx | 28 ++--- Reseter2/IComp.cs | 3 + Reseter2/TewTreeView.cs | 7 +- Reseter2/Words/BilderWords.cs | 7 ++ Reseter2/Words/BilderWords.resx | 2 +- Reseter2/Words/WordsCategory.cs | 1 + Reseter2/Words/WordsComp.cs | 33 +++++- .../Words/WordsEditCompControl.Designer.cs | 36 +++++- Reseter2/Words/WordsEditCompControl.cs | 10 +- 12 files changed, 255 insertions(+), 96 deletions(-) diff --git a/Reseter2/CompName.cs b/Reseter2/CompName.cs index 290be09..871af9f 100644 --- a/Reseter2/CompName.cs +++ b/Reseter2/CompName.cs @@ -14,12 +14,16 @@ namespace Reseter2 private string Name { get; set; } private string Description { get; set; } private IPAddress Ip { get; set; } + private string netName; - public CompId(string name) + public CompId(string netname) { - this.Name = name; + this.netName = netname; + this.Name = netname; } + + public CompId(IPAddress ip) { this.Ip = ip; @@ -30,6 +34,8 @@ namespace Reseter2 this.Description = description; } + + public CompId(string name, string description, IPAddress ip) { this.Name = name; @@ -43,10 +49,25 @@ namespace Reseter2 return Name; } + public string GetNetNameStr() + { + if (netName == null) return GetIPStr(); + return netName; + } + public string GetNetName() + { + return netName; + } public IPAddress GetIP() { return Ip; } + + public string GetIPStr() + { + if (Ip != null) return Ip.ToString(); + return null; + } public int GetImage() { return imgIndex; @@ -60,6 +81,12 @@ namespace Reseter2 { Name = name; } + + public void SetNetName(string netname) + { + netName = netname; + } + public void SetImage(int image) { imgIndex = image; @@ -71,7 +98,7 @@ namespace Reseter2 public string GetResetName() { - if (Name != null) return Name; + if (netName != null) return netName; return Ip.ToString(); } diff --git a/Reseter2/Form1.Designer.cs b/Reseter2/Form1.Designer.cs index 99219aa..92f7018 100644 --- a/Reseter2/Form1.Designer.cs +++ b/Reseter2/Form1.Designer.cs @@ -40,7 +40,13 @@ 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.imageList1 = new System.Windows.Forms.ImageList(this.components); + this.imageList2 = new System.Windows.Forms.ImageList(this.components); this.tabPage3 = new System.Windows.Forms.TabPage(); this.button1 = new System.Windows.Forms.Button(); this.label6 = new System.Windows.Forms.Label(); @@ -53,19 +59,13 @@ this.sm_SaveItem = new System.Windows.Forms.ToolStripMenuItem(); this.tabPage4 = new System.Windows.Forms.TabPage(); this.bt_wordsBilder = new System.Windows.Forms.Button(); - 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.imageList2 = new System.Windows.Forms.ImageList(this.components); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); + this.cm_words.SuspendLayout(); this.tabPage3.SuspendLayout(); this.cm_history.SuspendLayout(); this.tabPage4.SuspendLayout(); - this.cm_words.SuspendLayout(); this.SuspendLayout(); // // tb_comp @@ -163,7 +163,6 @@ // // treeView1 // - this.treeView1.CheckBoxes = true; 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))); @@ -186,6 +185,41 @@ 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 = "Перезагрузить один"; + // // imageList1 // this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); @@ -200,6 +234,14 @@ this.imageList1.Images.SetKeyName(7, "17icon2-24.png"); this.imageList1.Images.SetKeyName(8, "40icon-24.png"); // + // imageList2 + // + this.imageList2.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList2.ImageStream"))); + this.imageList2.TransparentColor = System.Drawing.Color.Transparent; + this.imageList2.Images.SetKeyName(0, "off.ico"); + this.imageList2.Images.SetKeyName(1, "on.ico"); + this.imageList2.Images.SetKeyName(2, "or.ico"); + // // tabPage3 // this.tabPage3.Controls.Add(this.button1); @@ -320,7 +362,7 @@ // // bt_wordsBilder // - this.bt_wordsBilder.Location = new System.Drawing.Point(102, 25); + this.bt_wordsBilder.Location = new System.Drawing.Point(11, 33); this.bt_wordsBilder.Name = "bt_wordsBilder"; this.bt_wordsBilder.Size = new System.Drawing.Size(155, 23); this.bt_wordsBilder.TabIndex = 0; @@ -328,49 +370,6 @@ this.bt_wordsBilder.UseVisualStyleBackColor = true; this.bt_wordsBilder.Click += new System.EventHandler(this.bt_wordsBilder_Click); // - // 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 = "Перезагрузить один"; - // - // imageList2 - // - this.imageList2.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList2.ImageStream"))); - this.imageList2.TransparentColor = System.Drawing.Color.Transparent; - this.imageList2.Images.SetKeyName(0, "off.ico"); - this.imageList2.Images.SetKeyName(1, "on.ico"); - this.imageList2.Images.SetKeyName(2, "or.ico"); - // // Form1 // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -388,11 +387,11 @@ 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); this.tabPage4.ResumeLayout(false); - this.cm_words.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Reseter2/Form1.cs b/Reseter2/Form1.cs index e963352..545f0ff 100644 --- a/Reseter2/Form1.cs +++ b/Reseter2/Form1.cs @@ -53,7 +53,7 @@ namespace Reseter2 lb_history.DisplayMember = "ToStr"; treeView1.Nodes.AddRange(WordsList.ListNodes()); - //treeView1.Check + //treeView1.MouseCaptureChanged.; tabControl1.SelectedIndex = 1; @@ -144,7 +144,13 @@ namespace Reseter2 private void bt_wordsBilder_Click(object sender, EventArgs e) { BilderWords bilderWords = new BilderWords(); - bilderWords.ShowDialog(); + DialogResult result = bilderWords.ShowDialog(); + if (result == DialogResult.OK) + { + treeView1.Nodes.Clear(); + treeView1.Nodes.AddRange(WordsList.ListNodes()); + } + } private void Form1_Load(object sender, EventArgs e) @@ -185,11 +191,13 @@ namespace Reseter2 } else { + bool nedoCheked = false; int nodeCheked = 0; for (int i = 0; i < treeNode.Nodes.Count; i++) { treeView1_treeViewChangeRootCheckBox(treeNode.Nodes[i]); if (treeNode.Nodes[i].Checked) nodeCheked++; + if (treeNode.Nodes[i].StateImageIndex == 2) nedoCheked = true; } bool Cheked = false; @@ -197,23 +205,47 @@ namespace Reseter2 { Cheked = true; treeNode.Checked = Cheked; + treeNode.StateImageIndex = 1; } - else if (nodeCheked != 0) - { + else if (nodeCheked != 0 || nedoCheked) + { treeNode.StateImageIndex = 2; + }else if(nodeCheked == 0) + { + Cheked = false; + treeNode.Checked = Cheked; + treeNode.StateImageIndex = 0; } - + return Cheked; } } + private void treeView1_ChangePrentRootCheckBox(TreeNode treeNode) + { + treeView1_treeViewChangeRootCheckBox(treeNode); + if (treeNode.Parent != null) + { + + + + treeView1_treeViewChangeRootCheckBox(treeNode.Parent); + if (treeNode.Parent.Parent != null) + { + treeView1_ChangePrentRootCheckBox(treeNode.Parent); + + } + + } + } + private void treeView1_DoubleClick(object sender, EventArgs e) { - MessageBox.Show("dfsdf"); + } private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) @@ -223,24 +255,52 @@ namespace Reseter2 { WordsComp wordsComp = (WordsComp)e.Node.Tag; - MessageBox.Show("Перезагрузить ПК: " + wordsComp.GetName()); - + DialogResult result = MessageBox.Show("Перезагрузить ПК: " + wordsComp.NameNode(),"Создание новой задачи", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if(result == DialogResult.Yes) + { + Reseter.AddTask(wordsComp.GetComp()); + tabControl1.SelectedIndex = 0; + } } } private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { - System.Diagnostics.Debug.WriteLine("klic"); - treeView1_treeViewChangeCheckBox(e.Node); + TreeView tree = (TreeView)sender; - for (int i = 0; i < tree.Nodes.Count; i++) + + if(e.Button == MouseButtons.Right) { - treeView1_treeViewChangeRootCheckBox(tree.Nodes[i]); + tree.SelectedNode = e.Node; + } + //tree.BeginUpdate(); + Rectangle BoundsIcon = new Rectangle(e.Node.Bounds.X -48, e.Node.Bounds.Y, 24, 24); + if (BoundsIcon.Contains(e.Location)) + { + e.Node.Checked = !e.Node.Checked; + if (e.Node.Checked) + { + e.Node.StateImageIndex = 1; + } + else + { + e.Node.StateImageIndex = 0; + } } - + + treeView1_ChangePrentRootCheckBox(e.Node); + + // for (int i = 0; i < tree.Nodes.Count; i++) + // { + // treeView1_treeViewChangeRootCheckBox(tree.Nodes[i]); + // } + tree.EndUpdate(); + } + + private void treeView1_MouseCaptureChanged(object sender, EventArgs e) { // System.Diagnostics.Debug.WriteLine(sender.ToString()); diff --git a/Reseter2/Form1.resx b/Reseter2/Form1.resx index b104b00..2992d83 100644 --- a/Reseter2/Form1.resx +++ b/Reseter2/Form1.resx @@ -131,7 +131,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACk - UQAAAk1TRnQBSQFMAgEBCQEAASABAAEgAQABGAEAARgBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFg + UQAAAk1TRnQBSQFMAgEBCQEAATABAAEwAQABGAEAARgBAAT/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/ @@ -489,8 +489,8 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmV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/AzMD/wJtA/8BVQHCAQgDMwH0ATMD/wFtEAABbQ7/Am0J/wMzAv8CbQP/AZgBlwH/ + AQgBlwEIAZgBlwP/AW0QAAFtDv8CbQr/AVUCMwH/Am0E/wFVAZcCCAGXAVUE/wFtEAABbQ7/Am0L/wIz + Af8CbQX/AZgCVQGYBf8BbRAAAW0B9A3/Am0B9Av/ATMB/wJtAfQN/wFtEAABkgG8DP8B8QHsAZIBvAz/ + AbwCkgG8DP8BvAGSEQAB7AG8AfMI/wHzAbwB7AIAAewBvAHzCP8B8wG8AewCAAHsAbwB8wj/AfMBvAHs + EwABkgHsCG0B7AHtBAABkgHsCG0B7AHtBAABkgHsCG0B7AHtEgABQgFNAT4HAAE+AwABKAMAAUADAAEQ + AwABAQEAAQEFAAGAFwAD/wEAAcABAwHAAQMBwAEDAgABgAEBAYABAQGAAQFiAAGAAQEBgAEBAYABAQIA + AcABAwHAAQMBwAEDAgAL diff --git a/Reseter2/IComp.cs b/Reseter2/IComp.cs index 92829a0..7c4e4ac 100644 --- a/Reseter2/IComp.cs +++ b/Reseter2/IComp.cs @@ -10,12 +10,15 @@ namespace Reseter2 internal interface IComp { string GetName(); + string GetNetName(); + string GetNetNameStr(); string GetResetName(); IPAddress GetIP(); int GetImage(); void SetIP(IPAddress ip); void SetName(string name); + void SetNetName(string netName); void SetImage(int imdexImg); void SetDescription(string description); diff --git a/Reseter2/TewTreeView.cs b/Reseter2/TewTreeView.cs index a80e049..48ba229 100644 --- a/Reseter2/TewTreeView.cs +++ b/Reseter2/TewTreeView.cs @@ -1,5 +1,7 @@ -using System; +using Reseter2.Words; +using System; using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; @@ -8,11 +10,12 @@ using System.Windows.Forms; namespace Reseter2 { + [DefaultEvent(nameof(NewTreeView))] class NewTreeView:TreeView { protected override void WndProc(ref Message m) { - if(m.Msg == 0x0203 && this.CheckBoxes) + if(m.Msg == 0x0203) { Point localPos = this.PointToClient(Cursor.Position); var hitTestInfo = this.HitTest(localPos); diff --git a/Reseter2/Words/BilderWords.cs b/Reseter2/Words/BilderWords.cs index fb86fde..c10774c 100644 --- a/Reseter2/Words/BilderWords.cs +++ b/Reseter2/Words/BilderWords.cs @@ -58,6 +58,8 @@ namespace Reseter2.Words treeView1.DragDrop += new DragEventHandler(TreeView1_DragDrop); + this.DialogResult = DialogResult.Abort; + } private void TreeView1_ItemDrag(object sender, ItemDragEventArgs e) @@ -367,6 +369,7 @@ namespace Reseter2.Words binaryFormatter.Serialize(file, ChangeCategory); file.Close(); WordsList.MainCategory = ChangeCategory; + this.DialogResult = DialogResult.OK; this.Close(); } @@ -379,6 +382,7 @@ namespace Reseter2.Words binaryFormatter.Serialize(file, ChangeCategory); file.Close(); WordsList.MainCategory = ChangeCategory; + this.DialogResult = DialogResult.OK; } private void bt_close_Click(object sender, EventArgs e) @@ -402,9 +406,11 @@ namespace Reseter2.Words file.Close(); file.Dispose(); WordsList.MainCategory = ChangeCategory; + this.DialogResult = DialogResult.OK; this.Close(); break; case DialogResult.No: + this.DialogResult = DialogResult.Abort; this.Close(); break; } @@ -413,6 +419,7 @@ namespace Reseter2.Words } else { + this.Close(); } } diff --git a/Reseter2/Words/BilderWords.resx b/Reseter2/Words/BilderWords.resx index c39fd7f..11834ec 100644 --- a/Reseter2/Words/BilderWords.resx +++ b/Reseter2/Words/BilderWords.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACQ - JAAAAk1TRnQBSQFMAgEBCQEAATgBAAE4AQABEAEAARABAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFA + JAAAAk1TRnQBSQFMAgEBCQEAAUgBAAFIAQABEAEAARABAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABMAMAAQEBAAEQBgABGBIAAf8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/ AX8B/wF/Af8BfwH/AX8B/wF/Af8Bf2AAAf8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/ Af8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8Bf2AAAf8BfwH/AX8B/wF/Af8BfwH/AX8B/wF/Af8BfwH/ diff --git a/Reseter2/Words/WordsCategory.cs b/Reseter2/Words/WordsCategory.cs index ce62823..64da4ef 100644 --- a/Reseter2/Words/WordsCategory.cs +++ b/Reseter2/Words/WordsCategory.cs @@ -110,6 +110,7 @@ namespace Reseter2.Words treeNode.Tag = this; treeNode.ImageIndex = 0; treeNode.SelectedImageIndex = 0; + treeNode.StateImageIndex = 0; foreach (var item in items) { diff --git a/Reseter2/Words/WordsComp.cs b/Reseter2/Words/WordsComp.cs index 85badb0..5ec98c8 100644 --- a/Reseter2/Words/WordsComp.cs +++ b/Reseter2/Words/WordsComp.cs @@ -34,7 +34,7 @@ namespace Reseter2.Words } - public void Set(String name, String ip, String description, int imgIndex) + public void Set(String name, String ip, String description, int imgIndex, string netname) { IPAddress iPAddress; try @@ -49,12 +49,18 @@ namespace Reseter2.Words Comp.SetName(name); Comp.SetDescription(description); Comp.SetImage(imgIndex); + Comp.SetNetName(netname); } public string GetName() { return Comp.GetName(); } + + public string GetNetName() + { + return Comp.GetNetName(); + } public override bool ChekMove(IWordsItem wordsItem) { return true ; @@ -71,7 +77,10 @@ namespace Reseter2.Words } return null; } - + public IComp GetComp() + { + return Comp; + } public override void Delete() { @@ -83,12 +92,30 @@ namespace Reseter2.Words { return new List(); } + + public string NameNode() + { + string buf; + if (Comp.GetName() == null) + { + buf = Comp.GetNetNameStr(); + } + else + { + buf = Comp.GetName(); + if (Comp.GetNetNameStr() != null) buf += "(" + Comp.GetNetNameStr() + ")"; + + } + return buf; + } public override TreeNode NodeList() { - TreeNode treeNode = new TreeNode(GetName()); + TreeNode treeNode = new TreeNode(); + treeNode.Text = NameNode(); treeNode.Tag = this; treeNode.ImageIndex = Comp.GetImage(); treeNode.SelectedImageIndex = Comp.GetImage(); + treeNode.StateImageIndex = 0; return treeNode; } diff --git a/Reseter2/Words/WordsEditCompControl.Designer.cs b/Reseter2/Words/WordsEditCompControl.Designer.cs index c07a058..cd03ed9 100644 --- a/Reseter2/Words/WordsEditCompControl.Designer.cs +++ b/Reseter2/Words/WordsEditCompControl.Designer.cs @@ -36,6 +36,8 @@ this.label4 = new System.Windows.Forms.Label(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.tb_netName = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // lb_name @@ -59,7 +61,7 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 53); + this.label3.Location = new System.Drawing.Point(3, 92); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(50, 13); this.label3.TabIndex = 5; @@ -69,7 +71,7 @@ // this.lb_ip.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.lb_ip.Location = new System.Drawing.Point(6, 69); + this.lb_ip.Location = new System.Drawing.Point(6, 108); this.lb_ip.Name = "lb_ip"; this.lb_ip.Size = new System.Drawing.Size(245, 20); this.lb_ip.TabIndex = 4; @@ -78,7 +80,7 @@ // this.lb_description.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.lb_description.Location = new System.Drawing.Point(6, 108); + this.lb_description.Location = new System.Drawing.Point(6, 147); this.lb_description.Multiline = true; this.lb_description.Name = "lb_description"; this.lb_description.Size = new System.Drawing.Size(245, 63); @@ -87,7 +89,7 @@ // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(3, 92); + this.label4.Location = new System.Drawing.Point(3, 131); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(57, 13); this.label4.TabIndex = 7; @@ -113,12 +115,33 @@ this.label1.TabIndex = 9; this.label1.Text = "Значек"; // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(3, 53); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(72, 13); + this.label5.TabIndex = 11; + this.label5.Text = "Сетевое имя"; + // + // tb_netName + // + this.tb_netName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tb_netName.Location = new System.Drawing.Point(6, 69); + this.tb_netName.Name = "tb_netName"; + this.tb_netName.Size = new System.Drawing.Size(245, 20); + this.tb_netName.TabIndex = 10; + this.tb_netName.VisibleChanged += new System.EventHandler(this.WordsEditCompControl_VisibleChanged); + // // WordsEditCompControl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.AutoValidate = System.Windows.Forms.AutoValidate.Disable; + this.Controls.Add(this.label5); + this.Controls.Add(this.tb_netName); this.Controls.Add(this.label1); this.Controls.Add(this.comboBox1); this.Controls.Add(this.label4); @@ -128,7 +151,8 @@ this.Controls.Add(this.label2); this.Controls.Add(this.lb_name); this.Name = "WordsEditCompControl"; - this.Size = new System.Drawing.Size(254, 178); + this.Size = new System.Drawing.Size(254, 213); + this.VisibleChanged += new System.EventHandler(this.WordsEditCompControl_VisibleChanged); this.ResumeLayout(false); this.PerformLayout(); @@ -143,5 +167,7 @@ private System.Windows.Forms.Label label4; private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox tb_netName; } } diff --git a/Reseter2/Words/WordsEditCompControl.cs b/Reseter2/Words/WordsEditCompControl.cs index 300ee82..87caa9a 100644 --- a/Reseter2/Words/WordsEditCompControl.cs +++ b/Reseter2/Words/WordsEditCompControl.cs @@ -29,6 +29,7 @@ namespace Reseter2.Words lb_name.Text = wordscomp.GetName(); lb_ip.Text = wordscomp.GetIP(); lb_description.Text = wordscomp.GetDescription(); + tb_netName.Text = wordscomp.GetNetName(); wordsComp = wordscomp; treeNode = treenode; comboBox1.SelectedIndex = treeNode.ImageIndex; @@ -40,10 +41,15 @@ namespace Reseter2.Words private void WordsEditCompControl_VisibleChanged(object sender, EventArgs e) { - treeNode.Text = lb_name.Text; + wordsComp.Set(lb_name.Text.Length > 0 ? lb_name.Text : null, + lb_ip.Text.Length > 0 ? lb_ip.Text : null, + lb_description.Text.Length > 0 ? lb_description.Text : null, + comboBox1.SelectedIndex, + tb_netName.Text.Length > 0 ? tb_netName.Text : null); + treeNode.Text = wordsComp.NameNode(); treeNode.ImageIndex = comboBox1.SelectedIndex; treeNode.SelectedImageIndex = comboBox1.SelectedIndex; - wordsComp.Set(lb_name.Text, lb_ip.Text, lb_description.Text, comboBox1.SelectedIndex); + } private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)