private void LoadExample(NXmlElement element) { string groupNamespace = NExamplesHomePage.GetNamespace(element); string name = element.GetAttributeValue("name"); string type = groupNamespace + "." + element.GetAttributeValue("type"); try { type = "Nevron.Nov.Examples." + type; Type exampleType = Type.GetType(type); if (exampleType != null) { NDomType domType = NDomType.FromType(exampleType); NDebug.Assert(domType != null, "The example type:" + type + " is not a valid type"); // Create the example DateTime start = DateTime.Now; NExampleBase example = domType.CreateInstance() as NExampleBase; example.Title = name; example.Initialize(); m_Splitter.Pane2.Content = example; string stats = "Example created in: " + (DateTime.Now - start).TotalSeconds + " seconds, "; // Evaluate the example start = DateTime.Now; OwnerDocument.Evaluate(); stats += " evaluated in: " + (DateTime.Now - start).TotalSeconds + " seconds"; m_StatusLabel.Text = stats; } // Set the breadcrumb CreateBreadcrumb(element); } catch (Exception ex) { NTrace.WriteException("Failed to load example", ex); m_Splitter.Pane2.Content = new NErrorPanel("Failed to load example. Exception was: " + ex.Message); } }
/// <summary> /// Called when a theme menu item is clicked -> applies the specified theme /// </summary> /// <param name="arg1"></param> private void OnThemeMenuItemClick(NEventArgs arg1) { NCheckableMenuItem item = (NCheckableMenuItem)arg1.CurrentTargetNode; if (item.Tag is NTheme) { NApplication.ApplyTheme((NTheme)item.Tag); // Update the current theme menu item and check it m_CurrentThemeMenuItem.Checked = false; item.Checked = true; m_CurrentThemeMenuItem = item; // Resize the right panel if the theme is in touch mode. NExampleBase exampleBase = m_Splitter.Pane2.Content as NExampleBase; if (exampleBase == null) { return; } NSplitter splitter = exampleBase.Content as NSplitter; if (splitter == null) { return; } NSplitter exampleSplitter = splitter.Pane1.Content as NSplitter; if (exampleSplitter == null) { return; } bool touchMode = NApplication.Desktop.TouchMode; exampleSplitter.SplitOffset = touchMode ? 450 : 300; } else { throw new Exception("Clicked menu item not a theme?"); } }
private void CloseExample() { NExampleBase oldExample = m_Splitter.Pane2.Content as NExampleBase; if (oldExample != null) { // Notify the old example that it is about to be closed oldExample.OnClosing(); } m_Splitter.Pane2.Content = null; // Remove the current breadcrumb if (m_Toolbar != null) { NCommandBarItemCollection items = m_Toolbar.Items; for (int i = items.Count - 1; i >= 2; i--) { m_Toolbar.Items.RemoveAt(i); } } }