protected virtual bool EnsureCurAddToExists(out bool created) { created = false; if (overlay.ParseTree == null) { return(false); } // find tikzpicture Parser.Tikz_Picture tpict = overlay.ParseTree.GetTikzPicture(); if (tpict == null) { if (overlay.AllowEditing) { // add a new tikzpicture Tikz_Picture tp = new Tikz_Picture(); tp.starttag = "\\begin{tikzpicture}"; tp.AddChild(new Tikz_Something("\r\n")); tp.endtag = "\\end{tikzpicture}"; //overlay.BeginUpdate(); overlay.ParseTree.AddChild(tp); tp.UpdateText(); //overlay.EndUpdate(); } else { return(false); } } if (curAddTo == null || !(curAddTo is Parser.Tikz_Path)) { created = AddNewCurAddTo(); } return(true); }
protected bool EnsureParseTreeExists() { // Try to create a new ParseTree if (overlay.ParseTree == null) { // TODO return(false); //TryCreateNew(this, out lret); if (overlay.AllowEditing) { // create a new parsetree Tikz_ParseTree t = new Tikz_ParseTree(); Tikz_Picture tp = new Tikz_Picture(); tp.starttag = "\\begin{tikzpicture}"; tp.AddChild(new Tikz_Something("\r\n")); tp.endtag = "\\end{tikzpicture}"; overlay.BeginUpdate(); // overlay.ParseTree = t; t.AddChild(tp); tp.UpdateText(); overlay.EndUpdate(); return(true); } else { GlobalUI.ShowMessageBox("Parse tree could not be created. Please correct all parser errors in the code and try again.", "Function not available", MessageBoxButton.OK, MessageBoxImage.Exclamation); return(false); } } else { return(true); } }