diff --git a/Reseter2/Form1.Designer.cs b/Reseter2/Form1.Designer.cs index 809c814..8bff8dc 100644 --- a/Reseter2/Form1.Designer.cs +++ b/Reseter2/Form1.Designer.cs @@ -51,9 +51,9 @@ this.tabPage4 = new System.Windows.Forms.TabPage(); this.cm_words = new System.Windows.Forms.ContextMenuStrip(this.components); this.mi_newitem = new System.Windows.Forms.ToolStripMenuItem(); - this.mi_newcategory = 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.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); @@ -273,11 +273,11 @@ // this.cm_words.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.mi_newitem, - this.mi_newcategory, this.mi_edit, - this.mi_delete}); + this.mi_delete, + this.перезагрузитьОдинToolStripMenuItem}); this.cm_words.Name = "cm_words"; - this.cm_words.Size = new System.Drawing.Size(181, 114); + this.cm_words.Size = new System.Drawing.Size(185, 114); // // mi_newitem // @@ -286,12 +286,6 @@ this.mi_newitem.Text = "Новый элемент"; this.mi_newitem.Click += new System.EventHandler(this.mi_newitem_Click); // - // mi_newcategory - // - this.mi_newcategory.Name = "mi_newcategory"; - this.mi_newcategory.Size = new System.Drawing.Size(166, 22); - this.mi_newcategory.Text = "Новая категория"; - // // mi_edit // this.mi_edit.Name = "mi_edit"; @@ -304,6 +298,12 @@ this.mi_delete.Size = new System.Drawing.Size(166, 22); this.mi_delete.Text = "Удалить"; // + // перезагрузитьОдинToolStripMenuItem + // + this.перезагрузитьОдинToolStripMenuItem.Name = "перезагрузитьОдинToolStripMenuItem"; + this.перезагрузитьОдинToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.перезагрузитьОдинToolStripMenuItem.Text = "Перезагрузить один"; + // // Form1 // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -351,9 +351,9 @@ private System.Windows.Forms.FlowLayoutPanel flow_words; private System.Windows.Forms.ContextMenuStrip cm_words; private System.Windows.Forms.ToolStripMenuItem mi_newitem; - private System.Windows.Forms.ToolStripMenuItem mi_newcategory; private System.Windows.Forms.ToolStripMenuItem mi_edit; private System.Windows.Forms.ToolStripMenuItem mi_delete; + private System.Windows.Forms.ToolStripMenuItem перезагрузитьОдинToolStripMenuItem; } } diff --git a/Reseter2/Reseter2.csproj b/Reseter2/Reseter2.csproj index 40591e6..968c309 100644 --- a/Reseter2/Reseter2.csproj +++ b/Reseter2/Reseter2.csproj @@ -35,6 +35,7 @@ + @@ -86,6 +87,11 @@ BilderWords.cs + + True + True + Resource1.resx + UserControl @@ -131,6 +137,10 @@ BilderWords.cs + + ResXFileCodeGenerator + Resource1.Designer.cs + WordsCategoryControl.cs @@ -156,6 +166,8 @@ - + + + \ No newline at end of file diff --git a/Reseter2/Resources/comp.png b/Reseter2/Resources/comp.png new file mode 100644 index 0000000..428fc37 Binary files /dev/null and b/Reseter2/Resources/comp.png differ diff --git a/Reseter2/Words/BilderWords.Designer.cs b/Reseter2/Words/BilderWords.Designer.cs index 559c6a9..afbd802 100644 --- a/Reseter2/Words/BilderWords.Designer.cs +++ b/Reseter2/Words/BilderWords.Designer.cs @@ -30,6 +30,8 @@ { this.rb_category = new System.Windows.Forms.RadioButton(); this.rb_comp = new System.Windows.Forms.RadioButton(); + this.treeView1 = new System.Windows.Forms.TreeView(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); this.SuspendLayout(); // // rb_category @@ -55,11 +57,32 @@ this.rb_comp.Text = "Компьютер"; this.rb_comp.UseVisualStyleBackColor = true; // + // treeView1 + // + this.treeView1.AllowDrop = true; + this.treeView1.Location = new System.Drawing.Point(12, 63); + this.treeView1.Name = "treeView1"; + this.treeView1.Size = new System.Drawing.Size(207, 434); + this.treeView1.TabIndex = 2; + this.treeView1.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView1_BeforeSelect); + this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); + // + // groupBox1 + // + this.groupBox1.Location = new System.Drawing.Point(225, 13); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(268, 484); + this.groupBox1.TabIndex = 3; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Параметры"; + // // BilderWords // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(327, 264); + this.ClientSize = new System.Drawing.Size(504, 504); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.treeView1); this.Controls.Add(this.rb_comp); this.Controls.Add(this.rb_category); this.Name = "BilderWords"; @@ -73,5 +96,7 @@ private System.Windows.Forms.RadioButton rb_category; private System.Windows.Forms.RadioButton rb_comp; + private System.Windows.Forms.TreeView treeView1; + private System.Windows.Forms.GroupBox groupBox1; } } \ No newline at end of file diff --git a/Reseter2/Words/BilderWords.cs b/Reseter2/Words/BilderWords.cs index 75a4e7f..98f7106 100644 --- a/Reseter2/Words/BilderWords.cs +++ b/Reseter2/Words/BilderWords.cs @@ -12,12 +12,25 @@ namespace Reseter2.Words { internal partial class BilderWords : Form { + private Control control; public BilderWords() { InitializeComponent(); + WordsCategory WCvebinar = new WordsCategory("Вебинарные"); + WordsList.AddCategory(WCvebinar, WordsList.MainCategory); + WordsList.AddItem(new WordsComp(new CompId("8.8.8.8")), WCvebinar); + WordsList.AddItem(new WordsComp(new CompId("1ma00234")), WordsList.MainCategory); + WordsList.AddItem(new WordsComp(new CompId("1ma003333")), WordsList.MainCategory); + // TreeNode trno = new TreeNode("main"); + + treeView1.Nodes.AddRange(WordsList.ListNodes()); + //trno.ImageIndex = 1; + + } + public BilderWords(WordsCategory category):base() { @@ -38,5 +51,31 @@ namespace Reseter2.Words } } + + private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) + { + if (e.Node.Tag is WordsComp) + { + WordsComp wordsComp = (WordsComp)e.Node.Tag; + control = new WordsEditCompControl(); + groupBox1.Controls.Add(control); + } + if (e.Node.Tag is WordsCategory) + { + WordsCategory wordsCategory = (WordsCategory)e.Node.Tag; + control = new WordsEditCategoryControl(); + groupBox1.Controls.Add(control); + } + } + + private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e) + { + if(control != null) + { + groupBox1.Controls.Remove(control); + control.Dispose(); + } + + } } } diff --git a/Reseter2/Words/IWordsItem.cs b/Reseter2/Words/IWordsItem.cs index 7bc4415..84c022d 100644 --- a/Reseter2/Words/IWordsItem.cs +++ b/Reseter2/Words/IWordsItem.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace Reseter2.Words { @@ -13,6 +14,7 @@ namespace Reseter2.Words public abstract List CategoryList(); public abstract void ChekChange(bool chek); + public abstract TreeNode NodeList(); diff --git a/Reseter2/Words/Resource1.Designer.cs b/Reseter2/Words/Resource1.Designer.cs new file mode 100644 index 0000000..4eea888 --- /dev/null +++ b/Reseter2/Words/Resource1.Designer.cs @@ -0,0 +1,73 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Reseter2.Words { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resource1 { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resource1() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Reseter2.Words.Resource1", typeof(Resource1).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap comp1 { + get { + object obj = ResourceManager.GetObject("comp1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Reseter2/Words/Resource1.resx b/Reseter2/Words/Resource1.resx new file mode 100644 index 0000000..03148d2 --- /dev/null +++ b/Reseter2/Words/Resource1.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\comp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Reseter2/Words/WordsCategory.cs b/Reseter2/Words/WordsCategory.cs index 007cb6b..f7d14c8 100644 --- a/Reseter2/Words/WordsCategory.cs +++ b/Reseter2/Words/WordsCategory.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace Reseter2.Words { @@ -15,6 +16,7 @@ namespace Reseter2.Words public WordsCategory(string name) { Name = name; + items = new List(); } @@ -22,11 +24,21 @@ namespace Reseter2.Words { items.Add(newitem); } - + public string GetName() { return Name; } + + public IWordsItem Items(int item) + { + return items[item]; + } + + public int Count() + { + return items.Count; + } public override void ChekChange(bool chek) { cheked = chek; @@ -54,5 +66,18 @@ namespace Reseter2.Words } return itemsCatrgory; } + + public override TreeNode NodeList() + { + TreeNode treeNode = new TreeNode(GetName()); + treeNode.Tag = this; + treeNode.ImageIndex = 1; + + foreach (var item in items) + { + treeNode.Nodes.Add(item.NodeList()); + } + return treeNode; + } } } diff --git a/Reseter2/Words/WordsComp.cs b/Reseter2/Words/WordsComp.cs index 758fc97..8141f72 100644 --- a/Reseter2/Words/WordsComp.cs +++ b/Reseter2/Words/WordsComp.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace Reseter2.Words { @@ -36,5 +37,12 @@ namespace Reseter2.Words { return new List(); } + public override TreeNode NodeList() + { + TreeNode treeNode = new TreeNode(GetName()); + treeNode.Tag = this; + treeNode.ImageIndex = 2; + return treeNode; + } } } diff --git a/Reseter2/Words/WordsEditCompControl.Designer.cs b/Reseter2/Words/WordsEditCompControl.Designer.cs index a23e34a..1b5f1ad 100644 --- a/Reseter2/Words/WordsEditCompControl.Designer.cs +++ b/Reseter2/Words/WordsEditCompControl.Designer.cs @@ -28,9 +28,7 @@ /// private void InitializeComponent() { - this.label1 = new System.Windows.Forms.Label(); this.serviceController1 = new System.ServiceProcess.ServiceController(); - this.comboBox1 = new System.Windows.Forms.ComboBox(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); @@ -39,26 +37,9 @@ this.label4 = new System.Windows.Forms.Label(); this.SuspendLayout(); // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 8); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(125, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Родительский элемент"; - // - // comboBox1 - // - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Location = new System.Drawing.Point(136, 5); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(177, 21); - this.comboBox1.TabIndex = 1; - // // textBox1 // - this.textBox1.Location = new System.Drawing.Point(66, 33); + this.textBox1.Location = new System.Drawing.Point(66, 3); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(247, 20); this.textBox1.TabIndex = 2; @@ -66,7 +47,7 @@ // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(3, 36); + this.label2.Location = new System.Drawing.Point(3, 6); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(47, 13); this.label2.TabIndex = 3; @@ -75,7 +56,7 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 62); + this.label3.Location = new System.Drawing.Point(3, 32); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(50, 13); this.label3.TabIndex = 5; @@ -83,14 +64,14 @@ // // textBox2 // - this.textBox2.Location = new System.Drawing.Point(66, 59); + this.textBox2.Location = new System.Drawing.Point(66, 29); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(247, 20); this.textBox2.TabIndex = 4; // // textBox3 // - this.textBox3.Location = new System.Drawing.Point(66, 85); + this.textBox3.Location = new System.Drawing.Point(66, 55); this.textBox3.Multiline = true; this.textBox3.Name = "textBox3"; this.textBox3.Size = new System.Drawing.Size(247, 63); @@ -99,13 +80,13 @@ // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(3, 87); + this.label4.Location = new System.Drawing.Point(3, 57); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(57, 13); this.label4.TabIndex = 7; this.label4.Text = "Описание"; // - // WordsCompCategoryControl + // WordsEditCompControl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -115,20 +96,15 @@ this.Controls.Add(this.textBox2); this.Controls.Add(this.label2); this.Controls.Add(this.textBox1); - this.Controls.Add(this.comboBox1); - this.Controls.Add(this.label1); - this.Name = "WordsCompCategoryControl"; - this.Size = new System.Drawing.Size(316, 150); + this.Name = "WordsEditCompControl"; + this.Size = new System.Drawing.Size(316, 123); this.ResumeLayout(false); this.PerformLayout(); } #endregion - - private System.Windows.Forms.Label label1; private System.ServiceProcess.ServiceController serviceController1; - private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; diff --git a/Reseter2/Words/WordsList.cs b/Reseter2/Words/WordsList.cs index 88b5c65..973c48a 100644 --- a/Reseter2/Words/WordsList.cs +++ b/Reseter2/Words/WordsList.cs @@ -4,15 +4,30 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace Reseter2.Words { static class WordsList { - private static WordsCategory MainCategory = new WordsCategory("Main"); - private static void AddItem(IWordsItem item) + public static WordsCategory MainCategory = new WordsCategory("Main"); + public static void AddItem(IWordsItem item, WordsCategory wordsCategory) { - + wordsCategory.Add(item); + } + public static void AddCategory(IWordsItem item, WordsCategory wordsCategory) + { + wordsCategory.Add(item); + } + public static TreeNode[] ListNodes() + { + TreeNode[] treeNodes = new TreeNode[MainCategory.Count()]; + for(int i = 0; i < MainCategory.Count(); i++) + { + treeNodes[i] = MainCategory.Items(i).NodeList(); + } + + return treeNodes; } } }