示例#1
0
 public static void AddSectionHeader(ContactListData.ContactGroup data)
 {
     // Adds a section header to the current Y coordinate of the current page
     currentFirstI = data.Letter;
     currentPage.Elements.Add(new Label("- " + currentFirstI + " -", 0, currentY + 6, 720, 18, Font.HelveticaBold, 18, TextAlign.Center));
     currentY   += 26;
     alternateBG = false;
 }
示例#2
0
        public static void AddRecord(Document document, ContactListData.ContactGroup contactGroup)
        {
            // Creates TextAreas that are expandable
            foreach (var data in contactGroup.Contacts)
            {
                TextArea companyName  = new TextArea(data.CompanyName, 62, currentY + 3, 156, 11, Font.TimesRoman, 11);
                TextArea contactName  = new TextArea(data.ContactName, 222, currentY + 3, 136, 11, Font.TimesRoman, 11);
                TextArea contactTitle = new TextArea(data.ContactTitle, 362, currentY + 3, 156, 11, Font.TimesRoman, 11);

                // Gets the height required for the current record
                float requiredHeight = SetExpandableRecords(document, contactGroup, companyName, contactName, contactTitle);

                // Creates non expandable Labels
                Label customerID = new Label(data.CustomerID, 2, currentY + 3, 58, 11, Font.TimesRoman, 11);
                Label phone      = new Label(data.Phone, 522, currentY + 3, 96, 11, Font.TimesRoman, 11);
                Label fax        = new Label(data.Fax == null ? "" : data.Fax, 622, currentY + 3, 96, 11, Font.TimesRoman, 11);

                // Adds alternating background if required
                if (alternateBG)
                {
                    currentPage.Elements.Add(new Rectangle(0, currentY, 720, requiredHeight + 6, RgbColor.Black, new WebColor("E0E0FF"), 0.0F));
                }

                // Toggles alternating background
                alternateBG = !alternateBG;

                // Adds elements to the current page
                currentPage.Elements.Add(customerID);
                currentPage.Elements.Add(companyName);
                currentPage.Elements.Add(contactName);
                currentPage.Elements.Add(contactTitle);
                currentPage.Elements.Add(phone);
                currentPage.Elements.Add(fax);

                // increments the current Y position on the page
                currentY += requiredHeight + 6;
            }
        }
示例#3
0
        public static float SetExpandableRecords(Document document, ContactListData.ContactGroup data, TextArea companyName, TextArea contactName, TextArea contactTitle)
        {
            // Gets the maximum height requred of the three TextAreas
            float requiredHeight = GetMaxRecordHeight(companyName, contactName, contactTitle);

            // Add space for the section header if required
            float sectionHeaderHeight = 0;

            if (currentFirstI != data.Letter)
            {
                sectionHeaderHeight = 26;
            }

            // Add a new page if needed
            if (bodyBottom < currentY + requiredHeight + sectionHeaderHeight + 4)
            {
                AddNewPage(document);
                if (sectionHeaderHeight == 0)
                {
                    // Update Y coordinate of TextArea when placed on the new page
                    companyName.Y  = currentY + 3;
                    contactName.Y  = currentY + 3;
                    contactTitle.Y = currentY + 3;
                }
            }

            // Add section header if required
            if (sectionHeaderHeight > 0)
            {
                AddSectionHeader(data);
                companyName.Y  = currentY + 3;
                contactName.Y  = currentY + 3;
                contactTitle.Y = currentY + 3;
            }
            return(requiredHeight);
        }