/// <summary> /// Loads an checks for missing files /// </summary> public void LoadFiles() { bool missingFiles = false; if (!Directory.Exists(Path.Combine(assemblyPath, @"Resources"))) { Directory.CreateDirectory(assemblyPath + "\\Resources"); } if (File.Exists(Path.Combine(assemblyPath, @"Resources\WhiteList.txt"))) { string temp = Path.Combine(assemblyPath, @"Resources\WhiteList.txt"); string[] WhiteListLines = System.IO.File.ReadAllLines(Path.Combine(assemblyPath, @"Resources\WhiteList.txt")); Init_WhiteList(WhiteListLines); } else { string[] exampleLines = { "#C++", ".h", ".cpp", "#C", ".c", "#Pascal", ".pas", "#HTML", ".html", ".css", "#VHDL", ".vhdl" }; using (System.IO.StreamWriter file = new System.IO.StreamWriter((assemblyPath + "\\Resources\\WhiteList.txt"))) { foreach (string line in exampleLines) { file.WriteLine(line); } } string[] WhiteListLines = System.IO.File.ReadAllLines(Path.Combine(assemblyPath, @"Resources\WhiteList.txt")); Init_WhiteList(WhiteListLines); missingFiles = true; } tm = new TexMaker(); if (tm.MissingFiles | missingFiles) { StatusText = "Missing files added"; } else { StatusText = "Successfully loaded"; } }
/// <summary> /// Genereates output.tex if Setting_General_ContextStartup is not set /// </summary> /// <param name="path"></param> public void GenerateOutputTex(string path) { if (_viewModel.List.Count > 0) { TexMaker tm = _viewModel.Tex; tm.FileList = _viewModel.List; tm.WhiteList = _viewModel.CurrentWhiteList; List <string> texLines = tm.Build(); String outputString = ""; if (texLines != null) { foreach (string line in texLines) { outputString += line; } try { System.IO.File.WriteAllText((path + "\\output.tex"), outputString); } catch (Exception ex) { string t; t = Environment.NewLine + "Exception caught" + Environment.NewLine + "Date: " + DateTime.UtcNow.Date.ToString("dd/MM/yyyy") + ", Time: " + DateTime.Now.ToString("HH:mm:ss tt") + Environment.NewLine + ex.Message + Environment.NewLine + ex.ToString() + Environment.NewLine + "Runtime terminating: "; using (System.IO.StreamWriter file = new System.IO.StreamWriter(assemblyPath + "\\CrashLog.txt", true)) { file.WriteLine(t); } t = null; } } } }