public override void GetDetails(PdfStructureElement tag)
        {
            helper.SetMargins(0.75f);
            SetWidths(threecolumns);
            SetColumns();

            var table = new tTable(this, "");
            table.ParentTag = tag;

            // row 1
            var cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "SRG:");
            var row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.Irgcomb));
            table.Add(row);

            // row 2
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "SRO:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.SRAName));
            table.Add(row);

            // row 3
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Program Administrator:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.ProgramAdmin));
            table.Add(row);

            // row 4
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Council Assignment:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.CouncilAssignment));
            table.Add(row);

            // row 5
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Conflict of Interest:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.ConflictOfInterest));
            table.Add(row);

            table.Write();
        }
        private void WriteFundingPlanComments(PdfStructureElement tag)
        {
            if (helper.Portfolio.Information.Comment != string.Empty && helper.Portfolio.Information.Comment.Trim() == string.Empty)
                return;

            SetWidths(twelvecolumns);
            SetColumns();

            PdfStructureElement part = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(part);
            content.EndMarkedContentSequence();

            helper.AddLine(1);
            tTable table = new tTable(this, string.Empty);
            table.ParentTag = part;

            var row = new tRow(table);
            var cell = new tCell(0, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.Portfolio.Information.Comment);
            cell.fontSize = 6.0f;
            cell.Colspan = 12;
            row.Add(cell);
            table.Add(row);
            table.Write();

            helper.AddLine(1);
        }
        public void WriteOERApprovalSignature(PdfStructureElement tag)
        {
            if (this.Strategy.isIncludeOERSignature == false)
                return;

            PdfStructureElement part = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(part);
            content.EndMarkedContentSequence();

            helper.AddLine(2);
            helper.SetMargins(1f);
            SetWidths(signaturecolumns);
            SetColumns();

            var table = new tTable(this, "");
            table.ParentTag = part;
            table.ColumnCount = Columns.Length;

            var dict = new PdfDictionary();

            // row 1
            var cell = new tCell(0, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "");
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Deputy Director OER Approval"));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            var row = new tRow();
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "");
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Date "));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);
            table.Add(row);


            //  row 2
            row = new tRow();
            cell = new tCell();
            cell.MakeDoubleLine(0, 2);
            row.Add(cell);
            table.Add(row);


            // row 3
            row = new tRow();
            cell = new tCell(0, "P", "Deputy Director OER Approval");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);
            table.Add(row);

            table.Write();
        }
        public void WriteSignatures(PdfStructureElement tag)
        {
            if (this.Strategy.isIncludeFinalSignature == false)
                return;

            PdfStructureElement part = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(part);
            content.EndMarkedContentSequence();

            helper.AddLine(2);
            helper.SetMargins(1f);
            SetWidths(signaturecolumns);
            SetColumns();

            var ChiefGMO = helper.Portfolio.History[1].UpdatedBy;
            var BranchChief = helper.Portfolio.History[0].UpdatedBy;

            var DivisionDirector = helper.Portfolio.History[2].UpdatedBy;
            var NIEHSDirector = helper.Portfolio.History[3].UpdatedBy;

            var BranchChief_ApprovalDate = helper.Portfolio.History[0].UpdateDate.ToString("d");
            var ChiefGMO_ApprovalDate = helper.Portfolio.History[0].UpdateDate.ToString("d");
            var DivisionDirector_ApprovalDate = helper.Portfolio.History[0].UpdateDate.ToString("d");
            var NIEHSDirector_ApprovalDate = helper.Portfolio.History[0].UpdateDate.ToString("d");

            var TitleProxyOrDirector = helper.Portfolio.History[3].ValueOld.Contains("Pending NIEHS Director") ? "Director NIEHS" : "Deputy Director OER";

            var table = new tTable(this, "");
            table.ParentTag = part;
            table.ColumnCount = Columns.Length;

            var dict = new PdfDictionary();

            // row 1
            var cell = new tCell(0, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, BranchChief );
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Branch Chief {0}",BranchChief)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            var row = new tRow();
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, BranchChief_ApprovalDate);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Date {0}", ChiefGMO_ApprovalDate)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, ChiefGMO);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Chief GMO {0}",ChiefGMO)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL,ChiefGMO_ApprovalDate);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Date {0}",BranchChief_ApprovalDate)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);

            // 6, 7
            cell = new tCell(6, "P", DivisionDirector);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Division Director {0}",DivisionDirector)));
            cell.Dictionary = dict;
            cell.Font = GrantFonts.BOLD;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(7, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, DivisionDirector_ApprovalDate);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Date {0}",DivisionDirector_ApprovalDate)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);

            // 9, 10
            cell = new tCell(9, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, NIEHSDirector);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("{0} {1}",TitleProxyOrDirector, NIEHSDirector)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(10, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, NIEHSDirector_ApprovalDate);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString(string.Format("Date {0}", NIEHSDirector_ApprovalDate)));
            cell.Dictionary = dict;
            cell.fontSize = 6.0f;
            row.Add(cell);
            table.Add(row);


            //  row 2
            row = new tRow();
            cell = new tCell();
            cell.MakeDoubleLine(0, 2);
            row.Add(cell);

            cell = new tCell();
            cell.MakeDoubleLine(3, 2);
            row.Add(cell);

            cell = new tCell();
            cell.MakeDoubleLine(6, 2);
            row.Add(cell);

            cell = new tCell();
            cell.MakeDoubleLine(9, 2);
            row.Add(cell);
            table.Add(row);


            // row 3
            row = new tRow();
            cell = new tCell(0, "P", "Branch Chief"); 
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(3, "P", "Chief GMO");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            // 6, 7
            cell = new tCell(6, "P", "Division Director");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(7, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            // 9, 10
            cell = new tCell(9, "P", TitleProxyOrDirector);
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(10, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            cell.fontSize = 6.0f;
            row.Add(cell);
            table.Add(row);

            table.Write();
        }
        private void WriteApplication(tTable table, FDApplication application)
        {
            var row = new tRow(table);

            var cell = new tCell(0, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.IsActive ? "Approved" : "Disapproved");
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(1, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.SpecialType);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(2, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.ProjectNumber);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            var percent = application.IrgPercentileNum == 0 ? "" : application.IrgPercentileNum.ToString();
            cell = new tCell(3, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, percent);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            var priorityscore = application.PriorityScoreNum == 0 ? "" : application.PriorityScoreNum.ToString();
            cell = new tCell(4, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, priorityscore);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(5, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, application.PIName);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(6, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, application.ProjectTitle);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(7, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, application.OrgName);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(8, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, application.POName);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(9, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.RFAPANumber);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(10, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.DirectCostRequestedAmt);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);


            cell = new tCell(11, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, application.ESTotalCostRecommendedAmt);
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            table.Add(row);
        }
        private void WriteApplicationsColumnHeaders(tTable table)
        {
            var row = new tRow(table);

            var cell = new tCell(0, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Approval");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(1, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Type");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(2, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Project Num");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(3, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "% Tile");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(4, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "PS");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(5, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "PI");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(6, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Project Title");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(7, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Institution");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(8, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "PO");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(9, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "FOA");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(10, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "Req DC$");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);

            cell = new tCell(11, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, "ES Rec TC$");
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 6.0f;
            row.Add(cell);


            table.Add(row);
        }
        private void WriteApplicationsHeader(tTable table, string name)
        {
            var row = new tRow(table);
            var cell = new tCell(0, "TH", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, name);
            cell.FontColor = GrantFonts.Black;
            cell.Color = GrantFonts.CMWLightBlue;
            cell.Border = Borders.All;
            cell.fontSize = 8.5f;
            cell.Colspan = 12;
            row.Add(cell);

            table.Add(row);
        }
        /// <summary>
        /// Formats text for details section
        /// </summary>
        public override void GetDetails(PdfStructureElement tag)
        {
            helper.AddLine(1);
            helper.SetMargins(0.75f);
            SetWidths(fourcolumns);
            SetColumns();

            var grant = helper.Grant;

            var table = new tTable(this, "");
            table.ParentTag = tag;

            // row 1
            var cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Application/ Grant:");
            var row = new tRow();
            row.Add(cell);
            row.Add(new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.FullGrantNum));
            row.Add(new tCell(2, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Priority Score/Percentile:"));
            string priority = grant.PriorityScoreNumber.ToString() + "/" + grant.IRGPercentileNum.FormatTwoDecimals();
            row.Add(new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, priority));
            table.Add(row);

            // row 2
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "PI:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.PIName));
            row.Add(new tCell(2, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "SRG:"));
            row.Add(new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.Irgcomb));
            table.Add(row);

            // row 3
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Institution:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.OrgName));
            row.Add(new tCell(2, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "SRO:"));
            row.Add(new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.SRAName));
            table.Add(row);

            // row 4
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Title:");
            row = new tRow();
            row.Add(cell);
            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.ProjectTitle);
            cell.Colspan = 3;
            row.Add(cell);
            table.Add(row);

            //row 5
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Last Competing Council Review Date:");
            row = new tRow();
            row.Add(cell);
            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.OriginalCouncilMeetingDate);
            cell.Colspan = 3;
            row.Add(cell);
            table.Add(row);

            // row 6
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Current Council Review Date:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.CouncilMeetingDate));
            row.Add(new tCell(2, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Program Administrator:"));
            row.Add(new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.ProgramAdmin));
            table.Add(row);

            // row 7
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Council Assignment:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.CouncilAssignment));
            row.Add(new tCell(2, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "RFA/PA#:"));
            row.Add(new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.RFAPANumber));
            table.Add(row);

            // row 8
            var conflictOfinterest = (grant.ConflictOfInterest.Trim().Length > 0) ? grant.ConflictOfInterest.Trim() : "None Known";
            cell = new tCell(0, "H2", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Conflict of Interest:");
            row = new tRow();
            row.Add(cell);
            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, conflictOfinterest);
            cell.Colspan = 3;
            row.Add(cell);
            table.Add(row);
            table.Write();
        }
        /// <summary>
        /// Formats the data for funding details
        /// </summary>
        /// <param name="application">application</param>
        /// <param name="table">table</param>
        public void GetFundingDetails(PdfStructureElement tag)
        {

            float[] fourcolumns = { 1.75f, 1.75f, 1.75f, 1.75f };
            helper.SetMargins(0.75f);
            SetWidths(fourcolumns);
            SetColumns();

            string rHeader = "Funding Details:";
            helper.AddLine(1);
            content.BeginMarkedContentSequence(new PdfStructureElement(tag, new PdfName("H2")));
            content.BeginText();
            content.SetFontAndSize(GrantFonts.bf_times_bold, 12);
            content.ShowTextAligned(it.Element.ALIGN_LEFT, rHeader, document.LeftMargin, helper.CurrentY, 0);
            content.EndText();
            content.EndMarkedContentSequence();
            helper.AddLine();

            var table = new tTable(this, "Table");
            table.ParentTag = tag;

            // row 

            var dict = new PdfDictionary();
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));

            var row = new tRow("TR");
            var cell = new tCell(0, "TH", it.Element.ALIGN_CENTER, GrantFonts.BOLD, "Year");
            cell.Dictionary.Put(PdfName.A, dict);
            row.Add(cell);
            cell = new tCell(1, "TH", it.Element.ALIGN_CENTER, GrantFonts.BOLD, "Direct Cost");
            cell.Dictionary.Put(PdfName.A, dict);
            row.Add(cell);
            cell = new tCell(2, "TH", it.Element.ALIGN_CENTER, GrantFonts.BOLD, "Total Cost");
            cell.Dictionary.Put(PdfName.A, dict);
            row.Add(cell);
            table.Add(row);

            int exist = helper.Grant.FundingDetail.Count;
            int numToAdd = 5 - exist;
            int  lastYear = helper.Grant.FundingDetail.Last().Year;

            for (int ii = 0; ii < numToAdd; ii++)
            {
                int adjust = ii + 1;
                helper.Grant.FundingDetail.Add(new CMWGrantFundingDetail() { Year = lastYear + adjust, DirectCost = 0, TotalCost = 0 });
                
            }

            foreach (var item in helper.Grant.FundingDetail)
            {
                var year = string.Format("{0}", item.Year);
                var dCost = string.Format("{0:C}", item.DirectCost);
                var tCost = string.Format("{0:C}", item.TotalCost);

                row = new tRow("TR");
                cell = new tCell(0, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, year);
                row.Add(cell);
                row.Add(new tCell(1, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, dCost));
                row.Add(new tCell(2, "TD", it.Element.ALIGN_CENTER, GrantFonts.NORMAL, tCost));
                table.Add(row);
            }

            table.Write();
        }
