예제 #1
0
        void OnRecipeListNavigate(object sender, RequestNavigateEventArgs e)
        {
            RecipeViewerApp app  = (RecipeViewerApp)System.Windows.Application.Current;
            RecipeListItem  item = (RecipeListItem)((Hyperlink)sender).Tag;

            app.Properties["CurrentRecipe"] = item.Key;
        }
예제 #2
0
        private void MoveToNewRecipe(UInt32 index)
        {
            if (recipeList != null)
            {
                //Push the current recipe onto the journalling stack, so we can back/forward
                //using the NavigationWindow's buttons
                //RecipeCardJournalEntry backEntry = new RecipeCardJournalEntry((int)currentIndex, "foo");
                //navWindow.AddBackEntry(backEntry);
                currentIndex = index;

                RecipeViewerApp app  = (RecipeViewerApp)System.Windows.Application.Current;
                RecipeListItem  item = (RecipeListItem)recipeList[(int)currentIndex];
                recipeDocument = app.GetRecipe(item.Key);
                currentRecipeCard.DataContext = recipeDocument;
                UpdateMenuState();
            }
        }
예제 #3
0
        private void OnPageLoading(object sender, EventArgs e)
        {
            //  Retrieve the current recipe object from the app properties
            RecipeViewerApp app = (RecipeViewerApp)System.Windows.Application.Current;

            navWindow = (NavigationWindow)app.MainWindow;
            Recipes        list = (Recipes)app.Properties["RecipeList"];
            String         key  = (String)app.Properties["CurrentRecipe"];
            RecipeListItem item = list.Find(key);

            if (item != null)
            {
                //  Retrieve the full recipe document
                recipeDocument = app.GetRecipe(item.Key);
                if (recipeDocument != null)
                {
                    RecipePanel.DataContext = recipeDocument;

                    //  Get the list of attachments
                    recipeAttachments = item.Attachments;

                    //  Get the first picture attachment,
                    //  and assign it to the image in the XAML page
                    foreach (RecipeAttachment attachment in recipeAttachments)
                    {
                        if (attachment.GetType() == typeof(BitmapAttachment))
                        {
                            BitmapSource bs = (BitmapSource)attachment.Content;
                            if (bs != null)
                            {
                                RecipeImage.Source = bs;
                            }
                            break;
                        }
                    }
                }
            }
        }