External/Aga.Controls/Tree/NodeControls/NodeStateIcon.cs
author moel.mich
Sun, 27 May 2012 15:16:19 +0000
changeset 345 0c551e8818e0
permissions -rw-r--r--
Added the source code of Aga.Controls (TreeViewAdv for .Net) version 1.7.0.0.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Text;
     4 using System.Drawing;
     5 using Aga.Controls.Properties;
     6 
     7 namespace Aga.Controls.Tree.NodeControls
     8 {
     9 	public class NodeStateIcon: NodeIcon
    10 	{
    11 		private Image _leaf;
    12 		private Image _opened;
    13 		private Image _closed;
    14 
    15 		public NodeStateIcon()
    16 		{
    17 			_leaf = MakeTransparent(Resources.Leaf);
    18 			_opened = MakeTransparent(Resources.Folder);
    19 			_closed = MakeTransparent(Resources.FolderClosed);
    20 		}
    21 
    22 		private static Image MakeTransparent(Bitmap bitmap)
    23 		{
    24 			bitmap.MakeTransparent(bitmap.GetPixel(0,0));
    25 			return bitmap;
    26 		}
    27 
    28 		protected override Image GetIcon(TreeNodeAdv node)
    29 		{
    30 			Image icon = base.GetIcon(node);
    31 			if (icon != null)
    32 				return icon;
    33 			else if (node.IsLeaf)
    34 				return _leaf;
    35 			else if (node.CanExpand && node.IsExpanded)
    36 				return _opened;
    37 			else
    38 				return _closed;
    39 		}
    40 	}
    41 }