示例#10
0
        public bool Load(string filename)
        {
            GameFile h = new GameFile();

            if (!h.Load(filename))
            {
                return(false);
            }

            FileStream f = null;

            byte[] d = null;

            try
            {
                f = new FileStream(filename, FileMode.Open, FileAccess.Read);

                int c = (int)f.Length;

                if (c > 0)
                {
                    d = new byte[c];

                    f.Read(d, 0, c);
                }
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                f?.Close();
            }

            if (d == null)
            {
                return(false);
            }

            try
            {
                const string ObjectReference = "[Objects]\r\n";

                byte[] b = Encoding.ASCII.GetBytes(ObjectReference);

                int i = Utils.Contains(d, d.Length, b);

                if (i == 0)
                {
                    return(false);
                }

                i += ObjectReference.Length;

                while (d[i] == 0)
                {
                    i++;
                }

                int width = BitConverter.ToInt32(d, i);

                i += 4;

                if (width < 8 || width > 1000)
                {
                    return(false);
                }

                int height = BitConverter.ToInt32(d, i);

                i += 4;

                if (height < 8 || height > 1000)
                {
                    return(false);
                }

                int size = BitConverter.ToInt32(d, i);

                i += 4;

                eVersion version;

                if (d.Length - i == size * 32)
                {
                    version = h.ContainsKey("Classes/CartelRegions", "1") ? eVersion.Sfc2Op : eVersion.Sfc3;
                }
                else if (d.Length - i == size * 28)
                {
                    version = eVersion.Sfc2Eaw;
                }
                else
                {
                    return(false);
                }

                Initialize(version);

                using MemoryStream m = new MemoryStream(d);
                using BinaryReader r = new BinaryReader(m, Encoding.UTF8, true);

                m.Seek(i, SeekOrigin.Begin);

                for (i = 0; i < size; i++)
                {
                    tCell cell = new tCell(version, r);

                    if (cell.Economic > 100)
                    {
                        cell.Economic = 100;
                    }

                    if (cell.Impedence > 2f)
                    {
                        cell.Impedence = 2f;
                    }

                    if (cell.Strength > 200)
                    {
                        cell.Strength = 200;
                    }

                    cell.Region       = GetNormalizedIndex(h, eClass.Regions, cell.Region);
                    cell.CartelRegion = GetNormalizedIndex(h, eClass.CartelRegions, cell.CartelRegion);

                    cell.Terrain = GetNormalizedIndex(h, eClass.Terrain, cell.Terrain);
                    cell.Planet  = GetNormalizedIndex(h, eClass.Planets, cell.Planet);
                    cell.Base    = GetNormalizedIndex(h, eClass.Bases, cell.Base);

                    Cells.Add(cell);
                }

                Version = version;

                Width  = width;
                Height = height;

                return(true);
            }
            catch (Exception)
            { }

            return(false);
        }
        public override void WriteSignatures(PdfStructureElement tag)
        {

            PdfStructureElement part = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(part);
            content.EndMarkedContentSequence();

            helper.AddLine(2);
            helper.SetMargins(1f);
            SetWidths(fivecolumns);
            SetColumns();

            CMWApprovalSignature pAdmin = helper.RFA.ApprovalSignatureBlock.ProgramOfficer;
            CMWApprovalSignature bChief = helper.RFA.ApprovalSignatureBlock.BranchChief;
            CMWApprovalSignature dirOEP = helper.RFA.ApprovalSignatureBlock.DirectorOEP;
            CMWApprovalSignature dirDER = helper.RFA.ApprovalSignatureBlock.DirectorDER;

            var table = new tTable(this, "");
            table.ParentTag = part;
            table.ColumnCount = Columns.Length;

            var dict = new PdfDictionary();

            // row 1
            var cell = new tCell(0, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, pAdmin.FullName);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Program Administrator " + pAdmin.FullName));
            cell.Dictionary = dict;
            var row = new tRow();
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, pAdmin.ApprovalDate.ToString("d"));
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Date " + pAdmin.ApprovalDate.ToString("d")));
            cell.Dictionary = dict;
            row.Add(cell);

            cell = new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, bChief.FullName);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Branch Chief " + bChief.FullName));
            cell.Dictionary = dict;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, bChief.ApprovalDate.ToString("d"));
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Date " + bChief.ApprovalDate.ToString("d")));
            cell.Dictionary = dict;
            row.Add(cell);
            table.Add(row);

            //  row 2
            row = new tRow();
            cell = new tCell();
            cell.MakeDoubleLine(0, 2);
            row.Add(cell);

            cell = new tCell();
            cell.MakeDoubleLine(3, 2);
            row.Add(cell);
            table.Add(row);

            // row 3
            row = new tRow();
            cell = new tCell(0, "P", "Program Administrator");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(3, "P", "Branch Chief");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            row.Add(cell);
            table.Add(row);

            // row 4
            row = new tRow();
            table.Add(row);

            // row 5
            row = new tRow();
            cell = new tCell(0, "P", dirOEP.FullName);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Director, Office of Extramural Policy " + dirOEP.FullName));
            cell.Dictionary = dict;
            cell.Font = GrantFonts.BOLD;
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, dirOEP.ApprovalDate.ToString("d"));
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Date " + dirOEP.ApprovalDate.ToString("d")));
            cell.Dictionary = dict;
            row.Add(cell);

            string dirDERFullName = (dirDER.IsProxy == false) ? dirDER.FullName : dirDER.FullName + @" for Director, Division of Extramural Research";
            cell = new tCell(3, "P", it.Element.ALIGN_LEFT, GrantFonts.BOLD, dirDERFullName);
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Director, Division of Extramural Research " + dirDERFullName));
            cell.Dictionary = dict;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, dirDER.ApprovalDate.ToString("d"));
            dict = new PdfDictionary();
            dict.Put(PdfName.ACTUALTEXT, new PdfString("Date " + dirDER.ApprovalDate.ToString("d")));
            cell.Dictionary = dict;
            row.Add(cell);
            table.Add(row);

            // row 6
            row = new tRow();
            cell = new tCell();
            cell.MakeDoubleLine(0, 2);
            row.Add(cell);

            cell = new tCell();
            cell.MakeDoubleLine(3, 2);
            row.Add(cell);
            table.Add(row);

            // row 7
            row = new tRow();
            cell = new tCell(0, "P", "Director, Office of Extramural Policy");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(1, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(3, "P", "Director, Division of Extramural Research");
            cell.isSpoken = false;
            row.Add(cell);

            cell = new tCell(4, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, "Date");
            cell.isSpoken = false;
            row.Add(cell);
            table.Add(row);

            table.Write();
            AddSignatureComment(part, dirDER);
        }
        /// <summary>
        /// Writes Complex Application Funding Table
        /// </summary>
        public void WriteAppFundingDetails(PdfStructureElement tag)
        {
            int TotalNICHD_DC = 0;
            int TotalOtherIC_DC = 0;
            int TotalGrand_DC = 0;

            int TotalNICHD_TC = 0;
            int TotalOtherIC_TC = 0;
            int TotalGrand_TC = 0;

            // Create part
            PdfStructureElement partFunding = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(partFunding);
            content.EndMarkedContentSequence(); // end grant table

            // write the section header including the set aside amount

            helper.AddLine(2);
            string rHeader = "5. Funding Details:";
            content.BeginMarkedContentSequence(new PdfStructureElement(partFunding, new PdfName("H2")));
            content.BeginText();
            content.SetFontAndSize(GrantFonts.bf_times_bold, 12);
            content.ShowTextAligned(it.Element.ALIGN_LEFT, rHeader, document.LeftMargin, helper.CurrentY, 0);
            content.EndText();
            content.EndMarkedContentSequence();
            helper.AddLine();
            rHeader = "Set Aside =" + string.Format("$ {0:#,0}", helper.RFA.SAFundSetAside);
            content.BeginMarkedContentSequence(new PdfStructureElement(partFunding, new PdfName("P")));
            content.BeginText();
            content.SetFontAndSize(GrantFonts.bf_times_bold, 12);
            content.ShowTextAligned(it.Element.ALIGN_LEFT, rHeader, document.LeftMargin, helper.CurrentY, 0);
            content.EndText();
            content.EndMarkedContentSequence();

            helper.AddLine(2);
            helper.SetMargins(0.75f);
            SetWidths(sevencolumns);
            SetColumns();

            var dict = new PdfDictionary();
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(PdfName.ID, new PdfString("funding_details"));
            dict.Put(PdfName.COLSPAN, new PdfNumber(7));
            var list = new PdfArray();

            // New Title Row for the table
            var table = new tTable(this, "Table");
            table.ParentTag = partFunding;
            /*  FUNDING DETAILS  */
            var row = new tRow("TR");
            var cell = new tCell(0, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "FUNDING DETAILS");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Colspan = 7;
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);

            /*  FUNDING DETAILS COLUMNS  */
            dict = new PdfDictionary();                                                             /* dictionary PS */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("ps"));

            row = new tRow("TR");
            cell = new tCell(0, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "PS");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary INSTITUTION */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("institution"));


            cell = new tCell(1, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Institution");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary TITLE */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("title"));

            cell = new tCell(2, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Title");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary PI REQUESTED DC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("pi"));

            cell = new tCell(3, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "PI Requested DC");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary FUNDING IC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("funding_ic"));

            cell = new tCell(4, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Funding IC");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary STAFF REC DIRECT COST */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("staff_dc"));

            cell = new tCell(5, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Staff Rec Direct Cost");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary STAFF REC TOTAL COSTS*/
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            dict.Put(PdfName.ID, new PdfString("staff_tc"));

            cell = new tCell(6, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Staff Rec Total Costs");
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);

            //mainTable = table.ChildTag;

            for (int ii = 0; ii < helper.RFA.Grants.Count(); ii++)
            {
                var grant = helper.RFA.Grants[ii];

                dict = new PdfDictionary();                                                             /* dictionary APPLICATION DETAILS */
                dict.Put(PdfName.O, PdfName.TABLE);
                dict.Put(new PdfName("Scope"), new PdfName("Column"));
                dict.Put(PdfName.ID, new PdfString(grant.FullGrantNum));
                dict.Put(PdfName.COLSPAN, new PdfNumber(7));

                cell = new tCell(0, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "Application Details for " + grant.FullGrantNum + "/ " + grant.PIName);
                cell.Dictionary.Put(PdfName.A, dict);
                cell.Border = Borders.All;
                cell.Color = GrantFonts.CMWLightBlue;
                cell.fontSize = 9.5f;
                cell.Colspan = 7;
                row = new tRow("TR");
                row.Add(cell);
                table.Add(row);

                /*  FUNDING DETAILS LINE ITEMS */
                for (int jj = 0; jj < grant.FundingDetail.Count(); jj++)
                {
                    var detail = grant.FundingDetail[jj];

                    if (jj == 0)        //////////////////////////////////////////////////////                                                                                                                                                          FIRST ROW
                    {
                        row = new tRow("TR");

                        dict = new PdfDictionary();                                                             /* dictionary  PS */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("ps"));
                        list.Add(new PdfString("funding_details"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(0, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.PriorityScoreNumber.ToString());
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        //PS

                        dict = new PdfDictionary();                                                             /* dictionary INSTITUTION */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("institution"));
                        list.Add(new PdfString("funding_details"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(1, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.OrgName);
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        // Institution

                        dict = new PdfDictionary();                                                             /* dictionary TITLE */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("title"));
                        list.Add(new PdfString("funding_details"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(2, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.ProjectTitle);
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        // Title

                        dict = new PdfDictionary();                                                             /* dictionary PI */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("pi"));
                        list.Add(new PdfString("funding_details"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(3, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", grant.SRGDirectCost));
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        // PI Requested DC

                        dict = new PdfDictionary();                                                             /* dictionary FUNDING IC */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("funding_ic"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        list.Add(new PdfString("funding_details"));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(4, "TD", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, detail.SourceName);
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        //// Funding IC

                        dict = new PdfDictionary();                                                             /* dictionary STAFF REC DIRECT COST */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("staff_dc"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        list.Add(new PdfString("funding_details"));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(5, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", detail.DirectCost));
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        //// Staff Rec Direct Cost

                        dict = new PdfDictionary();                                                             /* dictionary STAFF REC TOTAL COST */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("staff_tc"));
                        list.Add(new PdfString(grant.FullGrantNum));
                        list.Add(new PdfString("funding_details"));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(6, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", detail.TotalCost));
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        table.Add(row);
                        // Staff Rec Total Costs
                    }
                    else        //////////////////////////////////////////////////////                                                                                                                                                          NOT THE FIRST ROW
                    {
                        row = new tRow("TR");

                        cell = new tCell();
                        cell.MakeEmpty(0, 1);
                        cell.Border = Borders.All;
                        row.Add(cell);
                        //PS

                        cell = new tCell();
                        cell.MakeEmpty(1, 1);
                        cell.Border = Borders.All;
                        row.Add(cell);
                        // Institution

                        cell = new tCell();
                        cell.MakeEmpty(2, 1);
                        cell.Border = Borders.All;
                        row.Add(cell);
                        // Title

                        cell = new tCell();
                        cell.MakeEmpty(3, 1);
                        cell.Border = Borders.All;
                        row.Add(cell);
                        // PI Requested DC

                        string sourceID = grant.FullGrantNum + "_" + detail.SourceName;

                        dict = new PdfDictionary();                                                             /* dictionary  FUNDING IC*/
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Row"));
                        dict.Put(PdfName.ID, new PdfString(sourceID));
                        dict.Put(PdfName.COLSPAN, new PdfNumber(5));

                        cell = new tCell(4, "TH", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, detail.SourceName);
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        //// Funding IC


                        dict = new PdfDictionary();                                                             /* dictionary STAFF REC DIRECT COST*/
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("staff_dc"));
                        list.Add(new PdfString(sourceID));
                        list.Add(new PdfString(grant.FullGrantNum));
                        list.Add(new PdfString("funding_details"));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(5, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", detail.DirectCost));
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        //// Staff Rec Direct Cost

                        dict = new PdfDictionary();                                                             /* dictionary STAFF REC TOTAL COST */
                        dict.Put(PdfName.O, PdfName.TABLE);
                        dict.Put(new PdfName("Scope"), new PdfName("Column"));
                        list = new PdfArray();
                        list.Add(new PdfString("staff_tc"));
                        list.Add(new PdfString(sourceID));
                        list.Add(new PdfString(grant.FullGrantNum));
                        list.Add(new PdfString("funding_details"));
                        dict.Put(PdfName.HEADERS, list);

                        cell = new tCell(6, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", detail.TotalCost));
                        cell.Dictionary.Put(PdfName.A, dict);
                        cell.Border = Borders.All;
                        cell.VerticalAlign = it.Element.ALIGN_BOTTOM;
                        cell.fontSize = 9.5f;
                        row.Add(cell);
                        table.Add(row);
                        // Staff Rec Total Costs
                    }


                    /*
                                                                                                                                Direct and Total Costs
                    */
                    if (detail.SourceName.Trim().Equals("NICHD", StringComparison.InvariantCultureIgnoreCase))
                    {
                        TotalNICHD_DC += detail.DirectCost;
                        TotalNICHD_TC += detail.TotalCost;
                    }
                    else
                    {
                        TotalOtherIC_DC += detail.DirectCost;
                        TotalOtherIC_TC += detail.TotalCost;
                    }
                    TotalGrand_DC += detail.DirectCost;
                    TotalGrand_TC += detail.TotalCost;
                }
            }

            /*  FUNDING TOTALS */
            row = new tRow("TR");

            dict = new PdfDictionary();                                                             /* dictionary FUNDING TOTALS */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(PdfName.ID, new PdfString("funding_totals"));
            dict.Put(PdfName.COLSPAN, new PdfNumber(7));

            cell = new tCell(0, "TH", it.Element.ALIGN_LEFT, GrantFonts.BOLD, "FUNDING TOTALS");
            cell.Dictionary = dict;
            cell.Colspan = 7;
            cell.FontColor = GrantFonts.White;
            cell.Color = GrantFonts.CMWBlue;
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);
            // Funding Totals

            /*  FUNDING TOTALS LINE ITEMS*/
            dict = new PdfDictionary();                                                             /* dictionary Total NICHD */
            dict.Put(PdfName.ID, new PdfString("total_nichd"));
            dict.Put(PdfName.COLSPAN, new PdfNumber(5));
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Row"));

            row = new tRow("TR");
            cell = new tCell(0, "TH", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Total NICHD");
            cell.Colspan = 5;
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            // Total NICHD

            dict = new PdfDictionary();                                                             /* dictionary DC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_dc"));
            list.Add(new PdfString("funding_totals"));
            list.Add(new PdfString("total_nichd"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(5, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalNICHD_DC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary TC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_tc"));
            list.Add(new PdfString("funding_totals"));
            list.Add(new PdfString("total_nichd"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(6, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalNICHD_TC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);

            dict = new PdfDictionary();                                                             /* dictionary Total From All Other ICs*/
            dict.Put(PdfName.ID, new PdfString("total_from"));
            dict.Put(PdfName.COLSPAN, new PdfNumber(5));
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Row"));

            row = new tRow("TR");
            cell = new tCell(0, "TH", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Total From All Other ICs");
            cell.Colspan = 5;
            cell.fontSize = 9.5f;
            cell.Border = Borders.All;
            row.Add(cell);
            // Total From All Other ICs

            dict = new PdfDictionary();                                                             /* dictionary DC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_dc"));
            list.Add(new PdfString("total_from"));
            list.Add(new PdfString("funding_totals"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(5, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalOtherIC_DC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary TC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_tc"));
            list.Add(new PdfString("total_from"));
            list.Add(new PdfString("funding_totals"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(6, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalOtherIC_TC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);

            dict = new PdfDictionary();                                                             /* dictionary GRAND TOTAL */
            dict.Put(PdfName.ID, new PdfString("grand_total"));
            dict.Put(PdfName.COLSPAN, new PdfNumber(5));
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Row"));

            row = new tRow("TR");
            cell = new tCell(0, "TH", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "GRAND TOTAL");
            cell.Colspan = 5;
            cell.fontSize = 9.5f;
            cell.Border = Borders.All;
            row.Add(cell);
            // GRAND TOTAL

            dict = new PdfDictionary();                                                             /* dictionary DC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_dc"));
            list.Add(new PdfString("grand_total"));
            list.Add(new PdfString("funding_totals"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(5, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalGrand_DC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);

            dict = new PdfDictionary();                                                             /* dictionary TC */
            dict.Put(PdfName.O, PdfName.TABLE);
            dict.Put(new PdfName("Scope"), new PdfName("Column"));
            list = new PdfArray();
            list.Add(new PdfString("staff_tc"));
            list.Add(new PdfString("grand_total"));
            list.Add(new PdfString("funding_totals"));
            dict.Put(PdfName.HEADERS, list);

            cell = new tCell(6, "TD", it.Element.ALIGN_RIGHT, GrantFonts.NORMAL, string.Format("$ {0:#,0}", TotalGrand_TC));
            cell.Dictionary.Put(PdfName.A, dict);
            cell.Border = Borders.All;
            cell.fontSize = 9.5f;
            row.Add(cell);
            table.Add(row);

            table.Write();
        }
        /// <summary>
        /// Get Details for Application Recommendation
        /// </summary>
        public void GetDetailsAppRecommendation(PdfStructureElement tag, CMWGrant grant)
        {
            PdfStructureElement partIndiv = new PdfStructureElement(tag, new PdfName("Part"));
            content.BeginMarkedContentSequence(partIndiv);
            content.EndMarkedContentSequence();

            var table = new tTable(this, "");
            table.ParentTag = partIndiv;

            // row 1
            var cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Application/Grant #:");
            var row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.FullGrantNum));
            table.Add(row);

            // row 2
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Principal Investigator:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.PIName));
            table.Add(row);

            // row 3
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Institution:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.OrgName));
            table.Add(row);

            // row 4
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Title:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, grant.ProjectTitle));
            table.Add(row);

            var numerator = new NICHDMATH(grant.PriorityScoreNumber);
            var denominator = new NICHDMATH(grant.IRGPercentileNum);
            var answer = numerator / denominator;

            // row 4
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, @"PS/%ile:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, answer.Value.ToString()));
            table.Add(row);
            table.Write();

            string rHeader = "Recommendation:";
            helper.AddLine(2);
            content.BeginMarkedContentSequence(new PdfStructureElement(partIndiv, new PdfName("H2")));
            content.BeginText();
            content.SetFontAndSize(GrantFonts.bf_times_bold, 12);
            content.ShowTextAligned(it.Element.ALIGN_LEFT, rHeader, document.LeftMargin, helper.CurrentY, 0);
            content.EndText();
            content.EndMarkedContentSequence();

            helper.AddLine(2);
            float YPosition = AddTextAppRecommendation(partIndiv, grant, helper.CurrentY);
            helper.GetLineFromY(YPosition);

        }
        /// <summary>
        /// Get Details for Competition
        /// </summary>
        public void GetDetailsCompetition(PdfStructureElement tag)
        {
            helper.AddLine(1);
            helper.SetMargins(0.75f);
            SetWidths(threecolumns);
            SetColumns();

            var table = new tTable(this, "");
            table.ParentTag = tag;

            // row 1
            var cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Application Received:");
            var row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.AppsReceived.ToString()));
            table.Add(row);


            // row 2
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Nonresponsive Applications:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.AppsNonResponsive.ToString()));
            table.Add(row);


            // row 4
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Noncompetitive Applications:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.AppsNonCompetitive.ToString()));
            table.Add(row);

            // row 5
            cell = new tCell(0, "H2", it.Element.ALIGN_RIGHT, GrantFonts.BOLD, "Competitive Applications:");
            row = new tRow();
            row.Add(cell);
            row.Add(new tCell(2, "P", it.Element.ALIGN_LEFT, GrantFonts.NORMAL, helper.RFA.AppsCompetitive.ToString()));
            table.Add(row);

            table.Write();
        }
