Inheritance: ISearchPane
 public static void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
 {
     args.Request.SearchSuggestionCollection.AppendQuerySuggestions((from result in Utils.DataManager.searchables
                                                                     where result.resultTitle.ToLower().StartsWith(args.QueryText.ToLower())
                                                                     orderby result.resultTitle ascending
                                                                     select result.resultTitle).Take(5));
 }
        void SearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var vm = ((DashboardViewModel)DataContext);
            var suggestions = vm.SearchSuggestiongsAsync(args.QueryText);

            args.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions.Result);
        }
 void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
 {
      args.Request.SearchSuggestionCollection.AppendQuerySuggestions((from el in students
                                                                     where el.Name.StartsWith(args.QueryText) 
                                                                     orderby el.Name ascending
                                                                     select el.Name).Take(5));
 }
Example #4
0
        private void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;
            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search pane to submit a query", NotifyType.StatusMessage);
            }
            else
            {
                var request = e.Request;
                foreach (string suggestion in suggestionList)
                {
                    if (suggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
                    {
                        // Add suggestion to Search Pane
                        request.SearchSuggestionCollection.AppendQuerySuggestion(suggestion);

                        // Break since the Search Pane can show at most 25 suggestions
                        if (request.SearchSuggestionCollection.Size >= MainPage.SearchPaneMaxSuggestions)
                        {
                            break;
                        }
                    }
                }

                if (request.SearchSuggestionCollection.Size > 0)
                {
                    MainPage.Current.NotifyUser("Suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                }
                else
                {
                    MainPage.Current.NotifyUser("No suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                }
            }
        }
        private void SetupSearchSuggestions()
        {
            _currentSearchPane = SearchPane.GetForCurrentView();

            _currentSearchPane.PlaceholderText = "Search for a Car by Name";
            _currentSearchPane.SuggestionsRequested += CurrentSearchPaneOnSuggestionsRequested;
        }
 /// <summary>
 /// Creates the search controller.
 /// </summary>
 public SearchController()
 {
     this.searchPane = SearchPane.GetForCurrentView();
     if (this.searchPane != null)
     {
         this.searchPane.QuerySubmitted += OnAppQuerySubmitted;            
     }
 }
        public ListeBiens() {

            this.InitializeComponent();

            this.DataContext = this;

            this._panelRecherche = SearchPane.GetForCurrentView();
            this._panelRecherche.QuerySubmitted += _panelRecherche_QuerySubmitted;
        }
Example #8
0
 void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
 {
     string query = args.QueryText.ToLower();
     
     if (suggestionList != null)
     {
         List<string> result = suggestionList.FindAll(a => a.Contains(query));
         args.Request.SearchSuggestionCollection.AppendQuerySuggestions(result);
     }
 }
        private void SetupRealtimeSearchEvents()
        {

            _currentSearchPane = SearchPane.GetForCurrentView();
            _currentSearchPane.QueryChanged += SearchPaneQueryChanged;
            _currentSearchPane.SuggestionsRequested += SearchPaneSuggestionsRequested;

            _currentSearchPane.PlaceholderText = "Search for Content";

        }
Example #10
0
        private async void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;
            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search pane to submit a query", NotifyType.StatusMessage);
            }
            else if (string.IsNullOrEmpty(UrlTextBox.Text))
            {
                MainPage.Current.NotifyUser("Please enter the web service URL", NotifyType.StatusMessage);
            }
            else
            {
                // The deferral object is used to supply suggestions asynchronously for example when fetching suggestions from a web service.
                var request = e.Request;
                var deferral = request.GetDeferral();

                try
                {
                    // Use the web service Url entered in the UrlTextBox that supports OpenSearch Suggestions in order to see suggestions come from the web service.
                    // See http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions/1.0 for details on OpenSearch Suggestions format.
                    // Replace "{searchTerms}" of the Url with the query string.
                    Task task = GetSuggestionsAsync(Regex.Replace(UrlTextBox.Text, "{searchTerms}", Uri.EscapeDataString(queryText)), request.SearchSuggestionCollection);
                    await task;

                    if (task.Status == TaskStatus.RanToCompletion)
                    {
                        if (request.SearchSuggestionCollection.Size > 0)
                        {
                            MainPage.Current.NotifyUser("Suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                        }
                        else
                        {
                            MainPage.Current.NotifyUser("No suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                        }
                    }
                }
                catch (TaskCanceledException)
                {
                    // We have canceled the task.
                }
                catch (FormatException)
                {
                    MainPage.Current.NotifyUser(@"Suggestions could not be retrieved, please verify that the URL points to a valid service (for example http://contoso.com?q={searchTerms}", NotifyType.ErrorMessage);
                }
                catch (Exception)
                {
                    MainPage.Current.NotifyUser("Suggestions could not be displayed, please verify that the service provides valid OpenSearch suggestions", NotifyType.ErrorMessage);
                }
                finally
                {
                    deferral.Complete();
                }
            }
        }
Example #11
0
        void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            string query = args.QueryText.ToLower();
            string[] terms = { "salt", "pepper", "water", "egg", "vinegar", "flour", "rice", "sugar", "oil" };

            foreach (var term in terms)
            {
                if (term.StartsWith(query))
                    args.Request.SearchSuggestionCollection.AppendQuerySuggestion(term);
            }
        }
Example #12
0
        private void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;
            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search pane to submit a query", NotifyType.StatusMessage);
            }
            else
            {
                var request = e.Request;
                bool isRecommendationFound = false;
                foreach (string suggestion in suggestionList)
                {
                    // TODO: create a recommendation when full hit
                    if (suggestion.CompareTo(queryText) == 0)
                    {
                        // Add recommendation to Search Pane
                        RandomAccessStreamReference image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/windows-sdk.png"));

                        request.SearchSuggestionCollection.AppendResultSuggestion(
                            suggestion,              // text to display 
                            "found " + suggestion,   // details
                            "tag#" + suggestion,     // tags usable when called back by ResultSuggestionChosen event
                            image,                   // image if any
                            "image of " + suggestion // image alternate text
                            );
                        isRecommendationFound = true;
                    }
                    else  // otherwise, this is a suggestion
                    if (suggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
                    {
                        // Add suggestion to Search Pane
                        request.SearchSuggestionCollection.AppendQuerySuggestion(suggestion);
                    }

                    // Break since the Search Pane can show at most 5 suggestions
                    if (request.SearchSuggestionCollection.Size >= MainPage.SearchPaneMaxSuggestions)
                    {
                        break;
                    }
                }

                if (request.SearchSuggestionCollection.Size > 0)
                {
                    // TODO: show if it is a recommendation or just a partial suggestion
                    string prefix = isRecommendationFound ? "*" : "";
                    MainPage.Current.NotifyUser(prefix + "Suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                }
                else
                {
                    MainPage.Current.NotifyUser("No suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                }
            }
        }
Example #13
0
        private void SearchPaneOnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var navigator = _container.Resolve<IRtNavigator>();

            var result = navigator.GetData<SearchController, SearchResult[]>(c => c.SearchForSuggestions(args.QueryText));

            args.Request.SearchSuggestionCollection.AppendQuerySuggestions(
                result.Data
                .OrderBy(r => r.Description)
                .Select(r => r.Description)
                .Distinct());
        }
Example #14
0
 private async void searchPane_SuggestionsRequested(SearchPane sender,
                                                    SearchPaneSuggestionsRequestedEventArgs args)
 {
     if (args.QueryText.Length >= 2)
     {
         var linkService = ServiceLocator.Current.GetInstance<ILinkService>();
         SearchPaneSuggestionsRequestDeferral deferral = args.Request.GetDeferral();
         List<Link> results = await linkService.Search(args.QueryText);
         List<string> searchResults = results.Select(s => s.Name).ToList();
         args.Request.SearchSuggestionCollection.AppendQuerySuggestions(searchResults);
         deferral.Complete();
     }
 }
 private async void OnQuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)
 {
     try
     {
         await _messageHub.Send(new SearchQuerySubmittedMessage(args.QueryText));
     }
     catch (Exception ex)
     {
         // Due to an issues I've noted online: http://social.msdn.microsoft.com/Forums/en/winappswithcsharp/thread/bea154b0-08b0-4fdc-be31-058d9f5d1c4e
         // I am limiting the use of 'async void'  In a few rare occasions I use it
         // and manually route the exceptions to the UnhandledExceptionHandler
         ((App)App.Current).OnUnhandledException(ex);
     }
 }
Example #16
0
        public PageMap()
        {
            this.InitializeComponent();

            _searchPane = SearchPane.GetForCurrentView();
            _searchPane.PlaceholderText = "Please enter your address";
            _searchPane.ShowOnKeyboardInput = true;
            _searchPane.SearchHistoryEnabled = false;

            _mapDataAccess = new DataAccess<MapModel>();
            _mapLocationAccess = new DataAccess<MapLocationModel>();
            _mapLocationFolderAccess = new DataAccess<MapLocationFolderModel>();

            _mapPins = new ObservableCollection<MapPin>();
        }
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            _searchPane = SearchPane.GetForCurrentView();
            _searchPane.QuerySubmitted += QuerySubmitted;
            _searchPane.SuggestionsRequested += SuggestionsRequested;

            _dataTransfer = DataTransferManager.GetForCurrentView();
            _dataTransfer.DataRequested += DataRequested;

            _playToManager = PlayToManager.GetForCurrentView();
            _playToManager.SourceRequested += SourceRequested;

            _settingsPane = SettingsPane.GetForCurrentView();
            _settingsPane.CommandsRequested += CommandsRequested;
        }
Example #18
0
        void searchPanel_SuggestionsRequested(SearchPane s, SearchPaneSuggestionsRequestedEventArgs e)
        {
            //provide search suggestions to the search pane

            //http://weblogs.asp.net/nmarun/archive/2012/09/28/implementing-search-contract-in-windows-8-application.aspx

            IEnumerable<string> names = from suggestion in ((App)App.Current).AvailableStations
                                        where suggestion.Title.StartsWith(e.QueryText,
                                                                   StringComparison.CurrentCultureIgnoreCase)
                                        select suggestion.Title;

            // Take(5) is implemented because the SearchPane 
            // can show a maximum of 5 suggestions
            // passing a larger collection will only show the first 5
            e.Request.SearchSuggestionCollection.AppendQuerySuggestions(names.Take(5));
        }
        void _panelRecherche_QuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args) {
            if (args.QueryText != String.Empty) {
                var resultats = from bien in _biensReference
                                where bien.Titre.Contains(args.QueryText)
                                select bien;

                _biensAffiches.Clear();
                foreach (BienEntite bien in resultats)
                    _biensAffiches.Add(bien);
            }
            else {
                _biensAffiches.Clear();
                foreach (BienEntite bien in _biensReference)
                    _biensAffiches.Add(bien);
            }
        }
Example #20
0
        private void SetupSearch(string initial = null)
        {
            if (searchPanel == null)
            {
                searchPanel = SearchPane.GetForCurrentView(); //grab the search pane
                searchPanel.PlaceholderText = LocalizationManager.GetLocalizedValue("SearchPanePlaceholder"); //grab the localized place holder text
                if (initial != null)
                    searchPanel.Show(initial); //show the searchpanel if it doesn't have a value already.
            }

            searchPanel.QuerySubmitted += searchPanel_QuerySubmitted;

            searchPanel.SuggestionsRequested += searchPanel_SuggestionsRequested;

            //if (initial != null)
            //    searchPanel.Show(initial);
        }
 /// <summary>
 /// Called when the user submits a search query.
 /// </summary>
 private async void OnAppQuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)
 {
     var frame = Window.Current.Content as Frame;
     if (frame != null)
     {
         var searchResultsPage = frame.Content as MainPage;
         if (searchResultsPage != null)
         {
             var viewModel = searchResultsPage.DataContext as SearchResultsPageControlViewModel;
             if (viewModel != null)
             {
                 await viewModel.SearchAsync(args.QueryText);
             }
             else
             {
                 await NavigationController.Instance.NavigateToPageControlAsync<SearchResultsPageControl>(args.QueryText);
             }
         }
     }
 }
Example #22
0
        private async void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;
            if (string.IsNullOrEmpty(queryText))
            {
                MainPage.Current.NotifyUser("Use the search pane to submit a query", NotifyType.StatusMessage);
            }
            else
            {
                // The deferral object is used to supply suggestions asynchronously for example when fetching suggestions from a web service.
                var request = e.Request;
                var deferral = request.GetDeferral();

                StorageFile file = await Package.Current.InstalledLocation.GetFileAsync(exampleResponse);
                string response = await FileIO.ReadTextAsync(file);
                JsonArray parsedResponse = JsonArray.Parse(response);
                if (parsedResponse.Count > 1)
                {
                    parsedResponse = JsonArray.Parse(parsedResponse[1].Stringify());
                    foreach (JsonValue value in parsedResponse)
                    {
                        request.SearchSuggestionCollection.AppendQuerySuggestion(value.GetString());
                        if (request.SearchSuggestionCollection.Size >= MainPage.SearchPaneMaxSuggestions)
                        {
                            break;
                        }
                    }
                }

                if (request.SearchSuggestionCollection.Size > 0)
                {
                    MainPage.Current.NotifyUser("Suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                }
                else
                {
                    MainPage.Current.NotifyUser("No suggestions provided for query: " + queryText, NotifyType.StatusMessage);
                }

                deferral.Complete();
            }
        }
Example #23
0
        public async Task EnableSearch()
        {
            this.searchTerms = await new DemoItemsData().GetSearchTerms();
            this.searchTerms = this.searchTerms.Distinct().ToList();
            this.searchTerms.Sort();

            Nullable <bool> demoEnabled = (Nullable <bool>)ApplicationData.Current.RoamingSettings.Values[SettingsFlyoutHelper.DemoSettingStorageString];

            if (demoEnabled == null)
            {
                ApplicationData.Current.RoamingSettings.Values[SettingsFlyoutHelper.DemoSettingStorageString] = false;
            }

            int  count  = 0;
            bool repeat = true;

            while (repeat)
            {
                try
                {
                    count++;
                    Windows.ApplicationModel.Search.SearchPane searchPane = SearchPane.GetForCurrentView();

                    // Register QuerySubmitted handler for the window at window
                    // creation time and only registered once
                    // so that the app can receive user queries at any time.
                    searchPane.QuerySubmitted +=
                        new TypedEventHandler <SearchPane,
                                               SearchPaneQuerySubmittedEventArgs>(this.OnQuerySubmitted);
                    SearchPane.GetForCurrentView().ShowOnKeyboardInput = true;
                    SearchPane.GetForCurrentView().SuggestionsRequested
                          += OnSuggestionsRequested;
                    repeat = false;
                }
                catch (Exception)
                {
                }
            }
        }
Example #24
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;
            
            if (rootFrame == null)
            {
                rootFrame = new Frame();
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException) { }
                }

                Window.Current.Content = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                if (!rootFrame.Navigate(typeof(Categories)))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            searchPane = SearchPane.GetForCurrentView();

            ElementsDataSource model = new ElementsDataSource();
            await model.LoadElements();
            elements = model.Elements;

            Window.Current.Activate();

            searchPane.SuggestionsRequested += new TypedEventHandler<SearchPane, SearchPaneSuggestionsRequestedEventArgs>(OnSearchPaneSuggestionsRequested);
        }
Example #25
0
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            _SearchPane = SearchPane.GetForCurrentView();
            _SearchPane.SuggestionsRequested += searchPane_SuggestionsRequested;

            SettingsPane.GetForCurrentView().CommandsRequested += App_SettingsRequested;

            var rootFrame = Window.Current.Content as Frame;
            if (rootFrame == null)
            {
                rootFrame = new Frame();
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                if (!rootFrame.Navigate(typeof (AppHub), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            Window.Current.Activate();
        }
Example #26
0
        public CalendarPage()
        {
            this.InitializeComponent();

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();

            this.TopAppBar.Content = new PrayerTimes.AppBar(this);

            searchPane = SearchPane.GetForCurrentView();
            searchPane.QuerySubmitted += new TypedEventHandler<SearchPane, SearchPaneQuerySubmittedEventArgs>(this.OnQuerySubmitted);
            //searchPane.SuggestionsRequested += new TypedEventHandler<SearchPane, SearchPaneSuggestionsRequestedEventArgs>(this.OnSearchPaneSuggestionsRequested);


            //_compass = Compass.GetDefault(); // Get the default compass object
            //// Assign an event handler for the compass reading-changed event
            //if (_compass != null)
            //{
            //    // Establish the report interval for all scenarios
            //    uint minReportInterval = _compass.MinimumReportInterval;
            //    uint reportInterval = minReportInterval > 16 ? minReportInterval : 16;
            //    _compass.ReportInterval = reportInterval;
            //    _compass.ReadingChanged += new TypedEventHandler<Compass, CompassReadingChangedEventArgs>(ReadingChanged);
            //}
        }
 private void App_QuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)
 {
     //
     // check
     //
     if (RootFrame != null)
     {
         //
         // If the app is already running and uses top-level frame navigation we can just
         // navigate to the search results
         //
         RootFrame.Navigate(typeof(SearchResultsPage1), args.QueryText);
     }
 }
Example #28
0
 //添加改变选中项的方法并推送到UI
 void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
 {
     foreach (singer temp in vmodel.MyList)
     {
         string MaybeRight = temp.Title;
         if (MaybeRight.StartsWith(args.QueryText, StringComparison.CurrentCultureIgnoreCase))
         {
             args.Request.SearchSuggestionCollection.AppendQuerySuggestion(MaybeRight);
         }
     }
 }
 void SearchPane_QuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)
 {
     // search something
 }
Example #30
0
 public Scenario5()
 {
     this.InitializeComponent();
     searchPane = SearchPane.GetForCurrentView();
     httpClient = new HttpClient();
 }
Example #31
0
        //
        // http://blog.falafel.com/Blogs/john-waters/2012/10/10/doing-an-asynchronous-search-in-windows-8
        //
        async void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            string query = args.QueryText.ToLower();

            var deferral = args.Request.GetDeferral();

            try
            {
                var ctx = new RisDbContext();
                var matches = await ctx.GetHistoryEntriesStartingWith(query);

                args.Request.SearchSuggestionCollection.AppendQuerySuggestions(matches);
            }
            finally
            {
                deferral.Complete();
            }
        }
Example #32
0
 void searchPane_QuerySubmitted(Windows.ApplicationModel.Search.SearchPane sender, Windows.ApplicationModel.Search.SearchPaneQuerySubmittedEventArgs args)
 {
     ((ItemsShowcaseViewModel)DataContext).SearchCommand.Execute(sender.QueryText);
     backButton.Visibility = Visibility.Visible;
     Grid.SetColumn(titlePanel, 1);
 }