コード例 #1
0
 public void BBQRecipeTapped(object sender, object parameter)
 {
     var arg = parameter as ItemClickEventArgs;
     var item = arg.ClickedItem as BBQRecipe;
     selectedBBQRecipe = item;
     navigationService.Navigate(typeof(Shell));
 }
コード例 #2
0
        public BBQRecipeViewModel()
        {
            if (App.MainViewModel.SelectedBBQRecipe != null)
            {
                CurrentBBQRecipe = App.MainViewModel.SelectedBBQRecipe;
            }
            else
            {
                CurrentBBQRecipe = new BBQRecipe();
                CurrentBBQRecipe.Id = 0;
            }

            id = CurrentBBQRecipe.Id;
            name = CurrentBBQRecipe.Name;
            shortDesc = CurrentBBQRecipe.ShortDesc;
            ingredients = CurrentBBQRecipe.Ingredients;
            directions = CurrentBBQRecipe.Directions;
            prepTime = CurrentBBQRecipe.PrepTime;
            totalTime = CurrentBBQRecipe.TotalTime;
            serves = CurrentBBQRecipe.Serves;
            imageSource = CurrentBBQRecipe.ImageSource;

            SaveCommand = new DelegateCommand(SaveBBQRecipe);
            DeleteCommand = new DelegateCommand(DeleteBBQRecipe);
        }
コード例 #3
0
        public BBQRecipeViewModel()
        {

            if (App.MainViewModel.SelectedBBQRecipe != null)
            {
                CurrentBBQRecipe = App.MainViewModel.SelectedBBQRecipe;
            }
            else
            {
                CurrentBBQRecipe = new BBQRecipe();
                CurrentBBQRecipe.Id = 0;
            }

            id = CurrentBBQRecipe.Id;
            name = CurrentBBQRecipe.Name;
            shortDesc = CurrentBBQRecipe.ShortDesc;
            ingredients = CurrentBBQRecipe.Ingredients;
            directions = CurrentBBQRecipe.Directions;
            prepTime = CurrentBBQRecipe.PrepTime;
            totalTime = CurrentBBQRecipe.TotalTime;
            serves = CurrentBBQRecipe.Serves;
            imageSource = CurrentBBQRecipe.ImageSource;

            SaveCommand = new DelegateCommand(SaveBBQRecipe);
            DeleteCommand = new DelegateCommand(DeleteBBQRecipe);
            ShareCommand = new DelegateCommand(ShareBBQRecipe);

            DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
            dataTransferManager.DataRequested += DataTransferManager_DataRequested;


        }
コード例 #4
0
 public BBQRecipe Add(BBQRecipe item)
 {
     if(item == null)
     {
         throw new ArgumentNullException("item");
     }
     item.Id = _nextId++;
     bbqRecipes.Add(item);
     return item;
 }
コード例 #5
0
        public MainViewModel()
        {
            BBQRepo = new BBQRecipeRepository();
            selectedBBQRecipe = new BBQRecipe();

            if (!IsDataLoaded)
            {
                Recipes = BBQRepo.GetAll().ToObservableCollection();
                IsDataLoaded = true;
            }

            navigationService = SimpleIoc.Default.GetInstance<INavigationService>();
        }
コード例 #6
0
        public bool Update(BBQRecipe item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            int index = bbqRecipes.FindIndex(p => p.Id == item.Id);

            if (index == -1)
            {
                return false;
            }

            bbqRecipes.RemoveAt(index);
            bbqRecipes.Add(item);
            return true;
        }
コード例 #7
0
        public DetailPageViewModel()
        {

            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                recipe = new BBQRecipe
                {
                    Name = "Dry Glazed Pork Tenderloin",
                    ShortDesc = "",
                    Ingredients = string.Concat("3 light brown sugar, packed", Environment.NewLine,
                                            "3 clove garlic, minced", Environment.NewLine,
                                            "1 tbsp finely grated orange zest", Environment.NewLine,
                                            "3 tbsp paprika", Environment.NewLine,
                                            "1 tbsp sesame seeds", Environment.NewLine,
                                            "1 tbsp ground ginger", Environment.NewLine,
                                            "1 tbsp ground coriander", Environment.NewLine,
                                            "2 tsp fine salt", Environment.NewLine,
                                            "2 tsp ground black pepper", Environment.NewLine,
                                            "1 tsp cream of tartar", Environment.NewLine,
                                            "3 1 lb. pork tenderloins"),
                    Directions = string.Concat("1. For dry glaze, stir brown sugar, garlic and orange zest to blend. In a separate bowl, stir remaining ingredients, then add to brown sugar mixture. Set aside until ready to use.", Environment.NewLine,
                                           "2. Clean pork tenderloin of any connective tissue. Preheat grill to medium and clean well. Rub tenderloins completely with dry glaze and immediately place on grill. Grill, uncovered, for about 8 minutes on each side until an internal temperature of 165°F is reached, rotating tenderloins 90° on each side. Let pork sit for a moment before slicing and serving."
                                           ),
                    Serves = 10,
                    PrepTime = 0,
                    TotalTime = 0,

                    ImagePath = "ms-appx:///Assets/DryGlazedPorkTenderloin.jpg"
                };
            }
            else
            {
                recipe = new BBQRecipe();
            }


        }
コード例 #8
0
 public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary<string, object> state)
 {
     if (state.Any())
     {
         // use cache value(s)
         if (state.ContainsKey(nameof(recipeId))) recipeId = state[nameof(recipeId)]?.ToString();
         // clear any cache
         state.Clear();
     }
     else
     {
         // use navigation parameter
         recipeId = parameter?.ToString();
         if (recipeId != null)
         {
             Recipe = App.Recipes.Find(x => x.Id == recipeId);
         }
         else
         {
             Recipe = new BBQRecipe();
         }
     }
     return Task.CompletedTask;
 }
コード例 #9
0
        private bool Update(BBQRecipe item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            int index = App.Recipes.FindIndex(p => p.Id == item.Id);

            if (index == -1)
            {
                return false;
            }

            App.Recipes.RemoveAt(index);
            App.Recipes.Add(item);

            IsDirty = true;
            return true;
        }
コード例 #10
0
 public void Save(BBQRecipe item)
 {
     if(item.Id == null)
     {
         Add(item);
     }
     else
     {
         Update(item);
     }
 }
コード例 #11
0
 private void Add(BBQRecipe item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     item.Id = Guid.NewGuid().ToString();
     App.Recipes.Add(item);
     IsDirty = true;
 }
コード例 #12
0
 public BBQRecipe Add(BBQRecipe item)
 {
     if(item == null)
     {
         throw new ArgumentNullException("item");
     }
     item.Id = Guid.NewGuid().ToString();
     bbqRecipes.Add(item);
     return item;
 }