示例#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);
        }
示例#2
0
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            NPaintVisitor pv = args.PaintVisitor;

            pv.ClearStyles();

            if (m_PaintImageInRectangle)
            {
                pv.PaintImage(NResources.Image_JpegSuite_q080_jpg.ImageSource, new NRectangle(m_PosX, m_PosY, m_Width, m_Height));
            }
            else
            {
                pv.PaintImage(NResources.Image_JpegSuite_q080_jpg.ImageSource, new NPoint(m_PosX, m_PosY));
            }

            // paint a border around the canvas
            pv.SetStroke(NColor.Black, 1);
            pv.PaintRectangle(0, 0, canvas.Width, canvas.Height);
        }
示例#3
0
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            NPaintVisitor pv = args.PaintVisitor;

            int count = m_Values.Length;

            // calculate total value
            double total = 0;

            for (int i = 0; i < count; i++)
            {
                total += m_Values[i];
            }

            // paint the pie slices
            double beginAngle = 0;

            pv.ClearStyles();

            for (int i = 0; i < count; i++)
            {
                double sweepAngle = NMath.PI2 * (m_Values[i] / total);

                NGraphicsPath path = new NGraphicsPath();
                path.AddPie(0.1 * W, 0.1 * H, 0.8 * W, 0.8 * H, beginAngle, sweepAngle);

                if (i == 0)
                {
                    const double detachment = 20;
                    double       midAngle   = beginAngle + sweepAngle / 2;
                    double       dx         = Math.Cos(midAngle) * detachment;
                    double       dy         = Math.Sin(midAngle) * detachment;
                    path.Translate(dx, dy);
                }

                pv.SetFill(m_ColorFills[i]);
                pv.PaintPath(path);

                beginAngle += sweepAngle;
            }

            // paint a border around the canvas
            pv.ClearFill();
            pv.SetStroke(NColor.Black, 1);
            pv.PaintRectangle(0, 0, canvas.Width, canvas.Height);
        }
示例#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 * 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);
            NFont font = new NFont(NFontDescriptor.DefaultSansFamilyName, 10);


            NGraphicsPath path = font.GetTextPath(builder.ToString(), textBounds, this.OwnerDocument, ref settings);

            paintVisitor.PaintPath(path);
        }
        /// <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);
        }
示例#6
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);
        }
示例#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));
        }
示例#8
0
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            canvas.HorizontalPlacement = ENHorizontalPlacement.Center;
            canvas.VerticalPlacement   = ENVerticalPlacement.Center;

            NPaintVisitor pv = args.PaintVisitor;

            pv.ClearStyles();
            pv.SetStroke(NColor.MidnightBlue, 1);
            pv.SetFill(NColor.LightSteelBlue);

            NMatrix m1 = NMatrix.Identity;

            m1.Rotate(NAngle.Degree2Rad * m_Angle1);

            NMatrix m2 = NMatrix.Identity;

            m2.Rotate(NAngle.Degree2Rad * m_Angle2);
            m2.Translate(100, 0);

            NMatrix m3 = NMatrix.Identity;

            m3.Rotate(NAngle.Degree2Rad * m_Angle3);
            m3.Translate(100, 0);

            NRegion clipRegion = NRegion.FromRectangle(m_ClipRect);

            pv.PushClip(clipRegion);

            pv.PushTransform(new NMatrix(m_PositionX, 0));
            PaintVerticalBar(pv);

            pv.PushTransform(new NMatrix(0, m_PositionY));
            PaintBase(pv);

            pv.PushTransform(m1);
            PaintLink(pv, 20);
            PaintJoint(pv, 20);

            pv.PushSnapToPixels(false);
            pv.PushTransform(m2);
            PaintLink(pv, 16);
            PaintJoint(pv, 16);

            pv.PushTransform(m3);
            PaintGripper(pv);
            PaintJoint(pv, 12);

            pv.PopTransform();            // m3
            pv.PopTransform();            // m2
            pv.PopTransform();            // m1
            pv.PopTransform();            // mTY
            pv.PopTransform();            // mTX
            pv.PopSnapToPixels();
            pv.PopClip();

            // paint a border around the clip rectangle
            pv.ClearFill();
            pv.SetStroke(NColor.Red, 1);
            pv.PaintRectangle(m_ClipRect);

            // paint a border around the canvas
            pv.SetStroke(NColor.Black, 1);
            pv.PaintRectangle(0, 0, canvas.Width, canvas.Height);
        }