Example #1
0
        private void PressEnterEnterQuery(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (!checkDates())
                {
                    return;
                }


                query = QueryEntry.Text;
                int i = 0;

                string queryNum = queryCounter.ToString();
                search = new Searcher(sortedTermDictionary, DocsDict);
                if (!search.checkPercent(query))
                {
                    search.ParseQuery(query, stem);
                }

                search.getAllRelatedDocuments(fromMonth, toMonth, queryNum, stem);
                if (search.ans.Count == 0)
                {
                    PopUpWindow popup = new PopUpWindow();
                    popup.popUpTxtBox.Text = "No documents found.";
                    popup.ShowDialog();
                }

                initiateShowResultsWindow();
            }
        }
Example #2
0
        private bool checkDates()
        {
            bool ans = false;

            this.Dispatcher.Invoke((Action)(() =>
            {
                if (textFromMonth.Text == "" || textToMonth.Text == "")
                {
                    fromMonth = 1;
                    toMonth = 12;
                    ans = true;
                }
                else
                {
                    PopUpWindow popup;

                    int num1 = 0;
                    bool isNumeric1 = int.TryParse(textFromMonth.Text, out num1);
                    int num2 = 0;
                    bool isNumeric2 = int.TryParse(textToMonth.Text, out num2);


                    if (!isNumeric1 || !isNumeric2 || (num1 > 12 || num1 <= 0) || (num2 > 12 || num2 <= 0) || (num1 > num2))
                    {
                        popup = new PopUpWindow();
                        popup.popUpTxtBox.Text = "Please enter a valid month.";
                        popup.ShowDialog();
                        ans = false;
                    }


                    fromMonth = num1;
                    toMonth = num2;
                    ans = true;
                }
            }));

            return(ans);
        }