External/Aga.Controls/Tree/NodeControls/NodeStateIcon.cs
author sl
Thu, 01 Jan 2015 23:35:49 +0100
changeset 405 5715aefd2bcc
permissions -rw-r--r--
SharpDisplay: Migrating to new robust client scheme.
     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 }