예제 #1
0
        private void contextFavoriteDelete_Click(object sender, RoutedEventArgs e)
        {
            var menuItem = (sender as MenuItem).DataContext;
            Model.Item item = null;
            try
            {
                item = (Model.Item)menuItem;
            }
            catch (InvalidCastException ice)
            {
                MessageBox.Show("Unable to remove item from favorites: " + "\n" + ice.Message + "\n" + ice.StackTrace);
                return;
            }

            FavoriteHandler fHandler = new FavoriteHandler();
            foreach(Model.Item i in fHandler.favorites.ToList())
            {
                if (item.ItemName.Equals(i.ItemName))
                {
                    fHandler.favorites.Remove(i);//remove the item
                }
            }
            FavoritesListBox.ItemsSource = new ListHelper().populateList(fHandler.favorites);
        }
예제 #2
0
        private void Pivot_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            //BrowsePivot selected
            if (MasterPivot.SelectedItem == BrowsePivot)
            {
                //set focus to this to remove soft keyboard from screen (from Search page)
                this.Focus();

                bool noTableSelected = true;
                string tableValue = getCategory(out noTableSelected);
                if (!noTableSelected)
                {
                    MessageBox.Show("No Table selected in Categories.  Defaulting to Monster."); //has already been set to Monster in getCategory()
                }
                string strSelect = @"SELECT name FROM " + tableValue + " ORDER BY name ASC";//need to check for empty entry
                List<Model.Item> _ItemEntries = (Application.Current as App).db.SelectBrowse(strSelect); //execute query for results

                //add the sql property for each item.  This query will be used when the specific item is clicked.
                foreach(Model.Item i in _ItemEntries.ToList<Model.Item>())
                {
                    i.ItemSQL = @"SELECT id, name, full_text FROM " + tableValue + " WHERE name LIKE " + @"""" + i.ItemName + @"""" + " LIMIT 1";
                }

                BrowseListBox.ItemsSource = new ListHelper().populateList(_ItemEntries);
            }
            else if (MasterPivot.SelectedItem == FavoritePivot)
            {
                //set focus to this to remove soft keyboard from screen (from Search page)
                this.Focus();

                //set the source
                FavoriteHandler fHandler = new FavoriteHandler();
                FavoritesListBox.ItemsSource = new ListHelper().populateList(fHandler.favorites);
            }
            //SearchPivot selected
            else if (MasterPivot.SelectedItem == SearchPivot)
            {
                searchTextBox.Focus();

                //Collapse the browser control so the user doesn't see a blank white page.
                if (browserControl.Visibility == System.Windows.Visibility.Visible)
                {
                    browserControl.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
           
            else
            {
                //set focus to this to remove soft keyboard from screen (from Search page)
                this.Focus();
            }
        }
예제 #3
0
        /// <summary>
        /// Attempt to add the selected item to the list of favorites.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contextFavorite_Click(object sender, RoutedEventArgs e)
        {
            var menuItem = (sender as MenuItem).DataContext;
            Model.Item item = null;
            try
            {
                item = (Model.Item)menuItem;
            }
            catch (InvalidCastException ice)
            {
                MessageBox.Show("Unable to add item to favorites: " + "\n" + ice.Message + "\n" + ice.StackTrace);
                return;
            }

            //The items in the browse list are BrowseItem objects, meaning the html associated with them is retrieved after the user clicks on one.  
            //This means we must run a query to get the html.  This is good for performance because it means that massive strings containing HTML won't be retrieved for every list item
            //as soon as the item is loaded.
            string fullHTML = retrieveResult(@"""" + item.ItemName + @""""); //escape commas and crap

            if (fullHTML.Length > 0)
            {
                //We want to add a Model.Item object to the list of favorites so a new instance will need to be created here, using the retrieved html.
                FavoriteHandler fHandler = new FavoriteHandler();
                bool noTableSelected = true;
                string tableValue = getCategory(out noTableSelected);
                if (!noTableSelected)
                {
                    MessageBox.Show("No Table selected in Categories.  Defaulting to Monster."); //has already been set to Monster in getCategory()
                }
                //Select only 1 item from database!
                string strSelect = @"SELECT id, name, full_text FROM " + tableValue + " WHERE name LIKE " + @"""" + item.ItemName + @"""" + " LIMIT 1 ";

                fHandler.addtoFavorites(new Model.Item(item.ItemName, strSelect, fullHTML));
            }
            else //Why would anyone add an item like this anyways - just say no.
            {
                MessageBox.Show("No page exists for this item.  Unable to add to favorites.");
            }

        }
예제 #4
0
        private void TextBlock_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            try
            {
                //go to a web browser control with the html string passed in
                Model.Item selectedItem = (Model.Item)FavoritesListBox.SelectedItem;

                //todo - find the item in the favorites list so we can get the sql.
                FavoriteHandler fHandler = new FavoriteHandler();
                Model.Item item = null;
                try
                {
                    item = (Model.Item)fHandler.favorites.First(Item => Item.ItemName.Equals(selectedItem.ItemName));
                }
                catch (ArgumentNullException ane)
                {
                    MessageBox.Show("Error loading up Favorited Item: " + selectedItem.ItemName + "\n " + ane.Message + "||\n" + ane.StackTrace);
                }
                catch (InvalidOperationException ioe)
                {
                    MessageBox.Show("Error loading up Favorited Item: " + selectedItem.ItemName + "\n " + ioe.Message + "||\n" + ioe.StackTrace);
                }

                //we use history result here because we stored the sql when adding the item as a favorite.

                string fullHTML = retrieveHistoryOrFavoriteResult(item.ItemSQL);
                if (fullHTML != string.Empty)
                {
                    currentHTML = fullHTML; //set the html to be the selected result
                    NavigationService.Navigate(new Uri("/ListHitViewer.xaml", UriKind.Relative));
                }
            }
            catch (InvalidCastException ice)
            {
                MessageBox.Show("Unable to load page for item: " + "\n" + ice.Message + "\n" + ice.StackTrace);
            }
        }