示例#1
0
        void Generate(string filePath)
        {
            List<Parameter> userParameters = new List<Parameter>();
            ProfileInfo userProfile = new ProfileInfo();
            ReportType currentReport = ReportType.ROM;

            //get the excel sheet
            var worksheets = Workbook.Worksheets(filePath);
            var sheets = worksheets.ToArray();
            var profileSheet = sheets[1];
            var dataSheet = sheets[2];

            //read the uer profile data
            userProfile.Name = profileSheet.Rows[0].Cells[0].Text;
            DateTime t = new DateTime(1900, 1, 1);
            double num = 0;
            Double.TryParse(profileSheet.Rows[1].Cells[0].Text, out num);
            t = t.AddDays(num - 2);
            userProfile.Date = t;
            userProfile.Opperator = profileSheet.Rows[2].Cells[0].Text;
            userProfile.RBID = profileSheet.Rows[3].Cells[0].Text;
            userProfile.Sport = profileSheet.Rows[4].Cells[0].Text;
            userProfile.Gender = profileSheet.Rows[5].Cells[0].Text;

            int rowStart = 0;
            int rowEnd = dataSheet.Rows.Length - 5;

            switch (cmbx_Reports.SelectedIndex)
            {
                case 0:
                    userProfile.Report = ReportType.TMS;
                    userProfile.reportHeading = profileSheet.Rows[6].Cells[0].Text;
                    userProfile.ReportText = profileSheet.Rows[7].Cells[0].Text;
                    break;
                case 1:
                    userProfile.Report = ReportType.ROM;
                    userProfile.reportHeading = profileSheet.Rows[8].Cells[0].Text;
                    userProfile.ReportText = profileSheet.Rows[9].Cells[0].Text;
                    rowEnd = 20;
                    break;
                case 2:
                    userProfile.Report = ReportType.OHS;
                    userProfile.reportHeading = profileSheet.Rows[10].Cells[0].Text;
                    userProfile.ReportText = profileSheet.Rows[11].Cells[0].Text;
                    rowStart = 20;
                    rowEnd = 34;
                    break;
                case 3:
                    userProfile.Report = ReportType.LNG;
                    userProfile.reportHeading = profileSheet.Rows[12].Cells[0].Text;
                    userProfile.ReportText = profileSheet.Rows[13].Cells[0].Text;
                    rowStart = 33;
                    rowEnd = 41;
                    break;
                default:
                    userProfile.Report = ReportType.TMS;
                    MessageBox.Show("Unknown Error : Setting report type to TMS");
                    break;
            }

            //error prevention???
            string prefix = "";
            //look through the rows, and decide what report we are dealing with
            for (int row = rowStart; row < rowEnd; row++)
            {
                if (row < 20)
                    currentReport = ReportType.ROM;
                else if (row >= 20 && row < 33)
                    currentReport = ReportType.OHS;
                else
                    currentReport = ReportType.LNG;

                Row currentRow = dataSheet.Rows[row];
                Parameter userParameter = new Parameter();

                string tmpPrefix = currentRow.Cells[1].Text;

                //error prevention???
                if (tmpPrefix != "")
                    prefix = tmpPrefix + " ";

                //loop through the cells on a row basis
                for (int cell = 0; cell < currentRow.Cells.Length; cell++)
                {
                    //get the current cell iinfor inf null move onwards
                    Cell currentCell = currentRow.Cells[cell];
                    if (currentCell == null)
                        continue;

                    switch (currentCell.ColumnIndex)
                    {
                        case 0:
                            userParameter.Value = Convert.ToDouble(currentCell.Text);
                            break;
                        case 1:
                            userParameter.Percentage = Convert.ToDouble(currentCell.Text) * 0.01;
                            if (userParameter.Percentage < 0.0f)
                                userParameter.Percentage = 0.0f;
                            else if (userParameter.Percentage > 1.0f)
                                userParameter.Percentage = 1.0f;

                            break;
                        case 2:
                            userParameter.Color = currentCell.Text;
                            break;
                        case 3:
                            if (currentCell.Text != "")
                                userParameter.LSI = Math.Round(Convert.ToDouble(currentCell.Text)); break;
                        case 4:
                            userParameter.UnitOfMeasure = currentCell.Text == "degrees" ? Convert.ToChar('\u00b0').ToString() : currentCell.Text;
                            break;
                        case 5:
                            userParameter.RedVal = Convert.ToDouble(currentCell.Text) * 0.01;
                            break;
                        case 6:
                            if (currentCell.Text != "NA")
                                userParameter.AmberVal = Convert.ToDouble(currentCell.Text) * 0.01;
                            else userParameter.AmberVal = 0.0;
                            break;
                        case 7:
                            userParameter.GreenVal = Convert.ToDouble(currentCell.Text) * 0.01;
                            break;
                        case 8:
                            string side = "";
                            switch (currentReport)
                            {
                                case ReportType.ROM:
                                    side = row < 10 ? "LEFT " : "RIGHT ";
                                    break;
                                case ReportType.OHS:
                                    if (row >= 23 && row < 28)
                                        side = "LEFT ";
                                    else if (row >= 28)
                                        side = "RIGHT ";
                                    break;
                                case ReportType.LNG:
                                    side = row < 37 ? "LEFT " : "RIGHT ";
                                    break;
                            }
                            userParameter.Name = side + currentCell.Text;
                            break;
                    }
                }
                userParameters.Add(userParameter);
                //Console.ReadKey();

            }
            // Create a new PDF document
            PdfDocument document = new PdfDocument();
            document.Info.Title = "Redback Report - " + userProfile.Name;

            PdfPage cover_page = document.AddPage();
            XGraphics coverGfx = XGraphics.FromPdfPage(cover_page);
            Cover_Page cover = new Cover_Page(cover_page, userProfile, coverGfx);
            int score = 0;
            string sctxt = "";
            switch (cmbx_Reports.SelectedIndex)
            {
                case 0:
                    PdfPage page = document.AddPage();
                    XGraphics gfx = XGraphics.FromPdfPage(page);

                    ROM_Page rom = new ROM_Page(page, userProfile, userParameters);
                    sctxt = dataSheet.Rows[dataSheet.Rows.Length - 5].Cells[1].Text;
                    score = (int)Math.Round(Convert.ToDouble(sctxt));
                    rom.DrawHeader(gfx, "ROM", score);
                    rom.DrawGraph(gfx);

                    page = document.AddPage();
                    gfx = XGraphics.FromPdfPage(page);

                    OHS_Page squat = new OHS_Page(page, userProfile, userParameters, 20);
                    sctxt = dataSheet.Rows[dataSheet.Rows.Length - 4].Cells[1].Text;
                    score = (int)Math.Round(Convert.ToDouble(sctxt));
                    squat.DrawHeader(gfx, "Overhead Squat", score);
                    squat.DrawPentagon(gfx);
                    squat.DrawBarCharts(gfx);

                    page = document.AddPage();
                    gfx = XGraphics.FromPdfPage(page);

                    Lunge_Page lunge = new Lunge_Page(page, userProfile, userParameters, 33);
                    sctxt = dataSheet.Rows[dataSheet.Rows.Length - 3].Cells[1].Text;
                    score = (int)Math.Round(Convert.ToDouble(sctxt));
                    lunge.DrawHeader(gfx, "Lunge" , score);
                    lunge.DrawStats(gfx);

                    break;

                case 1:
                    // Create an empty page
                    PdfPage rom_pdf = document.AddPage();
                    // Get an XGraphics object for drawing
                    XGraphics gfx1 = XGraphics.FromPdfPage(rom_pdf);

                    ROM_Page rom_Page = new ROM_Page(rom_pdf, userProfile, userParameters);
                    sctxt = dataSheet.Rows[dataSheet.Rows.Length - 5].Cells[1].Text;
                    score = (int)Math.Round(Convert.ToDouble(sctxt));
                    rom_Page.DrawHeader(gfx1, "ROM", score);
                    rom_Page.DrawGraph(gfx1);

                    break;

                case 2:
                    // Create an empty page
                    PdfPage ohs_pdf = document.AddPage();
                    // Get an XGraphics object for drawing
                    XGraphics gfx2 = XGraphics.FromPdfPage(ohs_pdf);

                    OHS_Page squat_page = new OHS_Page(ohs_pdf, userProfile, userParameters);
                    sctxt = dataSheet.Rows[dataSheet.Rows.Length - 4].Cells[1].Text;
                    score = (int)Math.Round(Convert.ToDouble(sctxt));
                    squat_page.DrawHeader(gfx2, "Overhead Squat", score);
                    squat_page.DrawPentagon(gfx2);
                    squat_page.DrawBarCharts(gfx2);
                    break;

                case 3:
                    // Create an empty page
                    PdfPage lunge_pdf = document.AddPage();
                    // Get an XGraphics object for drawing
                    XGraphics gfx3 = XGraphics.FromPdfPage(lunge_pdf);

                    Lunge_Page lunge_Page = new Lunge_Page(lunge_pdf, userProfile, userParameters);
                    sctxt = dataSheet.Rows[dataSheet.Rows.Length - 3].Cells[1].Text;
                    score = (int)Math.Round(Convert.ToDouble(sctxt));
                    lunge_Page.DrawHeader(gfx3, "Lunge", score);
                    lunge_Page.DrawStats(gfx3);

                    break;
            }

            PdfPage glossary_Page = document.AddPage();
            XGraphics glosGfx = XGraphics.FromPdfPage(glossary_Page);

            Glossary_Page gp = new Glossary_Page(glossary_Page, glosGfx);

            string rbDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Redback Reports\";
            if (!Directory.Exists(rbDirectory))
                Directory.CreateDirectory(rbDirectory);

            // Save the document...
            string filename = rbDirectory + userProfile.Name + ((ReportType)cmbx_Reports.SelectedIndex).ToString() +  " RB Report.pdf";
            document.Save(filename);
            txt_FilePath.Text = "File location :" + rbDirectory;
            // ...and start a viewer.
            pdfProcess = Process.Start(filename);
        }
示例#2
0
 public Lunge_Page(PdfPage page, ProfileInfo profleInfo, List<Parameter> userParameters, int dataStart = 0)
     : base(page, profleInfo, userParameters, dataStart)
 {
 }
示例#3
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));
        }
示例#4
0
 public OHS_Page(PdfPage page, ProfileInfo userProfile, List<Parameter> userParameters, int dataReadStart = 0)
     : base(page, userProfile, userParameters, dataReadStart)
 {
 }
示例#5
0
 public ROM_Page(PdfPage page, ProfileInfo userInfo, List<Parameter> userParameters)
     : base(page, userInfo, userParameters)
 {
 }