示例#15
0
        public static bool APlus(int MapNum, int SX, int SY, int TX, int TY, eCell FreeCell, ref tPoint[] Path)
        {
            bool APlus = false;
            // A+ Pathfinding Algorithm:
            // Implementation by Herbert Glarner ([email protected])
            // Unlimited use for whatever purpose allowed provided that above credits are given.
            // Suggestions and bug reports welcome.
            int   lMaxList = 0;
            int   lActList;
            float sCheapCost; int lCheapIndex;
            float sTotalCost;
            int   lCheapX, lCheapY;
            int   lOffX, lOffY;
            int   lTestX, lTestY;
            int   lMaxX, lMaxY;
            float sAdditCost;
            int   lPathPtr;

            // The test program wants to access this grid. For this reason it is defined
            // and initialized globally. Usually one would define and initialize it only
            // in this procedure.
            // The two fields of tGrid can also be merged into the source matrix.
            // Dim abGridCopy() As tGrid

            const float cSqr2 = 1.4142135623731f;

            // Define the upper boundaries of the grid.
            lMaxX = Information.UBound(mapMatrix[MapNum].gaeGrid, 1); lMaxY = Information.UBound(mapMatrix[MapNum].gaeGrid, 2);

            // For each cell of the grid a bit is defined to hold it's "closed" status
            // and the index to the Open-List.
            // The test program wants to access this grid. For this reason it is defined
            // and initialized globally. Usually one would define and initialize it only
            // in this procedure. (Don't omit here: we need an empty matrix.)
            tGrid[,] abGridCopy = new tGrid[lMaxX + 1, lMaxY + 1];

            // The starting point is added to the working list. It has no parent (-1).
            // The cost to get here is 0 (we start here). The direct distance enters
            // the Heuristic.
            tCell[] grList = new tCell[0 + 1];

            grList[0].x         = SX; grList[0].y = SY; grList[0].Parent = -1; grList[0].Cost = 0;
            grList[0].Heuristic = (float)(Math.Sqrt((TX - SX) * (TX - SX) + (TY - SY) * (TY - SY)));


            // Start the algorithm
            for (;;)
            {
                // Get the cell with the lowest Cost+Heuristic. Initialize the cheapest cost
                // with an impossible high value (change as needed). The best found index
                // is set to -1 to indicate "none found".
                sCheapCost  = 10000000;
                lCheapIndex = -1;
                // Check all cells of the list. Initially, there is only the start point,
                // but more will be added soon.
                for (lActList = 0; lActList <= lMaxList; lActList++)
                {
                    // Only check if not closed already.
                    if (!grList[lActList].Closed)
                    {
                        // If this cells total cost (Cost+Heuristic) is lower than the so
                        // far lowest cost, then store this total cost and the cell's index
                        // as the so far best found.
                        sTotalCost = grList[lActList].Cost + grList[lActList].Heuristic;
                        if (sTotalCost < sCheapCost)
                        {
                            // New cheapest cost found.
                            sCheapCost = sTotalCost; lCheapIndex = lActList;
                        }
                    }
                }                 // lActList

                // lCheapIndex contains the cell with the lowest total cost now.
                // If no such cell could be found, all cells were already closed and there
                // is no path at all to the target.
                if (lCheapIndex == -1)
                {
                    // There is no path.
                    APlus = false; return(APlus);
                }

                // Get the cheapest cell's coordinates
                lCheapX = grList[lCheapIndex].x;
                lCheapY = grList[lCheapIndex].y;

                // If the best field is the target field, we have found our path.
                if (lCheapX == TX & lCheapY == TY)
                {
                    // Path found.
                    break;
                }

                // Check all immediate neighbors
                for (lOffY = -1; lOffY <= 1; lOffY++)
                {
                    for (lOffX = -1; lOffX <= 1; lOffX++)
                    {
                        // Ignore the actual field, process all others (8 neighbors).
                        if (lOffX != 0 | lOffY != 0)
                        {
                            if (!modTypes.Options.allowEightDirectionalMovement && !(lOffX != 0 & lOffY != 0))
                            {
                                continue;
                            }
                            // Get the neighbor's coordinates.
                            lTestX = lCheapX + lOffX; lTestY = lCheapY + lOffY;
                            // Don't test beyond the grid's boundaries.
                            if (lTestX >= 0 & lTestX <= lMaxX & lTestY >= 0 & lTestY <= lMaxY)
                            {
                                // The cell is within the grid's boundaries.
                                // Make sure the field is accessible. To be accessible,
                                // the cell must have the value as per the function
                                // argument FreeCell (change as needed). Of course, the
                                // target is allowed as well.
                                if (mapMatrix[MapNum].gaeGrid[lTestX, lTestY] == FreeCell || mapMatrix[MapNum].gaeGrid[lTestX, lTestY] == eCell.target)
                                {
                                    // The cell is accessible.
                                    // For this we created the "bitmatrix" abGridCopy().
                                    if (abGridCopy[lTestX, lTestY].ListStat == eListStat.Unprocessed)
                                    {
                                        // Register the new cell in the list.
                                        lMaxList += 1;
                                        Array.Resize(ref grList, lMaxList + 1);

                                        // The parent is where we come from (the cheapest field);
                                        // it's index is registered.
                                        grList[lMaxList].x = lTestX; grList[lMaxList].y = lTestY; grList[lMaxList].Parent = lCheapIndex;
                                        // Additional cost is 1 for othogonal movement, cSqr2 for
                                        // diagonal movement (change if diagonal steps should have
                                        // a different cost).
                                        if (Math.Abs(lOffX) + Math.Abs(lOffY) == 1)
                                        {
                                            sAdditCost = (float)(1.0);
                                        }
                                        else
                                        {
                                            sAdditCost = cSqr2;
                                        }
                                        // Store cost to get there by summing the actual cell's cost
                                        // and the additional cost.
                                        grList[lMaxList].Cost = grList[lCheapIndex].Cost + sAdditCost;
                                        // Calculate distance to target as the heuristical part
                                        grList[lMaxList].Heuristic = (float)(Math.Sqrt((TX - lTestX) * (TX - lTestX) + (TY - lTestY) * (TY - lTestY)));

                                        // Register in the Grid copy as open.
                                        abGridCopy[lTestX, lTestY].ListStat = eListStat.IsOpen;
                                        // Also register the index to quickly find the element in the
                                        // "closed" list.
                                        abGridCopy[lTestX, lTestY].Index = lMaxList;
                                    }
                                    else if (abGridCopy[lTestX, lTestY].ListStat == eListStat.IsOpen)
                                    {
                                        // Is the cost to get to this already open field cheaper when using
                                        // this path via lTestX/lTestY ?
                                        lActList   = abGridCopy[lTestX, lTestY].Index;
                                        sAdditCost = (float)((Math.Abs(lOffX) + Math.Abs(lOffY) == 1 ? 1.0 : cSqr2));
                                        if (grList[lCheapIndex].Cost + sAdditCost < grList[lActList].Cost)
                                        {
                                            // The cost to reach the already open field is lower via the
                                            // actual field.

                                            // Store new cost
                                            grList[lActList].Cost = grList[lCheapIndex].Cost + sAdditCost;
                                            // Store new parent
                                            grList[lActList].Parent = lCheapIndex;
                                        }
                                        // ElseIf abGridCopy(lTestX, lTestY) = IsClosed Then
                                        // This cell can be ignored
                                    }
                                }
                            }
                        }
                    }             // lOffX
                }                 // lOffY
                // Close the just checked cheapest cell.
                grList[lCheapIndex].Closed            = true;
                abGridCopy[lCheapX, lCheapY].ListStat = eListStat.IsClosed;
            }

            // The path can be found by backtracing from the field TX/TY until SX/SY.
            // The path is traversed in backwards order and stored reversely (!) in
            // the "argument" Path().
            Path     = new tPoint[0 + 1];
            lPathPtr = -1;
            // lCheapIndex (lCheapX/Y) initially contains the target TX/TY
            do
            {
                // Store the coordinates of the current cell
                lPathPtr += 1;
                Array.Resize(ref Path, lPathPtr + 1);
                Path[lPathPtr].x = grList[lCheapIndex].x;
                Path[lPathPtr].y = grList[lCheapIndex].y;
                // Follow the parent
                lCheapIndex = grList[lCheapIndex].Parent;
            } while (lCheapIndex != -1);

            Console.WriteLine("Path found");

            APlus = true;
            return(APlus);
        }