Click here to Skip to main content
15,896,409 members
Articles / Multimedia / GDI+

Customizable Tree Control with Animation Support

Rate me:
Please Sign up or sign in to vote.
4.72/5 (17 votes)
8 Apr 2008CPOL4 min read 108.2K   23   115  
A tree control implementation, allowing complete customization and animation support
/////////////////////////////////////////////////////////////////////////////
//
// (c) 2007 BinaryComponents Ltd.  All Rights Reserved.
//
// http://www.binarycomponents.com/
//
/////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Text;

namespace BinaryComponents.VectorGraphics.Primitives
{
	public abstract class VisualItem
	{
		protected VisualItem()
		{
			_style = new Styles.Style();
		}

		public Container Parent
		{
			get
			{
				return _parent;
			}
			internal set
			{
				_parent = value;
			}
		}

		public Styles.Style Style
		{
			get
			{
				return _style;
			}
		}

		public Types.Rectangle GetBounds( Renderers.Renderer renderer )
		{
			if( _bounds == null )
			{
				_bounds = CalculateBounds( renderer );

				if( _bounds == null )
				{
					throw new InvalidOperationException();
				}
			}
			return _bounds;
		}

		public abstract void Visit( Visitor visitor );

		public abstract VisualItem Copy();

		protected abstract Types.Rectangle CalculateBounds( Renderers.Renderer renderer );

		internal void DirtyBounds()
		{
			_bounds = null;

			if( Parent != null )
			{
				Parent.DirtyBounds();
			}
		}

		private Styles.Style _style;
		private Container _parent;
		private Types.Rectangle _bounds;
	}
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
I'm currently working for a small start-up company, BinaryComponents Ltd, producing the FeedGhost RSS reader.

FeedGhost RSS Reader:
http://www.feedghost.com

Bespoke Software Development
http://www.binarycomponents.com

Comments and Discussions