//create a new CurAddTo (even though their already might be one) //(needed for edge tool) protected virtual bool AddNewCurAddTo() { // find tikzpicture Tikz_Picture tpict = overlay.ParseTree.GetTikzPicture(); if (tpict == null) { return(false); } Parser.Tikz_Path tp = new Parser.Tikz_Path(); tp.starttag = @"\draw "; tp.endtag = ";"; if (overlay.EdgeStyle != "") { Parser.Tikz_Options topt = new Parser.Tikz_Options(); topt.starttag = "["; topt.endtag = "]"; Parser.Tikz_Option to = new Parser.Tikz_Option(); to.type = Parser.Tikz_OptionType.key; to.key = overlay.EdgeStyle; topt.AddOption(to); tp.AddChild(topt); tp.options = topt; } if (overlay.CurEditing != null) { overlay.CurEditing.tikzitem.AddChild(tp); overlay.CurEditing.tikzitem.AddChild(new Parser.Tikz_Something("\r\n")); } else { tpict.AddChild(tp); tpict.AddChild(new Parser.Tikz_Something("\r\n")); } curAddTo = tp; return(true); }
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); } }