DrawRoundedRectangle() public method

Draws a rectangles with round corners.
public DrawRoundedRectangle ( XBrush brush, Rect rect, System ellipseSize ) : void
brush XBrush
rect Rect
ellipseSize System
return void
    void RenderRoundedRectangles(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XPen pen = new XPen(XColors.RoyalBlue, Math.PI);

      gfx.DrawRoundedRectangle(pen, 10, 0, 100, 60, 30, 20);
      gfx.DrawRoundedRectangle(XBrushes.Orange, 130, 0, 100, 60, 30, 20);
      gfx.DrawRoundedRectangle(pen, XBrushes.Orange, 10, 80, 100, 60, 30, 20);
      gfx.DrawRoundedRectangle(pen, XBrushes.Orange, 150, 80, 60, 60, 20, 20);
    }
Example #2
1
    /// <summary>
    /// Draws rounded rectangles.
    /// </summary>
    void DrawRoundedRectangle(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawRoundedRectangle");

      XPen pen = new XPen(XColors.RoyalBlue, Math.PI);

      gfx.DrawRoundedRectangle(pen, 10, 0, 100, 60, 30, 20);
      gfx.DrawRoundedRectangle(XBrushes.Orange, 130, 0, 100, 60, 30, 20);
      gfx.DrawRoundedRectangle(pen, XBrushes.Orange, 10, 80, 100, 60, 30, 20);
      gfx.DrawRoundedRectangle(pen, XBrushes.Orange, 150, 80, 60, 60, 20, 20);

      EndBox(gfx);
    }
Example #3
0
        public void DrawStats(XGraphics gfx)
        {
            XFont large = new XFont("Arial", 20);
            XFont small = new XFont("Arial", 12);

            double yOff = page_.Height * 0.11;

            XRect rect = new XRect(20, yOff, page_.Width - 40, page_.Height - (yOff + 20));
            DrawingUtil.DrawOutlineRect(rect, gfx, cornerRadius);
            gfx.DrawRoundedRectangle(backgroundBrush, rect, cornerRadius);
            XPoint center = new XPoint(page_.Width * 0.5, page_.Height * 0.45);

            XImage sideLunge = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\SideLunge.png");
            XImage frontLunge = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\FrontLunge.png");

            gfx.DrawString("Left Lunge", large, XBrushes.Black, new XPoint(center.X - page_.Width * 0.25, page_.Height * 0.25), XStringFormats.Center);
            gfx.DrawString("Right Lunge", large, XBrushes.Black, new XPoint(center.X + page_.Width * 0.25, page_.Height * 0.25), XStringFormats.Center);

            for (int i = 0; i < 4; i++)
            {
                Parameter param1 = userParameters_.ElementAt(dataReadStart + i);
                Parameter param2 = userParameters_.ElementAt(dataReadStart + i + 4);
                char degree = Convert.ToChar('\u00b0');
                XBrush leftParamCol = XBrushes.Green;
                XBrush rightParamCol = XBrushes.Green;

                double y = (i * page_.Height * 0.15f) + page_.Height * 0.35;
                gfx.DrawString(param1.Name, small, XBrushes.Black, new XPoint(center.X - page_.Width * 0.25, y), XStringFormats.Center);

                leftParamCol = DrawingUtil.Instance.ChooseBrushColor(param1.Color);
                XRect infoRect = new XRect(center.X - page_.Width * 0.25 - 25, y + 20, 50, 35);
                DrawingUtil.DrawOutlineRect(infoRect, gfx, new XSize(10, 10));
                gfx.DrawRoundedRectangle(leftParamCol, infoRect, new XSize(10, 10));
                gfx.DrawString(param1.Value.ToString() + degree, small, XBrushes.Black, new XPoint(infoRect.X + 25, infoRect.Y + 17.5), XStringFormats.Center);

                gfx.DrawString(param2.Name, small, XBrushes.Black, new XPoint(center.X + page_.Width * 0.25, y), XStringFormats.Center);
                rightParamCol = DrawingUtil.Instance.ChooseBrushColor(param2.Color);
                infoRect = new XRect(center.X + page_.Width * 0.25 - 25, y + 20, 50, 35);
                DrawingUtil.DrawOutlineRect(infoRect, gfx, new XSize(10, 10));
                gfx.DrawRoundedRectangle(rightParamCol, infoRect, new XSize(10, 10));
                gfx.DrawString(param2.Value.ToString() + degree, small, XBrushes.Black, new XPoint(infoRect.X + 25, infoRect.Y + 17.5), XStringFormats.Center);

                XImage img = i > 1 ? frontLunge : sideLunge;

                double wRatio = (double)img.PixelWidth / (double)sideLunge.PixelHeight;
                XRect imgRect = new XRect(center.X - wRatio * 40, y, wRatio * 80, 80);
                gfx.DrawImage(img, imgRect);
            }
        }
