|
///File Name: CategoryNode.cs
///This file include declaration of the class CategoryNode , this class
///represent a category node in the tree.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DesktopManager.Tree.Nodes.Interfaces;
using System.Drawing;
using DesktopManager.Tree.Nodes.MenuItems;
using System.Runtime.Serialization;
namespace DesktopManager.Tree.Nodes
{
[Serializable]
public class CategoryNode : RootNode
{
public CategoryNode()
: base()
{
this.InitProperties();
// this.m_ListStandByFilePaths = new List<string>();
}
protected override void InitProperties()
{
base.InitProperties();
this.Text = "New Category";
this.m_IsLableEditable = true;
this.Name = "New Category";
this.ImageKey = "Category";
this.ForeColor = Color.Green;
}
protected CategoryNode(SerializationInfo i_Info, StreamingContext i_Context)
: base(i_Info, i_Context)
{
this.CategoryDeleted += this.newNode_CategoryDeleted;
}
protected override ContextMenuStrip GetContextMenu()
{
ContextMenuStrip nodeContextMenu = base.GetContextMenu();
ToolStripMenuItem deleteGropItem = new DeleteGroup();
deleteGropItem.Click += this.deleteGroupEventHandler;
nodeContextMenu.Items.Add(deleteGropItem);
return nodeContextMenu;
}
private void deleteGroupEventHandler(object i_Sender, EventArgs e)
{
remove();
}
public event EventHandler CategoryDeleted;
protected void OnCategoryDeleted(TreeNode i_NewParent)
{
if (this.CategoryDeleted != null)
{
this.CategoryDeleted(i_NewParent, EventArgs.Empty);
}
}
private void remove()
{
TreeNode[] childNodesHirarchy = this.Nodes.Cast<TreeNode>().ToArray();
TreeNode parendNode = this.Parent;
foreach (TreeNode node in this.Nodes)
{
node.Remove();
}
this.Remove();
parendNode.Nodes.AddRange(childNodesHirarchy);
OnCategoryDeleted(parendNode);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.