コード例 #1
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);
        }