示例#1
0
        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);
            }
        }
示例#2
0
        private string getValidationErrorText(ExpressionTree.ValidationError ValError)
        {
            string s;

            switch (ValError)
            {
            case ExpressionTree.ValidationError.Valid:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Valid);
                break;

            case ExpressionTree.ValidationError.BadComparitor:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Bad_Comparitor);
                break;

            case ExpressionTree.ValidationError.BadField:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Bad_Field);
                break;

            case ExpressionTree.ValidationError.PlaylistError:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Playlist_Error);
                break;

            case ExpressionTree.ValidationError.BadExpression:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Bad_Expression);
                break;

            case ExpressionTree.ValidationError.UnmatchedParens:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Unmatched_Parens);
                break;

            case ExpressionTree.ValidationError.ShortExpression:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Short_Expression);
                break;

            case ExpressionTree.ValidationError.UnknownKeyword:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Unknown_Keyword);
                break;

            case ExpressionTree.ValidationError.BooleanValueError:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Boolean_Value_Error);
                break;

            case ExpressionTree.ValidationError.NumericValueError:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Numeric_Value_Error);
                break;

            case ExpressionTree.ValidationError.NumericComparatorError:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Numeric_Comparitor_Error);
                break;

            case ExpressionTree.ValidationError.BadSelectByModifier:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Bad_SelectBy);
                break;

            case ExpressionTree.ValidationError.BadLimitToModifier:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Bad_LimitTo);
                break;

            case ExpressionTree.ValidationError.BadSortByModifier:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Bad_SortBy);
                break;

            case ExpressionTree.ValidationError.BadThenByModifier:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Bad_ThenBy);
                break;

            case ExpressionTree.ValidationError.ThenByWithoutSortByOrSelectBy:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_ThenBy_Without_SortBy_Or_SelectBy);
                break;

            case ExpressionTree.ValidationError.BadModifier:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Bad_Modifier);
                break;

            default:
                s = Localization.Get(UI_Key.Edit_Auto_Playlist_Invalid);
                break;
            }
            return(s);
        }