/// <summary> /// Performs the element post-children custom paint. Overriden to paint the status /// of this example tile (if it has one) in its bottom-left corner. /// </summary> /// <param name="visitor"></param> protected override void OnPostPaint(NPaintVisitor visitor) { base.OnPostPaint(visitor); if (String.IsNullOrEmpty(m_Status)) { return; } // Paint a new label in the bottom left corner NRectangle bounds = GetContentEdge(); NFont font = new NFont(FontName, 5.0, ENFontStyle.Regular); font.RasterizationMode = ENFontRasterizationMode.Aliased; NSize textSize = font.MeasureString(m_Status, this.OwnerDocument); NRectangle textRect = new NRectangle(bounds.X - 1, bounds.Bottom - textSize.Height, textSize.Width + 3, textSize.Height); // Paint the text background NColor color = HomePage.GetStatusColor(m_Status); visitor.SetFill(color); visitor.PaintRectangle(textRect); // Paint the text visitor.SetFill(NColor.White); visitor.SetFont(font); NPoint location = textRect.Location; NPaintTextPointSettings settings = new NPaintTextPointSettings(); visitor.PaintString(location, m_Status, ref settings); }
/// <summary> /// /// </summary> /// <param name="args"></param> private void OnCanvasPrePaint(NCanvasPaintEventArgs args) { NCanvas canvas = args.TargetNode as NCanvas; if (canvas == null) { return; } NPaintVisitor paintVisitor = args.PaintVisitor; NPaintTextPointSettings settings = new NPaintTextPointSettings(); settings.SingleLine = m_SingleLineCheckBox.Checked; settings.VertAlign = (ENTextVertAlign)m_VerticalAlignmentCombo.SelectedItem.Tag; settings.HorzAlign = (ENTextHorzAlign)m_HorizontalAlignmentCombo.SelectedItem.Tag; NPoint location = canvas.GetContentEdge().Center; // set styles paintVisitor.ClearStyles(); paintVisitor.SetFont(new NFont(NFontDescriptor.DefaultSansFamilyName, 10)); paintVisitor.SetFill(NColor.Black); // create text to paint StringBuilder builder = new StringBuilder(); builder.AppendLine("Paint text at location [" + location.X.ToString("0.") + ", " + location.Y.ToString("0.") + "]"); builder.AppendLine("Horizontal Alignment [" + settings.HorzAlign.ToString() + "]"); builder.AppendLine("Vertical Alignment [" + settings.VertAlign.ToString() + "]"); // paint string paintVisitor.PaintString(location, builder.ToString(), ref settings); // paint location double inflate = 5.0; paintVisitor.SetFill(NColor.Red); paintVisitor.PaintRectangle(new NRectangle(location.X - inflate, location.Y - inflate, inflate * 2.0, inflate * 2.0)); }
/// <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); }