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