переделал редактор справочника

This commit is contained in:
klavirshik 2024-08-08 19:16:53 +02:00
parent 2d30585572
commit 572272f004
12 changed files with 349 additions and 50 deletions

View File

@ -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;
}
}

View File

@ -35,6 +35,7 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -86,6 +87,11 @@
<DependentUpon>BilderWords.cs</DependentUpon>
</Compile>
<Compile Include="Words\IWordsItem.cs" />
<Compile Include="Words\Resource1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resource1.resx</DependentUpon>
</Compile>
<Compile Include="Words\WordsCategory.cs" />
<Compile Include="Words\WordsCategoryControl.cs">
<SubType>UserControl</SubType>
@ -131,6 +137,10 @@
<EmbeddedResource Include="Words\BilderWords.resx">
<DependentUpon>BilderWords.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Words\Resource1.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resource1.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Words\WordsCategoryControl.resx">
<DependentUpon>WordsCategoryControl.cs</DependentUpon>
</EmbeddedResource>
@ -156,6 +166,8 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="Resources\comp.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

BIN
Reseter2/Resources/comp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

View File

@ -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;
}
}

View File

@ -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();
}
}
}
}

View File

@ -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<WordsCategory> CategoryList();
public abstract void ChekChange(bool chek);
public abstract TreeNode NodeList();

73
Reseter2/Words/Resource1.Designer.cs generated Normal file
View File

@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Reseter2.Words {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом 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() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[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;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap comp1 {
get {
object obj = ResourceManager.GetObject("comp1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="comp1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\comp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -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<IWordsItem>();
}
@ -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;
}
}
}

View File

@ -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<WordsCategory>();
}
public override TreeNode NodeList()
{
TreeNode treeNode = new TreeNode(GetName());
treeNode.Tag = this;
treeNode.ImageIndex = 2;
return treeNode;
}
}
}

View File

@ -28,9 +28,7 @@
/// </summary>
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;

View File

@ -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;
}
}
}