public Example__Base CreateExample(Base parent) { if (m_ExampleType != null) { if (m_ExampleType.IsSubclassOf(typeof(Example__Base))) { Example__Base example = null; try { example = (Example__Base)Activator.CreateInstance(m_ExampleType, new object[] { parent }); } catch { try { example = (Example__Base)Activator.CreateInstance(m_ExampleType); } catch { example = null; } } if (example != null) { example.Parent = parent; example.Dock = Pos.Fill; return(example); } } } return(null); }
void NodeSelected(Base control) { Alt.GUI.Temporary.Gwen.Control.TreeNode node = control as Alt.GUI.Temporary.Gwen.Control.TreeNode; if (node != null && node.UserData != null) { ExampleNode example = node.UserData as ExampleNode; if (example != null) { if (m_LastControl != null) { if (m_LastControl != null) { if (m_ExamplePanel != null) { m_ExamplePanel.RemoveChild(m_LastControl, false); } try { m_LastControl.Dispose(); m_LastControl = null; } catch { } } } m_LastControl = example.CreateExample(m_ExamplePanel); m_Caption.Text = TitlePrefix + (string.IsNullOrEmpty(example.m_Description) ? node.Text : example.m_Description); } } }
public void Shutdown() { foreach (Base b in m_ExamplesList.Children) { CollapsibleCategory cat = b as CollapsibleCategory; foreach (Base button in cat.Children) { ExampleNode node = button.UserData as ExampleNode; if (node != null && node.m_Example != null) { if (node.m_Example == m_LastControl) { node.m_Example = null; continue; } try { node.m_Example.Dispose(); node.m_Example = null; } catch { } } } } if (m_LastControl != null) { if (m_Center != null) { m_Center.RemoveChild(m_LastControl, false); } try { m_LastControl.Dispose(); m_LastControl = null; } catch { } } m_Center.Children.Clear(); }
public ExampleNode(Type type, Example__Base example, Base parent, ExamplesHolder holder) { m_ExampleType = type; m_Example = example; m_ExampleParent = parent; m_Holder = holder; if (m_Example != null) { m_Example.Parent = m_ExampleParent; m_Example.Dock = Pos.Fill; m_Example.Hide(); m_Example.Holder = m_Holder; } }
void OnExampleSelect(Base control) { if (control == null) { return; } if (m_LastControl != null) { m_LastControl.OnDeactivate(); m_LastControl.Hide(); } Example__Base example = (control.UserData as ExampleNode).Example; if (example != null) { example.Show(); example.OnActivate(); } m_LastControl = example; }
Alt.GUI.Temporary.Gwen.Control.Button RegisterDemo(string name, CollapsibleCategory cat, Type exampleType, Example__Base example) { Alt.GUI.Temporary.Gwen.Control.Button btn = cat.Add(name); btn.UserData = new ExampleNode(exampleType, example, m_Center, this); btn.Clicked += OnExampleSelect; return(btn); }
Alt.GUI.Temporary.Gwen.Control.Button RegisterDemo(string name, CollapsibleCategory cat, Type exampleType, Example__Base example, Color textColor) { Alt.GUI.Temporary.Gwen.Control.Button btn = RegisterDemo(name, cat, exampleType, example); btn.TextColor = textColor; btn.UseCurrentColorAsNormal = true; return(btn); }