Ejemplo n.º 1
0
 public MainPageViewModel()
 {
     _dataService = ServiceLocator.Current.GetInstance<IDataService>();
     _navigationService = ServiceLocator.Current.GetInstance<INavigationService>();
     NavigationService navService = _navigationService as NavigationService;
    navService.Configure("RecipeDetailView", typeof(RecipeDetailView));
     RecipeBox = _dataService.GetData();
     OpenBoxCommand = new RelayCommand(OpenRecipeBox);
     ShowRecipeDetailCommand = new RelayCommand<Recipe>(ShowRecipeDetail);
 }
Ejemplo n.º 2
0
            GenerateDesignRecipeBox()
        {
            RecipeBox rb = new RecipeBox();
            rb.Name = "Design Only";
            rb.Description = "Design time data margely bargely doogely doo";
            for (int i = 0; i < 4; i++)
            {
                RecipeGroup recipeGroup = new RecipeGroup();
                recipeGroup.Name = "Group " + i;
                for (int k = 0; k < 8; k++)
                {
                    Recipe r = new Recipe();
                    r.Name = "Recipe " + i + k;
                    r.Description = "The Recipe description is going here";

                    
                    Ingredient flour = new Ingredient("Flour", IngredientType.Dry);
                    flour.AdjustPercent(65);
                    r.AddIngredient(flour);

                    Ingredient water = new Ingredient("Water", IngredientType.Wet);
                    water.AdjustPercent(25);
                    r.AddIngredient(water);

                    Ingredient group = new Ingredient();
                    group.Name = "Starter";
                    group.AdjustPercent(10);

                    Ingredient flour2 = new Ingredient("Flour", IngredientType.Dry);
                    flour2.AdjustPercent(75);
                    r.AddIngredient(group);
                    group.AddIngredient(flour2);

                    Ingredient water2 = new Ingredient("Water", IngredientType.Wet);
                    water2.AdjustPercent(25);
                    group.AddIngredient(water2);
                    r.TotalWeight = 1000;

                    Step step = new Step();
                    step.Description =
                        "Here is some direction on how to do some shit when your doing those things you do with the stuff  and all that crap...You now have killer direction and such";
                    r.Steps.Add(step);
                    r.Steps.Add(new Step("Here is another step that you'll need to follow"));
                    r.BalancePercentages();

                    recipeGroup.Recipes.Add(r);
                }
                rb.RecipeGroups.Add(recipeGroup);
            }
            return rb;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IDataService dataService)
        {
            _dataService = dataService;
            //if (IsInDesignMode)
            //{

            //}
            // else

            DataService ds = new DataService();
            RecipeBox = ds.GetData(IsInDesignMode);
            NewRecipeCommand = new RelayCommand(newRecipe);

            Recipes = new ObservableCollection<Recipe>(recipeBox.RecipeGroups);
            SelectedRecipe = recipes.First();

            SaveRecipeBoxCommand = new RelayCommand(saveRecipeBox);
            SaveAsRecipeBoxCommand = new RelayCommand(saveAsRecipeBox);
            WindowWidth = 600;

            DeleteRecipeCommand = new RelayCommand(deleteRecipe);
        }
Ejemplo n.º 4
0
        public async void SaveDataAsync(RecipeBox rb, bool newLocation = false)
        {
            try
            {
                Windows.Storage.ApplicationDataContainer localSettings =
    Windows.Storage.ApplicationData.Current.LocalSettings;
                string lastSavePath = localSettings.Values["LastSavePath"] as string;

                if (newLocation || string.IsNullOrEmpty(lastSavePath) || !File.Exists(lastSavePath))
                {
                    FileSavePicker fsp = new FileSavePicker();
                    fsp.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                    fsp.SuggestedFileName = rb.Name;
                    fsp.FileTypeChoices.Add("XML", new List<string>() { ".xml" });
                    StorageFile file = await fsp.PickSaveFileAsync();
                    lastSavePath = file.Path;

                    string saveText = JsonConvert.SerializeObject(rb);
                    await FileIO.WriteTextAsync(file, saveText);
                    return;
                    //FolderBrowserDialog fb = new FolderBrowserDialog();
                    //DialogResult dr = fb.ShowDialog();
                    //if (dr == DialogResult.OK) lastSavePath = fb.SelectedPath;
                    //lastSavePath += "\\" + rb.Name + ".xml";
                }

                //XmlSerializer xs = new XmlSerializer(typeof(RecipeBox));
                //await FileIO.WriteTextAsync()
                //xs.Serialize(tw, rb);
                localSettings.Values["LastSavePath"] = lastSavePath;

            }
            catch (Exception e)
            {
                throw (e);
            }

        }
