форма редактора

This commit is contained in:
klavirshik 2024-08-08 22:58:10 +02:00
parent 572272f004
commit 0206cba08b
8 changed files with 196 additions and 139 deletions

View File

@ -28,75 +28,132 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.rb_category = new System.Windows.Forms.RadioButton();
this.rb_comp = new System.Windows.Forms.RadioButton();
this.treeView1 = new System.Windows.Forms.TreeView(); this.treeView1 = new System.Windows.Forms.TreeView();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.panel1 = new System.Windows.Forms.Panel();
this.bt_close = new System.Windows.Forms.Button();
this.bt_saveClose = new System.Windows.Forms.Button();
this.bt_save = new System.Windows.Forms.Button();
this.cb_create = new System.Windows.Forms.ComboBox();
this.bt_new = new System.Windows.Forms.Button();
this.bt_deleteItem = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// rb_category
//
this.rb_category.AutoSize = true;
this.rb_category.Checked = true;
this.rb_category.Location = new System.Drawing.Point(13, 13);
this.rb_category.Name = "rb_category";
this.rb_category.Size = new System.Drawing.Size(78, 17);
this.rb_category.TabIndex = 0;
this.rb_category.TabStop = true;
this.rb_category.Text = "Категория";
this.rb_category.UseVisualStyleBackColor = true;
this.rb_category.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// rb_comp
//
this.rb_comp.AutoSize = true;
this.rb_comp.Location = new System.Drawing.Point(97, 13);
this.rb_comp.Name = "rb_comp";
this.rb_comp.Size = new System.Drawing.Size(83, 17);
this.rb_comp.TabIndex = 1;
this.rb_comp.Text = "Компьютер";
this.rb_comp.UseVisualStyleBackColor = true;
//
// treeView1 // treeView1
// //
this.treeView1.AllowDrop = true; this.treeView1.AllowDrop = true;
this.treeView1.Location = new System.Drawing.Point(12, 63); this.treeView1.Location = new System.Drawing.Point(12, 41);
this.treeView1.Name = "treeView1"; this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(207, 434); this.treeView1.Size = new System.Drawing.Size(207, 471);
this.treeView1.TabIndex = 2; this.treeView1.TabIndex = 2;
this.treeView1.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView1_BeforeSelect); this.treeView1.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView1_BeforeSelect);
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
// //
// groupBox1 // groupBox1
// //
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.panel1);
this.groupBox1.Location = new System.Drawing.Point(225, 13); this.groupBox1.Location = new System.Drawing.Point(225, 13);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(268, 484); this.groupBox1.Size = new System.Drawing.Size(268, 502);
this.groupBox1.TabIndex = 3; this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "Параметры"; this.groupBox1.Text = "Параметры";
// //
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel1.Location = new System.Drawing.Point(3, 19);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(262, 480);
this.panel1.TabIndex = 0;
//
// bt_close
//
this.bt_close.Location = new System.Drawing.Point(417, 521);
this.bt_close.Name = "bt_close";
this.bt_close.Size = new System.Drawing.Size(75, 23);
this.bt_close.TabIndex = 4;
this.bt_close.Text = "Закрыть";
this.bt_close.UseVisualStyleBackColor = true;
//
// bt_saveClose
//
this.bt_saveClose.Location = new System.Drawing.Point(280, 521);
this.bt_saveClose.Name = "bt_saveClose";
this.bt_saveClose.Size = new System.Drawing.Size(131, 23);
this.bt_saveClose.TabIndex = 5;
this.bt_saveClose.Text = "Сохранить и закрыть";
this.bt_saveClose.UseVisualStyleBackColor = true;
//
// bt_save
//
this.bt_save.Location = new System.Drawing.Point(199, 521);
this.bt_save.Name = "bt_save";
this.bt_save.Size = new System.Drawing.Size(75, 23);
this.bt_save.TabIndex = 6;
this.bt_save.Text = "Сохранить";
this.bt_save.UseVisualStyleBackColor = true;
//
// cb_create
//
this.cb_create.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cb_create.FormattingEnabled = true;
this.cb_create.Location = new System.Drawing.Point(12, 13);
this.cb_create.Name = "cb_create";
this.cb_create.Size = new System.Drawing.Size(175, 21);
this.cb_create.TabIndex = 7;
//
// bt_new
//
this.bt_new.Location = new System.Drawing.Point(193, 12);
this.bt_new.Name = "bt_new";
this.bt_new.Size = new System.Drawing.Size(23, 23);
this.bt_new.TabIndex = 8;
this.bt_new.Text = "+";
this.bt_new.UseVisualStyleBackColor = true;
this.bt_new.Click += new System.EventHandler(this.bt_new_Click);
//
// bt_deleteItem
//
this.bt_deleteItem.Location = new System.Drawing.Point(12, 521);
this.bt_deleteItem.Name = "bt_deleteItem";
this.bt_deleteItem.Size = new System.Drawing.Size(112, 23);
this.bt_deleteItem.TabIndex = 9;
this.bt_deleteItem.Text = "Удалить элемент";
this.bt_deleteItem.UseVisualStyleBackColor = true;
//
// BilderWords // BilderWords
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(504, 504); this.ClientSize = new System.Drawing.Size(504, 556);
this.Controls.Add(this.bt_deleteItem);
this.Controls.Add(this.bt_new);
this.Controls.Add(this.cb_create);
this.Controls.Add(this.bt_save);
this.Controls.Add(this.bt_saveClose);
this.Controls.Add(this.bt_close);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox1);
this.Controls.Add(this.treeView1); this.Controls.Add(this.treeView1);
this.Controls.Add(this.rb_comp);
this.Controls.Add(this.rb_category);
this.Name = "BilderWords"; this.Name = "BilderWords";
this.Text = "BilderWords"; this.Text = "Редактор справочника";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.RadioButton rb_category;
private System.Windows.Forms.RadioButton rb_comp;
private System.Windows.Forms.TreeView treeView1; private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button bt_close;
private System.Windows.Forms.Button bt_saveClose;
private System.Windows.Forms.Button bt_save;
private System.Windows.Forms.ComboBox cb_create;
private System.Windows.Forms.Button bt_new;
private System.Windows.Forms.Button bt_deleteItem;
} }
} }

