示例#1
0
        private async void DoModifyRecipe()
        {
            var modify = new ModifyRecipeViewModel(this);

            ViewModelStack.Push(modify);
            if (await modify.Completed)
            {
                var recipe    = CreateModifiedRecipe(modify);
                var viewModel = new RecipeViewModel(mRecipe.Owner, recipe);
                mRecipe.Owner.Items.Add(viewModel);
            }
        }
        private async void DoAddIngredient()
        {
            var ingredient = new IngredientViewModel(ID.Next, SearchText ?? "<New Ingredient>");
            var editor     = ingredient.CreateEditor();

            ViewModelStack.Push(editor);
            if (await editor.Completed)
            {
                mIngredients.Add(new IngredientItem(ingredient));
                IngredientID = ingredient.ID;
            }
        }
示例#3
0
        private async void DoEdit()
        {
            var editor = mCurrentItem.CreateEditor();

            ViewModelStack.Push(editor);

            var accepted = await editor.Completed;

            if (accepted)
            {
                OnListChanged();
            }
        }
示例#4
0
        private async void DoAdd()
        {
            var item = CreateNew();

            var editor = item.CreateEditor();

            ViewModelStack.Push(editor);

            var accepted = await editor.Completed;

            if (accepted)
            {
                mItems.Add(item);
                OnListChanged();
            }
        }
示例#5
0
        public SaveFileViewModel(ISaveFileService service)
        {
            ViewModelStack.Initialize(this);

            mService = service;
            var data = mService.ReadSaveFile();

            Ingredients = new IngredientListViewModel();
            foreach (var ingredient in data.Ingredients)
            {
                Ingredients.Items.Add(new IngredientViewModel(ingredient));
            }

            Recipes = new RecipeListViewModel(Ingredients);
            foreach (var recipe in data.Recipes)
            {
                Recipes.Items.Add(new RecipeViewModel(Recipes, recipe));
            }

            mSaveCommand = new DelegateCommand(DoSave);
        }
示例#6
0
        private async void DoReduceRecipe()
        {
            var reduce = new ReduceRecipeViewModel(this);

            ViewModelStack.Push(reduce);
            if (await reduce.Completed)
            {
                foreach (var item in reduce.Items)
                {
                    var ingredient  = item.Ingredient;
                    var measurement = item.SelectedItem as MeasurementFractionItem;
                    if (measurement == null)
                    {
                        continue;
                    }

                    ingredient.Amount = new Amount
                    {
                        Measurement = measurement.Measurement,
                        Value       = measurement.Amount,
                    };
                }
            }
        }