Ejemplo 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);
        }
Ejemplo n.º 2
0
        void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            NStroke stroke = (NStroke)canvas.Tag;

            NPaintVisitor visitor = args.PaintVisitor;

            visitor.SetStroke(stroke);
            visitor.SetFill(null);

            double strokeWidth   = stroke.Width;
            double rectWidth     = 300;
            double ellipseWidth  = 150;
            double polylineWidth = 180;
            double dist          = 20;

            double x1 = 10 + strokeWidth / 2;
            double x2 = x1 + rectWidth + dist + strokeWidth;
            double x3 = x2 + ellipseWidth;
            double x4 = x3 + dist + strokeWidth;
            double x5 = x4 + polylineWidth + dist + strokeWidth / 2;
            double y1 = 10 + strokeWidth / 2;
            double y2 = y1 + strokeWidth + 10;
            double y3 = y1 + 50;

            // draw a horizontal line
            visitor.PaintLine(x1, y1, x3, y1);

            // draw a rectangle
            visitor.PaintRectangle(x1, y2, rectWidth, 100);

            // draw an ellipse
            visitor.PaintEllipse(x2, y2, ellipseWidth, 100);

            // draw a polyline
            NPolyline polyLine = new NPolyline(4);

            polyLine.Add(new NPoint(x4, y2 + 90));
            polyLine.Add(new NPoint(x4 + 60, y2));
            polyLine.Add(new NPoint(x4 + 120, y2 + 90));
            polyLine.Add(new NPoint(x4 + 180, y2));
            visitor.PaintPolyline(polyLine);

            // draw text
            string dashStyleName = stroke.DashStyle.ToString();

            visitor.ClearStroke();
            visitor.SetFont(m_LabelFont);
            visitor.SetFill(m_LabelFill);

            NPaintTextRectSettings settings = new NPaintTextRectSettings();

            visitor.PaintString(new NRectangle(x5, y3, 200, 50), dashStyleName, ref settings);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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;

            NRectangle contentEge = canvas.GetContentEdge();

            // create the text bounds
            double width  = contentEge.Width * 0.5;
            double height = contentEge.Height * 0.5;
            NPoint center = contentEge.Center;

            NRectangle textBounds = new NRectangle(center.X - width / 2.0, center.Y - height / 2.0, width, height);

            // create the settings
            NPaintTextRectSettings settings = new NPaintTextRectSettings();

            settings.SingleLine = false;
            settings.WrapMode   = ENTextWrapMode.WordWrap;
            settings.HorzAlign  = ENTextHorzAlign.Center;
            settings.VertAlign  = ENTextVertAlign.Center;

            // create the text
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("This text is displayed using Liberation Fonts!");
            builder.AppendLine("distributed under the SIL Open Font License (OFL)");

            // paint the bounding box
            paintVisitor.ClearStyles();
            paintVisitor.SetFill(NColor.LightBlue);
            paintVisitor.PaintRectangle(textBounds);

            // init font and fill
            paintVisitor.SetFill(NColor.Black);
            ENFontStyle fontStyle = NFontFaceDescriptor.FontVariantToFontStyle(m_FontDescriptor.FontVariant);

            paintVisitor.SetFont(new NFont(m_FontDescriptor.FamilyName, 10, fontStyle));

            // paint the text
            paintVisitor.PaintString(textBounds, builder.ToString(), ref settings);
        }
Ejemplo n.º 5
0
        /// <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;
            NRectangle    contentEge   = canvas.GetContentEdge();

            // create the settings
            NPaintTextRectSettings settings = new NPaintTextRectSettings();

            settings.SingleLine = false;
            settings.WrapMode   = ENTextWrapMode.WordWrap;
            settings.HorzAlign  = ENTextHorzAlign.Left;
            settings.VertAlign  = ENTextVertAlign.Top;

            // create the text
            string text = m_TextBox.Text;

            // calculate the text bounds the text bounds
            double resolution = canvas.OwnerDocument.GetEffectiveResolution();
            NFont  font       = new NFont(NFontDescriptor.DefaultSansFamilyName, 10, ENFontStyle.Regular);
            NSize  textSize   = font.MeasureString(text.ToCharArray(), resolution, contentEge.Width, false, ref settings);

            NPoint     center     = contentEge.Center;
            NRectangle textBounds = new NRectangle(
                center.X - textSize.Width / 2.0,
                center.Y - textSize.Height / 2.0,
                textSize.Width,
                textSize.Height);

            // paint the bounding box
            paintVisitor.ClearStyles();
            paintVisitor.SetFill(NColor.LightBlue);
            paintVisitor.PaintRectangle(textBounds);

            // init font and fill
            paintVisitor.SetFill(NColor.Black);
            paintVisitor.SetFont(font);

            // paint the text
            paintVisitor.PaintString(textBounds, text.ToCharArray(), 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;

            NRectangle contentEge = canvas.GetContentEdge();

            // create the text bounds
            double width  = contentEge.Width * m_WidthPercentUpDown.Value / 100.0;
            double height = contentEge.Height * m_HeightPercentUpDown.Value / 100.0;
            NPoint center = contentEge.Center;

            NRectangle textBounds = new NRectangle(center.X - width / 2.0, center.Y - height / 2.0, width, height);

            // create the settings
            NPaintTextRectSettings settings = new NPaintTextRectSettings();

            settings.SingleLine = m_SingleLineCheckBox.Checked;
            settings.WrapMode   = (ENTextWrapMode)m_WrapModeCombo.SelectedIndex;
            settings.HorzAlign  = (ENTextHorzAlign)m_HorizontalAlignmentCombo.SelectedIndex;
            settings.VertAlign  = (ENTextVertAlign)m_VerticalAlignmentCombo.SelectedIndex;

            // create the text
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("Paint text at bounds [" + textBounds.X.ToString("0.") + ", " + textBounds.Y.ToString("0.") + "]");
            builder.AppendLine("Horizontal Alignment [" + settings.HorzAlign.ToString() + "]");
            builder.AppendLine("Vertical Alignment [" + settings.VertAlign.ToString() + "]");

            // paint the bounding box
            paintVisitor.ClearStyles();
            paintVisitor.SetFill(NColor.LightBlue);
            paintVisitor.PaintRectangle(textBounds);

            // init font and fill
            paintVisitor.SetFill(NColor.Black);
            paintVisitor.SetFont(new NFont(NFontDescriptor.DefaultSansFamilyName, 10));

            // paint the text
            paintVisitor.PaintString(textBounds, builder.ToString(), ref settings);
        }
Ejemplo n.º 7
0
        /// <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));
        }
Ejemplo n.º 8
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);
        }