Click here to Skip to main content
15,896,606 members
Articles / Programming Languages / C#

Visual Style Element Browser

Rate me:
Please Sign up or sign in to vote.
4.84/5 (19 votes)
12 Feb 2008CPOL1 min read 64.3K   4.7K   81  
A simple tree which exposes the different VisualStyleElements available in NET 2.0
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace CommonTools
{
	public class ViewMap : Panel
	{
		object m_curKey = null;
		Dictionary<object, Control>	m_views = new Dictionary<object,Control>();
		public ViewMap()
		{
		}
		public void AddView(object key, Control view)
		{
			view.Dock = DockStyle.Fill;
			view.Visible = false;
			Form form = view as Form;
			if (form != null)
			{
				form.TopLevel = false;
				form.FormBorderStyle = FormBorderStyle.None;
			}
			m_views[key] = view;
			if (Controls.Contains(view) == false)
				Controls.Add(view);
		}
		public Control GetView(object key)
		{
			if (key == null)
				return null;
			if (m_views.ContainsKey(key))
				return m_views[key];
			return null;
		}
		public object CurKey
		{
			get { return m_curKey; }
			set { SelectView(value); }
		}
		public void SelectView(object key)
		{
			Control selectedview = GetView(key);
			foreach (Control view in m_views.Values)
			{
				if (object.ReferenceEquals(selectedview, view) == false)
					view.Hide();
			}
			if (selectedview != null)
				selectedview.Show();
			m_curKey = key;
		}
	}
}

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
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions