/// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var group = OptredenDataSource.GetGroup((String)navigationParameter);

            this.DefaultViewModel["Group"] = group;
            this.DefaultViewModel["Items"] = group.Items;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var recipeDataGroups = OptredenDataSource.GetGroups((String)navigationParameter);

            this.DefaultViewModel["Groups"] = recipeDataGroups;
            this.groupGridView.ItemsSource  = this.groupedItemsViewSource.View.CollectionGroups;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Invoked when the application is activated to display search results.
        /// </summary>
        /// <param name="e">Details about the activation request.</param>
        protected async override void OnSearchActivated(Windows.ApplicationModel.Activation.SearchActivatedEventArgs e)
        {
            //reinitialize the app if a new instance was launched for search
            if (e.PreviousExecutionState == ApplicationExecutionState.NotRunning ||
                e.PreviousExecutionState == ApplicationExecutionState.ClosedByUser ||
                e.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //Load recipe data
                await OptredenDataSource.LoadLocalDataAsync();

                //Register handler for SuggestionsRequested
                SearchPane.GetForCurrentView().SuggestionsRequested += App_SuggestionsRequested;
                //register handler for CommandsRequested events from the settings pane
                SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested;
            }
            // TODO: Register the Windows.ApplicationModel.Search.SearchPane.GetForCurrentView().QuerySubmitted
            // event in OnWindowCreated to speed up searches once the application is already running

            // If the Window isn't already using Frame navigation, insert our own Frame
            var previousContent = Window.Current.Content;
            var frame           = previousContent as Frame;

            // If the app does not contain a top-level frame, it is possible that this
            // is the initial launch of the app. Typically this method and OnLaunched
            // in App.xaml.cs can call a common method.
            if (frame == null)
            {
                // Create a Frame to act as the navigation context and associate it with
                // a SuspensionManager key
                frame = new Frame();
                DemoApp.Common.SuspensionManager.RegisterFrame(frame, "AppFrame");

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await DemoApp.Common.SuspensionManager.RestoreAsync();
                    }
                    catch (DemoApp.Common.SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }
            }

            frame.Navigate(typeof(SearchResultsPage), e.QueryText);
            Window.Current.Content = frame;

            // Ensure the current window is active
            Window.Current.Activate();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override async void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display
            if (pageState != null && pageState.ContainsKey("SelectedItem"))
            {
                navigationParameter = pageState["SelectedItem"];
            }

            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var item = await OptredenDataSource.GetItem((String)navigationParameter);

            if (item != null)
            {
                this.DefaultViewModel["Group"] = item.Group;
                this.DefaultViewModel["Items"] = item.Group.Items;
                this.flipView.SelectedItem     = item;
            }
            DataTransferManager.GetForCurrentView().DataRequested += ItemDetailPage_DataRequested;
        }
Ejemplo n.º 5
0
        //You can search by name of the band or by genre, if the querytext matches a genre, all bands of that genre are shown, bands that match are shown anyway
        //filtering is by genre

        #region search
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            var queryText = navigationParameter as String;

            // TODO: Application-specific searching logic.  The search process is responsible for
            //       creating a list of user-selectable result categories:
            //
            //       filterList.Add(new Filter("<filter name>", <result count>));
            //
            //       Only the first filter, typically "All", should pass true as a third argument in
            //       order to start in an active state.  Results for the active filter are provided
            //       in Filter_SelectionChanged below.

            var filterList = new List <Filter>();


            //search recipes and tabulate results
            IEnumerable <LineUpDataGroup> groups = OptredenDataSource.GetGroups("AllGroups");
            string query = queryText.ToLower();
            ObservableCollection <OptredenDataItem> all = new ObservableCollection <OptredenDataItem>();

            foreach (var groupie in groups)
            {
                foreach (var optreden in groupie.Items)
                {
                    all.Add(optreden);
                }
            }

            //filterList.Add(new Filter("All", all.Count(), true));

            var bands = Festival.SingleFestival.Bands;

            foreach (Genre genre in Festival.SingleFestival.Genres)
            {
                var optredens = new ObservableCollection <OptredenDataItem>();
                if (genre.Name.ToLower().Contains(query))
                {
                    foreach (Band band in bands.Where(ba => ba.Genres.Where(ge => ge.ID == genre.ID).Count() > 0))
                    {
                        foreach (OptredenDataItem optreden in all.Where(optredenr => optredenr.Band.ID == band.ID))
                        {
                            optredens.Add(optreden);
                        }
                    }
                }
                _results.Add(genre.Name, optredens);
            }

            foreach (Band band in bands)
            {
                foreach (Genre genre in band.Genres)
                {
                    foreach (OptredenDataItem optreden in all.Where(optredenr => optredenr.Band.ID == band.ID))
                    {
                        if (!_results[genre.Name].Contains(optreden) && optreden.Band.Name.ToLower().Contains(query))
                        {
                            _results[genre.Name].Add(optreden);
                        }
                    }
                }
            }
            var allval = new ObservableCollection <OptredenDataItem>();

            foreach (KeyValuePair <string, ObservableCollection <OptredenDataItem> > keypair in _results)
            {
                foreach (var optreden in keypair.Value)
                {
                    if (!allval.Contains(optreden))
                    {
                        allval.Add(optreden);
                    }
                }
            }
            _results.Add("All", allval);
            filterList.Add(new Filter("All", allval.Count(), true));
            foreach (KeyValuePair <string, ObservableCollection <OptredenDataItem> > keypair in _results)
            {
                int count = keypair.Value.Count();
                if (count > 0 && keypair.Key != "All")
                {
                    filterList.Add(new Filter(keypair.Key, count, false));
                }
            }

            // Communicate results through the view model
            this.DefaultViewModel["QueryText"]   = '\u201c' + queryText + '\u201d';
            this.DefaultViewModel["Filters"]     = filterList;
            this.DefaultViewModel["ShowFilters"] = filterList.Count > 1;
        }
Ejemplo n.º 6
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;

            // 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();
                //Associate the frame with a SuspensionManager key
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }
                // Load recipe data
                try
                {
                    await OptredenDataSource.LoadRemoteDataAsync();
                }
                catch (Exception) { }

                //if the app was closed by the user the last time it ran, and if "Remember
                //where i was" is enabled, restore the navigation state
                if (args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser)
                {
                    if (ApplicationData.Current.RoamingSettings.Values.ContainsKey("Remember"))
                    {
                        bool remember = (bool)ApplicationData.Current.RoamingSettings.Values["Remember"];
                        if (remember)
                        {
                            await SuspensionManager.RestoreAsync();
                        }
                    }
                }
                //register handler for SuggestionsRequested events from the search pane
                SearchPane.GetForCurrentView().SuggestionsRequested += App_SuggestionsRequested;

                //register handler for CommandsRequested events from the settings pane
                SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested;



                var file = await Package.Current.InstalledLocation.GetFileAsync(@"Data\license.xml");

                await Windows.ApplicationModel.Store.CurrentAppSimulator.ReloadSimulatorAsync(file);

                if (!string.IsNullOrWhiteSpace(args.Arguments))
                {
                    rootFrame.Navigate(typeof(ItemDetailPage), args.Arguments);
                    Window.Current.Content = rootFrame;
                    Window.Current.Activate();
                    return;
                }

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

            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                if (!String.IsNullOrWhiteSpace(args.Arguments))
                {
                    ((Frame)Window.Current.Content).Navigate(typeof(ItemDetailPage),
                                                             args.Arguments);
                }
                Window.Current.Activate();
                return;
            }

            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(GroupedItemsPage), "AllGroups"))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }