Beispiel #1
0
        /// <summary>
        /// Handles the Click event of the ItemResult control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ItemClickEventArgs"/> instance containing the event data.</param>
        public void ItemResult_Click(object sender, ItemClickEventArgs e)
        {
            ItemReceipe item = ((ItemReceipe)e.ClickedItem);

            this.Model.SelectReceipe(item.Receipe);
            this.Frame.Navigate(typeof(ReceipeDetail), this.Model);
        }
Beispiel #2
0
 /// <summary>
 /// Go to the ReceipeDetail page when the user click on the receipe
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="ItemClickEventArgs"/> instance containing the event data.</param>
 private void ReceipeClick_Click(object sender, ItemClickEventArgs e)
 {
     if (e.ClickedItem is ItemReceipe)
     {
         ItemReceipe item = (ItemReceipe)e.ClickedItem;
         Receipe     re   = item.Receipe;
         this.Model.SelectReceipe(re);
         this.Frame.Navigate(typeof(ReceipeDetail), this.Model);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Handles the Click event of the GoToDetailReceipe control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ItemClickEventArgs"/> instance containing the event data.</param>
        private void GoToDetailReceipe_Click(object sender, ItemClickEventArgs e)
        {
            if (e.ClickedItem is ItemReceipe)
            {
                ItemReceipe item    = (ItemReceipe)e.ClickedItem;
                Receipe     receipe = item.Receipe;
                this.Model.SelectReceipe(receipe);

                //navigate to the ReceipeDetail page
                this.Frame.Navigate(typeof(ReceipeDetail), this.Model);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Handles the Click event of the RemoveReceipe, update the model and the json file.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Windows.UI.Xaml.RoutedEventArgs"/> instance containing the event data.</param>
        public async void RemoveReceipe_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (this.Frame != null && button != null && button.DataContext is ItemReceipe)
            {
                ItemReceipe item = (ItemReceipe)button.DataContext;
                Receipe     re   = item.Receipe;
                this.Model.RemoveReceipeList(re, (string)button.Tag, this.date);
                StorageFolder folder      = KnownFolders.PicturesLibrary;
                StorageFile   receipeFile = await folder.CreateFileAsync("receipes.json", CreationCollisionOption.ReplaceExisting);

                await Windows.Storage.FileIO.WriteTextAsync(receipeFile, this.Model.StringifyReceipesList());
            }
        }
Beispiel #5
0
        /// <summary>
        /// Display all the ingredients of a receipe
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void ClickHandleIngredients(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            if (b != null && b.DataContext is ItemReceipe)
            {
                ItemReceipe item    = (ItemReceipe)b.DataContext;
                Receipe     receipe = item.Receipe;

                List <ItemIngredient> itemsIng = new List <ItemIngredient>();

                foreach (Ingredient ing in receipe.ingredients)
                {
                    itemsIng.Add(ToolItem.CreateItemIngredient(ing));
                }

                this.listIngredientsViewSource.Source = itemsIng;

                if (this.IngredientTextBlock != null)
                {
                    this.IngredientTextBlock.Text = (string)receipe.Title;
                }
            }
        }