protected override void OnPostPaint(NPaintVisitor visitor) { base.OnPostPaint(visitor); if (String.IsNullOrEmpty(m_Status)) { return; } visitor.ClearStyles(); visitor.SetFont(Font); // Determine status bounds NRectangle contentArea = GetContentEdge(); double length = NMath.Max(contentArea.Width, contentArea.Height) * 0.3; NRectangle statusBounds = new NRectangle(contentArea.Right - length - 5, contentArea.Top + 5, length, length); // Fill the status bounds with a circle NExamplesHomePage homePage = (NExamplesHomePage)GetFirstAncestor(NExamplesHomePage.NExamplesHomePageSchema); NColor color = homePage.GetStatusColor(m_Status); visitor.SetFill(new NColor(color, 160)); visitor.PaintEllipse(statusBounds); // Create text paint settings NPaintTextRectSettings settings = new NPaintTextRectSettings(); settings.HorzAlign = ENTextHorzAlign.Center; settings.VertAlign = ENTextVertAlign.Center; // Paint the status text in the top right corner visitor.SetFill(NColor.White); visitor.PaintString(statusBounds, m_Status, ref settings); }
/// <summary> /// Default constructor /// </summary> public NExamplesContent() { // Create the navigation panel m_ExamplesHomePage = new NExamplesHomePage(); m_ExamplesHomePage.LoadFromStream(NResources.Instance.GetResourceStream("RSTR_Examples_xml")); m_ExamplesHomePage.TileSelected += OnTileSelected; // Host it Content = m_ExamplesHomePage; // Create the example panel m_ExampleHost = new NExampleHost(); m_ExampleHost.HomeButton.Click += OnHomeButtonClick; }
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> /// Performs the element post-children custom paint. Overriden to paint the status /// of this category header's group (if it has one) in the top-right corner of the header. /// </summary> /// <param name="visitor"></param> protected override void OnPostPaint(NPaintVisitor visitor) { base.OnPostPaint(visitor); if (String.IsNullOrEmpty(m_Status)) { return; } // Determine the text bounds NRectangle bounds = GetContentEdge(); NSize textSize = Font.MeasureString(((NLabel)Box2).Text); NRectangle textBounds = NRectangle.FromCenterAndSize(bounds.Center, textSize.Width, textSize.Height); textBounds.X += Box1.Width / 2; // Calculate a rectangle for the status text located to the right of the text rectangle textSize = StatusFont.MeasureString(m_Status, OwnerDocument); NRectangle textRect = new NRectangle(textBounds.Right + StatusLeftPadding, textBounds.Top, textSize.Width + StatusRightPadding, textSize.Height); // Paint the text background NExamplesHomePage homePage = (NExamplesHomePage)GetFirstAncestor(NExamplesHomePage.NExamplesHomePageSchema); NColor color = homePage.GetStatusColor(m_Status); visitor.SetFill(color); visitor.PaintRectangle(textRect); // Paint the text visitor.SetFill(NColor.White); visitor.SetFont(StatusFont); NPoint location = textRect.Location; NPaintTextPointSettings settings = new NPaintTextPointSettings(); visitor.PaintString(location, m_Status, ref settings); }