Exemple #1
0
        public PagiPlanDataPage GetPageObject(int pageIndex)
        {
            for (int i = 0; i < pageList.Count; i++)
            {
                PagiPlanDataPage p = pageList[i];
                if (pageIndex == p.pageIndex)
                {
                    return(p);
                }
            }

            return(null);
        }
Exemple #2
0
        public PagiPlanDataPage GetPageObject(string pageName)
        {
            for (int i = 0; i < pageList.Count; i++)
            {
                PagiPlanDataPage p = pageList[i];
                if (pageName == p.pageName)
                {
                    return(p);
                }
            }

            return(null);
        }
Exemple #3
0
        public bool ParseFile(string pageFileName, ref int paginationstart)
        {
            paginationstart = 1;
            string [] lines;

            if (File.Exists(pageFileName) == false)
            {
                return(false);
            }

            try
            {
                lines = File.ReadAllLines(pageFileName);
            }
            catch
            {
                return(false);
            }

            int pageoffset = -1;

            string thisEdition      = "";
            string thisSection      = "";
            int    pageCount        = 1;
            int    pageIndex        = 1;
            PagiPlanDataSection sec = null;
            PagiPlanDataEdition ed  = null;

            foreach (string line in lines)
            {
                string[] elements = line.Split('\t');
                if (elements.Length < 15)
                {
                    continue;
                }

                if (elements[PAGI_EDITION] != thisEdition)
                {
                    ed = new PagiPlanDataEdition(elements[PAGI_EDITION]);
                    ed.masterEdition  = (elements[PAGI_EDITION] == elements[PAGI_MASTEREDITION]);
                    ed.editionComment = ed.editionName;


                    plan.editionList.Add(ed);
                    thisEdition = ed.editionName;
                }

                string section = elements[PAGI_SECTION];
                if (section.IndexOf("SUP") < 0)
                {
                    section = "Main";
                }

                if (section != thisSection)
                {
                    sec = new PagiPlanDataSection(section);
                    sec.pagesInSection = 0;

                    ed.sectionList.Add(sec);
                    pageCount   = 1;
                    thisSection = section;
                }

                PagiPlanDataPage page = new PagiPlanDataPage(elements[PAGI_PAGENAME]);
                page.fileName      = elements[PAGI_FILENAME];
                page.masterEdition = elements[PAGI_MASTEREDITION];
                page.pageIndex     = Globals.TryParse(elements[PAGI_PAGEINDEX], pageCount);

                int pagination = Globals.TryParse(elements[PAGI_PAGINATION], pageCount++);
                if (pageoffset == -1)
                {
                    pageoffset = pagination;
                }

                // Adjust pagination for covers to start at 1
                page.pagination = pagination - (pageoffset - 1);
                if (pagination > 1)
                {
                    page.pageIndex = page.pagination;
                }
                page.priority   = Globals.TryParse(elements[PAGI_PRIORITY], 0);
                page.uniquePage = (elements[PAGI_UNIQUEPAGE] == "X") ? PageUniqueType.Unique : PageUniqueType.Common;
                page.pageType   = (elements[PAGI_PAGETYPE] != "") ? PageType.Panorama : PageType.Normal;

                page.monoPage    = elements[PAGI_COLORS] != "Q";
                page.comment     = elements[PAGI_PAGENAMECOMMENT];
                page.miscstring1 = elements[PAGI_LAYOUT];
                page.miscstring2 = elements[PAGI_PLATETEXT];
                page.version     = 0;

                page.pageID       = pageIndex.ToString();
                page.masterPageID = pageIndex.ToString();
                pageIndex++;

                plan.publicationDate  = String2DateTime(elements[PAGI_PUBDATE]);
                plan.publicationName  = elements[PAGI_PUBLICATION];
                plan.publicationAlias = plan.publicationName;

                if (elements.Length > 16)
                {
                    plan.publicationAlias = elements[PAGI_PECOMPUBLICATION];
                }

                if (elements.Length > 17)
                {
                    ed.editionComment = elements[PAGI_PECOMEDITION];
                }

                sec.pageList.Add(page);
            }

            ResolveCommonPages();

            paginationstart = pageoffset > 0 ? pageoffset : 1;

            return(true);
        }