forked from jaysonragasa/MultiRDPClient.NET
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathViewMap.cs
More file actions
56 lines (55 loc) · 1.15 KB
/
ViewMap.cs
File metadata and controls
56 lines (55 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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;
}
}
}