Добпиливаем редактор словоря
This commit is contained in:
parent
0206cba08b
commit
8d6fb3a631
|
|
@ -50,6 +50,14 @@ namespace Reseter2
|
|||
{
|
||||
Ip = ip;
|
||||
}
|
||||
public void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
public void SetDescription(string description)
|
||||
{
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public string GetResetName()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,11 @@ namespace Reseter2
|
|||
string GetName();
|
||||
string GetResetName();
|
||||
IPAddress GetIP();
|
||||
|
||||
void SetIP(IPAddress ip);
|
||||
void SetName(string name);
|
||||
void SetDescription(string description);
|
||||
|
||||
string GetDescription();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
// treeView1
|
||||
//
|
||||
this.treeView1.AllowDrop = true;
|
||||
this.treeView1.HideSelection = false;
|
||||
this.treeView1.Location = new System.Drawing.Point(12, 41);
|
||||
this.treeView1.Name = "treeView1";
|
||||
this.treeView1.Size = new System.Drawing.Size(207, 471);
|
||||
|
|
@ -124,6 +125,7 @@
|
|||
this.bt_deleteItem.TabIndex = 9;
|
||||
this.bt_deleteItem.Text = "Удалить элемент";
|
||||
this.bt_deleteItem.UseVisualStyleBackColor = true;
|
||||
this.bt_deleteItem.Click += new System.EventHandler(this.bt_deleteItem_Click);
|
||||
//
|
||||
// BilderWords
|
||||
//
|
||||
|
|
@ -140,6 +142,7 @@
|
|||
this.Controls.Add(this.treeView1);
|
||||
this.Name = "BilderWords";
|
||||
this.Text = "Редактор справочника";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BilderWords_FormClosing);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace Reseter2.Words
|
||||
{
|
||||
|
|
@ -17,23 +18,61 @@ namespace Reseter2.Words
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
|
||||
WordsCategory WCvebinar = new WordsCategory("Вебинарные");
|
||||
WordsList.AddCategory(WCvebinar, WordsList.MainCategory);
|
||||
WordsList.AddItem(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");
|
||||
|
||||
|
||||
//// TreeNode trno = new TreeNode("main");
|
||||
|
||||
|
||||
treeView1.Nodes.AddRange(WordsList.ListNodes());
|
||||
//trno.ImageIndex = 1;
|
||||
cb_create.Items.Add("Категория");
|
||||
cb_create.Items.Add("Компьютер");
|
||||
cb_create.SelectedItem = 0;
|
||||
cb_create.SelectedIndex = 0;
|
||||
treeView1.ItemDrag += new ItemDragEventHandler(TreeView1_ItemDrag);
|
||||
treeView1.DragEnter += new DragEventHandler(TreeView1_DragEnter);
|
||||
treeView1.DragOver += new DragEventHandler(TreeView1_DragOver);
|
||||
treeView1.DragDrop += new DragEventHandler(TreeView1_DragDrop);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void TreeView1_ItemDrag(object sender, ItemDragEventArgs e)
|
||||
{
|
||||
if(e.Button == MouseButtons.Left)
|
||||
{
|
||||
DoDragDrop(e.Item, DragDropEffects.Move);
|
||||
}
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void TreeView1_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Effect = e.AllowedEffect;
|
||||
}
|
||||
private void TreeView1_DragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));
|
||||
treeView1.SelectedNode = treeView1.GetNodeAt(targetPoint);
|
||||
}
|
||||
private void TreeView1_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));
|
||||
TreeNode node = treeView1.GetNodeAt(targetPoint);
|
||||
int PointH = targetPoint.Y - node.Bounds.Y;
|
||||
//treeView1.GetNodeAt(targetPoint).Bounds.Top.ToString()
|
||||
//e.Y.ToString()
|
||||
|
||||
//node.Bounds.Y
|
||||
|
||||
|
||||
MessageBox.Show(PointH.ToString());
|
||||
|
||||
|
||||
}
|
||||
|
||||
public BilderWords(WordsCategory category):base()
|
||||
{
|
||||
|
|
@ -48,43 +87,128 @@ namespace Reseter2.Words
|
|||
|
||||
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (e.Node.Tag is WordsComp)
|
||||
if (e.Node != null)
|
||||
{
|
||||
WordsComp wordsComp = (WordsComp)e.Node.Tag;
|
||||
control = new WordsEditCompControl(wordsComp);
|
||||
panel1.Controls.Add(control);
|
||||
}
|
||||
if (e.Node.Tag is WordsCategory)
|
||||
{
|
||||
WordsCategory wordsCategory = (WordsCategory)e.Node.Tag;
|
||||
control = new WordsEditCategoryControl(wordsCategory);
|
||||
panel1.Controls.Add(control);
|
||||
if (e.Node.Tag is WordsComp)
|
||||
{
|
||||
WordsComp wordsComp = (WordsComp)e.Node.Tag;
|
||||
control = new WordsEditCompControl(wordsComp, e.Node);
|
||||
panel1.Controls.Add(control);
|
||||
}
|
||||
if (e.Node.Tag is WordsCategory)
|
||||
{
|
||||
WordsCategory wordsCategory = (WordsCategory)e.Node.Tag;
|
||||
control = new WordsEditCategoryControl(wordsCategory, e.Node);
|
||||
panel1.Controls.Add(control);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
|
||||
{
|
||||
|
||||
if(control != null)
|
||||
{
|
||||
panel1.Controls.Remove(control);
|
||||
control.Visible = false;
|
||||
control.Dispose();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void bt_new_Click(object sender, EventArgs e)
|
||||
{
|
||||
WordsCategory ParentCategory;
|
||||
TreeNode selectNode = treeView1.SelectedNode;
|
||||
TreeNodeCollection ParentNodes;
|
||||
int index = 0;
|
||||
if(selectNode == null)
|
||||
{
|
||||
ParentCategory = WordsList.MainCategory;
|
||||
ParentNodes = treeView1.Nodes;
|
||||
}
|
||||
else if(selectNode.Tag is WordsCategory)
|
||||
{
|
||||
ParentCategory = (WordsCategory)selectNode.Tag;
|
||||
ParentNodes = selectNode.Nodes;
|
||||
selectNode.Expand();
|
||||
}
|
||||
else if (selectNode.Parent == null)
|
||||
{
|
||||
ParentCategory = WordsList.MainCategory;
|
||||
ParentNodes = treeView1.Nodes;
|
||||
index = selectNode.Index+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ParentCategory = (WordsCategory)selectNode.Parent.Tag;
|
||||
ParentNodes = selectNode.Parent.Nodes;
|
||||
index = selectNode.Index+1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
object item = null;
|
||||
TreeNode treeNode = new TreeNode();
|
||||
switch (cb_create.SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
WordsList.AddCategory(new WordsCategory("Новая категория"), WordsList.MainCategory);
|
||||
item = new WordsCategory("Новая категория");
|
||||
WordsList.InsertItem(index, (WordsCategory)item, ParentCategory);
|
||||
treeNode.ImageIndex = 1;
|
||||
treeNode.Text = "Новая категория";
|
||||
break;
|
||||
case 1:
|
||||
WordsList.AddItem(new WordsComp(new CompId("Новый ПК")), WordsList.MainCategory);
|
||||
item = new WordsComp(new CompId("Новый ПК"));
|
||||
WordsList.InsertItem(index, (WordsComp)item, ParentCategory);
|
||||
treeNode.ImageIndex = 0;
|
||||
treeNode.Text = "Новый ПК";
|
||||
break;
|
||||
}
|
||||
treeNode.Tag = item;
|
||||
ParentNodes.Insert(index,treeNode);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void BilderWords_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
bool save = false;
|
||||
}
|
||||
|
||||
private void bt_deleteItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
TreeNode selectNode = treeView1.SelectedNode;
|
||||
if (selectNode == null) return;
|
||||
WordsCategory ParentCategory;
|
||||
TreeNodeCollection ParentNodes;
|
||||
treeView1.SelectedNode = null;
|
||||
control.Visible = false;
|
||||
control.Dispose();
|
||||
if (selectNode.Parent == null)
|
||||
{
|
||||
ParentCategory = WordsList.MainCategory;
|
||||
ParentNodes = treeView1.Nodes;
|
||||
}
|
||||
treeView1.Nodes.Clear();
|
||||
treeView1.Nodes.AddRange(WordsList.ListNodes());
|
||||
else
|
||||
{
|
||||
ParentCategory = (WordsCategory)selectNode.Parent.Tag;
|
||||
ParentNodes = selectNode.Parent.Nodes;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (selectNode.Tag == null) return;
|
||||
IWordsItem wordsItem = (IWordsItem)selectNode.Tag;
|
||||
|
||||
ParentCategory.DeleteItem(wordsItem);
|
||||
ParentNodes.Remove(selectNode);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace Reseter2.Words
|
|||
public abstract List<WordsCategory> CategoryList();
|
||||
|
||||
public abstract void ChekChange(bool chek);
|
||||
public abstract void Delete();
|
||||
public abstract TreeNode NodeList();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,19 @@ namespace Reseter2.Words
|
|||
{
|
||||
items.Add(newitem);
|
||||
}
|
||||
public void Insert(int index, IWordsItem newitem)
|
||||
{
|
||||
items.Insert(index, newitem);
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
public void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public IWordsItem Items(int item)
|
||||
{
|
||||
|
|
@ -39,6 +47,20 @@ namespace Reseter2.Words
|
|||
{
|
||||
return items.Count;
|
||||
}
|
||||
|
||||
public void DeleteItem(IWordsItem wordsItem)
|
||||
{
|
||||
wordsItem.Delete();
|
||||
items.Remove(wordsItem);
|
||||
}
|
||||
|
||||
public override void Delete() {
|
||||
foreach(IWordsItem item in items)
|
||||
{
|
||||
item.Delete();
|
||||
}
|
||||
items.Clear();
|
||||
}
|
||||
public override void ChekChange(bool chek)
|
||||
{
|
||||
cheked = chek;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
|
@ -17,6 +18,36 @@ namespace Reseter2.Words
|
|||
Comp = comp;
|
||||
|
||||
}
|
||||
public WordsComp(String name, String ip, String description)
|
||||
{
|
||||
IPAddress iPAddress;
|
||||
try
|
||||
{
|
||||
iPAddress = IPAddress.Parse(ip);
|
||||
}
|
||||
catch
|
||||
{
|
||||
iPAddress = null;
|
||||
}
|
||||
Comp = new CompId(name,description, iPAddress);
|
||||
|
||||
}
|
||||
|
||||
public void Set(String name, String ip, String description)
|
||||
{
|
||||
IPAddress iPAddress;
|
||||
try
|
||||
{
|
||||
iPAddress = IPAddress.Parse(ip);
|
||||
}
|
||||
catch
|
||||
{
|
||||
iPAddress = null;
|
||||
}
|
||||
Comp.SetIP(iPAddress);
|
||||
Comp.SetName(name);
|
||||
Comp.SetDescription(description);
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
|
|
@ -39,6 +70,12 @@ namespace Reseter2.Words
|
|||
{
|
||||
cheked = chek;
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
|
||||
Comp = null;
|
||||
}
|
||||
public override List<WordsComp> ChekList()
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@
|
|||
this.Controls.Add(this.label1);
|
||||
this.Name = "WordsEditCategoryControl";
|
||||
this.Size = new System.Drawing.Size(254, 52);
|
||||
this.VisibleChanged += new System.EventHandler(this.WordsEditCategoryControl_VisibleChanged);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
|
|
|||
|
|
@ -13,20 +13,31 @@ namespace Reseter2.Words
|
|||
[DefaultEvent(nameof(WordsEditCategoryControl))]
|
||||
internal partial class WordsEditCategoryControl : UserControl
|
||||
{
|
||||
private WordsCategory wordsCategory;
|
||||
private TreeNode treeNode;
|
||||
public WordsEditCategoryControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordsEditCategoryControl(WordsCategory wordsCategory)
|
||||
public WordsEditCategoryControl(WordsCategory wordscategory, TreeNode treenode)
|
||||
{
|
||||
InitializeComponent();
|
||||
lb_name.Text = wordsCategory.GetName();
|
||||
lb_name.Text = wordscategory.GetName();
|
||||
wordsCategory = wordscategory;
|
||||
treeNode = treenode;
|
||||
|
||||
}
|
||||
|
||||
private void label1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void WordsEditCategoryControl_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
treeNode.Text = lb_name.Text;
|
||||
wordsCategory.SetName(lb_name.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@
|
|||
this.Controls.Add(this.lb_name);
|
||||
this.Name = "WordsEditCompControl";
|
||||
this.Size = new System.Drawing.Size(254, 169);
|
||||
this.VisibleChanged += new System.EventHandler(this.WordsEditCompControl_VisibleChanged);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,17 +14,30 @@ namespace Reseter2.Words
|
|||
[DefaultEvent(nameof(WordsEditCompControl))]
|
||||
internal partial class WordsEditCompControl : UserControl
|
||||
{
|
||||
|
||||
private WordsComp wordsComp;
|
||||
private TreeNode treeNode;
|
||||
public WordsEditCompControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public WordsEditCompControl(WordsComp wordsComp)
|
||||
public WordsEditCompControl(WordsComp wordscomp, TreeNode treenode)
|
||||
{
|
||||
InitializeComponent();
|
||||
lb_name.Text = wordsComp.GetName();
|
||||
lb_ip.Text = wordsComp.GetIP();
|
||||
lb_description.Text = wordsComp.GetDescription();
|
||||
lb_name.Text = wordscomp.GetName();
|
||||
lb_ip.Text = wordscomp.GetIP();
|
||||
lb_description.Text = wordscomp.GetDescription();
|
||||
wordsComp = wordscomp;
|
||||
treeNode = treenode;
|
||||
}
|
||||
public void Save()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void WordsEditCompControl_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
treeNode.Text = lb_name.Text;
|
||||
wordsComp.Set(lb_name.Text, lb_ip.Text, lb_description.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@ namespace Reseter2.Words
|
|||
{
|
||||
wordsCategory.Add(item);
|
||||
}
|
||||
public static void AddCategory(IWordsItem item, WordsCategory wordsCategory)
|
||||
public static void InsertItem(int index,IWordsItem item, WordsCategory wordsCategory)
|
||||
{
|
||||
wordsCategory.Add(item);
|
||||
wordsCategory.Insert(index, item);
|
||||
}
|
||||
|
||||
public static TreeNode[] ListNodes()
|
||||
{
|
||||
TreeNode[] treeNodes = new TreeNode[MainCategory.Count()];
|
||||
|
|
|
|||
Loading…
Reference in New Issue