Example #4
0
        public void DrawBarCharts(XGraphics gfx)
        {
            XPoint backgroundPoint = new XPoint(20, page_.Height * 0.55);
            XRect backgroundRect = new XRect(backgroundPoint.X, backgroundPoint.Y, page_.Width - 40, page_.Height * 0.425);
            double quarterRectWidth = backgroundRect.Width * 0.25;
            double offset = quarterRectWidth * 0.25;
            DrawingUtil.DrawOutlineRect(backgroundRect, gfx, new XSize(40,40));
            gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromKnownColor(XKnownColor.Gray)),
                backgroundRect,
                new XSize(40, 40));

            DoubleBar ShoulderFlexionBar = new DoubleBar(userParameters_[dataReadStart + 4], userParameters_[dataReadStart + 9], gfx);
            ShoulderFlexionBar.Draw(new XPoint(quarterRectWidth - offset, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            DoubleBar hipFlexionBar = new DoubleBar(userParameters_[dataReadStart + 5], userParameters_[dataReadStart + 10], gfx);
            hipFlexionBar.Draw(new XPoint(quarterRectWidth * 2 - offset, backgroundPoint.Y + 20),
                backgroundRect,
                 XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            DoubleBar kneeFlexionBar = new DoubleBar(userParameters_[dataReadStart + 6], userParameters_[dataReadStart + 11], gfx);
            kneeFlexionBar.Draw(new XPoint(quarterRectWidth * 3 - offset, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            DoubleBar ankleFlexionBar = new DoubleBar(userParameters_[dataReadStart + 7], userParameters_[dataReadStart + 12], gfx);
            ankleFlexionBar.Draw(new XPoint(quarterRectWidth * 4 - offset, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png"));

            gfx.DrawString("Degrees :",
                new XFont("Arial", 10),
                XBrushes.Black,
                (backgroundPoint + new XPoint(0, 20)) + new XPoint(backgroundRect.Width * 0.05, backgroundRect.Height * 0.05),
                XStringFormats.Center);

            gfx.DrawString("LSI % :",
                new XFont("Arial", 10),
                XBrushes.Black,
                (backgroundPoint + new XPoint(0, 20)) + new XPoint(backgroundRect.Width * 0.05, backgroundRect.Height * 0.125),
                XStringFormats.Center);

            XPoint top = new XPoint(backgroundPoint.X, backgroundPoint.Y + backgroundRect.Height * 0.2);
            XPoint bottom = new XPoint(backgroundPoint.X, backgroundPoint.Y + backgroundRect.Height * 0.8);
            for (int i = 11; i > 0; i--)
            {
                float increment = -i * 0.1f;

                XPoint percentagePoint = DrawingUtil.Instance.Interpolate(top, bottom, increment);
                percentagePoint = new XPoint(percentagePoint.X, Math.Floor(percentagePoint.Y));
                gfx.DrawString(((11 - i) * 10).ToString() + "%", new XFont("Arial", 8), XBrushes.Black, percentagePoint + new XPoint(5, -2));
                gfx.DrawLine(XPens.LightGray, percentagePoint, percentagePoint + new XPoint(backgroundRect.Width, 0));
            }
        }
    /// <summary>
    /// Demonstrates the use of XGraphics.DrawRoundedRectangle.
    /// </summary>
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

#if DEBUG
      gfx.WriteComment("begin DrawRoundedRectangle");
#endif
      // Stroke rounded rectangle
      gfx.DrawRoundedRectangle(properties.Pen1.Pen, 50, 100, 450, 150, 50, 30);
#if DEBUG
      gfx.WriteComment("end DrawRoundedRectangle");
#endif

      // Fill rounded rectangle
      gfx.DrawRoundedRectangle(properties.Brush2.Brush, new Rectangle(50, 300, 450, 150), new SizeF(30, 20));

      // Stroke and fill rounded rectangle
      gfx.DrawRoundedRectangle(properties.Pen2.Pen, properties.Brush2.Brush, 
        new XRect(50, 500, 450, 150),  new XSize(75, 75));
    }
Example #6
0
        public void DrawBarCharts(XGraphics gfx)
        {
            XPoint backgroundPoint = new XPoint(20, page.Height * 0.585);
            XRect backgroundRect = new XRect(backgroundPoint.X, backgroundPoint.Y, page.Width - 40, page.Height * 0.41);
            gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromKnownColor(XKnownColor.Gray)),
                backgroundRect,
                new XSize(40, 40));

            DoubleBar ShoulderFlexionBar = new DoubleBar(userParameters["LEFT Shoulder Flexion"], userParameters["RIGHT Shoulder Flexion"], gfx);
            ShoulderFlexionBar.Draw(new XPoint(quaterWidth * 0.5  - 10,backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Shoulder Flexion.png"));

            DoubleBar hipFlexionBar = new DoubleBar(userParameters["LEFT Hip Flexion"], userParameters["RIGHT Hip Flexion"], gfx);
            hipFlexionBar.Draw(new XPoint(quaterWidth * 2 - (quaterWidth * 0.5) - 10, backgroundPoint.Y + 20),
                backgroundRect,
                 XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Hip Flexion.png"));

            DoubleBar kneeFlexionBar = new DoubleBar(userParameters["LEFT Knee Flexion"], userParameters["RIGHT Knee Flexion"], gfx);
            kneeFlexionBar.Draw(new XPoint(quaterWidth * 3 - (quaterWidth * 0.5) - 10, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Knee Flexion.png"));

            DoubleBar ankleFlexionBar = new DoubleBar(userParameters["LEFT Ankle Flexion"], userParameters["RIGHT Ankle Flexion"], gfx);
            ankleFlexionBar.Draw(new XPoint(quaterWidth * 4 - (quaterWidth * 0.5) - 10, backgroundPoint.Y + 20),
                backgroundRect,
                XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Ankle Flexion.png"));

            XPoint top = new XPoint(backgroundPoint.X, backgroundPoint.Y + backgroundRect.Height * 0.2);
            XPoint bottom = new XPoint(backgroundPoint.X, backgroundPoint.Y + backgroundRect.Height * 0.8);
            for (int i = 11; i > 0; i--)
            {
                float increment = -i * 0.1f;

                XPoint percentagePoint = Interpolate(top, bottom, increment);
                gfx.DrawString(((11 - i) * 10).ToString() + "%", new XFont("Arial", 8), XBrushes.Black, percentagePoint + new XPoint(5, 0));
                gfx.DrawLine(XPens.Black, percentagePoint, percentagePoint + new XPoint(backgroundRect.Width, 0));

            }
        }
Example #7
0
        public Glossary_Page(PdfPage page, XGraphics gfx)
        {
            XRect headRect = new XRect(page.Width * 0.05, page.Height * 0.05, page.Width * 0.9, page.Height * 0.1);
            gfx.DrawRoundedRectangle(XBrushes.Gray, headRect, new XSize(20, 20));

            gfx.DrawString("Report Glossary", new XFont("Arial", 24), XBrushes.Black, new XPoint(page.Width * 0.5, headRect.Y + headRect.Height * 0.5), XStringFormats.Center);

            //Parameters
            XRect mainRect = new XRect(page.Width * 0.05, page.Height * 0.175, page.Width * 0.9, page.Height * 0.5);
            gfx.DrawRoundedRectangle(XBrushes.Gray, mainRect, new XSize(20, 20));

            XFont parial = new XFont("Arial", 8);
            XTextFormatter frm = new XTextFormatter(gfx);
            double txtOffset = mainRect.X + mainRect.Width * 0.3;

            gfx.DrawString("Parameters :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.05));
            gfx.DrawLine(XPens.White, new XPoint(mainRect.X, mainRect.Y + mainRect.Height * 0.075), new XPoint(mainRect.X + mainRect.Width, mainRect.Y + mainRect.Height * 0.075));

            gfx.DrawString("Hip Flexion :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.255));
            frm.DrawString("is a measurement of the ability of the individual to move their thigh toward the torso when squatting", parial, XBrushes.Black,
                new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.225, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Hip Abduction :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.31));
            frm.DrawString("Is a measurement of the femur's movement away from the mid-line positon of the body", parial, XBrushes.Black,
                new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.285, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Hip Internal Rotation :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.365));
            frm.DrawString("Is a measurement of the hip joints ability to rotate in an inward motion towards the mid-line position of the body", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.345, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Hip External Rotation :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.42));
            frm.DrawString("Is a measurement of the hip joints ability to rotate in an outward motion away from the mid-line position of the body", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.4, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Shoulder Flexion :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.475));
            frm.DrawString("is a measurement of the ability of the individual to raise their hand over the head in a forward motion", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.455, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Knee Flexion :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.53));
            frm.DrawString("is a measurement of the range of motion at the knee when squatting", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.51, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Ankle Flexion :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.585));
            frm.DrawString("is a measurement of the range of motion into dorsiflexion at the ankle joint when squatting", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.565, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Tibia / Spine Alignment :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.64));
            frm.DrawString("is a measure of the ability of the individual's ability to maintain the spine in neutral during the squat", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.62, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Pelvic Stability :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.695));
            frm.DrawString("is a measure of the ability of the individual's ability to keep the pelvis stable during the squat", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.675, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Knee Stability :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.75));
            frm.DrawString("is a measurement of the individuals ability to keep the knees in neutral alignment during the squat", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.73, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Depth of Squat :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.805));
            frm.DrawString("is a measurement of how deep the individual is able to squat", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.785, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("Spinal Alignment :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.86));
            frm.DrawString("Is a measurement of the ability of the individual to maintain neutral spine angle throughout the squat pattern", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.84, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            gfx.DrawString("LSI :", parial, XBrushes.White, new XPoint(mainRect.X + mainRect.Width * 0.1, mainRect.Y + mainRect.Height * 0.915));
            frm.DrawString("Limb Symmetry Index: LSI is a value given to the symmetry between both left and right of the body I.e Left and right knee flexion", parial, XBrushes.Black,
            new XRect(txtOffset, mainRect.Y + mainRect.Height * 0.895, mainRect.Width * 0.7, mainRect.Height), XStringFormats.TopLeft);

            XRect contactRect = new XRect(page.Width * 0.05, page.Height * 0.7, page.Width * 0.9, page.Height * 0.25);
            gfx.DrawRoundedRectangle(XBrushes.Gray, contactRect, new XSize(20, 20));

            XImage img = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\logo.png");
            double rat = (double)img.PixelWidth / (double)img.PixelHeight;
            gfx.DrawImage(img, new XRect((page.Width * 0.5) - 50, contactRect.Y + contactRect.Height * 0.05, rat * 50, 50));

            string t = "Redback Biotek is a global leader in the field of 3D biomechanical analysis and is supported by a world -class" +
                " team of clinicians and fitness experts.Our commitment is to provide fast," +
                " accurate and easy to understand reporting that offer you qualitative insight into your movement competency." +
                "\n\nIf you require more details about our 3D bio-mechanical analysis or would like to make another appointment for a follow-up screen please contact Paul Clarke:";

            frm.DrawString(t, parial, XBrushes.Black, new XRect(contactRect.X + 20, contactRect.Y + 75, contactRect.Width - 40, contactRect.Height));

            gfx.DrawString("+353 86 8595155", parial, XBrushes.Black, new XPoint(contactRect.X + contactRect.Width * 0.035, contactRect.Y + contactRect.Height - 40));
            gfx.DrawString("*****@*****.**", parial, XBrushes.Black, new XPoint(contactRect.X + contactRect.Width -(contactRect.Width * 0.25), contactRect.Y + contactRect.Height - 40));
            t = "Redback Biotek is the owner of all intellectual property rights in this report and associated material published on it.Those works are protected by copyright laws and treaties around the world.All such rights are reserved.";
            frm.DrawString(t, new XFont("Arial", 5), XBrushes.Black, new XRect(contactRect.X + 20, contactRect.Y + contactRect.Height - 17.5, contactRect.Width - 40, contactRect.Height));
        }
Example #8
0
        private void drawGridOnPdfdocument(DataGridView displayGrid, XGraphics gfx, int displayXOffset, int displayYOffset)
        {
            XColor back = XColors.Transparent;
            back.A = 0.1;
            XSolidBrush BorderBrush = new XSolidBrush(back);
            XPen pen = new XPen(XColors.Gray, 1);
            //Side Panels
            double height = displayGrid.Height + 5;
            double width = displayGrid.Width + 7;
            gfx.DrawRoundedRectangle(pen, BorderBrush, displayGrid.Location.X - 8, displayGrid.Location.Y - 20 + displayYOffset, width, height, 10, 10);
            gfx.DrawRoundedRectangle(pen, BorderBrush, displayGrid.Location.X - 5, displayGrid.Location.Y + 365, 1058, 28, 5, 5);
            XFont headerfont = new XFont("Aerial", 13, XFontStyle.Bold);
            XTextFormatter tf = new XTextFormatter(gfx);
            XPen newPen = new XPen(Color.Black);
            XColor fillColor = XColors.DarkOrange;
            XBrush brush = new XSolidBrush(fillColor);
            fillColor.A = 0.8;

            int headerOffset = 0;
            foreach (DataGridViewColumn colmn in displayGrid.Columns)
            {
                if (colmn.Visible)
                {
                    Rectangle header_rect = displayGrid.GetCellDisplayRectangle(colmn.Index, -1, false);
                    XRect pdf_rect = new XRect(header_rect.X + displayXOffset, header_rect.Y + displayYOffset, header_rect.Width, header_rect.Height);
                    headerOffset = header_rect.Height;
                    gfx.DrawRectangle(newPen, pdf_rect);
                    tf.Alignment = XParagraphAlignment.Center;
                    tf.DrawString(colmn.HeaderText, headerfont, XBrushes.Black, pdf_rect, XStringFormats.TopLeft);
                }

            }

            XFont font = new XFont("Aerial", 13, XFontStyle.Bold);
            foreach (DataGridViewRow dgRow in displayGrid.Rows)
                foreach (DataGridViewColumn dgCol in displayGrid.Columns)
                {
                    if (dgCol.Visible)
                    {
                        Rectangle rect = displayGrid.GetCellDisplayRectangle(dgCol.Index, dgRow.Index, true);
                        XRect pdf_rect = new XRect(rect.X + displayXOffset, rect.Y + displayYOffset, rect.Width, rect.Height);
                        gfx.DrawRectangle(newPen, pdf_rect);
                        tf.Alignment = XParagraphAlignment.Center;
                        string displayText = getCellFormatedValue(displayGrid.Rows[dgRow.Index].Cells[dgCol.Index]);
                        tf.DrawString(displayText, headerfont, XBrushes.Black, pdf_rect, XStringFormats.TopLeft);
                    }

                }
        }
        public override void Render(ref PdfSharp.Drawing.XGraphics gfx, double offsetLeft, double offsetTop, double scaleX, double scaleY)
        {
            PreRender(ref gfx, offsetLeft, offsetTop, scaleX, scaleY);
            double borderWidth = Util.MillimeterToPoint(BorderWidth);
            double radiusx     = Math.Min(Util.MillimeterToPoint(Width), Util.MillimeterToPoint(BorderRadius)) * 2.0;
            double radiusy     = Math.Min(Util.MillimeterToPoint(Height), Util.MillimeterToPoint(BorderRadius)) * 2.0;

            XPen pen = new XPen(BorderColor, borderWidth);

            if (BorderRadius == 0.0)
            {
                gfx.DrawRectangle(FillColor,
                                  Util.MillimeterToPoint(offsetLeft + Left),
                                  Util.MillimeterToPoint(offsetTop + Top),
                                  Util.MillimeterToPoint(Width * scaleX),
                                  Util.MillimeterToPoint(Height * scaleY));

                gfx.DrawRectangle(pen,
                                  Util.MillimeterToPoint(offsetLeft + Left + (BorderWidth / 2.0)),
                                  Util.MillimeterToPoint(offsetTop + Top + (BorderWidth / 2.0)),
                                  Util.MillimeterToPoint((Width - BorderWidth) * scaleX),
                                  Util.MillimeterToPoint((Height - BorderWidth) * scaleY));
            }
            else
            {
                double width  = (Width - BorderWidth) * scaleX;
                double height = (Height - BorderWidth) * scaleY;



                gfx.DrawRoundedRectangle(FillColor,
                                         Util.MillimeterToPoint(offsetLeft + Left),
                                         Util.MillimeterToPoint(offsetTop + Top),
                                         Util.MillimeterToPoint((Width) * scaleX),
                                         Util.MillimeterToPoint((Height) * scaleY),
                                         Math.Min(Util.MillimeterToPoint(Width), radiusx + Util.MillimeterToPoint(BorderWidth)) - 0.1,
                                         Math.Min(Util.MillimeterToPoint(Height), radiusy + Util.MillimeterToPoint(BorderWidth)) - 0.1);

                gfx.DrawRoundedRectangle(pen,
                                         Util.MillimeterToPoint(offsetLeft + Left + (BorderWidth / 2.0)),
                                         Util.MillimeterToPoint(offsetTop + Top + (BorderWidth / 2.0)),
                                         Util.MillimeterToPoint(width),
                                         Util.MillimeterToPoint(height),
                                         Math.Min(Util.MillimeterToPoint(width), radiusx) - 0.1,
                                         Math.Min(Util.MillimeterToPoint(height), radiusy) - 0.1);
            }



            /**/

            /*if (radiusx == 0.0 && radiusy == 0.0)
             * {
             * if (Fill)
             * {
             *  gfx.DrawRectangle(FillColor,
             *    Util.MillimeterToPoint(offsetLeft + Left),
             *    Util.MillimeterToPoint(offsetTop + Top),
             *    Util.MillimeterToPoint(Width * scaleX),
             *    Util.MillimeterToPoint(Height * scaleY));
             * }
             * if (BorderWidth > 0.0 && DrawBorder) {
             *  gfx.DrawRectangle(pen,
             *  Util.MillimeterToPoint(offsetLeft + Left + (borderWidth / 2f)),
             *  Util.MillimeterToPoint(offsetTop + Top + (borderWidth / 2f)),
             *  Util.MillimeterToPoint((Width - (borderWidth / 2f)) * scaleX),
             *  Util.MillimeterToPoint((Height - (borderWidth / 2f)) * scaleY));
             * }
             * }
             * else
             * {
             * if (Fill)
             * {
             *  gfx.DrawRoundedRectangle(FillColor,
             *    Util.MillimeterToPoint(offsetLeft + Left + borderWidth),
             *    Util.MillimeterToPoint(offsetTop + Top + borderWidth),
             *    Util.MillimeterToPoint((Width - (borderWidth * 2.0)) * scaleX),
             *    Util.MillimeterToPoint((Height - (borderWidth * 2.0)) * scaleY),
             *    radiusx,
             *    radiusy);
             * }
             * if (BorderWidth > 0.0)
             * {
             *  gfx.DrawRoundedRectangle(pen,
             *  Util.MillimeterToPoint(offsetLeft + Left+(BorderRadius/2f)),
             *  Util.MillimeterToPoint(offsetTop + Top + (BorderRadius / 2f)),
             *  Util.MillimeterToPoint((Width - (BorderRadius / 2f)) * scaleX),
             *  Util.MillimeterToPoint((Height - (BorderRadius / 2f)) * scaleY),
             *  radiusx,
             *  radiusy);
             * }
             * }*/

            base.Render(ref gfx, offsetLeft, offsetTop, scaleX, scaleY);
        }
Example #10
0
        public void DrawPentagon(XGraphics gfx)
        {
            XRect backgroundRect = new XRect(20, page.Height * 0.15, page.Width - 40, page.Height * 0.425);
            gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromKnownColor(XKnownColor.Gray)),
                backgroundRect,
                new XSize(40, 40));

            double c1 = Math.Cos((2 * Math.PI) / 5);
            double c2 = Math.Cos(Math.PI / 5);
            double s1 = Math.Sin((2 * Math.PI) / 5);
            double s2 = Math.Sin((4 * Math.PI) / 5);

            XPoint[] pentatPoints = new XPoint[5];

            XPoint center = new XPoint(page.Width * 0.5, page.Height * 0.425);
            XPoint top = new XPoint(page.Width * 0.5, page.Height * 0.25);

            double lengthOfLine = Distance(top, center);
            XPoint bottomLeft = new XPoint(center.X + (lengthOfLine * -s2), center.Y - (lengthOfLine * -c2));
            XPoint bottomRight = new XPoint(center.X + (lengthOfLine * s2), center.Y - (lengthOfLine * -c2));
            XPoint topLeft = new XPoint(center.X + (lengthOfLine * -s1), center.Y - (lengthOfLine * c1));
            XPoint topRight = new XPoint(center.X + (lengthOfLine * s1), center.Y - (lengthOfLine * c1));

            pentatPoints[0] = top;
            pentatPoints[1] = topRight;
            pentatPoints[2] = bottomRight;
            pentatPoints[3] = bottomLeft;
            pentatPoints[4] = topLeft;

            gfx.DrawPolygon(XBrushes.DimGray, pentatPoints, XFillMode.Winding);

            XPen yellowPen = new XPen(XColors.Yellow, 2.5);
            XPen greenPen = new XPen(XColors.Green, 2.5);
            XPen perimeterPen = XPens.LightGray;
            XPen redPen = new XPen(XColors.Red, 2.5);

            //center out
            gfx.DrawLine(greenPen, center, top);
            gfx.DrawLine(greenPen, center, bottomLeft);
            gfx.DrawLine(greenPen, center, bottomRight);
            gfx.DrawLine(greenPen, center, topLeft);
            gfx.DrawLine(greenPen, center, topRight);

            XBrush brush = XBrushes.Black;
            XSize size = new XSize(50, 50);
            XSize ellipseSize = new XSize(10, 10);
            //images
            XImage leftKneeImg = XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Left Knee Stability.png");
            XImage rightKneeImg = XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Right Knee Stability.png");
            XImage tibia_spineImg = XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Tibia Spine Angle.png");
            XImage dosImg = XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Depth of Squat.png");
            XImage pelvicImg = XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Pelvic Stability.png");

            //infoboxes
            DrawPentaInfoBox(gfx, top + new XPoint(-50, -75), tibia_spineImg, userParameters["Tibia / Spine Angle"]);
            DrawPentaInfoBox(gfx, topLeft + new XPoint(-100,-35), leftKneeImg, userParameters["LEFT Knee Stability"]);
            DrawPentaInfoBox(gfx, topRight + new XPoint(25, -35), rightKneeImg, userParameters["RIGHT Knee Stability"]);
            DrawPentaInfoBox(gfx, bottomRight + new XPoint(25, -60), pelvicImg, userParameters["Pelvic Stability"]);
            DrawPentaInfoBox(gfx, bottomLeft + new XPoint(-125, -60), dosImg, userParameters["Depth of Squat"]);

            //percentage Lines
            gfx.DrawString(0 + "%", new XFont("Arial", 10), XBrushes.Black, center + new XPoint(5,0));
            for (int i = 10; i > 0; i--)
            {
                float increment = -i * 0.1f;

                gfx.DrawString((i * 10).ToString() + "%", new XFont("Arial", 8), XBrushes.Black, Interpolate(center, top, increment) + new XPoint(5,0));

                gfx.DrawLine(perimeterPen, Interpolate(center,topLeft, increment), Interpolate(center, top, increment));
                gfx.DrawLine(perimeterPen, Interpolate(center, top, increment), Interpolate(center, topRight, increment));
                gfx.DrawLine(perimeterPen, Interpolate(center, topRight, increment), Interpolate(center, bottomRight, increment));
                gfx.DrawLine(perimeterPen, Interpolate(center, bottomRight, increment), Interpolate(center, bottomLeft, increment));
                gfx.DrawLine(perimeterPen, Interpolate(center, bottomLeft, increment), Interpolate(center, topLeft, increment));
            }

            XPoint centerTibia = Interpolate(center, top, -userParameters["Tibia / Spine Angle"].Percentage);
            XPoint centerRightKnee = Interpolate(center, topRight, -userParameters["RIGHT Knee Stability"].Percentage);
            XPoint centerPelvicStability = Interpolate(center, bottomRight, -userParameters["Pelvic Stability"].Percentage);
            XPoint centerDos = Interpolate(center, bottomLeft, -userParameters["Depth of Squat"].Percentage);
            XPoint centerLeftKnee = Interpolate(center, topLeft, -userParameters["LEFT Knee Stability"].Percentage);

            gfx.DrawLine(redPen, center, Interpolate(center, top, -userParameters["Tibia / Spine Angle"].RedVal));
            gfx.DrawLine(redPen, center, Interpolate(center, topRight, -userParameters["RIGHT Knee Stability"].RedVal));
            gfx.DrawLine(redPen, center, Interpolate(center, bottomRight, -userParameters["Pelvic Stability"].RedVal));
            gfx.DrawLine(redPen, center, Interpolate(center, bottomLeft, -userParameters["Depth of Squat"].RedVal));
            gfx.DrawLine(redPen, center, Interpolate(center, topLeft, -userParameters["LEFT Knee Stability"].RedVal));

            gfx.DrawPolygon(new XPen(XColor.FromArgb(1, 0, 255, 255)),
                new XSolidBrush(XColor.FromArgb(127,255,255,0)),
                new XPoint[] { centerTibia, centerRightKnee, centerPelvicStability, centerDos, centerLeftKnee },
                XFillMode.Alternate);
        }
Example #11
0
    /// <summary>
    /// Renders the content of the page.
    /// </summary>
    public void Render(XGraphics gfx)
    {
      XRect rect;
      XPen pen;
      double x = 50, y = 100;
      XFont fontH1 = new XFont("Times", 18, XFontStyle.Bold);
      XFont font = new XFont("Times", 12);
      XFont fontItalic = new XFont("Times", 12, XFontStyle.BoldItalic);
      double ls = font.GetHeight(gfx);

      // Draw some text
      gfx.DrawString("Create PDF on the fly with PDFsharp",
          fontH1, XBrushes.Black, x, x);
      gfx.DrawString("With PDFsharp you can use the same code to draw graphic, " +
          "text and images on different targets.", font, XBrushes.Black, x, y);
      y += ls;
      gfx.DrawString("The object used for drawing is the XGraphics object.", 
          font, XBrushes.Black, x, y);
      y += 2 * ls;

      // Draw an arc
      pen = new XPen(XColors.Red, 4);
      pen.DashStyle = XDashStyle.Dash;
      gfx.DrawArc(pen, x + 20, y, 100, 60, 150, 120);

      // Draw a star
      XGraphicsState gs = gfx.Save();
      gfx.TranslateTransform(x + 140, y + 30);
      for (int idx = 0; idx < 360; idx += 10)
      {
        gfx.RotateTransform(10);
        gfx.DrawLine(XPens.DarkGreen, 0, 0, 30, 0);
      }
      gfx.Restore(gs);

      // Draw a rounded rectangle
      rect = new XRect(x + 230, y, 100, 60);
      pen = new XPen(XColors.DarkBlue, 2.5);
      XColor color1 = XColor.FromKnownColor(KnownColor.DarkBlue);
      XColor color2 = XColors.Red;
      XLinearGradientBrush lbrush = new XLinearGradientBrush(rect, color1, color2, 
        XLinearGradientMode.Vertical);
      gfx.DrawRoundedRectangle(pen, lbrush, rect, new XSize(10, 10));
      
      // Draw a pie
      pen = new XPen(XColors.DarkOrange, 1.5);
      pen.DashStyle = XDashStyle.Dot;
      gfx.DrawPie(pen, XBrushes.Blue, x + 360, y, 100, 60, -130, 135);
      
      // Draw some more text
      y += 60 + 2 * ls;
      gfx.DrawString("With XGraphics you can draw on a PDF page as well as " +
          "on any System.Drawing.Graphics object.", font, XBrushes.Black, x, y);
      y += ls * 1.1;
      gfx.DrawString("Use the same code to", font, XBrushes.Black, x, y);
      x += 10;
      y += ls * 1.1;
      gfx.DrawString("• draw on a newly created PDF page", font, XBrushes.Black, x, y);
      y += ls;
      gfx.DrawString("• draw above or beneath of the content of an existing PDF page", 
          font, XBrushes.Black, x, y);
      y += ls;
      gfx.DrawString("• draw in a window", font, XBrushes.Black, x, y);
      y += ls;
      gfx.DrawString("• draw on a printer", font, XBrushes.Black, x, y);
      y += ls;
      gfx.DrawString("• draw in a bitmap image", font, XBrushes.Black, x, y);
      x -= 10;
      y += ls * 1.1;
      gfx.DrawString("You can also import an existing PDF page and use it like " +
          "an image, e.g. draw it on another PDF page.", font, XBrushes.Black, x, y);
      y += ls * 1.1 * 2;
      gfx.DrawString("Imported PDF pages are neither drawn nor printed; create a " + 
          "PDF file to see or print them!", fontItalic, XBrushes.Firebrick, x, y);
      y += ls * 1.1;
      gfx.DrawString("Below this text is a PDF form that will be visible when " + 
          "viewed or printed with a PDF viewer.", fontItalic, XBrushes.Firebrick, x, y);
      y += ls * 1.1;
      XGraphicsState state = gfx.Save();
      XRect rcImage = new XRect(100, y, 100, 100 * Math.Sqrt(2));
      gfx.DrawRectangle(XBrushes.Snow, rcImage);
      gfx.DrawImage(XPdfForm.FromFile("../../../../../PDFs/SomeLayout.pdf"), rcImage);
      gfx.Restore(state);
    }
Example #12
0
        public void DrawPentagon(XGraphics gfx)
        {
            //set up the background grey
            XRect backgroundRect = new XRect(20, page_.Height * 0.11, page_.Width - 40, page_.Height * 0.425);
            DrawingUtil.DrawOutlineRect(backgroundRect, gfx, cornerRadius);
            gfx.DrawRoundedRectangle(backgroundBrush,
                backgroundRect,
                cornerRadius);
            XPoint center = new XPoint(page_.Width * 0.5, backgroundRect.Y + backgroundRect.Height * 0.6);

            XPoint[] polyPoints = DrawingUtil.Instance.GeneratePoints(center, 130, 5, gfx);
            gfx.DrawPolygon(backgroundBrush, polyPoints, XFillMode.Winding);

            XPen yellowPen = new XPen(XColors.Yellow, 2.5);
            XPen greenPen = new XPen(XColors.Green, 2.5);
            XPen perimeterPen = XPens.LightGray;
            XPen redPen = new XPen(XColors.Red, 2.5);

            //center out
            foreach(XPoint p in polyPoints)
                gfx.DrawLine(greenPen, center, p);

            XBrush brush = XBrushes.Black;
            XSize size = new XSize(50, 50);
            XSize ellipseSize = new XSize(10, 10);
            //images
            XImage leftKneeImg = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\LKS.png");
            XImage rightKneeImg = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\RKS.png");
            XImage tibia_spineImg = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\STA.png");
            XImage dosImg = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\DOS.png");
            XImage pelvicImg = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\PS.png");

            //infoboxes
            DrawPentaInfoBox(gfx, polyPoints[0] + new XPoint(-50, -70), tibia_spineImg, userParameters_[dataReadStart + 1]);
            DrawPentaInfoBox(gfx, polyPoints[1] + new XPoint(25, -35), rightKneeImg, userParameters_[dataReadStart + 8]);
            DrawPentaInfoBox(gfx, polyPoints[2] + new XPoint(25, -60), pelvicImg, userParameters_[dataReadStart + 2]);
            DrawPentaInfoBox(gfx, polyPoints[3] + new XPoint(-125, -60), dosImg, userParameters_[dataReadStart + 0]);
            DrawPentaInfoBox(gfx, polyPoints[4] + new XPoint(-120,-35), leftKneeImg, userParameters_[dataReadStart + 3]);

            //percentage Lines
            gfx.DrawString(0 + "%", new XFont("Arial", 10), XBrushes.Black, center + new XPoint(5, 0));
            for (int j = 0; j < polyPoints.Length - 1; j++)
            {
                XPoint pt1 = polyPoints[j];
                XPoint pt2 = polyPoints[j + 1];

                for (int i = 10; i > 0; i--)
                {
                    float increment = -i * 0.1f;
                    if (j < 1)
                        gfx.DrawString((i * 10).ToString() + '%', new XFont("Arial", 8), XBrushes.Black, DrawingUtil.Instance.Interpolate(center, polyPoints[0], increment) + new XPoint(5, 0));

                    gfx.DrawLine(perimeterPen,
                        DrawingUtil.Instance.Interpolate(center, pt1, increment),
                        DrawingUtil.Instance.Interpolate(center, pt2, increment));
                }
            }

            XPoint centerTibia = DrawingUtil.Instance.Interpolate(center, polyPoints[0], -userParameters_[dataReadStart + 1].Percentage);
            XPoint centerRightKnee = DrawingUtil.Instance.Interpolate(center, polyPoints[1], -userParameters_[dataReadStart + 8].Percentage);
            XPoint centerPelvicStability = DrawingUtil.Instance.Interpolate(center, polyPoints[2], -userParameters_[dataReadStart + 2].Percentage);
            XPoint centerDos = DrawingUtil.Instance.Interpolate(center, polyPoints[3], -userParameters_[dataReadStart + 0].Percentage);
            XPoint centerLeftKnee = DrawingUtil.Instance.Interpolate(center, polyPoints[4], -userParameters_[dataReadStart + 3].Percentage);

            gfx.DrawLine(redPen, center, DrawingUtil.Instance.Interpolate(center, polyPoints[0], -userParameters_[dataReadStart + 1].RedVal));
            gfx.DrawLine(redPen, center, DrawingUtil.Instance.Interpolate(center, polyPoints[1], -userParameters_[dataReadStart + 8].RedVal));
            gfx.DrawLine(redPen, center, DrawingUtil.Instance.Interpolate(center, polyPoints[2], -userParameters_[dataReadStart + 2].RedVal));
            gfx.DrawLine(redPen, center, DrawingUtil.Instance.Interpolate(center, polyPoints[3], -userParameters_[dataReadStart + 0].RedVal));
            gfx.DrawLine(redPen, center, DrawingUtil.Instance.Interpolate(center, polyPoints[4], -userParameters_[dataReadStart + 3].RedVal));

            gfx.DrawPolygon(new XPen(XColor.FromArgb(1, 0, 255, 255)),
                new XSolidBrush(XColor.FromArgb(40,255,255,0)),
                new XPoint[] { centerTibia, centerRightKnee, centerPelvicStability, centerDos, centerLeftKnee },
                XFillMode.Alternate);

            gfx.DrawLines(new XPen(XColors.Orange, 1), new XPoint[] { centerTibia, centerRightKnee, centerPelvicStability, centerDos, centerLeftKnee, centerTibia });
        }
Example #13
0
        void DrawPentaInfoBox(XGraphics gfx, XPoint point, XImage image, Parameter parameter)
        {
            double val = parameter.Value;
            string str = parameter.Name;
            XBrush brush = ChooseBrushColor(parameter.Percentage,
                parameter.RedVal,
                parameter.AmberVal);
            XSize ellipseSize = new XSize(10, 10);

            gfx.DrawRoundedRectangle(brush, new XRect(point.X, point.Y, 50, 50), ellipseSize);
            gfx.DrawString(str, new XFont("Arial", 12), XBrushes.White, point + new XPoint(0,60));
            gfx.DrawString(val.ToString() + "%", new XFont("Arial", 12), XBrushes.White, point + new XPoint(10,30));
            gfx.DrawImage(image, new XRect(point + new XPoint(50,0),new XSize(50,50)));
        }
Example #14
0
 void DrawPentaInfoBox(XGraphics gfx, XPoint point, XImage img, Parameter parameter)
 {
     double wRatio = (double)img.PixelWidth / (double)img.PixelHeight;
     double val = parameter.Value;
     string str = parameter.Name;
     XBrush brush = DrawingUtil.Instance.ChooseBrushColor(parameter.Color);
     XSize ellipseSize = new XSize(10, 10);
     DrawingUtil.DrawOutlineRect(new XRect(point.X, point.Y + 10, 55, 30), gfx, ellipseSize);
     gfx.DrawRoundedRectangle(brush, new XRect(point.X, point.Y + 10, 55, 30), ellipseSize);
     gfx.DrawString(str, arialSmall, XBrushes.Black, point + new XPoint(0,60));
     gfx.DrawString(val.ToString() + " " + parameter.UnitOfMeasure, arialSmall,
         XBrushes.Black, new XPoint(point.X + 25,point.Y + 25),XStringFormats.Center);
     gfx.DrawImage(img, new XRect(point + new XPoint(60,0), new XSize(wRatio * 50, 50)));
 }
Example #15
0
 public static void DrawOutlineRect(XRect rect, XGraphics gfx, XSize rounded)
 {
     rect = new XRect(rect.Left - 1,rect.Top - 1, rect.Width + 2, rect.Height + 2);
     gfx.DrawRoundedRectangle(XBrushes.Black, rect, rounded);
 }
Example #16
0
        public void DrawGraph(XGraphics gfx)
        {
            double yOff = page_.Height * 0.11;

            XRect rect = new XRect(20, yOff, page_.Width - 40, page_.Height - (yOff + 20));
            DrawingUtil.DrawOutlineRect(rect, gfx, cornerRadius);

            gfx.DrawRoundedRectangle(backgroundBrush, rect, cornerRadius);
            XPoint center = new XPoint(page_.Width * 0.5, page_.Height * 0.45);

            //Left & right boxes
            XRect leftRect = new XRect(center.X - 250, yOff + 5, 160, 25);
            XRect rightRect = new XRect(center.X + 90, yOff + 5, 160, 25);
            DrawingUtil.DrawOutlineRect(leftRect, gfx, new XSize(10,10));
            gfx.DrawRoundedRectangle(XBrushes.Yellow, leftRect, new XSize(10, 10));
            DrawingUtil.DrawOutlineRect(rightRect, gfx, new XSize(10,10));
            gfx.DrawRoundedRectangle(XBrushes.CornflowerBlue, rightRect, new XSize(10, 10));
            gfx.DrawString("Left", new XFont("Arial", 20), XBrushes.Black, new XPoint(leftRect.X + 80, leftRect.Y + 15), XStringFormats.Center);
            gfx.DrawString("Right", new XFont("Arial", 20), XBrushes.Black, new XPoint(rightRect.X + 80, rightRect.Y + 15), XStringFormats.Center);

            float graphSize = (float)page_.Height * 0.175f;
            XPoint[] polyPoints = DrawingUtil.Instance.GeneratePoints(center, graphSize, 7, gfx);
            gfx.DrawPolygon(backgroundBrush, polyPoints, XFillMode.Winding);

            XPen yellowPen = new XPen(XColors.Yellow, 2.5);
            XPen greenPen = new XPen(XColors.Green, 2.5);
            XPen perimeterPen = XPens.LightGray;
            XPen redPen = new XPen(XColors.Red, 2.5);

            GraphIcon hipFlexImg = new GraphIcon(XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\HipFlex.png"),"Hip Flexion");
            GraphIcon hamStringImg = new GraphIcon(XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\HSExt.png"), "Hamstring Extension");
            GraphIcon hipAbdImg = new GraphIcon(XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\HipAbd.png"), "Hip Abduction");
            GraphIcon hipIntImg = new GraphIcon(XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\HipInt.png"), "Hip Internal Rotation");
            GraphIcon hipExtImg = new GraphIcon(XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\HipExt.png"), "Hip External Rotation");
            GraphIcon kneeFlexImg = new GraphIcon(XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\KneeFlex.png"), "Knee Flexion");
            GraphIcon AnkleFlexImg = new GraphIcon(XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\AnkleFlex.png"), "Ankle Flexion");

            GraphIcon[] icons = new GraphIcon[] { hipFlexImg, hamStringImg, hipAbdImg, hipIntImg, hipExtImg, kneeFlexImg, AnkleFlexImg };

            //center out
            for (int l = 0; l < polyPoints.Length - 1; l++)
                gfx.DrawLine(greenPen, center, polyPoints[l]);

            //percentage Lines & icons
            gfx.DrawString(0 + "%", new XFont("Arial", 10), XBrushes.Black, center + new XPoint(5, 0));
            for (int j = 0; j < polyPoints.Length - 1; j++)
            {
                XPoint pt1 = polyPoints[j];
                XPoint pt2 = polyPoints[j + 1];

                for (int i = 10; i > 0; i--)
                {
                    float increment = -i * 0.1f;
                    if (j < 1)
                        gfx.DrawString((i * 10).ToString() + '%', new XFont("Arial", 8), XBrushes.Black, DrawingUtil.Instance.Interpolate(center, polyPoints[0], increment) + new XPoint(5, 0));

                    gfx.DrawLine(perimeterPen,
                        DrawingUtil.Instance.Interpolate(center, pt1, increment),
                        DrawingUtil.Instance.Interpolate(center, pt2, increment));
                }

                XVector vec = new XVector(pt1.X, pt1.Y);
                XVector vec2 = new XVector(center.X, center.Y);

                XImage img = icons[j].img;
                double wRatio = (double)img.PixelWidth / (double)img.PixelHeight;

                XVector dir = vec2 - vec;
                dir.Normalize();
                double txtOffset = dir.X * -10;
                XPoint halfmg = new XPoint(-20, -20);
                XPoint imgpos = new XPoint(dir.X * (-graphSize - 50), dir.Y * (-graphSize - 50)) + center + halfmg;
                gfx.DrawImage(img, new XRect(imgpos, new XSize(wRatio * 60, 60)));
                gfx.DrawString(icons[j].txt, arialSmall, XBrushes.Black, imgpos + new XPoint(txtOffset, -10), XStringFormats.Center);
            }

            //leftSide
            XPoint[] percentagePoints = new XPoint[polyPoints.Length - 1];
            for (int k = 0; k < polyPoints.Length - 1; k++)
            {
                Parameter kv = userParameters_.ElementAt(k);
                percentagePoints[k] = DrawingUtil.Instance.Interpolate(center, polyPoints[k], -kv.Percentage);
                gfx.DrawLine(yellowPen, center, DrawingUtil.Instance.Interpolate(center, polyPoints[k], -kv.AmberVal));
                gfx.DrawLine(redPen, center, DrawingUtil.Instance.Interpolate(center, polyPoints[k], -kv.RedVal));
            }

            gfx.DrawPolygon(new XPen(XColor.FromArgb(1, 0, 255, 255)),
                new XSolidBrush(XColor.FromArgb(100, 255, 255, 0)),
                percentagePoints,
                XFillMode.Alternate);
            XPoint[] linePoints = new XPoint[percentagePoints.Length + 1];
            for (int i = 0; i < percentagePoints.Length; i++)
            {
                linePoints[i] = percentagePoints[i];
            }

            linePoints[linePoints.Length - 1] = percentagePoints[0];
            gfx.DrawLines(new XPen(XColor.FromArgb(255, 255, 255, 0), 2), linePoints);

            //right side
            for (int k = 10; k < polyPoints.Length + 9; k++)
            {
                Parameter kv = userParameters_.ElementAt(k);
                percentagePoints[k - 10] = DrawingUtil.Instance.Interpolate(center, polyPoints[k - 10], -kv.Percentage);
                gfx.DrawLine(yellowPen, center, DrawingUtil.Instance.Interpolate(center, polyPoints[k -10], -kv.AmberVal));
                gfx.DrawLine(redPen, center, DrawingUtil.Instance.Interpolate(center, polyPoints[k - 10], -kv.RedVal));
            }

            gfx.DrawPolygon(new XPen(XColor.FromArgb(1, 0, 255, 255)),
                new XSolidBrush(XColor.FromArgb(100, 54, 127, 180)),
                percentagePoints,
                XFillMode.Alternate);

            for (int i = 0; i < percentagePoints.Length; i++)
            {
                linePoints[i] = percentagePoints[i];
            }
            linePoints[linePoints.Length - 1] = percentagePoints[0];
            gfx.DrawLines(new XPen(XColor.FromArgb(255, 54, 127, 180), 2), linePoints);

            XRect leftRectLSI = new XRect(center.X - 250, page_.Height * 0.725, 120, 25);
            XRect rightRectLSI = new XRect(center.X + 70, page_.Height * 0.725, 120, 25);
            XRect LSIRect = new XRect(page_.Width - 100, page_.Height * 0.725, 35, 25);

            XSize rad = new XSize(10, 10);

            DrawingUtil.DrawOutlineRect(leftRectLSI, gfx, rad);
            DrawingUtil.DrawOutlineRect(rightRectLSI, gfx, rad);
            DrawingUtil.DrawOutlineRect(LSIRect, gfx, rad);

            gfx.DrawRoundedRectangle(XBrushes.Yellow, leftRectLSI,rad);
            gfx.DrawRoundedRectangle(XBrushes.CornflowerBlue, rightRectLSI, rad);
            gfx.DrawRoundedRectangle(XBrushes.LightGray, LSIRect, rad);
            gfx.DrawString("Left", new XFont("Arial", 14), XBrushes.Black, new XPoint(leftRectLSI.X + 60, leftRectLSI.Y + 12.5), XStringFormats.Center);
            gfx.DrawString("Right", new XFont("Arial", 14), XBrushes.Black, new XPoint(rightRectLSI.X + 60, rightRectLSI.Y + 12.5), XStringFormats.Center);
            gfx.DrawString("LSI", new XFont("Arial", 14), XBrushes.Black, new XPoint(LSIRect.X + 17.5, LSIRect.Y + 10), XStringFormats.Center);

            for (int l = 0; l < polyPoints.Length - 1; l++)
            {
                XBrush leftParamCol = XBrushes.Green;
                XBrush rightParamCol = XBrushes.Green;
                XBrush lsiParamCol = XBrushes.Green;

                XFont arial = new XFont("Arial", 13,XFontStyle.Bold);

                Parameter leftParam = userParameters_.ElementAt(l);
                Parameter rightParam = userParameters_.ElementAt(l + 10);;

                leftParamCol = DrawingUtil.Instance.ChooseBrushColor(leftParam.Color);
                rightParamCol = DrawingUtil.Instance.ChooseBrushColor(rightParam.Color);

                char degree = Convert.ToChar('\u00b0');

                double increment = l * page_.Height * 0.025;
                double y = page_.Height * 0.775 + increment;

                XRect rl = new XRect(leftRectLSI.X + (leftRectLSI.Width * 0.5) - 25, y, 50, 15);
                DrawingUtil.DrawOutlineRect(rl, gfx, rad);

                gfx.DrawRoundedRectangle(leftParamCol, rl, rad);
                gfx.DrawString(leftParam.Value.ToString() + degree, arial, XBrushes.Black, new XPoint(rl.X + 25, rl.Y + 7.5), XStringFormats.Center);

                XRect rr = new XRect(rightRectLSI.X + (rightRectLSI.Width * 0.5) - 25, y, 50, 15);
                DrawingUtil.DrawOutlineRect(rr, gfx, rad);

                gfx.DrawRoundedRectangle(rightParamCol, rr, rad);
                gfx.DrawString(rightParam.Value.ToString() + degree, arial, XBrushes.Black, new XPoint(rr.X + 25, rr.Y + 7.5), XStringFormats.Center);

                XRect rlsi = new XRect(LSIRect.X + (LSIRect.Width * 0.5) - 17.5, y, 35, 15);
                DrawingUtil.DrawOutlineRect(rlsi, gfx, rad);

                lsiParamCol = DrawingUtil.Instance.ChooseBrushColor(leftParam.LSI, 49, 74);
                gfx.DrawRoundedRectangle(lsiParamCol, rlsi, rad);
                gfx.DrawString(leftParam.LSI.ToString("0") + "%", arial, XBrushes.Black, new XPoint(rlsi.X + 17.5, rlsi.Y + 7.5), XStringFormats.Center);

                gfx.DrawString(leftParam.Name.Substring(4,leftParam.Name.Length - 4), new XFont("Arial", 10), XBrushes.Black,
                    DrawingUtil.Instance.Interpolate(new XPoint(rl.X + rl.Width, y + 7.5), new XPoint(rr.X, y), -0.5), XStringFormats.TopCenter);

                gfx.DrawLine(XPens.DarkSlateGray, new XPoint(leftRectLSI.X, rl.Y + 17.5), new XPoint(rlsi.X + 35, rl.Y + 17.5));
            }
        }
        public static void Test(PdfSharp.Drawing.XGraphics gfx)
        {
            XRect  rect;
            XPen   pen;
            double x = 50, y = 100;
            XFont  fontH1     = new XFont("Times", 18, XFontStyle.Bold);
            XFont  font       = new XFont("Times", 12);
            XFont  fontItalic = new XFont("Times", 12, XFontStyle.BoldItalic);
            double ls         = font.GetHeight(gfx);

            // Draw some text
            gfx.DrawString("Create PDF on the fly with PDFsharp",
                           fontH1, XBrushes.Black, x, x);
            gfx.DrawString("With PDFsharp you can use the same code to draw graphic, " +
                           "text and images on different targets.", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("The object used for drawing is the XGraphics object.",
                           font, XBrushes.Black, x, y);
            y += 2 * ls;

            // Draw an arc
            pen           = new XPen(XColors.Red, 4);
            pen.DashStyle = XDashStyle.Dash;
            gfx.DrawArc(pen, x + 20, y, 100, 60, 150, 120);

            // Draw a star
            XGraphicsState gs = gfx.Save();

            gfx.TranslateTransform(x + 140, y + 30);
            for (int idx = 0; idx < 360; idx += 10)
            {
                gfx.RotateTransform(10);
                gfx.DrawLine(XPens.DarkGreen, 0, 0, 30, 0);
            }
            gfx.Restore(gs);

            // Draw a rounded rectangle
            rect = new XRect(x + 230, y, 100, 60);
            pen  = new XPen(XColors.DarkBlue, 2.5);
            XColor color1 = XColor.FromKnownColor(System.Drawing.KnownColor.DarkBlue);
            XColor color2 = XColors.Red;
            XLinearGradientBrush lbrush = new XLinearGradientBrush(rect, color1, color2,
                                                                   XLinearGradientMode.Vertical);

            gfx.DrawRoundedRectangle(pen, lbrush, rect, new XSize(10, 10));

            // Draw a pie
            pen           = new XPen(XColors.DarkOrange, 1.5);
            pen.DashStyle = XDashStyle.Dot;
            gfx.DrawPie(pen, XBrushes.Blue, x + 360, y, 100, 60, -130, 135);

            // Draw some more text
            y += 60 + 2 * ls;
            gfx.DrawString("With XGraphics you can draw on a PDF page as well as " +
                           "on any System.Drawing.Graphics object.", font, XBrushes.Black, x, y);
            y += ls * 1.1;
            gfx.DrawString("Use the same code to", font, XBrushes.Black, x, y);
            x += 10;
            y += ls * 1.1;
            gfx.DrawString("• draw on a newly created PDF page", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw above or beneath of the content of an existing PDF page",
                           font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw in a window", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw on a printer", font, XBrushes.Black, x, y);
            y += ls;
            gfx.DrawString("• draw in a bitmap image", font, XBrushes.Black, x, y);
            x -= 10;
            y += ls * 1.1;
            gfx.DrawString("You can also import an existing PDF page and use it like " +
                           "an image, e.g. draw it on another PDF page.", font, XBrushes.Black, x, y);
            y += ls * 1.1 * 2;
            gfx.DrawString("Imported PDF pages are neither drawn nor printed; create a " +
                           "PDF file to see or print them!", fontItalic, XBrushes.Firebrick, x, y);
            y += ls * 1.1;
            gfx.DrawString("Below this text is a PDF form that will be visible when " +
                           "viewed or printed with a PDF viewer.", fontItalic, XBrushes.Firebrick, x, y);
            y += ls * 1.1;
            XGraphicsState state   = gfx.Save();
            XRect          rcImage = new XRect(100, y, 100, 100 * System.Math.Sqrt(2));

            gfx.DrawRectangle(XBrushes.Snow, rcImage);
            gfx.DrawImage(XPdfForm.FromFile("../../../../../PDFs/SomeLayout.pdf"), rcImage);
            gfx.Restore(state);
        }
Example #18
0
        public Cover_Page(PdfPage page, ProfileInfo userProfile, XGraphics gfx)
        {
            centerX = page.Width * 0.5;
            XRect headingRect = new XRect(page.Width * 0.1, page.Height * 0.05, page.Width * 0.8, page.Height * 0.125);
            string heading = userProfile.reportHeading;

            gfx.DrawRoundedRectangle(XBrushes.DimGray, headingRect, new XSize(20, 20));
            gfx.DrawString(heading, new XFont("Arial", 26), XBrushes.Black, new XPoint(page.Width * 0.5, page.Height * 0.09), XStringFormats.Center);
            gfx.DrawString(@"""Movement in Motion""", new XFont("Arial", 14), XBrushes.White, new XPoint(page.Width * 0.5, page.Height * 0.15), XStringFormats.Center);

            XImage img = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\logo.png");
            gfx.DrawImage(img, new XPoint(centerX - (img.PointWidth / 2), page.Height * 0.2));

            XRect profileRect = new XRect(page.Width * 0.25, page.Height * 0.375, page.Width * 0.5f, page.Height * 0.1);
            gfx.DrawRoundedRectangle(XBrushes.DimGray, profileRect, new XSize(20, 20));

            XRect tagRect1 = new XRect(profileRect.X + page.Width * 0.015, profileRect.Y + page.Height * 0.015, page.Width * 0.09, page.Height * 0.07);
            gfx.DrawRoundedRectangle(XBrushes.LightGray, tagRect1, new XSize(10, 10));
            gfx.DrawString("Name : ", new XFont("Arial", 10), XBrushes.Black, tagRect1.X + 5, tagRect1.Y + 10);
            gfx.DrawString(userProfile.Name, new XFont("Arial", 10), XBrushes.Black, tagRect1.X + tagRect1.Width + 10, tagRect1.Y + 10);
            gfx.DrawString("RB ID : ", new XFont("Arial", 10), XBrushes.Black, tagRect1.X + 5, tagRect1.Y + 30);
            gfx.DrawString(userProfile.RBID.Replace(",", ""), new XFont("Arial", 10), XBrushes.Black, tagRect1.X + tagRect1.Width + 10, tagRect1.Y + 30);
            gfx.DrawString("Gender : ", new XFont("Arial", 10), XBrushes.Black, tagRect1.X + 5, tagRect1.Y + 50);
            gfx.DrawString(userProfile.Gender.Replace(",", ""), new XFont("Arial", 10), XBrushes.Black, tagRect1.X + tagRect1.Width + 10, tagRect1.Y + 50);

            XRect tagRect2 = new XRect(profileRect.X + page.Width * 0.25, profileRect.Y + page.Height * 0.015, page.Width * 0.09, page.Height * 0.07);
            gfx.DrawRoundedRectangle(XBrushes.LightGray, tagRect2, new XSize(10, 10));
            gfx.DrawString("Date : ", new XFont("Arial", 10), XBrushes.Black, tagRect2.X + 5, tagRect2.Y + 10);

            gfx.DrawString(userProfile.Date.ToShortDateString(), new XFont("Arial", 10), XBrushes.Black, tagRect2.X + tagRect2.Width + 10, tagRect2.Y + 10);
            gfx.DrawString("Opperator : ", new XFont("Arial", 10), XBrushes.Black, tagRect2.X + 5, tagRect2.Y + 30);
            gfx.DrawString(userProfile.Opperator.Replace(",", ""), new XFont("Arial", 10), XBrushes.Black, tagRect2.X + tagRect2.Width + 10, tagRect2.Y + 30);
            gfx.DrawString("Sport : ", new XFont("Arial", 10), XBrushes.Black, tagRect2.X + 5, tagRect2.Y + 50);
            gfx.DrawString(userProfile.Sport.Replace(",", ""), new XFont("Arial", 10), XBrushes.Black, tagRect2.X + tagRect2.Width + 10, tagRect2.Y + 50);

            XRect infoRect = new XRect(page.Width * 0.1, page.Height * 0.5, page.Width * 0.8, page.Height * 0.45);
            gfx.DrawRoundedRectangle(XBrushes.DimGray, infoRect, new XSize(20, 20));

            XRect descriptionRect = new XRect(infoRect.X + page.Width * 0.075f, infoRect.Y + page.Height * 0.025, page.Width * 0.65, page.Height * 0.15);
            gfx.DrawRoundedRectangle(XBrushes.LightGray, descriptionRect, new XSize(10, 10));
            string r = userProfile.ReportText;
            XTextFormatter frm = new XTextFormatter(gfx);
            frm.DrawString(r, new XFont("Arial", 12), XBrushes.Black, descriptionRect, XStringFormats.TopLeft);

            XImage img1 = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\CL.png");
            XImage img2 = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\PS.png");
            XImage img3 = XImage.FromFile(Directory.GetCurrentDirectory() + @"\Content\CR.png");

            double wRatio = (double)img1.PixelWidth / (double)img1.PixelHeight;
            gfx.DrawImage(img1, new XRect(new XPoint(infoRect.X + page.Width * 0.25 - (img1.PointWidth / 2), infoRect.Y + page.Height * 0.2),
                new XSize(wRatio * 100, 100)));

            wRatio = (double)img2.PixelWidth / (double)img2.PixelHeight;
            gfx.DrawImage(img2, new XRect(new XPoint(infoRect.X + page.Width * 0.5 - (img2.PointWidth / 2), infoRect.Y + page.Height * 0.2),
                new XSize(wRatio * 100, 100)));

            wRatio = (double)img3.PixelWidth / (double)img3.PixelHeight;
            gfx.DrawImage(img3, new XRect(new XPoint(infoRect.X + page.Width * 0.75 - (img3.PointWidth / 2), infoRect.Y + page.Height * 0.2),
                new XSize(wRatio * 100, 100)));

            XRect indicatorsRect = new XRect(infoRect.X + page.Width * 0.075f, infoRect.Y + page.Height * 0.34, page.Width * 0.65, page.Height * 0.1);
            gfx.DrawRoundedRectangle(XBrushes.LightGray, indicatorsRect, new XSize(10, 10));

            XRect colorRect = new XRect(indicatorsRect.X + indicatorsRect.Width * 0.01, indicatorsRect.Y + indicatorsRect.Height * 0.01, 20, 12);
            double txtOffset = colorRect.X + colorRect.Width * 1.7;

            gfx.DrawRoundedRectangle(DrawingUtil.Instance.ChooseBrushColor("Red"), colorRect, new XSize(5, 5));
            frm.DrawString("Requires further ongoing 3D screening or immediate intervention from a qualified practitioner", new XFont("Arial", 10), XBrushes.Black,
                new XRect(txtOffset, colorRect.Y, indicatorsRect.Width, indicatorsRect.Height));

            colorRect = new XRect(indicatorsRect.X + indicatorsRect.Width * 0.01, indicatorsRect.Y + indicatorsRect.Height * 0.41, 20, 12);
            txtOffset = colorRect.X + colorRect.Width * 1.7;
            gfx.DrawRoundedRectangle(DrawingUtil.Instance.ChooseBrushColor("Amber"), colorRect, new XSize(5, 5));
            frm.DrawString("Requires follow up intervention in the form of corrective exercises from a qualified health practitioner", new XFont("Arial", 10), XBrushes.Black,
            new XRect(txtOffset, colorRect.Y, indicatorsRect.Width - 20, indicatorsRect.Height));

            colorRect = new XRect(indicatorsRect.X + indicatorsRect.Width * 0.01, indicatorsRect.Y + indicatorsRect.Height * 0.81, 20, 12);
            txtOffset = colorRect.X + colorRect.Width * 1.7;
            gfx.DrawRoundedRectangle(DrawingUtil.Instance.ChooseBrushColor("Green"), colorRect, new XSize(5, 5));
            frm.DrawString("The individual demonstrates optimal movement competency", new XFont("Arial", 10), XBrushes.Black,
            new XRect(txtOffset, colorRect.Y, indicatorsRect.Width, indicatorsRect.Height));
        }
Example #19
0
    /// <summary>
    /// Draws all charts inside the ChartFrame.
    /// </summary>
    public void Draw(XGraphics gfx)
    {
      // Draw frame of ChartFrame. First shadow frame.
      int dx = 5;
      int dy = 5;
      gfx.DrawRoundedRectangle(XBrushes.Gainsboro,
                               this.location.X + dx, this.location.Y + dy,
                               this.size.Width, this.size.Height, 20, 20);

      XRect chartRect = new XRect(this.location.X, this.location.Y, this.size.Width, this.size.Height);
      XLinearGradientBrush brush = new XLinearGradientBrush(chartRect, XColor.FromArgb(0xFFD0DEEF), XColors.White,
                                                            XLinearGradientMode.Vertical);
      XPen penBorder = new XPen(XColors.SteelBlue, 2.5);
      gfx.DrawRoundedRectangle(penBorder, brush,
                               this.location.X, this.location.Y, this.size.Width, this.size.Height,
                               15, 15);

      XGraphicsState state = gfx.Save();
      gfx.TranslateTransform(this.location.X, this.location.Y);

      // Calculate rectangle for all charts. Y-Position will be moved for each chart.
      int charts = this.chartList.Count;
      uint dxChart = 20;
      uint dyChart = 20;
      uint dyBetweenCharts = 30;
      XRect rect = new XRect(dxChart, dyChart,
        this.size.Width - 2 * dxChart,
        (this.size.Height - (charts - 1) * dyBetweenCharts - 2 * dyChart) / charts);

      // draw each chart in list
      foreach (Chart chart in this.chartList)
      {
        RendererParameters parms = new RendererParameters(gfx, rect);
        parms.DrawingItem = chart;

        ChartRenderer renderer = GetChartRenderer(chart, parms);
        renderer.Init();
        renderer.Format();
        renderer.Draw();

        rect.Y += rect.Height + dyBetweenCharts;
      }
      gfx.Restore(state);

//      // Calculate rectangle for all charts. Y-Position will be moved for each chart.
//      int charts = this.chartList.Count;
//      uint dxChart = 0;
//      uint dyChart = 0;
//      uint dyBetweenCharts = 0;
//      XRect rect = new XRect(dxChart, dyChart,
//        this.size.Width - 2 * dxChart,
//        (this.size.Height - (charts - 1) * dyBetweenCharts - 2 * dyChart) / charts);
//
//      // draw each chart in list
//      foreach (Chart chart in this.chartList)
//      {
//        RendererParameters parms = new RendererParameters(gfx, rect);
//        parms.DrawingItem = chart;
//
//        ChartRenderer renderer = GetChartRenderer(chart, parms);
//        renderer.Init();
//        renderer.Format();
//        renderer.Draw();
//
//        rect.Y += rect.Height + dyBetweenCharts;
//      }
    }
Example #20
0
        public void DrawHeader(XGraphics gfx)
        {
            XRect userDetailsRect = new XRect(20, page.Height * 0.05, quaterWidth, page.Height * 0.075);
            gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromKnownColor(XKnownColor.Gray)),
                userDetailsRect,
                new XSize(20, 20));

            XRect innerRect = new XRect(userDetailsRect.X + 10, userDetailsRect.Y + 10,
                userDetailsRect.Height - 20, userDetailsRect.Height - 20);
            gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromKnownColor(XKnownColor.LightGray)),
                innerRect,
                new XSize(10, 10));

            gfx.DrawString("Name : " + userProfile.Name, new XFont("Arial", 10), XBrushes.Black, 35, innerRect.Y + 10);
            gfx.DrawString("RB ID : " + userProfile.RBID.Replace(",", ""), new XFont("Arial", 10), XBrushes.Black, 35, innerRect.Y + 30);

            XImage headerImage = XImage.FromFile(@"C:\Users\kevin\Desktop\PDFsharp\samples\Samples C#\Based on WPF\HelloWorld\Content\Redback 3D logo.png");
            gfx.DrawImage(headerImage, new XPoint((quaterWidth * 2.5) - (headerImage.PixelWidth / 2), page.Height * 0.075));

            XSolidBrush brush = new XSolidBrush();
            double score = Convert.ToDouble(userProfile.Score);

            if (score <= 33)
                brush = new XSolidBrush(XColors.Red);
            else if (score > 33 && score <= 66)
                brush = new XSolidBrush(XColor.FromArgb(255, 255, 190, 0));
            else
                brush = new XSolidBrush(XColors.Green);

            XRect scoreRect = new XRect((quaterWidth * 3) - 20, page.Height * 0.05, quaterWidth, page.Height * 0.075);
            gfx.DrawRoundedRectangle(new XSolidBrush(XColor.FromKnownColor(XKnownColor.Gray)),
                scoreRect,
                new XSize(20, 20));

            XRect innerRectScore = new XRect(scoreRect.X + (scoreRect.Width - 50), scoreRect.Y + 10,
                scoreRect.Height - 20, scoreRect.Height - 20);
            gfx.DrawRoundedRectangle(brush,
                innerRectScore,
                new XSize(10, 10));

            gfx.DrawString("Overhead Squat : ", new XFont("Arial", 10),
                XBrushes.Black, scoreRect.X + 10, scoreRect.Y + 35);

            gfx.DrawString(userProfile.Score + "%", new XFont("Arial", 10),
                XBrushes.Black, innerRectScore.X + 5, innerRectScore.Y + 25);
        }
Example #21
-1
        public static void BeginBox(XGraphics gfx, int number, string title,
            double borderWidth, double borderHeight,
            XColor shadowColor, XColor backColor, XColor backColor2,
            XPen borderPen)
        {
            const int dEllipse = 15;
            XRect rect = new XRect(0, 20, 300, 200);
            if (number % 2 == 0)
                rect.X = 300 - 5;
            rect.Y = 40 + ((number - 1) / 2) * (200 - 5);
            rect.Inflate(-10, -10);
            XRect rect2 = rect;
            rect2.Offset(borderWidth, borderHeight);
            gfx.DrawRoundedRectangle(new XSolidBrush(shadowColor), rect2, new XSize(dEllipse + 8, dEllipse + 8));
            XLinearGradientBrush brush = new XLinearGradientBrush(rect, backColor, backColor2, XLinearGradientMode.Vertical);
            gfx.DrawRoundedRectangle(borderPen, brush, rect, new XSize(dEllipse, dEllipse));
            rect.Inflate(-5, -5);

            XFont font = new XFont("Verdana", 12, XFontStyle.Regular);
            gfx.DrawString(title, font, XBrushes.Navy, rect, XStringFormats.TopCenter);

            rect.Inflate(-10, -5);
            rect.Y += 20;
            rect.Height -= 20;

            state = gfx.Save();
            gfx.TranslateTransform(rect.X, rect.Y);
        }