Exemplo n.º 1
0
        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);
        }
Exemplo n.º 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);
        }