View File

@ -16,6 +16,8 @@ namespace Reseter2.Words
public BilderWords() public BilderWords()
{ {
InitializeComponent(); InitializeComponent();
WordsCategory WCvebinar = new WordsCategory("Вебинарные"); WordsCategory WCvebinar = new WordsCategory("Вебинарные");
WordsList.AddCategory(WCvebinar, WordsList.MainCategory); WordsList.AddCategory(WCvebinar, WordsList.MainCategory);
WordsList.AddItem(new WordsComp(new CompId("8.8.8.8")), WCvebinar); WordsList.AddItem(new WordsComp(new CompId("8.8.8.8")), WCvebinar);
@ -26,7 +28,9 @@ namespace Reseter2.Words
treeView1.Nodes.AddRange(WordsList.ListNodes()); treeView1.Nodes.AddRange(WordsList.ListNodes());
//trno.ImageIndex = 1; //trno.ImageIndex = 1;
cb_create.Items.Add("Категория");
cb_create.Items.Add("Компьютер");
cb_create.SelectedItem = 0;
} }
@ -40,31 +44,21 @@ namespace Reseter2.Words
} }
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if(rb_category.Checked)
{
}
else
{
}
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{ {
if (e.Node.Tag is WordsComp) if (e.Node.Tag is WordsComp)
{ {
WordsComp wordsComp = (WordsComp)e.Node.Tag; WordsComp wordsComp = (WordsComp)e.Node.Tag;
control = new WordsEditCompControl(); control = new WordsEditCompControl(wordsComp);
groupBox1.Controls.Add(control); panel1.Controls.Add(control);
} }
if (e.Node.Tag is WordsCategory) if (e.Node.Tag is WordsCategory)
{ {
WordsCategory wordsCategory = (WordsCategory)e.Node.Tag; WordsCategory wordsCategory = (WordsCategory)e.Node.Tag;
control = new WordsEditCategoryControl(); control = new WordsEditCategoryControl(wordsCategory);
groupBox1.Controls.Add(control); panel1.Controls.Add(control);
} }
} }
@ -72,10 +66,25 @@ namespace Reseter2.Words
{ {
if(control != null) if(control != null)
{ {
groupBox1.Controls.Remove(control); panel1.Controls.Remove(control);
control.Dispose(); control.Dispose();
} }
} }
private void bt_new_Click(object sender, EventArgs e)
{
switch (cb_create.SelectedIndex)
{
case 0:
WordsList.AddCategory(new WordsCategory("Новая категория"), WordsList.MainCategory);
break;
case 1:
WordsList.AddItem(new WordsComp(new CompId("Новый ПК")), WordsList.MainCategory);
break;
}
treeView1.Nodes.Clear();
treeView1.Nodes.AddRange(WordsList.ListNodes());
}
} }
} }

