public static void LoadItem(int index) { _ScripterForm.CreateNewDocument(Scripter.DEF_FILE_NAME); string filename = "Template" + index + ".tem"; string path = Path.Combine(Path.Combine(Path.Combine(Scripter.AppPath, "data"), "templates"), filename); if (!File.Exists(path)) { UtilSys.MessageBox("File '" + path + "' does not exist."); return; } string[] buffer = UtilIO.ReadFile2Array(path); _ScripterForm.CurrentEditor.Loading = true; foreach (string line in buffer) { _ScripterForm.CurrentEditor.AddLine(line); } _ScripterForm.CurrentEditor.Loading = false; _ScripterForm.CurrentEditor.Dirty = false; _ScripterForm.CurrentEditor.InitUndoStack(); Scripter.DoEvents(); _ScripterForm.OnReParse(); Scripter.DoEvents(); _ScripterForm.CurrentEditor.Focus(); }
public static string[] Load(FrmScripter frmScp, MRU mru, string path) { if (!File.Exists(path)) { UtilSys.MessageBox("File '" + path + "' does not exist."); mru.Remove(path); mru.Save(); return(null); } frmScp.Output("Loading file: " + path); string[] buffer = UtilIO.ReadFile2Array(path); mru.Add(path); mru.Save(); return(buffer); }