Ejemplo n.º 5
0
        private RecipeBox GenerateDefaultRecipeBox()
        {
            RecipeBox rb = new RecipeBox();
            rb.Name = "Default";
            rb.Description = "A default set of basic recipes to get you started";
            RecipeGroup group = new RecipeGroup();
            group.Name = "Basic";

            #region build Flaxseed sourdough bread
            Ingredient FlaxSeed = new Ingredient("Flax Seed", IngredientType.Dry);
            FlaxSeed.Weight = 34;
            Ingredient Water = new Ingredient("Water", IngredientType.Wet);
            Water.Weight = 124;
            Ingredient SeedMix = new Ingredient("Flax Seed Mix", IngredientType.Miscellaneous);
            SeedMix.AddIngredient(FlaxSeed);
            SeedMix.AddIngredient(Water);            
            SeedMix.SetWeightFromChildren();

            Recipe flaxSeedRecipe = new Recipe("Flax Seed Sourdough");
            flaxSeedRecipe.Description = "Popped flax seeds give this bread a soft, interesting texture";
            flaxSeedRecipe.AddIngredientWithWeight(FlaxSeed);

            Ingredient starter = new Ingredient("Starter", IngredientType.Miscellaneous);
            Ingredient flour = new Ingredient("Bread Flour", IngredientType.Dry);
            flour.Weight = 21;
            Ingredient H20 = new Ingredient("Water", IngredientType.Wet);
            H20.Weight = 21;
            starter.AddIngredient(flour);
            starter.AddIngredient(H20);
            starter.SetWeightFromChildren();
            Ingredient levain = new Ingredient("Levain", IngredientType.Miscellaneous);
            levain.AddIngredient(starter);
            Ingredient levainWater = new Ingredient("Water", IngredientType.Wet);
            levainWater.Weight = 135;
            levain.AddIngredient(levainWater);
            Ingredient levainFlour = new Ingredient("Bread Flour", IngredientType.Dry);
            levain.AddIngredient(levainFlour);
            levain.SetWeightFromChildren();
            flaxSeedRecipe.AddIngredientWithWeight(levain);

            Ingredient finalFlour = new Ingredient("Bread Flour", IngredientType.Dry);
            finalFlour.Weight = 121;
            flaxSeedRecipe.AddIngredientWithWeight(finalFlour);
            Ingredient salt = new Ingredient("Salt", IngredientType.Salt);
            flaxSeedRecipe.AddIngredientWithWeight(salt);
            group.Recipes.Add(flaxSeedRecipe);
            #endregion

            Recipe buiscuit = new Recipe("Sourdough Biscuits");
            buiscuit.Description = "These need to rise for a long time, 18-24 hours preferably";
            Ingredient buiscuitStarter = new Ingredient("Starter", IngredientType.Miscellaneous);
            Ingredient buiscuitStarterFlour = new Ingredient("Flour", IngredientType.Dry);
            buiscuitStarterFlour.Weight = 58.5;
            buiscuitStarter.AddIngredient(buiscuitStarterFlour);
            Ingredient buiscuitStarterWater = new Ingredient("Water", IngredientType.Wet);
            buiscuitStarterWater.Weight = 58.5;
            buiscuitStarter.AddIngredient(buiscuitStarterWater);
            buiscuitStarter.BalancePercentages();
            buiscuit.AddIngredientWithWeight(buiscuitStarter);

            Ingredient buiscuitFlour = new Ingredient("AP Flour", IngredientType.Dry);
            buiscuitFlour.Weight = 222;
            buiscuit.AddIngredientWithWeight(buiscuitFlour);

            Ingredient sugar = new Ingredient("Sugar", IngredientType.Sweet);
            sugar.Weight = 5;
            buiscuit.AddIngredientWithWeight(sugar);

            Ingredient buiscuitSalt = new Ingredient("Salt", IngredientType.Salt);
            buiscuitSalt.Weight = 5;
            buiscuit.AddIngredientWithWeight(buiscuitSalt);

            Ingredient butter = new Ingredient("Butter", IngredientType.Fat);
            butter.Weight = 111;
            buiscuit.AddIngredientWithWeight(butter);

            Ingredient milk = new Ingredient("Milk", IngredientType.Wet);
            milk.Weight = 140;
            buiscuit.AddIngredientWithWeight(milk);
            group.Recipes.Add(buiscuit);

            rb.RecipeGroups.Add(group);
            return rb;
        }
Ejemplo n.º 6
0
 public void SaveData(RecipeBox recipeBox, bool newLocation)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
 public void SaveDataAsync(RecipeBox recipeBox, bool newLocation = false)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 8
0
        private static RecipeBox GenerateDefaultRecipeBox()
        {
            Recipe r = new Recipe();
            r.Name = "Sourdough";
            Ingredient flour = new Ingredient("Flour", IngredientType.Dry);
            flour.AdjustPercent(65);
            r.AddIngredient(flour);

            Ingredient water = new Ingredient("Water", IngredientType.Wet);
            water.AdjustPercent(25);
            r.AddIngredient(water);

            Ingredient group = new Ingredient();
            group.Name = "Starter";
            group.AdjustPercent(10);

            Ingredient flour2 = new Ingredient("Flour", IngredientType.Dry);
            flour2.AdjustPercent(75);
            r.AddIngredient(group);
            group.AddIngredient(flour2);

            Ingredient water2 = new Ingredient("Water", IngredientType.Wet);
            water2.AdjustPercent(25);
            group.AddIngredient(water2);
            r.TotalWeight = 1000;

            Step step = new Step();
            step.Description =
                "Here is some direction on how to do some shit when your doing those things you do with the stuff  and all that crap...You now have killer direction and such";
            r.Steps.Add(step);
            r.BalancePercentages();

            Recipe r2 = new Recipe();
            r2.Name = "Jimmy Gabooty";
            Ingredient pasta = new Ingredient("pasta", IngredientType.Dry);
            pasta.AdjustPercent(65);
            r2.AddIngredient(pasta);
            Ingredient milk = new Ingredient("Milk", IngredientType.Wet);
            milk.AdjustPercent(35);
            r2.AddIngredient(milk);
            r2.TotalWeight = 1000;
            RecipeBox rb = new RecipeBox();
            rb.Name = "Default";
            RecipeGroup recipeGroup = new RecipeGroup();
            recipeGroup.Name = "Group";
            recipeGroup.Recipes.Add(r);
            recipeGroup.Recipes.Add(r2);
            rb.RecipeGroups.Add(recipeGroup);
            return rb;
        }
Ejemplo n.º 9
0
        public void SaveData(RecipeBox rb, bool newLocation = false)
        {
            try
            {
                string savePath = Settings.Default.LastSavePath;
                if (newLocation || string.IsNullOrEmpty(savePath) || ! File.Exists(savePath))
                {
                    FolderBrowserDialog fb = new FolderBrowserDialog();
                    DialogResult dr = fb.ShowDialog();
                    if (dr == DialogResult.OK) savePath = fb.SelectedPath;
                    savePath += "\\" + rb.Name + ".xml";
                }

                XmlSerializer xs = new XmlSerializer(typeof(RecipeBox));
                TextWriter tw = new StreamWriter(savePath);
                xs.Serialize(tw, rb);
                Settings.Default.LastSavePath = savePath;
                tw.Close();
            }
            catch (Exception e)
            {

                MessageBox.Show(e.Message);
            }
            Settings.Default.Save();
        }