private void AddBulledParagraph(string paragraphName, dynamic List) { if (!string.IsNullOrEmpty(Settings.Default.LaTexLocation)) { _lt.Add(new LatexParagraph(paragraphName)); } _txt.AppendLine(); _txt.Append(paragraphName); List <string> listOfTopics = new List <string>(); foreach (dynamic item in List) { if ("text".Equals(item.Name)) //Тут стоит заглушка { continue; } if (item.text != null && item.body != null) { AddBulledParagraph(item.text.ToString(), item.body); } else { listOfTopics.Add(item.text.ToString()); _txt.AppendLine("• " + item.text.ToString()); } } if (!string.IsNullOrEmpty(Settings.Default.LaTexLocation)) { _lt.Add(new LatexList(LatexList.BULLET, listOfTopics)); } }
private void Form1_Load(object sender, EventArgs e) { TextArea = new Scintilla(); TextPanel.Controls.Add(TextArea); // BASIC CONFIG TextArea.Dock = DockStyle.Fill; TextArea.TextChanged += (this.OnTextChanged); // INITIAL VIEW CONFIG TextArea.WrapMode = WrapMode.None; TextArea.IndentationGuides = IndentView.LookBoth; InitNumberMargin(); lt = new LatexDocument.Document(@"C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe", @"D:\Latex\"); LatexPageTitle title = new LatexPageTitle("Test File", "Simone Luconi", "18 Giugno 2017"); lt.Add(title); LatexFont font = new LatexFont(); font.Size = LatexFont.TEXT_Huge; lt.Add(new LatexTextTitle("Big Title", font)); LatexImage img = new LatexImage(@"C:\Users\Matteo\Desktop\Giugno 2017\sfondo1.jpg", "Test Image"); lt.Add(img); font.Color = "blue"; lt.Add(new LatexParagraph("Blue paragraph", LoremIpsum, font)); lt.NewLine(); font.Color = null; font.Type = LatexFont.TEXT_BOLD; lt.Add(new LatexText("Bold text, ", font)); font.Type = LatexFont.TEXT_ITALIC; lt.Add(new LatexText("Italic text, ", font)); font.Type = LatexFont.TEXT_UNDERLINE; lt.Add(new LatexText("UnderLine text", font)); font.Type = null; font.Color = "red"; lt.Add(new LatexText("Red text", font)); lt.Font = "cmss"; LatexImage img2 = new LatexImage(@"C:\Users\Matteo\Desktop\Giugno 2017\sfondo1.jpg"); lt.Add(img2); lt.Add(new LatexParagraph("Change Font: Computer Modern Sans Serif", LoremIpsum)); lt.Font = LatexFont.DEFAULT_FONT; lt.NewPage(); font.Size = LatexFont.TEXT_Huge; font.Color = "red"; lt.Add(new LatexTextTitle("Formulas (red title)", font)); lt.AddMath(@"\lim_{x \to \infty} \exp(-x) = 0"); lt.NewLine(); lt.AddMath(@"\frac{n!}{k!(n-k)!} = \binom{n}{k}"); lt.NewLine(); lt.AddMath(@"\cos (2\theta) = \cos^2 \theta - \sin^2 \theta"); lt.NewLine(); lt.NewLine(); font.Color = null; lt.Add(new LatexTextTitle("Table", font)); lt.NewLine(); string[,] elements = new string[3, 3]; elements[0, 0] = "Pizza"; elements[0, 1] = "Pane"; elements[0, 2] = "Spaghetti"; elements[1, 0] = "1"; elements[1, 1] = "2"; elements[1, 2] = "3"; elements[2, 0] = "4"; elements[2, 1] = "5"; elements[2, 2] = "6"; lt.Add(new LatexTable(elements)); lt.Add(new LatexParagraph(LoremIpsum)); lt.NewLine(); lt.NewLine(); lt.Add(new LatexTextTitle("Table (no borders) Wrapped", font)); lt.Add(new LatexTable(elements, false, true)); lt.Add(new LatexParagraph(LoremIpsum)); lt.NewPage(); lt.Add(new LatexTextTitle("Bullet List", font)); List <string> items = new List <string>(); items.Add("Pizza"); items.Add("Pane"); items.Add("Pasta"); items.Add("Spaghetti"); lt.Add(new LatexList(LatexList.BULLET, items)); lt.Add(new LatexTextTitle("Enumerate List", font)); lt.Add(new LatexList(LatexList.ENUMERATE, items)); lt.Add(new LatexTextTitle("Descriptive List", font)); Dictionary <string, string> desc = new Dictionary <string, string>(); desc.Add("Pizza", LoremIpsum.Substring(0, 175)); desc.Add("Pane", LoremIpsum.Substring(0, 175)); desc.Add("Pasta", LoremIpsum.Substring(0, 175)); desc.Add("Spaghetti", LoremIpsum.Substring(0, 175)); lt.Add(new LatexList(desc)); lt.NewPage(); lt.Add(new LatexTextTitle("Pie Graph", font)); lt.NewLine(); List <LatexGraphValue> datas = new List <LatexGraphValue>(); datas.Add(new LatexGraphValue(10, "Pizza", "red")); datas.Add(new LatexGraphValue(20, "Pane", "green")); datas.Add(new LatexGraphValue(30, "Pasta", "blue")); datas.Add(new LatexGraphValue(40, "Spaghetti", "orange")); LatexPieGraph graph = new LatexPieGraph(datas); lt.Add(graph); lt.Add(new LatexTextTitle("Bar Graph", font)); lt.NewLine(); LatexBarGraph graph2 = new LatexBarGraph(datas); lt.Add(graph2); lt.NewPage(); font.Size = LatexFont.TEXT_Huge; lt.Add(new LatexTextTitle("Coordinates Graph", font)); LatexPlotGraph plotGraph = new LatexPlotGraph(); plotGraph.Title = @"Temperature dependence of CuSO$_4\cdot$5H$_2$O solubility"; plotGraph.XLabel = "Temperature in celsius"; plotGraph.YLabel = "Solubility[g per 100 g water]"; plotGraph.XMin = 0; plotGraph.XMax = 100; plotGraph.YMin = 0; plotGraph.YMax = 100; plotGraph.XTick = new int[] { 0, 20, 40, 60, 80, 100 }; plotGraph.YTick = new int[] { 0, 20, 40, 60, 80, 100, 120 }; plotGraph.LegendPosition = "north west"; plotGraph.YMajorGrids = true; plotGraph.GridStyle = "dashed"; LatexPlot plot = new LatexPlot(); plot.LineColor = "blue"; plot.MarksStyle = "square"; System.Windows.Point[] coordinates = new System.Windows.Point[8]; coordinates[0] = new System.Windows.Point(0, 23.1); coordinates[1] = new System.Windows.Point(10, 27.5); coordinates[2] = new System.Windows.Point(20, 32); coordinates[3] = new System.Windows.Point(30, 37.8); coordinates[4] = new System.Windows.Point(40, 44.6); coordinates[5] = new System.Windows.Point(60, 61.8); coordinates[6] = new System.Windows.Point(80, 83.8); coordinates[7] = new System.Windows.Point(100, 114); plot.Coordinates = coordinates; plot.Legend = @"CuSO$_4\cdot$5H$_2$O"; plotGraph.Plots = new LatexPlot[] { plot }; lt.Add(plotGraph); lt.Add(new LatexTextTitle("Math Graph", font)); LatexPlotGraph plotGraph2 = new LatexPlotGraph(); LatexPlot plot2 = new LatexPlot(); plot2.LineColor = "red"; plot2.Expression = "x^2 - 2*x - 1"; plot2.Legend = "$x^2 - 2*x - 1$"; LatexPlot plot3 = new LatexPlot(); plot3.LineColor = "blue"; plot3.Expression = "x^2 + 2*x + 1"; plot3.Legend = "$x^2 + 2*x + 1$"; plotGraph2.Plots = new LatexPlot[] { plot2, plot3 }; lt.Add(plotGraph2); TextArea.Text = lt.ToString(); }
private void createtex() { TextArea = new Scintilla(); TextArea.Dock = DockStyle.Fill; TextArea.WrapMode = WrapMode.None; TextArea.IndentationGuides = IndentView.LookBoth; InitNumberMargin(); LatexDocumentMargins margins = new LatexDocumentMargins(0.25, 0.25, 0.75, 0.75); //lt = new LatexDocument.Document(@"C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe", @"C:\Users\stefa\Desktop\Porudzbine\", margins); lt = new LatexDocument.Document(@"C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe", @"C:\Users\user\Desktop\Porudzbine\", margins); LatexFont font = new LatexFont(); font.Size = LatexFont.TEXT_Huge; lt.StartCenterAlign(); StringBuilder title_text = new StringBuilder(naslov.Text.TrimEnd()); for (int i = 0; i < title_text.Length; i++) { if (title_text[i] == ' ') { title_text[i] = '-'; } } LatexTextTitle title = new LatexTextTitle(naslov.Text.TrimEnd(), font); lt.Add(title); lt.EndAlign(); font.Size = LatexFont.DEFAULT_FONT; lt.Add(new LatexText(doortype.Text, font)); lt.NewLine(); Bitmap bm = new Bitmap(mainpb.Image); int j = 0; int c = bm.Height; while (c > 840) { Bitmap temp = bm.Clone(new Rectangle(0, 0, 900, 840), bm.PixelFormat); bm = bm.Clone(new Rectangle(0, 840, bm.Width, bm.Height - 840), bm.PixelFormat); temp.Save(@"C:\Users\user\Desktop\Porudzbine\image" + j.ToString() + ".png"); LatexImage itmp = new LatexImage(@"C:\Users\user\Desktop\Porudzbine\image" + j.ToString() + ".png", 0.8); lt.Add(itmp); c = c - 840; j++; lt.NewPage(); } bm.Save(@"C:\Users\user\Desktop\Porudzbine\image" + (j).ToString() + ".png"); //bm.Save(@"C:\Users\stefa\Desktop\Porudzbine\image" + (j).ToString()+".png"); LatexImage img = new LatexImage(@"C:\Users\user\Desktop\Porudzbine\image" + (j).ToString() + ".png", 0.8); //LatexImage img = new LatexImage(@"C:\Users\stefa\Desktop\Porudzbine\image" + (j).ToString() + ".png", 0.8); lt.Add(img); if (allDoors.Count > 5) { lt.NewPage(); } else { lt.NewLine(); lt.NewLine(); lt.NewLine(); } font.Type = LatexFont.TEXT_BOLD; lt.Add(new LatexText("Vratno krilo: ", font)); font.Type = null; lt.Add(new LatexText(krilatb.Text, font)); List <string> tmp = new List <string>(); foreach (string i in krila.Items) { tmp.Add(i); } lt.Add(new LatexList(LatexList.BULLET, tmp)); tmp.Clear(); font.Type = LatexFont.TEXT_BOLD; lt.Add(new LatexText("MDF28mm: ", font)); font.Type = null; lt.Add(new LatexText(mdf28tb.Text, font)); foreach (string i in mdf28.Items) { string o = ""; if (!char.IsWhiteSpace(i[0])) { int p = i.IndexOf('c'); string tmp1 = i.Substring(p + 1); p += tmp1.IndexOf('c'); o = i.Substring(0, p + 3) + " \\quad \\quad" + i.Substring(p + 3); } else { o = " \\quad \\quad \\quad \\quad \\quad \\quad \\quad \\quad \\quad \\quad \\quad \\quad" + i; } tmp.Add(o); } lt.Add(new LatexList(LatexList.BULLET, tmp)); tmp.Clear(); font.Type = LatexFont.TEXT_BOLD; lt.Add(new LatexText("MDF18mm: ", font)); font.Type = null; lt.Add(new LatexText(mdf18tb.Text, font)); foreach (string i in mdf18.Items) { tmp.Add(i); } lt.Add(new LatexList(LatexList.BULLET, tmp)); tmp.Clear(); if (doortype.SelectedIndex == 3) { font.Type = LatexFont.TEXT_BOLD; lt.Add(new LatexText("Hrastove trake: ", font)); font.Type = null; lt.Add(new LatexText(mdf16tb.Text, font)); foreach (string i in mdf16.Items) { tmp.Add(i); } lt.Add(new LatexList(LatexList.BULLET, tmp)); tmp.Clear(); if (mdf22.Items.Count != 0) { font.Type = LatexFont.TEXT_BOLD; lt.Add(new LatexText("MDF28mmStaklo: ", font)); font.Type = null; lt.Add(new LatexText(mdf22tb.Text, font)); foreach (string i in mdf22.Items) { tmp.Add(i); } lt.Add(new LatexList(LatexList.BULLET, tmp)); tmp.Clear(); } } else { font.Type = LatexFont.TEXT_BOLD; lt.Add(new LatexText("MDF16mm: ", font)); font.Type = null; lt.Add(new LatexText(mdf16tb.Text, font)); foreach (string i in mdf16.Items) { tmp.Add(i); } lt.Add(new LatexList(LatexList.BULLET, tmp)); tmp.Clear(); font.Type = LatexFont.TEXT_BOLD; lt.Add(new LatexText("HDF4mm: ", font)); font.Type = null; lt.Add(new LatexText(hdf4.Text, font)); foreach (string i in hdf4.Items) { tmp.Add(i); } lt.Add(new LatexList(LatexList.BULLET, tmp)); tmp.Clear(); if (mdf22.Items.Count != 0) { font.Type = LatexFont.TEXT_BOLD; lt.Add(new LatexText("MDF22mm: ", font)); font.Type = null; lt.Add(new LatexText(mdf22tb.Text, font)); foreach (string i in mdf22.Items) { tmp.Add(i); } lt.Add(new LatexList(LatexList.BULLET, tmp)); tmp.Clear(); } } lt.CreatePdf(title_text.ToString(), true); string[] aux = System.IO.Directory.GetFiles(@"C:\Users\user\Desktop\Porudzbine\", "*.aux"); foreach (string file in aux) { System.IO.File.Delete(file); } string[] tex = System.IO.Directory.GetFiles(@"C:\Users\user\Desktop\Porudzbine\", "*.tex"); foreach (string file in tex) { System.IO.File.Delete(file); } string[] log = System.IO.Directory.GetFiles(@"C:\Users\user\Desktop\Porudzbine\", "*.log"); foreach (string file in log) { System.IO.File.Delete(file); } string[] png = System.IO.Directory.GetFiles(@"C:\Users\user\Desktop\Porudzbine\", "*.png"); foreach (string file in png) { System.IO.File.Delete(file); } /*string[] dirs = System.IO.Directory.GetDirectories(@"C:\Users\user\Desktop\Porudzbine\"); * foreach (string dir in dirs) * { * System.IO.File.Delete(dir); * }*/ }