View File

@ -22,6 +22,19 @@ namespace Reseter2.Words
{ {
return Comp.GetName(); return Comp.GetName();
} }
public string GetDescription()
{
return Comp.GetDescription();
}
public string GetIP()
{
if(Comp.GetIP() != null)
{
return Comp.GetIP().ToString();
}
return null;
}
public override void ChekChange(bool chek) public override void ChekChange(bool chek)
{ {
cheked = chek; cheked = chek;

View File

@ -29,76 +29,37 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox(); this.lb_name = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.listBox1 = new System.Windows.Forms.ListBox();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(3, 35); this.label1.Location = new System.Drawing.Point(3, 10);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(112, 13); this.label1.Size = new System.Drawing.Size(112, 13);
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
this.label1.Text = "Название категории"; this.label1.Text = "Название категории";
this.label1.Click += new System.EventHandler(this.label1_Click); this.label1.Click += new System.EventHandler(this.label1_Click);
// //
// comboBox1 // lb_name
// //
this.comboBox1.FormattingEnabled = true; this.lb_name.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.comboBox1.Location = new System.Drawing.Point(134, 4); | System.Windows.Forms.AnchorStyles.Right)));
this.comboBox1.Name = "comboBox1"; this.lb_name.Location = new System.Drawing.Point(6, 26);
this.comboBox1.Size = new System.Drawing.Size(179, 21); this.lb_name.Name = "lb_name";
this.comboBox1.TabIndex = 1; this.lb_name.Size = new System.Drawing.Size(245, 20);
// this.lb_name.TabIndex = 3;
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(3, 7);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(125, 13);
this.label2.TabIndex = 2;
this.label2.Text = "Родтиельский элемент";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(134, 32);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(179, 20);
this.textBox1.TabIndex = 3;
//
// listBox1
//
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(6, 82);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(307, 147);
this.listBox1.TabIndex = 4;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 63);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(173, 13);
this.label3.TabIndex = 5;
this.label3.Text = "Порядок элементов в категории";
// //
// WordsEditCategoryControl // WordsEditCategoryControl
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label3); this.AutoSize = true;
this.Controls.Add(this.listBox1); this.Controls.Add(this.lb_name);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Name = "WordsEditCategoryControl"; this.Name = "WordsEditCategoryControl";
this.Size = new System.Drawing.Size(316, 233); this.Size = new System.Drawing.Size(254, 52);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -107,10 +68,6 @@
#endregion #endregion
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.TextBox lb_name;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label label3;
} }
} }

View File

@ -11,13 +11,19 @@ using System.Windows.Forms;
namespace Reseter2.Words namespace Reseter2.Words
{ {
[DefaultEvent(nameof(WordsEditCategoryControl))] [DefaultEvent(nameof(WordsEditCategoryControl))]
public partial class WordsEditCategoryControl : UserControl internal partial class WordsEditCategoryControl : UserControl
{ {
public WordsEditCategoryControl() public WordsEditCategoryControl()
{ {
InitializeComponent(); InitializeComponent();
} }
public WordsEditCategoryControl(WordsCategory wordsCategory)
{
InitializeComponent();
lb_name.Text = wordsCategory.GetName();
}
private void label1_Click(object sender, EventArgs e) private void label1_Click(object sender, EventArgs e)
{ {

View File

@ -29,20 +29,22 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.serviceController1 = new System.ServiceProcess.ServiceController(); this.serviceController1 = new System.ServiceProcess.ServiceController();
this.textBox1 = new System.Windows.Forms.TextBox(); this.lb_name = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox(); this.lb_ip = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox(); this.lb_description = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// textBox1 // lb_name
// //
this.textBox1.Location = new System.Drawing.Point(66, 3); this.lb_name.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.textBox1.Name = "textBox1"; | System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Size = new System.Drawing.Size(247, 20); this.lb_name.Location = new System.Drawing.Point(6, 22);
this.textBox1.TabIndex = 2; this.lb_name.Name = "lb_name";
this.lb_name.Size = new System.Drawing.Size(243, 20);
this.lb_name.TabIndex = 2;
// //
// label2 // label2
// //
@ -56,31 +58,35 @@
// label3 // label3
// //
this.label3.AutoSize = true; this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 32); this.label3.Location = new System.Drawing.Point(3, 45);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(50, 13); this.label3.Size = new System.Drawing.Size(50, 13);
this.label3.TabIndex = 5; this.label3.TabIndex = 5;
this.label3.Text = "IP адрес"; this.label3.Text = "IP адрес";
// //
// textBox2 // lb_ip
// //
this.textBox2.Location = new System.Drawing.Point(66, 29); this.lb_ip.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.textBox2.Name = "textBox2"; | System.Windows.Forms.AnchorStyles.Right)));
this.textBox2.Size = new System.Drawing.Size(247, 20); this.lb_ip.Location = new System.Drawing.Point(6, 61);
this.textBox2.TabIndex = 4; this.lb_ip.Name = "lb_ip";
this.lb_ip.Size = new System.Drawing.Size(243, 20);
this.lb_ip.TabIndex = 4;
// //
// textBox3 // lb_description
// //
this.textBox3.Location = new System.Drawing.Point(66, 55); this.lb_description.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.textBox3.Multiline = true; | System.Windows.Forms.AnchorStyles.Right)));
this.textBox3.Name = "textBox3"; this.lb_description.Location = new System.Drawing.Point(6, 100);
this.textBox3.Size = new System.Drawing.Size(247, 63); this.lb_description.Multiline = true;
this.textBox3.TabIndex = 6; this.lb_description.Name = "lb_description";
this.lb_description.Size = new System.Drawing.Size(243, 63);
this.lb_description.TabIndex = 6;
// //
// label4 // label4
// //
this.label4.AutoSize = true; this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(3, 57); this.label4.Location = new System.Drawing.Point(3, 84);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(57, 13); this.label4.Size = new System.Drawing.Size(57, 13);
this.label4.TabIndex = 7; this.label4.TabIndex = 7;
@ -90,14 +96,15 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.Controls.Add(this.label4); this.Controls.Add(this.label4);
this.Controls.Add(this.textBox3); this.Controls.Add(this.lb_description);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.textBox2); this.Controls.Add(this.lb_ip);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1); this.Controls.Add(this.lb_name);
this.Name = "WordsEditCompControl"; this.Name = "WordsEditCompControl";
this.Size = new System.Drawing.Size(316, 123); this.Size = new System.Drawing.Size(254, 169);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -105,11 +112,11 @@
#endregion #endregion
private System.ServiceProcess.ServiceController serviceController1; private System.ServiceProcess.ServiceController serviceController1;
private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox lb_name;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.TextBox lb_ip;
private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.TextBox lb_description;
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
} }
} }

View File

@ -12,12 +12,19 @@ namespace Reseter2.Words
{ {
[DefaultEvent(nameof(WordsEditCompControl))] [DefaultEvent(nameof(WordsEditCompControl))]
public partial class WordsEditCompControl : UserControl internal partial class WordsEditCompControl : UserControl
{ {
public WordsEditCompControl() public WordsEditCompControl()
{ {
InitializeComponent(); InitializeComponent();
} }
public WordsEditCompControl(WordsComp wordsComp)
{
InitializeComponent();
lb_name.Text = wordsComp.GetName();
lb_ip.Text = wordsComp.GetIP();
lb_description.Text = wordsComp.GetDescription();
}
} }
} }

1
Temp.txt Normal file
View File

@ -0,0 +1 @@