Example #1
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 void OnLaunched(LaunchActivatedEventArgs args)
        {
            SearchPane.GetForCurrentView().ShowOnKeyboardInput = true;

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
 void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
 {
     args.Request.SearchSuggestionCollection.AppendQuerySuggestions((from el in elements
                                                                     where el.Name.ToLower().StartsWith(args.QueryText.ToLower()) || el.Symbol.ToLower().StartsWith(args.QueryText.ToLower())
                                                                     orderby el.Name ascending
                                                                     select el.Name).Take(5));
 }
        /// <summary>
        /// User has choose a search suggestion.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void SearchPaneQuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)
        {
            Frame frame;

            if (Window.Current.Content == null)
            {
                frame = new Frame();
            }
            else
            {
                frame = Window.Current.Content as Frame;
            }

            if (args.QueryText.Contains(Consts.SearchSplitter))
            {
                var notebookName = args.QueryText.Substring(0, args.QueryText.IndexOf(Consts.SearchSplitter));
                var noteName     = args.QueryText.Substring(args.QueryText.IndexOf(Consts.SearchSplitter) + Consts.SearchSplitter.Length);
                var notebook     = NotesDataSource.SearchNotebook(notebookName);
                if (notebook == null)
                {
                    return;
                }
                var note = NotesDataSource.SearchNote(notebook.UniqueId, noteName);
                if (note == null)
                {
                    return;
                }

                frame.Navigate(typeof(ItemDetailPage), note.UniqueId);
            }
            else
            {
                frame.Navigate(typeof(SearchResults), args.QueryText);
            }
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     //<Snippetall_searchpane_showonkeyboardinput_on>
     // Turn on type to search.
     SearchPane.GetForCurrentView().ShowOnKeyboardInput = true;
     //</Snippetall_searchpane_showonkeyboardinput_on>
 }
        /// <summary>
        /// Place Splash Screen at the center of the page and register to the following events:
        /// DataTransferManager -> DataRequested
        /// SearchPane -> SuggestionsRequested, SearchPaneQuerySubmitted
        /// SettingsPane -> CommandsRequested
        /// NotesDataSource -> DataCompleted
        /// </summary>
        /// <param name="splashScreen">SplashScreen from IActivatedEventArgs</param>
        async private void Init(SplashScreen splashScreen)
        {
            if (!NotesDataSource.DataLoaded)
            {
                this.InitializeComponent();
                this.splashImageCoordinates = splashScreen.ImageLocation;
                this.splash = splashScreen;

                // Position the extended splash screen image in the same location as the splash screen image.
                this.loader.SetValue(Canvas.LeftProperty, this.splashImageCoordinates.X);
                this.loader.SetValue(Canvas.TopProperty, this.splashImageCoordinates.Y);
                this.loader.Height = this.splashImageCoordinates.Height;
                this.loader.Width  = this.splashImageCoordinates.Width;

                DataTransferManager datatransferManager;
                datatransferManager = DataTransferManager.GetForCurrentView();
                datatransferManager.DataRequested += new TypedEventHandler <DataTransferManager, DataRequestedEventArgs>(this.DataRequested);

                Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize);
                SearchPane.GetForCurrentView().SuggestionsRequested += SearchPaneSuggestionsRequested;
                SearchPane.GetForCurrentView().QuerySubmitted       += SearchPaneQuerySubmitted;

                SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;

                NotesDataSource data = new NotesDataSource();
                data.Completed += Data_Completed;
                await data.Load();
            }
            else
            {
                Data_Completed(this, null);
            }
        }
