Beispiel #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;
        }
Beispiel #2
0
        void OnPageLoaded(object sender, EventArgs e)
        {
            //  Retrieve the Recipe list and current index from the app properties
            RecipeViewerApp app = (RecipeViewerApp)System.Windows.Application.Current;

            recipeList = (Recipes)app.Properties["RecipeList"];
            MoveToNewRecipe(currentIndex);

            // Get access to the two storyboards we'll need
            pageTurnForwardStoryboard  = (Storyboard)recipeCardFile.Resources["recipeCardAnimationForward"];
            pageTurnBackwardStoryboard = (Storyboard)recipeCardFile.Resources["recipeCardAnimationBackward"];

            // Retrieve ref to parent main window
            navWindow = (NavigationWindow)Application.Current.MainWindow;
        }
Beispiel #3
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();
            }
        }
Beispiel #4
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;
                        }
                    }
                }
            }
        }
Beispiel #5
0
        protected Stream GetStream()
        {
            RecipeViewerApp app = (RecipeViewerApp)Application.Current;

            return(app.GetRecipeAttachment(documentKey, header.Key));
        }