private static List <string> getWordsBeforeCursor() { List <string> words; new ExpressionTree(ExpressionTree.CleanExpression(textbox.ToString(textbox.CaretLocation))).Compile(out words); return(words); }
private void btnTest_Click() { textbox.CloseIntellisense(); ExpressionTree et = new ExpressionTree(ExpressionTree.CleanExpression(textbox.ToString())); ExpressionTree.ValidationError ve = et.Compile(); if (ve == ExpressionTree.ValidationError.Valid) { bool sorted; var v = et.Filter(Database.LibrarySnapshot, out sorted); string message; if (v.Count == 1) { message = String.Format("Playlist returns {0} track.", v.Count.ToString()); } else { message = String.Format("Playlist returns {0} tracks.", v.Count.ToString()); } QMessageBox.Show(this, message, "Auto Playlist Test", QMessageBoxIcon.Information); } else { QMessageBox.Show(this, getValidationErrorText(ve), "Auto Playlist Test Failed", QMessageBoxIcon.Information); } }
private static void textbox_ContentsChanged(object sender, EventArgs e) { currentInstance.valid = new ExpressionTree(ExpressionTree.CleanExpression(textbox.ToString())).Compile(); currentInstance.lblOK.BackColor = (currentInstance.valid == ExpressionTree.ValidationError.Valid) ? Color.Green : Color.Red; currentInstance.updateMessage(); List <string> ww = getWordsBeforeCursor(); ww.RemoveAll(w => (w == "(" || w == ")" || w == "\"")); textbox.WordsBeforeCursor = ww; }