Example #6
0
        private async void SearchProductGroupAc(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            if (sender.QueryText.Length >= 2)
            {
                var deferral = args.Request.GetDeferral();

                var productGroupAcs = await ProductGroupManager.SearchAutoCompletePgAsync(sender.QueryText, 10);

                var suggestions = args.Request.SearchSuggestionCollection;

                foreach (var pg in productGroupAcs)
                {
                    var productImagesDirFormat = (string)Application.Current.Resources["ProductImagesDirFormat"];
                    var imageUrl = string.Format(productImagesDirFormat, pg.ImageUrl);                                                  //PL: http://localhost:50308/Content/Images/ProductImages/P-Kemiai-elemek-687268.jpg
                    var image    = RandomAccessStreamReference.CreateFromUri(new Uri(imageUrl));

                    suggestions.AppendResultSuggestion(pg.Title, pg.SubTitle, pg.FriendlyUrl, image, pg.Title);
                }

                if (suggestions.Size == 0)
                {
                    var uriMock = RandomAccessStreamReference.CreateFromUri(new Uri("http://valid-uri"));
                    suggestions.AppendResultSuggestion("Nincs találat", "", " ", uriMock, "");
                }

                deferral.Complete();
            }
        }
        // Module 12 - Generating Revenue with your App

        async void App_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            //var deferral = args.Request.GetDeferral();

            //var query = args.QueryText;

            //var pos = await GeopositionDataFetcher.Instance.GetLocationAsync();
            //var possibleDestinations = await LocationsDataFetcher.Instance.SearchLocationsAsync(query);
            //var currentSource = await LocationsDataFetcher.Instance.GetLocationByCountryCodeAsync(pos.CivicAddress.Country);

            //if (currentSource != null)
            //{

            //    foreach (var destination in possibleDestinations)
            //    {
            //        var title = string.Format("{0} to {1}", currentSource.Country, destination.Country);
            //        var detail = string.Format("{0} to {1}", currentSource.City, destination.City);

            //        var img = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/BlueYonderGraphics/flightIcon.png"));
            //        args.Request.SearchSuggestionCollection.AppendResultSuggestion(title,
            //                                                                       detail,
            //                                                                       string.Format("{0}|{1}",
            //                                                                       currentSource.LocationId,
            //                                                                       destination.LocationId),
            //                                                                       img,
            //                                                                       "no image");
            //    }
            //}
            //deferral.Complete();
        }
Example #8
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 void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            SearchPane.GetForCurrentView().SuggestionsRequested += new TypedEventHandler <SearchPane, SearchPaneSuggestionsRequestedEventArgs>(this.OnSearchPaneSuggestionsRequested);
            SettingsPane.GetForCurrentView().CommandsRequested  += this.OnSettingsCommandsRequested;

            // Ensure the current window is active
            Window.Current.Activate();
        }
Example #9
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
#if WINDOWS_PHONE_APP
            if (AppSettings.EnableSingleVerticalLayoutPhone81)
            {
                SearchBoxSnapped.Visibility = Visibility.Visible;
                SearchBoxSnapped.Focus(Windows.UI.Xaml.FocusState.Programmatic);
            }
            else
            {
                SearchBox.Visibility = Visibility.Visible;
                SearchBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
            }
#endif
#if WINDOWS_APP
            try
            {
                SearchPane searchPane;
                searchPane = SearchPane.GetForCurrentView();
                if (!searchPane.Visible)
                {
                    searchPane.Show();
                }
            }
            catch
            {
                //swallow exception
            }
#endif
        }
Example #10
0
        //Providing search suggestions - creates a self populated list from the dogs.txt file
        void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            Dictionary <string, List <BreedDataItem> > _results = new Dictionary <string, List <BreedDataItem> >();
            List <string> termList = new List <string>();
            var           groups   = BreedDataSource.GetGroups("AllGroups");
            string        query    = args.QueryText.ToLower();
            var           all      = new List <BreedDataItem>();

            _results.Add("All", all);

            foreach (var group in groups)
            {
                var items = new List <BreedDataItem>();
                _results.Add(group.ShortTitle, items);

                foreach (var item in group.Items)
                {
                    termList.Add(item.ShortTitle.ToLower());
                }
            }
            foreach (var term in termList)
            {
                if (term.StartsWith(query.ToLower()))
                {
                    args.Request.SearchSuggestionCollection.AppendQuerySuggestion(term);
                }
            }
        }
Example #11
0
        private void RegisterForSearch()
        {
            if (!_isSearchReg)
            {
                _isSearchReg = true;

                // Get Search Pane object
                this.searchPane            = SearchPane.GetForCurrentView();
                searchPane.PlaceholderText = _resourceLoader.GetString("AppSearchPlaceHolder");

                // Register for Search Pane QuerySubmitted event
                try
                {
                    this.searchPane.QuerySubmitted -= searchPane_QuerySubmitted;
                }
                catch { }
                this.searchPane.QuerySubmitted += searchPane_QuerySubmitted;
                //this.searchPane.QueryChanged += searchPane_QueryChanged;

                try
                {
                    this.searchPane.SuggestionsRequested -= searchPane_SuggestionsRequested;
                }
                catch { }
                this.searchPane.SuggestionsRequested += searchPane_SuggestionsRequested;
            }
        }
Example #12
0
        void SearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var vm          = ((DashboardViewModel)DataContext);
            var suggestions = vm.SearchSuggestiongsAsync(args.QueryText);

            args.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions.Result);
        }
Example #13
0
 private void QuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)
 {
     if (args.QueryText == "Apple")
     {
         this.Frame.Navigate(typeof(Apple));
     }
 }
Example #14
0
        /// <summary>
        /// Called when search pane suggestions are requested.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="SearchPaneSuggestionsRequestedEventArgs"/> instance containing the event data.</param>
        private async void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs e)
        {
            var queryText = e.QueryText;

            if (!string.IsNullOrEmpty(queryText))
            {
                // The deferral object is used to supply suggestions asynchronously for example when fetching suggestions from a web service.
                var deferral = e.Request.GetDeferral();
                try
                {
                    Debug.WriteLine("Requesting suggestions for query: " + queryText);
                    ListResponse <string> suggestions = await ApiClient.GetSearchSuggestionsAsync(queryText, 5);

                    if (suggestions.Result != null)
                    {
                        e.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions.Result);
                        Debug.WriteLine("Suggestions provided for query: " + queryText);
                    }
                    else
                    {
                        Debug.WriteLine("No suggestions provided for query: " + queryText + " error: " + suggestions.Error.Message);
                    }
                }
                catch (Exception)
                {
                    Debug.WriteLine("Suggestions could not be displayed");
                }
                finally
                {
                    deferral.Complete();
                }
            }
        }
Example #15
0
 private void Search_Click(object sender, RoutedEventArgs e)
 {
     SearchPane.GetForCurrentView().SuggestionsRequested += SuggestionsRequested;
     SearchPane.GetForCurrentView().Show();
     SearchPane.GetForCurrentView().QuerySubmitted += QuerySubmitted;
     SearchPane.GetForCurrentView().Show();
 }
Example #16
0
        private void OnSearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var request          = args.Request;
            var matches          = _cities.Where(x => x.Name.StartsWith(args.QueryText, StringComparison.OrdinalIgnoreCase)).Take(10);
            var matchesTimeZones = _cities.GroupBy(x => x.TimeZoneId).Where(x => x.Key.StartsWith(args.QueryText, StringComparison.OrdinalIgnoreCase)).Take(10);

            request.SearchSuggestionCollection.AppendQuerySuggestions(matches.Select(m => m.Name));
            request.SearchSuggestionCollection.AppendQuerySuggestions(matchesTimeZones.Select(m => m.Key));

            var resultSuggestion = matches.Where(x => x.Name.Equals(args.QueryText, StringComparison.OrdinalIgnoreCase)).Take(5);

            if (!resultSuggestion.Any())
            {
                return;
            }

            var image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/city.png"));

            foreach (var match in resultSuggestion)
            {
                request.SearchSuggestionCollection.AppendResultSuggestion(match.Name,
                                                                          match.CountryName + ", " + match.State,
                                                                          match.Id.ToString(), image, match.CountryName);
            }
        }
Example #17
0
 void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
 {
     args.Request.SearchSuggestionCollection.AppendQuerySuggestions((from el in App.MainViewModel.repos
                                                                     where el.name.ToLower().StartsWith(args.QueryText.ToLower())
                                                                     orderby el.name ascending
                                                                     select el.name).Take(5));
 }
        private void SetupSearchSuggestions()
        {
            _currentSearchPane = SearchPane.GetForCurrentView();

            _currentSearchPane.PlaceholderText       = "Search for a Car by Name";
            _currentSearchPane.SuggestionsRequested += CurrentSearchPaneOnSuggestionsRequested;
        }
Example #19
0
 public Scenario2()
 {
     this.InitializeComponent();
     // <Snippetcs_get_searchpane>
     searchPane = SearchPane.GetForCurrentView();
     // </Snippetcs_get_searchpane>
 }
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);

            SearchPane searchPane = SearchPane.GetForCurrentView();

            searchPane.SuggestionsRequested -= searchPane_SuggestionsRequested;
        }
Example #21
0
 public SplitPage()
 {
     InitializeComponent();
     App.SearchPane = SearchPane.GetForCurrentView();
     App.SearchPane.QuerySubmitted += new TypedEventHandler <SearchPane, SearchPaneQuerySubmittedEventArgs>(SearchPane_QuerySubmitted);
     ShareSourceLoad();
     ShareButton.Click += new RoutedEventHandler(ShareButton_Click);
 }
Example #22
0
        private void SearchPane_QuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)
        {
            var navService = (INavigationService)_container.GetInstance(typeof(INavigationService), null);

            navService.Navigate(typeof(SearchResultsView), new SearchTextParameter(args.QueryText));

            Window.Current.Activate();
        }
Example #23
0
        private void SetupRealtimeSearchEvents()
        {
            _currentSearchPane = SearchPane.GetForCurrentView();
            _currentSearchPane.QueryChanged         += SearchPaneQueryChanged;
            _currentSearchPane.SuggestionsRequested += SearchPaneSuggestionsRequested;

            _currentSearchPane.PlaceholderText = "Search for Content";
        }
