/// <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="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var groups = await RecipeDataSource.GetGroupsAsync(); this.DefaultViewModel["RecipeGroups"] = groups; }
/// <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="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { // TODO: Create an appropriate data model for your problem domain to replace the sample data. var group = await RecipeDataSource.GetGroupAsync((string)e.NavigationParameter); this.DefaultViewModel["Group"] = group; }
/// <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 sampleDataGroups = RecipeDataSource.GetGroups((String)navigationParameter); this.DefaultViewModel["Groups"] = sampleDataGroups; }
/// <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="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { var recipeDataGroups = await RecipeDataSource.GetGroupsAsync((String)e.NavigationParameter); this.DefaultViewModel["AllGroups"] = recipeDataGroups; groupListView.SelectedItem = null; }
/// <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="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { var group = await RecipeDataSource.GetGroupAsync((string)e.NavigationParameter); this.DefaultViewModel["Group"] = group; lstRecipes.SelectedItem = null; }
/// <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 } } if (args.PreviousExecutionState == ApplicationExecutionState.Running) { Window.Current.Activate(); return; } // Load recipe data await RecipeDataSource.LoadLocalDataAsync(); // Place the frame in the current Window Window.Current.Content = rootFrame; // 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(GroupedItemsPage), "AllGroups")) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Invoked when the application is activated to display search results. /// </summary> /// <param name="args">Details about the activation request.</param> protected async override void OnSearchActivated(Windows.ApplicationModel.Activation.SearchActivatedEventArgs args) { // TODO: Register the Windows.ApplicationModel.Search.SearchPane.GetForCurrentView().QuerySubmitted // event in OnWindowCreated to speed up searches once the application is already running // Reinitialize the app if a new instance was launched for search if (args.PreviousExecutionState == ApplicationExecutionState.NotRunning || args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser || args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Load recipe data await RecipeDataSource.LoadLocalDataAsync(); // Register handler for SuggestionsRequested events from the search pane SearchPane.GetForCurrentView().SuggestionsRequested += OnSuggestionsRequested; // Register handler for CommandsRequested events from the settings pane SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; } // 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(); ContosoCookbook.Common.SuspensionManager.RegisterFrame(frame, "AppFrame"); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate try { await ContosoCookbook.Common.SuspensionManager.RestoreAsync(); } catch (ContosoCookbook.Common.SuspensionManagerException) { //Something went wrong restoring state. //Assume there is no state and continue } } } frame.Navigate(typeof(SearchResultsPage), args.QueryText); Window.Current.Content = frame; // Ensure the current window is active Window.Current.Activate(); }
/// <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="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { item = await RecipeDataSource.GetItemAsync((String)e.NavigationParameter); this.DefaultViewModel["Group"] = item.Group; this.DefaultViewModel["Item"] = item; // Is recipe already pinned? if (SecondaryTile.Exists(item.UniqueId)) { btnPinToStart.Icon = new SymbolIcon(Symbol.UnPin); } DataTransferManager.GetForCurrentView().DataRequested += OnShareDataRequested; }
/// <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) { // 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 = RecipeDataSource.GetItem((String)navigationParameter); this.DefaultViewModel["Group"] = item.Group; this.DefaultViewModel["Items"] = item.Group.Items; this.flipView.SelectedItem = item; }
/// <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>(); filterList.Add(new Filter("All", 0, true)); // Search recipes and tabulate results var groups = RecipeDataSource.GetGroups("AllGroups"); string query = queryText.ToLower(); var all = new List <RecipeDataItem>(); _results.Add("All", all); foreach (var group in groups) { var items = new List <RecipeDataItem>(); _results.Add(group.Title, items); foreach (var item in group.Items) { if (item.Title.ToLower().Contains(query) || item.Directions.ToLower().Contains(query)) { all.Add(item); items.Add(item); } } filterList.Add(new Filter(group.Title, items.Count, false)); } filterList[0].Count = all.Count; // Communicate results through the view model this.DefaultViewModel["QueryText"] = '\u201c' + queryText + '\u201d'; this.DefaultViewModel["Filters"] = filterList; this.DefaultViewModel["ShowFilters"] = filterList.Count > 1; }
/// <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 // 사용자가 선택할 수 있는 결과 범주 목록을 만듭니다. // // filterList.Add(new Filter("<filter name>", <result count>)); // // 활성 상태에서 시작하려면 첫 번째 필터(일반적으로 "모두")만 세 번째 인수로 true를 // 전달해야 합니다. 활성 필터의 결과가 아래의 // Filter_SelectionChanged에 제공됩니다. var filterList = new List <Filter>(); filterList.Add(new Filter("All", 0, true)); // Search recipes and tabulate results var groups = RecipeDataSource.GetGroups("AllGroups"); string query = queryText.ToLower(); var all = new List <RecipeDataItem>(); _results.Add("All", all); foreach (var group in groups) { var items = new List <RecipeDataItem>(); _results.Add(group.Title, items); foreach (var item in group.Items) { if (item.Title.ToLower().Contains(query) || item.Directions.ToLower().Contains(query)) { all.Add(item); items.Add(item); } } filterList.Add(new Filter(group.Title, items.Count, false)); } filterList[0].Count = all.Count; // 뷰 모델을 통해 결과를 전달합니다. this.DefaultViewModel["QueryText"] = '\u201c' + queryText + '\u201d'; this.DefaultViewModel["CanGoBack"] = this._previousContent != null; this.DefaultViewModel["Filters"] = filterList; this.DefaultViewModel["ShowFilters"] = filterList.Count > 1; }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { InitializeVoiceCommands(); // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } Recipes = new RecipeDataSource(); Recipes.RecipesLoaded += Recipes_RecipesLoaded; }
public async Task GetAllCategoriesAsync() { this.allCategories = await RecipeDataSource.GetAllCategoriesAsync(); }
/// <summary> /// 최종 사용자가 응용 프로그램을 정상적으로 시작할 때 호출됩니다. 다른 진입점은 /// 특정 파일을 열거나, 검색 결과를 표시하는 등 응용 프로그램을 시작할 때 /// 사용됩니다. /// </summary> /// <param name="args">시작 요청 및 프로세스에 대한 정보입니다.</param> protected override async void OnLaunched(LaunchActivatedEventArgs args) { // Do not repeat app initialization when already running, just ensure that // the window is active if (args.PreviousExecutionState == ApplicationExecutionState.Running) { if (!String.IsNullOrEmpty(args.Arguments)) { ((Frame)Window.Current.Content).Navigate(typeof(ItemDetailPage), args.Arguments); } Window.Current.Activate(); return; } await RecipeDataSource.LoadLocalDataAsync();// 요리법 자료들을 연결 // Clear tiles and badges TileUpdateManager.CreateTileUpdaterForApplication().Clear(); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); // Register for push notifications var profile = NetworkInformation.GetInternetConnectionProfile(); if (profile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess) { var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); var buffer = CryptographicBuffer.ConvertStringToBinary(channel.Uri, BinaryStringEncoding.Utf8); var uri = CryptographicBuffer.EnetdcodeToBase64String(buffer); var client = new HttpClient(); try { var response = await client.GetAsync(new Uri("http://ContosoRecipes8.cloudapp.net?uri=" + uri + "&type=tile")); if (!response.IsSuccessStatusCode) { var dialog = new MessageDialog("Unable to open push notification channel"); dialog.ShowAsync(); } } catch (HttpRequestException) { var dialog = new MessageDialog("Unable to open push notification channel"); dialog.ShowAsync(); } } // Create a Frame to act as the navigation context and associate it with // a SuspensionManager key var rootFrame = new Frame(); SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); // If the app was activated from a secondary tile, show the recipe if (!String.IsNullOrEmpty(args.Arguments)) { rootFrame.Navigate(typeof(ItemDetailPage), args.Arguments); Window.Current.Content = rootFrame; Window.Current.Activate(); return; } if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate await SuspensionManager.RestoreAsync(); } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // 필요한 정보를 탐색 매개 변수로 전달하여 새 페이지를 // 구성합니다. if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups")) { throw new Exception("Failed to create initial page"); } } // 프레임을 현재 창에 배치하고 프레임이 활성 상태인지 확인합니다. Window.Current.Content = rootFrame; Window.Current.Activate(); }
/// <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"); // Load Recipes Async await RecipeDataSource.LoadLocalDataAsync(); // 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 += OnSuggestionsRequested; // Register handler for CommandsRequested events from the settings pane SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; 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 } } // 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(GroupedItemsPage), "AllGroups")) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }
public async Task GetAllRecipesByCategoryAsync(string categoryName) { this.allRecipesByCategory = await RecipeDataSource.GetRecipesByCategoryAsync(categoryName); }
public async Task GetRecipeAndInstructions(string title) { this.recipe = await RecipeDataSource.GetRecipeByTitleAsync(title); }