External/Aga.Controls/Tree/NodeControls/NodeStateIcon.cs
changeset 345 0c551e8818e0
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/External/Aga.Controls/Tree/NodeControls/NodeStateIcon.cs	Sun May 27 15:16:19 2012 +0000
     1.3 @@ -0,0 +1,41 @@
     1.4 +using System;
     1.5 +using System.Collections.Generic;
     1.6 +using System.Text;
     1.7 +using System.Drawing;
     1.8 +using Aga.Controls.Properties;
     1.9 +
    1.10 +namespace Aga.Controls.Tree.NodeControls
    1.11 +{
    1.12 +	public class NodeStateIcon: NodeIcon
    1.13 +	{
    1.14 +		private Image _leaf;
    1.15 +		private Image _opened;
    1.16 +		private Image _closed;
    1.17 +
    1.18 +		public NodeStateIcon()
    1.19 +		{
    1.20 +			_leaf = MakeTransparent(Resources.Leaf);
    1.21 +			_opened = MakeTransparent(Resources.Folder);
    1.22 +			_closed = MakeTransparent(Resources.FolderClosed);
    1.23 +		}
    1.24 +
    1.25 +		private static Image MakeTransparent(Bitmap bitmap)
    1.26 +		{
    1.27 +			bitmap.MakeTransparent(bitmap.GetPixel(0,0));
    1.28 +			return bitmap;
    1.29 +		}
    1.30 +
    1.31 +		protected override Image GetIcon(TreeNodeAdv node)
    1.32 +		{
    1.33 +			Image icon = base.GetIcon(node);
    1.34 +			if (icon != null)
    1.35 +				return icon;
    1.36 +			else if (node.IsLeaf)
    1.37 +				return _leaf;
    1.38 +			else if (node.CanExpand && node.IsExpanded)
    1.39 +				return _opened;
    1.40 +			else
    1.41 +				return _closed;
    1.42 +		}
    1.43 +	}
    1.44 +}