Click here to Skip to main content
15,884,027 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 107.6K   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.Graphs
{
	public class StaticData : IData
	{
		public StaticData( int rowCount, int columnCount )
		{
			_data = new double[rowCount, columnCount];
			_rowExtras = new Dictionary<string, string>[rowCount];
			_columnExtras = new Dictionary<string, string>[columnCount];

			for( int r = 0; r < rowCount; ++r )
			{
				_rowExtras[r] = new Dictionary<string, string>();
			}
			for( int c = 0; c < columnCount; ++c )
			{
				_columnExtras[c] = new Dictionary<string, string>();
			}
		}

		#region IData Members

		public int RowCount
		{
			get
			{
				return _data.GetLength( 0 );
			}
		}

		public int ColumnCount
		{
			get
			{
				return _data.GetLength( 1 );
			}
		}

		public double this[int r, int c]
		{
			get
			{
				return _data[r, c];
			}
			set
			{
				_data[r, c] = value;
			}
		}

		public string GetExtra( string key, string fallback )
		{
			string v;

			if( _extras.TryGetValue( key, out v ) )
			{
				return v;
			}
			else
			{
				return fallback;
			}
		}

		public string GetRowExtra( int row, string key, string fallback )
		{
			string v;

			if( _rowExtras[row].TryGetValue( key, out v ) )
			{
				return v;
			}
			else
			{
				return fallback;
			}
		}

		public string GetColumnExtra( int column, string key, string fallback )
		{
			string v;

			if( _columnExtras[column].TryGetValue( key, out v ) )
			{
				return v;
			}
			else
			{
				return fallback;
			}
		}

		#endregion

		public void SetExtra( string key, string value )
		{
			_extras.Add( key, value );
		}

		public void SetRowExtra( int row, string key, string value )
		{
			_rowExtras[row].Add( key, value );
		}

		public void SetColumnExtra( int column, string key, string value )
		{
			_columnExtras[column].Add( key, value );
		}

		private Dictionary<string, string> _extras = new Dictionary<string, string>();
		private Dictionary<string, string>[] _rowExtras, _columnExtras;
		private double[,] _data;
	}
}

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