// Make a tree of splitters, controlled by the string in sp static public SplitContainer SplitterTreeMakeFromCtrlString(BaseUtils.StringParser sp, Func <Orientation, int, SplitContainer> MakeSC, Func <string, Control> MakeNode, int lvl) { char tomake; if (sp.SkipUntil(new char[] { 'H', 'V', 'U' }) && (tomake = sp.GetChar()) != 'U') { sp.IsCharMoveOn('('); // ignore ( SplitContainer sc = MakeSC(tomake == 'H' ? Orientation.Horizontal : Orientation.Vertical, lvl); double percent = sp.NextDouble(",") ?? 0.5; sc.SplitterDistance(percent); SplitContainer one = SplitterTreeMakeFromCtrlString(sp, MakeSC, MakeNode, lvl + 1); if (one == null) { string para = sp.PeekChar() == '\'' ? sp.NextQuotedWord() : ""; sc.Panel1.Controls.Add(MakeNode(para)); } else { sc.Panel1.Controls.Add(one); } SplitContainer two = SplitterTreeMakeFromCtrlString(sp, MakeSC, MakeNode, lvl + 1); if (two == null) { string para = sp.PeekChar() == '\'' ? sp.NextQuotedWord() : ""; sc.Panel2.Controls.Add(MakeNode(para)); } else { sc.Panel2.Controls.Add(two); } return(sc); } else { return(null); } }
public void ParseGroup(StringParser sp) // parse until stopchar. WordLists has all the word combinations { WordLists = new List <List <string> >(); int list = 0; bool addedempty = false; while (!sp.IsEOL && sp.PeekChar() != groupchar) { bool bracketed = sp.IsCharMoveOn(openbracketchar); string p = sp.NextQuotedWord(bracketed ? stopwordinbracket : stopword); // get the quoted item. stop on right point if (p == null || (bracketed && !sp.IsCharMoveOn(closebracketchar))) // nothing, stop, EOL after bracket. Or bracketed but no bracket { break; } if (WordLists.Count <= list) // do we need another list.. { WordLists.Add(new List <string>()); addedempty = false; } WordLists.Last().Add(p); // add it, even if empty if (bracketed && p.Length > 0 && addedempty == false) { WordLists.Last().Add(""); // add an empty entry addedempty = true; // only add one please } if (!sp.IsCharMoveOn(orchar)) // if |, stay on same list, else move to next { list++; } } }