Ejemplo n.º 1
0
        private void NewLoad()
        {
            layoutTab      = new LayoutTab(pathTexFile);
            layoutTab.Dock = DockStyle.Fill;

            chapterTab      = new SectionTab(pathTexFile, "Chapter");
            chapterTab.Dock = DockStyle.Fill;

            sectionTab      = new SectionTab(pathTexFile, "Section");
            sectionTab.Dock = DockStyle.Fill;

            subSectionTab      = new SectionTab(pathTexFile, "Subsection");
            subSectionTab.Dock = DockStyle.Fill;

            subSubSectionTab      = new SectionTab(pathTexFile, "Subsubsection");
            subSubSectionTab.Dock = DockStyle.Fill;

            paragraphTab      = new SectionTab(pathTexFile, "Paragraph");
            paragraphTab.Dock = DockStyle.Fill;

            subParagraphTab      = new SectionTab(pathTexFile, "Subparagraph");
            subParagraphTab.Dock = DockStyle.Fill;

            titleTab      = new TitleTab(pathTexFile, "Title");
            titleTab.Dock = DockStyle.Fill;

            authorTab      = new TitleTab(pathTexFile, "Author");
            authorTab.Dock = DockStyle.Fill;

            dateTab      = new TitleTab(pathTexFile, "Date");
            dateTab.Dock = DockStyle.Fill;

            tocTab      = new TocTab(pathTexFile, "toc");
            tocTab.Dock = DockStyle.Fill;

            lofTab      = new TocTab(pathTexFile, "lof");
            lofTab.Dock = DockStyle.Fill;

            lotTab      = new TocTab(pathTexFile, "lot");
            lotTab.Dock = DockStyle.Fill;

            abstactTab      = new AbstractTab(pathTexFile);
            abstactTab.Dock = DockStyle.Fill;

            allTocTab      = new AllTocTab(pathTexFile);
            allTocTab.Dock = DockStyle.Fill;

            figureTab      = new FigureTab(pathTexFile, "figure");
            figureTab.Dock = DockStyle.Fill;

            tableTab      = new FigureTab(pathTexFile, "table");
            tableTab.Dock = DockStyle.Fill;

            tvMenu.SelectedNode = null;
        }
Ejemplo n.º 2
0
        public void ChangeBaseClass(string baseCls)
        {
            try
            {
                TreeNode chapterNode = new TreeNode();
                chapterNode.Name = "tnChapter";
                chapterNode.Text = "Chapter Style";
                List <string> lst = new List <string>();
                string        txt = MainService.ReadLatexFile(Constants.DocClsName, ".cls", pathTexFile);
                lst = txt.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList();
                int findIndex = -1;

                if (baseCls == "article")
                {
                    cls = "article";

                    if (tvMenu.Nodes["tnChapter"] != null)
                    {
                        tvMenu.Nodes["tnChapter"].Remove();
                    }

                    findIndex = lst.FindIndex(x => x.StartsWith(@"\renewcommand\abstractname"));
                    if (findIndex >= 0)
                    {
                        if (lst[findIndex].Contains(@"\flushleft"))
                        {
                            lst[findIndex] = lst[findIndex].Replace(@"}}", @"}\hfill}");
                            lst[findIndex] = lst[findIndex].Replace(@"\flushleft", "");
                        }
                        else if (lst[findIndex].Contains(@"\flushright)"))
                        {
                            lst[findIndex] = lst[findIndex].Replace(@"\flushright", @"\hfill");
                        }
                        else
                        {
                            lst[findIndex] = lst[findIndex].Replace(@"}}", @"}\hfill}");
                            lst[findIndex] = lst[findIndex].Replace(@"\renewcommand\abstractname{", @"\renewcommand\abstractname{\hfill");
                        }
                    }
                }
                else if (baseCls == "report")
                {
                    cls = "report";

                    if (tvMenu.Nodes["tnChapter"] == null)
                    {
                        chapterTab = new SectionTab(pathTexFile, "Chapter");
                        tvMenu.Nodes.Insert(4, chapterNode);
                    }

                    findIndex = lst.FindIndex(x => x.StartsWith(@"\renewcommand\abstractname"));
                    if (findIndex >= 0)
                    {
                        if (lst[findIndex].Contains(@"{\hfill") && lst[findIndex].Contains(@"\hfill}"))
                        {
                            lst[findIndex] = lst[findIndex].Replace(@"\hfill", "");
                        }
                        else if (lst[findIndex].Contains(@"{\hfill"))
                        {
                            lst[findIndex] = lst[findIndex].Replace(@"\hfill", @"\flushright");
                        }
                        else if (lst[findIndex].Contains(@"\hfill}"))
                        {
                            lst[findIndex] = lst[findIndex].Replace(@"\hfill}", "}");
                            lst[findIndex] = lst[findIndex].Replace(@"\renewcommand\abstractname{", @"\renewcommand\abstractname{\flushleft");
                        }
                    }
                }

                txt = String.Join(Environment.NewLine, lst);
                MainService.WriteLatexFile(Constants.DocClsName, ".cls", pathTexFile, txt);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }