public bool BeginLinesAdd(UIElement element) { if (BeginLines.Count < this.MaxBeginLines && !BeginLines.Contains(element) && !EndLines.Contains(element)) { BeginLines.Add(element); return(true); } return(false); }
public static bool ProcessEndscript(string dir, string filepath, BasicBase db, out string label, out string text) { label = null; text = string.Empty; GlobalDir = dir; if (!ProceedSafeLoading(filepath, out var EndLines)) { return(false); } var MenuEndLines = new List <string>(); int begin = -1; int end = -1; for (int loop = 0; loop < EndLines.Count; ++loop) { // If encountered <menu> tag, begin accumulating EndMenu lines if (EndLines[loop].Text == "<menu>") { begin = loop; continue; } // If encountered </menu> tag, stop accumulating EndMenu lines else if (EndLines[loop].Text == "</menu>") { end = loop; continue; } // If accumulating, append and continue else if (begin != -1 && end == -1) { MenuEndLines.Add(EndLines[loop].Text); } else { EndLines[loop].Text = ScriptX.CleanString(EndLines[loop].Text, true); } } if (begin != -1 && end != -1) { EndLines.RemoveRange(begin, end - begin + 1); } int total_line_count = EndLines.Count; var ErrorEndLines = new List <EndLine>(); var window = new Interact.EndMenu(MenuEndLines.ToArray(), Path.GetDirectoryName(filepath)); if (window.ShowDialog() == DialogResult.OK) { string filedir = Path.GetDirectoryName(filepath); watch.Reset(); watch.Start(); foreach (var endline in EndLines) { endline.Error = ExecuteEndscriptLine(endline.Text, db, filedir); if (endline.Error != null) { ErrorEndLines.Add(endline); } } watch.Stop(); if (ErrorEndLines.Count > 0) { var errorwindow = new Interact.ErrorView(ErrorEndLines); errorwindow.ShowDialog(); } var build = new StringBuilder(EndLines.Count * 100); foreach (var endline in EndLines) { build.Append(endline.Text + Environment.NewLine); } text = build.ToString(); label = $"Processed {total_line_count} lines of script in {watch.ElapsedMilliseconds}ms"; GlobalDir = string.Empty; return(true); } else { GlobalDir = string.Empty; return(false); } }