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.
moel@345
     1
using System;
moel@345
     2
using System.Collections.Generic;
moel@345
     3
using System.Text;
moel@345
     4
using System.Drawing;
moel@345
     5
using Aga.Controls.Properties;
moel@345
     6
moel@345
     7
namespace Aga.Controls.Tree.NodeControls
moel@345
     8
{
moel@345
     9
	public class NodeStateIcon: NodeIcon
moel@345
    10
	{
moel@345
    11
		private Image _leaf;
moel@345
    12
		private Image _opened;
moel@345
    13
		private Image _closed;
moel@345
    14
moel@345
    15
		public NodeStateIcon()
moel@345
    16
		{
moel@345
    17
			_leaf = MakeTransparent(Resources.Leaf);
moel@345
    18
			_opened = MakeTransparent(Resources.Folder);
moel@345
    19
			_closed = MakeTransparent(Resources.FolderClosed);
moel@345
    20
		}
moel@345
    21
moel@345
    22
		private static Image MakeTransparent(Bitmap bitmap)
moel@345
    23
		{
moel@345
    24
			bitmap.MakeTransparent(bitmap.GetPixel(0,0));
moel@345
    25
			return bitmap;
moel@345
    26
		}
moel@345
    27
moel@345
    28
		protected override Image GetIcon(TreeNodeAdv node)
moel@345
    29
		{
moel@345
    30
			Image icon = base.GetIcon(node);
moel@345
    31
			if (icon != null)
moel@345
    32
				return icon;
moel@345
    33
			else if (node.IsLeaf)
moel@345
    34
				return _leaf;
moel@345
    35
			else if (node.CanExpand && node.IsExpanded)
moel@345
    36
				return _opened;
moel@345
    37
			else
moel@345
    38
				return _closed;
moel@345
    39
		}
moel@345
    40
	}
moel@345
    41
}