Example #24
0
        private async void OnSearchSuggestionRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var deferral    = args.Request.GetDeferral();
            var suggestions = await SuggestionProvider.GetSuggestionsAsync(args.QueryText);

            args.Request.SearchSuggestionCollection.AppendQuerySuggestions(suggestions);
            deferral.Complete();
        }
Example #25
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            SearchPane.GetForCurrentView().ShowOnKeyboardInput = false;
            var deferral = e.SuspendingOperation.GetDeferral();

            //TODO: Save application state and stop any background activity
            deferral.Complete();
        }
Example #26
0
        /// <summary>
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// </summary>
        /// <param name="sender">The source of the suspend request.</param>
        /// <param name="e">Details about the suspend request.</param>
        private async void OnSuspending(object sender, SuspendingEventArgs e)
        {
            SearchPane.GetForCurrentView().ShowOnKeyboardInput = true;
            var deferral = e.SuspendingOperation.GetDeferral();
            await SuspensionManager.SaveAsync();

            deferral.Complete();
        }
Example #27
0
 public void OnCoverPress(object sender, MouseButtonEventArgs args)
 {
     if ((sender as FrameworkElement).Resources.Contains("i"))
     {
         AsyncFetchManga((string)(sender as FrameworkElement).Resources["i"]);
         SearchPane.ScrollToTop();
     }
 }
        private void MainPage_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            SearchSuggestionCollection coll = args.Request.SearchSuggestionCollection;

            if (args.QueryText.StartsWith("c", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Carolla");
                coll.AppendQuerySuggestion("Carmy carolla");
                coll.AppendQuerySuggestion("Carmy Highbrid");
                coll.AppendQuerySuggestion("Concept vehicles");
            }
            else if (args.QueryText.StartsWith("4", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("4 Runner");
                coll.AppendQuerySuggestion("Runner Flat");
            }
            else if (args.QueryText.StartsWith("h", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("High Lander");
                coll.AppendQuerySuggestion("High Lander Brid");
            }
            else if (args.QueryText.StartsWith("l", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Land Cruiser");
                coll.AppendQuerySuggestion("Runner Flat");
            }
            else if (args.QueryText.StartsWith("t", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Tacoma");
                coll.AppendQuerySuggestion("Tundra");
            }
            else if (args.QueryText.StartsWith("r", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Rav 4");
            }
            else if (args.QueryText.StartsWith("s", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Sienna");
                coll.AppendQuerySuggestion("Sequaio");
            }
            else if (args.QueryText.StartsWith("a", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Avalon");
                coll.AppendQuerySuggestion("Avalon Hybrid");
            }
            else if (args.QueryText.StartsWith("p", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Prius");
                coll.AppendQuerySuggestion("Prius C");
                coll.AppendQuerySuggestion("Prius V");
            }
            else if (args.QueryText.StartsWith("y", StringComparison.CurrentCultureIgnoreCase))
            {
                coll.AppendQuerySuggestion("Yaris");
                coll.AppendQuerySuggestion("Yaris C");
                coll.AppendQuerySuggestion("Yaris V");
            }
        }
Example #29
0
        /// <summary>
        /// Preserves state associated with this page in case the application is suspended or the
        /// page is discarded from the navigation cache.  Values must conform to the serialization
        /// requirements of <see cref="SuspensionManager.SessionState"/>.
        /// </summary>
        /// <param name="pageState">An empty dictionary to be populated with serializable state.</param>
        protected override void SaveState(Dictionary <String, Object> pageState)
        {
            var selectedItem = (Comic)FlipView.SelectedItem;

            pageState["SelectedItem"] = selectedItem.Number;
            UnregisterForPrinting();
            SearchPane.GetForCurrentView().ShowOnKeyboardInput = false;
            _dataTransferManager.DataRequested -= OnDataRequested;
        }
Example #30
0
 /// <summary>
 /// Raises the WindowCreated event.
 /// </summary>
 /// <param name="args">The <see cref="WindowCreatedEventArgs"/> instance containing the event data.</param>
 protected override void OnWindowCreated(WindowCreatedEventArgs args)
 {
     if (AppManifestHelper.IsSearchDeclared())
     {
         // Register the Windows.ApplicationModel.Search.SearchPane.GetForCurrentView().QuerySubmitted
         // event in OnWindowCreated to speed up searches once the application is already running
         SearchPane.GetForCurrentView().QuerySubmitted += OnQuerySubmitted;
     }
 }