Поправил поведение дерева
This commit is contained in:
parent
8d6fb3a631
commit
89cd78f048
|
|
@ -38,6 +38,11 @@
|
|||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.flow_words = new System.Windows.Forms.FlowLayoutPanel();
|
||||
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.tabPage3 = new System.Windows.Forms.TabPage();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
|
|
@ -49,17 +54,14 @@
|
|||
this.sm_RebootItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.sm_SaveItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
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_edit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mi_delete = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.перезагрузитьОдинToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.bt_wordsBilder = new System.Windows.Forms.Button();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
this.cm_words.SuspendLayout();
|
||||
this.tabPage3.SuspendLayout();
|
||||
this.cm_history.SuspendLayout();
|
||||
this.cm_words.SuspendLayout();
|
||||
this.tabPage4.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tb_comp
|
||||
|
|
@ -153,6 +155,41 @@
|
|||
this.flow_words.Size = new System.Drawing.Size(396, 682);
|
||||
this.flow_words.TabIndex = 0;
|
||||
//
|
||||
// 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 = "Перезагрузить один";
|
||||
//
|
||||
// tabPage3
|
||||
//
|
||||
this.tabPage3.Controls.Add(this.button1);
|
||||
|
|
@ -261,6 +298,7 @@
|
|||
//
|
||||
// tabPage4
|
||||
//
|
||||
this.tabPage4.Controls.Add(this.bt_wordsBilder);
|
||||
this.tabPage4.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage4.Name = "tabPage4";
|
||||
this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
|
||||
|
|
@ -269,40 +307,15 @@
|
|||
this.tabPage4.Text = "Настройки";
|
||||
this.tabPage4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cm_words
|
||||
// bt_wordsBilder
|
||||
//
|
||||
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, 114);
|
||||
//
|
||||
// mi_newitem
|
||||
//
|
||||
this.mi_newitem.Name = "mi_newitem";
|
||||
this.mi_newitem.Size = new System.Drawing.Size(180, 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(166, 22);
|
||||
this.mi_edit.Text = "Изменить";
|
||||
//
|
||||
// mi_delete
|
||||
//
|
||||
this.mi_delete.Name = "mi_delete";
|
||||
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 = "Перезагрузить один";
|
||||
this.bt_wordsBilder.Location = new System.Drawing.Point(102, 25);
|
||||
this.bt_wordsBilder.Name = "bt_wordsBilder";
|
||||
this.bt_wordsBilder.Size = new System.Drawing.Size(155, 23);
|
||||
this.bt_wordsBilder.TabIndex = 0;
|
||||
this.bt_wordsBilder.Text = "Редактор справочника";
|
||||
this.bt_wordsBilder.UseVisualStyleBackColor = true;
|
||||
this.bt_wordsBilder.Click += new System.EventHandler(this.bt_wordsBilder_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
|
|
@ -318,10 +331,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.cm_words.ResumeLayout(false);
|
||||
this.tabPage4.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
|
@ -354,6 +368,7 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem mi_edit;
|
||||
private System.Windows.Forms.ToolStripMenuItem mi_delete;
|
||||
private System.Windows.Forms.ToolStripMenuItem перезагрузитьОдинToolStripMenuItem;
|
||||
private System.Windows.Forms.Button bt_wordsBilder;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,5 +139,11 @@ namespace Reseter2
|
|||
BilderWords bilderWords = new BilderWords();
|
||||
bilderWords.ShowDialog();
|
||||
}
|
||||
|
||||
private void bt_wordsBilder_Click(object sender, EventArgs e)
|
||||
{
|
||||
BilderWords bilderWords = new BilderWords();
|
||||
bilderWords.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.treeView1 = new System.Windows.Forms.TreeView();
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.bt_close = new System.Windows.Forms.Button();
|
||||
|
|
@ -37,23 +37,15 @@
|
|||
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.treeView1 = new System.Windows.Forms.TreeView();
|
||||
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// 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);
|
||||
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.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBox1.Controls.Add(this.panel1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(225, 13);
|
||||
|
|
@ -65,7 +57,9 @@
|
|||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panel1.Location = new System.Drawing.Point(3, 19);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(262, 480);
|
||||
|
|
@ -73,6 +67,7 @@
|
|||
//
|
||||
// bt_close
|
||||
//
|
||||
this.bt_close.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
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);
|
||||
|
|
@ -82,6 +77,7 @@
|
|||
//
|
||||
// bt_saveClose
|
||||
//
|
||||
this.bt_saveClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
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);
|
||||
|
|
@ -91,6 +87,7 @@
|
|||
//
|
||||
// bt_save
|
||||
//
|
||||
this.bt_save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
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);
|
||||
|
|
@ -119,6 +116,7 @@
|
|||
//
|
||||
// bt_deleteItem
|
||||
//
|
||||
this.bt_deleteItem.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
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);
|
||||
|
|
@ -127,11 +125,33 @@
|
|||
this.bt_deleteItem.UseVisualStyleBackColor = true;
|
||||
this.bt_deleteItem.Click += new System.EventHandler(this.bt_deleteItem_Click);
|
||||
//
|
||||
// treeView1
|
||||
//
|
||||
this.treeView1.AllowDrop = true;
|
||||
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.treeView1.HideSelection = false;
|
||||
this.treeView1.Location = new System.Drawing.Point(9, 41);
|
||||
this.treeView1.Name = "treeView1";
|
||||
this.treeView1.ShowLines = false;
|
||||
this.treeView1.Size = new System.Drawing.Size(207, 471);
|
||||
this.treeView1.TabIndex = 4;
|
||||
this.treeView1.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView1_BeforeSelect);
|
||||
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
|
||||
this.treeView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseClick);
|
||||
//
|
||||
// imageList1
|
||||
//
|
||||
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
|
||||
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
|
||||
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
|
||||
//
|
||||
// BilderWords
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(504, 556);
|
||||
this.Controls.Add(this.treeView1);
|
||||
this.Controls.Add(this.bt_deleteItem);
|
||||
this.Controls.Add(this.bt_new);
|
||||
this.Controls.Add(this.cb_create);
|
||||
|
|
@ -139,7 +159,6 @@
|
|||
this.Controls.Add(this.bt_saveClose);
|
||||
this.Controls.Add(this.bt_close);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.treeView1);
|
||||
this.Name = "BilderWords";
|
||||
this.Text = "Редактор справочника";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.BilderWords_FormClosing);
|
||||
|
|
@ -149,7 +168,6 @@
|
|||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.TreeView treeView1;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Button bt_close;
|
||||
|
|
@ -158,5 +176,7 @@
|
|||
private System.Windows.Forms.ComboBox cb_create;
|
||||
private System.Windows.Forms.Button bt_new;
|
||||
private System.Windows.Forms.Button bt_deleteItem;
|
||||
private System.Windows.Forms.TreeView treeView1;
|
||||
private System.Windows.Forms.ImageList imageList1;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ namespace Reseter2.Words
|
|||
internal partial class BilderWords : Form
|
||||
{
|
||||
private Control control;
|
||||
private bool DragOn;
|
||||
public BilderWords()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
|
@ -21,7 +22,18 @@ namespace Reseter2.Words
|
|||
|
||||
WordsCategory WCvebinar = new WordsCategory("Вебинарные");
|
||||
WordsList.AddItem(WCvebinar, WordsList.MainCategory);
|
||||
WordsList.AddItem(new WordsComp(new CompId("8.8.8.8")), WCvebinar);
|
||||
WordsList.AddItem(new WordsComp(new CompId("8.8..8")), WCvebinar);
|
||||
WordsList.AddItem(new WordsComp(new CompId("8.8.3.8")), WCvebinar);
|
||||
WordsList.AddItem(new WordsComp(new CompId("8.8.2.8")), WCvebinar);
|
||||
WordsList.AddItem(new WordsComp(new CompId("8.8.1.8")), WCvebinar);
|
||||
WordsList.AddItem(new WordsComp(new CompId("1ma00234")), WordsList.MainCategory);
|
||||
WordsList.AddItem(new WordsComp(new CompId("1ma003333")), WordsList.MainCategory);
|
||||
WordsCategory WCvebinar1 = new WordsCategory("Вебинарные");
|
||||
WordsList.AddItem(WCvebinar1, WordsList.MainCategory);
|
||||
WordsList.AddItem(new WordsComp(new CompId("8.8.8.8")), WCvebinar1);
|
||||
WordsList.AddItem(new WordsComp(new CompId("8.8.8.2")), WCvebinar1);
|
||||
WordsList.AddItem(new WordsComp(new CompId("8.8.8.3")), WCvebinar1);
|
||||
WordsList.AddItem(new WordsComp(new CompId("8.8.8.1")), WCvebinar1);
|
||||
WordsList.AddItem(new WordsComp(new CompId("1ma00234")), WordsList.MainCategory);
|
||||
WordsList.AddItem(new WordsComp(new CompId("1ma003333")), WordsList.MainCategory);
|
||||
//// TreeNode trno = new TreeNode("main");
|
||||
|
|
@ -51,6 +63,7 @@ namespace Reseter2.Words
|
|||
|
||||
private void TreeView1_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
DragOn = true;
|
||||
e.Effect = e.AllowedEffect;
|
||||
}
|
||||
private void TreeView1_DragOver(object sender, DragEventArgs e)
|
||||
|
|
@ -60,17 +73,102 @@ namespace Reseter2.Words
|
|||
}
|
||||
private void TreeView1_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
DragOn = false;
|
||||
control.Visible = false;
|
||||
control.Dispose();
|
||||
int indexMod = 0;
|
||||
int index = 0;
|
||||
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
|
||||
TreeNode selectNode = treeView1.GetNodeAt(targetPoint);
|
||||
TreeNode moveNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
|
||||
if(selectNode == null)
|
||||
{
|
||||
// indexMod = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int PointH = targetPoint.Y - selectNode.Bounds.Y;
|
||||
if (PointH > 6) indexMod = 1;
|
||||
}
|
||||
|
||||
//if (!((IWordsItem)moveNode.Tag).ChekMove((IWordsItem)selectNode.Tag)) return;
|
||||
|
||||
WordsCategory DstCategory;
|
||||
TreeNodeCollection DstNodes;
|
||||
|
||||
|
||||
MessageBox.Show(PointH.ToString());
|
||||
|
||||
if (selectNode == null)
|
||||
{
|
||||
DstCategory = WordsList.MainCategory;
|
||||
DstNodes = treeView1.Nodes;
|
||||
if(targetPoint.Y < 5)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = treeView1.Nodes.Count;
|
||||
}
|
||||
|
||||
}
|
||||
else if (selectNode.Tag is WordsCategory)
|
||||
{
|
||||
DstCategory = (WordsCategory)selectNode.Tag;
|
||||
DstNodes = selectNode.Nodes;
|
||||
selectNode.Expand();
|
||||
// index = 1;
|
||||
}
|
||||
else if (selectNode.Parent == null)
|
||||
{
|
||||
DstCategory = WordsList.MainCategory;
|
||||
DstNodes = treeView1.Nodes;
|
||||
index = selectNode.Index + indexMod;
|
||||
}
|
||||
else
|
||||
{
|
||||
DstCategory = (WordsCategory)selectNode.Parent.Tag;
|
||||
DstNodes = selectNode.Parent.Nodes;
|
||||
index = selectNode.Index + indexMod;
|
||||
}
|
||||
|
||||
WordsCategory SrcCategory;
|
||||
TreeNodeCollection SrcNodes;
|
||||
if (moveNode == null)
|
||||
{
|
||||
SrcCategory = WordsList.MainCategory;
|
||||
SrcNodes = treeView1.Nodes;
|
||||
}
|
||||
else if (moveNode.Parent == null)
|
||||
{
|
||||
SrcCategory = WordsList.MainCategory;
|
||||
SrcNodes = treeView1.Nodes;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
SrcCategory = (WordsCategory)moveNode.Parent.Tag;
|
||||
SrcNodes = moveNode.Parent.Nodes;
|
||||
|
||||
}
|
||||
if(SrcCategory == DstCategory)
|
||||
{
|
||||
if(selectNode == null)
|
||||
{
|
||||
if (targetPoint.Y > 5) index--;
|
||||
}
|
||||
else if (moveNode.Index < selectNode.Index) index--;
|
||||
}
|
||||
|
||||
IWordsItem MoveItem = (IWordsItem)moveNode.Tag;
|
||||
if (!MoveItem.ChekMove(DstCategory)) return;
|
||||
WordsList.MoveItem(index, MoveItem, SrcCategory, DstCategory);
|
||||
|
||||
// treeView1.Nodes.Clear();
|
||||
// treeView1.Nodes.AddRange(WordsList.ListNodes());
|
||||
|
||||
SrcNodes.Remove(moveNode);
|
||||
DstNodes.Insert(index, moveNode);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +185,8 @@ namespace Reseter2.Words
|
|||
|
||||
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if (e.Node != null)
|
||||
|
||||
if (e.Node != null && !DragOn)
|
||||
{
|
||||
if (e.Node.Tag is WordsComp)
|
||||
{
|
||||
|
|
@ -108,7 +207,7 @@ namespace Reseter2.Words
|
|||
private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
|
||||
{
|
||||
|
||||
if(control != null)
|
||||
if(control != null && !DragOn)
|
||||
{
|
||||
control.Visible = false;
|
||||
control.Dispose();
|
||||
|
|
@ -155,6 +254,7 @@ namespace Reseter2.Words
|
|||
{
|
||||
case 0:
|
||||
item = new WordsCategory("Новая категория");
|
||||
index = 0;
|
||||
WordsList.InsertItem(index, (WordsCategory)item, ParentCategory);
|
||||
treeNode.ImageIndex = 1;
|
||||
treeNode.Text = "Новая категория";
|
||||
|
|
@ -197,9 +297,6 @@ namespace Reseter2.Words
|
|||
{
|
||||
ParentCategory = (WordsCategory)selectNode.Parent.Tag;
|
||||
ParentNodes = selectNode.Parent.Nodes;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -210,5 +307,31 @@ namespace Reseter2.Words
|
|||
ParentNodes.Remove(selectNode);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void treeView1_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));
|
||||
if (treeView1.GetNodeAt(targetPoint) == null) treeView1.SelectedNode = null;
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
treeView1.SelectedNode = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void treeView1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void panel2_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,4 +117,7 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
|
|
@ -16,7 +16,7 @@ namespace Reseter2.Words
|
|||
public abstract void ChekChange(bool chek);
|
||||
public abstract void Delete();
|
||||
public abstract TreeNode NodeList();
|
||||
|
||||
public abstract bool ChekMove(IWordsItem wordsItem);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
|
@ -26,9 +27,16 @@ namespace Reseter2.Words
|
|||
}
|
||||
public void Insert(int index, IWordsItem newitem)
|
||||
{
|
||||
//if (index > items.Count) index = items.Count;
|
||||
items.Insert(index, newitem);
|
||||
}
|
||||
|
||||
public void Move(int index, IWordsItem item, WordsCategory wordsdst)
|
||||
{
|
||||
items.Remove(item);
|
||||
wordsdst.Insert(index, item);
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return Name;
|
||||
|
|
@ -54,6 +62,17 @@ namespace Reseter2.Words
|
|||
items.Remove(wordsItem);
|
||||
}
|
||||
|
||||
public override bool ChekMove(IWordsItem wordsItem)
|
||||
{
|
||||
if(this == wordsItem) return false;
|
||||
foreach (var item in items)
|
||||
{
|
||||
if(!item.ChekMove(wordsItem)) return false;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Delete() {
|
||||
foreach(IWordsItem item in items)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ namespace Reseter2.Words
|
|||
{
|
||||
return Comp.GetName();
|
||||
}
|
||||
|
||||
public override bool ChekMove(IWordsItem wordsItem)
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
public string GetDescription()
|
||||
{
|
||||
return Comp.GetDescription();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,12 @@ namespace Reseter2.Words
|
|||
{
|
||||
wordsCategory.Insert(index, item);
|
||||
}
|
||||
|
||||
|
||||
public static void MoveItem(int index, IWordsItem item, WordsCategory SrcCategory, WordsCategory DstCategory)
|
||||
{
|
||||
SrcCategory.Move(index, item, DstCategory);
|
||||
}
|
||||
|
||||
public static TreeNode[] ListNodes()
|
||||
{
|
||||
TreeNode[] treeNodes = new TreeNode[MainCategory.Count()];
|
||||
|
|
|
|||
Loading…
Reference in New Issue