private void SearchTermList_ItemTap(object sender, ListBoxItemTapEventArgs e) { SearchTerm searchTerm = ((sender as RadDataBoundListBox).SelectedItem as SearchTerm); if (searchTerm != null) { //MessageBox.Show(searchTerm.search_text); NavigationService.Navigate(new Uri("/Views/SearchDetailPage.xaml?SearchText=" + searchTerm.search_text, UriKind.Relative)); } }
private void SearchList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (SearchTermList.SelectedIndex == -1) { return; } SearchTerm searchTerm = ((SearchTerm)SearchTermList.SelectedItem); if (searchTerm != null) { //MessageBox.Show(searchTerm.search_text); NavigationService.Navigate(new Uri("/Views/SearchDetailPage.xaml?SearchText=" + searchTerm.search_text, UriKind.Relative)); } }
private void MenuItemSearch_Click(object sender, RoutedEventArgs e) { string header = (sender as MenuItem).Header.ToString(); ListBoxItem selectedListBoxItem = this.SearchTermList.ItemContainerGenerator.ContainerFromItem((sender as MenuItem).DataContext) as ListBoxItem; if (selectedListBoxItem == null) { return; } SearchTerm data = selectedListBoxItem.DataContext as SearchTerm; if (header == "Delete") { int result = (Application.Current as App).db.DeleteSearchTerm(data.id); if (result == 0) { //MessageBox.Show("Delete Search Failed."); } else { //MessageBox.Show("Delete Search Success."); } } else if (header == "Delete all") { /* * if ((Application.Current as App).db.clearSearch() > 0) * { * vm.GetSearches(); * SearchListBox.DataContext = vm.Searches; * MessageBox.Show("All Searches deleted"); * } */ } App.ViewModel.LoadSearchTerms(); SearchTermList.ItemsSource = App.ViewModel.SearchTerms; SearchTermList.DataContext = App.ViewModel; SearchTermList.SelectedIndex = -1; //To highlight the tapped item just use something like selectedListBoxItem.Background = new SolidColorBrush(Colors.Green); }
public int SetSearch(string searchText) { int status = 0; try { IQueryable <SearchTerm> searchTermQuery = from searchTerm in (Application.Current as App).db.SearchTerms where searchTerm.search_text == searchText select searchTerm; //if exist update else create if (searchTermQuery.Any()) { SearchTerm searchTermUpdate = searchTermQuery.FirstOrDefault(); searchTermUpdate.is_deleted = 0; searchTermUpdate.date_modified = DateTime.Now; (Application.Current as App).db.SubmitChanges(); } else { SearchTerm searchTerm = new SearchTerm { search_text = searchText, lang_code = AppSettings.TransCodeSetting, is_deleted = 0, date_created = DateTime.Now, date_modified = DateTime.Now, }; (Application.Current as App).db.SearchTerms.InsertOnSubmit(searchTerm); (Application.Current as App).db.SubmitChanges(); } status = 1; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); System.Diagnostics.Debug.WriteLine(ex.StackTrace); } return(status); }
private void OnClearButtonClick(object sender, MouseButtonEventArgs e) { SearchTerm.Text = string.Empty; SearchTerm.Focus(); }
public void Execute(object parameter) { RadDataBoundListBox listBox = ElementTreeHelper.FindVisualAncestor <RadDataBoundListBox>(parameter as DependencyObject); RadContextMenu menu = RadContextMenu.GetContextMenu(listBox); RadDataBoundListBoxItem item = ElementTreeHelper.FindVisualAncestor <RadDataBoundListBoxItem>(parameter as DependencyObject); int chapterNo = 0; int verseNo = 0; string quranText = ""; string verseText = ""; if (item.Content is Verse) { Verse verse = (item.Content as Verse); int result = (Application.Current as App).db.SetLastRead(verse.chapter_id, verse.verse_id); if (result == 0) { MessageBox.Show("Last Read upadate Failed."); } else { //MessageBox.Show("Last Read Saved."); } } if (menu.Name == "menuVerse") { Verse verse = (item.Content as Verse); chapterNo = verse.chapter_id; verseNo = verse.verse_id; quranText = verse.AyahText; verseText = verse.verse_text; } else if (menu.Name == "menuVerseCompare") { VerseCompare verse = (item.Content as VerseCompare); chapterNo = verse.SuraID; verseNo = verse.VerseID; //quranText = verse.AyahText; verseText = verse.AyahText; } else if (menu.Name == "menuIndexItem") { IndexItem verse = (item.Content as IndexItem); chapterNo = verse.chapter_id; verseNo = verse.verse_id; quranText = verse.AyahText; verseText = verse.VerseText; } else if (menu.Name == "menuTopicItem") { TopicItem verse = (item.Content as TopicItem); chapterNo = verse.chapter_id; verseNo = verse.verse_id; quranText = verse.AyahText; verseText = verse.VerseText; } else if (menu.Name == "menuBookMark") { } else if (menu.Name == "menuSearchTerm") { } else { Verse verse = (item.Content as Verse); chapterNo = verse.chapter_id; verseNo = verse.verse_id; quranText = verse.AyahText; verseText = verse.verse_text; } if (this.Name == "CopyCompleteCommand") { string shareTextArabTrans = quranText + " | '" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; //string shareTextTrans = "'"+verseText+"' (" + chapterNo + ":" + verseNo + ")"; Clipboard.SetText(shareTextArabTrans); //MessageBox.Show("Copied to Clipboard: " + shareTextArabTrans); } else if (this.Name == "CopyCommand") { //string shareTextArabTrans = quranText + " '" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; string shareTextTrans = "'" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; Clipboard.SetText(shareTextTrans); //MessageBox.Show("Copied to Clipboard: " + shareTextTrans); } else if (this.Name == "ShareCommand") { //string shareTextArabTrans = quranText + " '" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; string shareTextTrans = "'" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; ShareStatusTask shareStatusTask = new ShareStatusTask(); shareStatusTask.Status = shareTextTrans; shareStatusTask.Show(); } else if (this.Name == "TweetCommand") { //string shareTextArabTrans = quranText + " '" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; string shareTextTrans = "'" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; //http://web.quran360.com/site/verse/tr/26/ch/1/v/1 shareTextTrans = shareTextTrans.Substring(0, 90); shareTextTrans = shareTextTrans + "... (cont) http://web.quran360.com/site/verse/tr/" + AppSettings.TransSetting + "/ch/" + chapterNo + "/v/" + verseNo; ShareStatusTask shareStatusTask = new ShareStatusTask(); shareStatusTask.Status = shareTextTrans; shareStatusTask.Show(); } else if (this.Name == "EmailCommand") { string shareSubject = "Quran360 Share | Quran (" + chapterNo + ":" + verseNo + ")"; string shareTextArabTrans = quranText + " '" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; //string shareTextTrans = "'" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; Microsoft.Phone.Tasks.EmailComposeTask email = new Microsoft.Phone.Tasks.EmailComposeTask(); email.Subject = shareSubject; email.Body = shareTextArabTrans; email.Show(); } else if (this.Name == "SmsCommand") { string shareSubject = "Read Quran: (" + chapterNo + ":" + verseNo + ")"; //string shareTextArabTrans = quranText + " '" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; string shareTextTrans = "'" + verseText + "' (" + chapterNo + ":" + verseNo + ")"; Microsoft.Phone.Tasks.SmsComposeTask sms = new Microsoft.Phone.Tasks.SmsComposeTask(); sms.Body = shareTextTrans; sms.Show(); } else if (this.Name == "SetCheckPointCommand") { try { //int chapterNo = (item.Content as Verse).chapter_id; //int verseNo = (item.Content as Verse).verse_id; int result = (Application.Current as App).db.SetBookMark(chapterNo, verseNo, -1); if (result == 0) { MessageBox.Show("ReadPoint Failed."); } else { //MessageBox.Show("ReadPoint Saved."); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("SetCheckPointCommand failed: " + ex.StackTrace); } } else if (this.Name == "SetBookmarkCommand") { try { //int chapterNo = (item.Content as Verse).chapter_id; //int verseNo = (item.Content as Verse).verse_id; int result = (Application.Current as App).db.SetBookMark(chapterNo, verseNo, (verseNo - 1)); if (result == 0) { MessageBox.Show("BookMark Failed."); } else { //MessageBox.Show("BookMark Saved."); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("SetBookmarkCommand failed: " + ex.StackTrace); } } else if (this.Name == "PlayCommand") { Verse verse = (item.Content as Verse); String url = "http://web.quran360.com/audio/v_saad_al_ghaamidi/00" + verse.chapter_id + "/00" + verse.chapter_id + "00" + verse.verse_id + ".mp3"; } else if (this.Name == "PauseCommand") { } else if (this.Name == "StopCommand") { } else if (this.Name == "DeleteBookMarkCommand") { BookMark bookMark = (item.Content as BookMark); int result = (Application.Current as App).db.DeleteBookMark(bookMark.id); if (result == 0) { MessageBox.Show("Delete BookMark Failed."); } else if (result == 2) { MessageBox.Show("Cannot Delete ReadPoint."); } else { //MessageBox.Show("Delete BookMark Success."); } } else if (this.Name == "DeleteSearchTermCommand") { SearchTerm searchTerm = (item.Content as SearchTerm); int result = (Application.Current as App).db.DeleteSearchTerm(searchTerm.id); if (result == 0) { MessageBox.Show("Delete Search Failed."); } else { //MessageBox.Show("Delete Search Success."); } } //this.ScheduleNotification(menu, item); }
public int SetSearch(string searchText) { int status = 0; try { IQueryable<SearchTerm> searchTermQuery = from searchTerm in (Application.Current as App).db.SearchTerms where searchTerm.search_text == searchText select searchTerm; //if exist update else create if (searchTermQuery.Any()) { SearchTerm searchTermUpdate = searchTermQuery.FirstOrDefault(); searchTermUpdate.is_deleted = 0; searchTermUpdate.date_modified = DateTime.Now; (Application.Current as App).db.SubmitChanges(); } else { SearchTerm searchTerm = new SearchTerm { search_text = searchText, lang_code = AppSettings.TransCodeSetting, is_deleted = 0, date_created = DateTime.Now, date_modified = DateTime.Now, }; (Application.Current as App).db.SearchTerms.InsertOnSubmit(searchTerm); (Application.Current as App).db.SubmitChanges(); } status = 1; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); System.Diagnostics.Debug.WriteLine(ex.StackTrace); } return status; }