# HG changeset patch # User Jason Maltzen # Date 2016-01-23 20:18:34 # Node ID ca4042a2cbb4c6eabc0892d85744cd9c70e1eff1 # Parent 2c3944282ed8a24e3ab46ab1dbe4b574ec93e247 Update recipe information display if the currently-selected recipe changes. diff --git a/RecipeGeneratorWindow.cs b/RecipeGeneratorWindow.cs --- a/RecipeGeneratorWindow.cs +++ b/RecipeGeneratorWindow.cs @@ -413,12 +413,16 @@ namespace DesertPaintLab } if (!exists) { - //Console.WriteLine("Add new recipe for {0}", args.Color); + //Console.WriteLine("Add new recipe for {0}", recipeColor); // bool isMissingReactions = args.Recipe.CheckMissingReactions(ref missingReactions); // string missingReactionLabel = isMissingReactions ? "X" : ""; colorStore.AppendValues(recipeColor); // , missingReactionLabel); countLabel.Text = String.Format("{0} / {1}", profile.RecipeCount+1, Palette.Count); } + //else + //{ + // Console.WriteLine("Updated recipe for {0}", recipeColor); + //} profile.SetRecipe(recipe); long progressTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; @@ -428,6 +432,16 @@ namespace DesertPaintLab profile.SaveRecipes(); lastProfileSave = progressTime; } + Gtk.TreeModel model; + Gtk.TreeSelection selection = recipeList.Selection; + if ((selection != null) && selection.GetSelected(out model, out iter)) + { + string colorName = (string)colorStore.GetValue(iter, 0); + if (colorName.Equals(recipeColor)) + { + ShowColor(recipe); + } + } } } @@ -472,6 +486,21 @@ namespace DesertPaintLab notifyProgress.WakeupMain(); } + private void ShowColor(PaintRecipe recipe) + { + Gtk.ListStore store = (Gtk.ListStore)recipeIngredientsView.Model; + store.Clear(); + if (recipe.CheckMissingReactions(ref missingReactions)) + { + statusLabel.Text = "WARNING: This recipe includes reactions that have not yet been recorded."; + } + foreach (PaintRecipe.RecipeIngredient ingredient in recipe.Ingredients) + { + store.AppendValues(ingredient.quantity.ToString(), ingredient.name); + } + paintSwatch.Color = recipe.ReactedColor; + } + protected void OnColorSelected(object o, EventArgs args) { Gtk.TreeModel model; @@ -483,18 +512,8 @@ namespace DesertPaintLab PaintRecipe recipe; if (profile.Recipes.TryGetValue(colorName, out recipe)) { - Gtk.ListStore store = (Gtk.ListStore)recipeIngredientsView.Model; - store.Clear(); - if (recipe.CheckMissingReactions(ref missingReactions)) - { - statusLabel.Text = "WARNING: This recipe includes reactions that have not yet been recorded."; - } - foreach (PaintRecipe.RecipeIngredient ingredient in recipe.Ingredients) - { - store.AppendValues(ingredient.quantity.ToString(), ingredient.name); - } + ShowColor(recipe); } - paintSwatch.Color = recipe.ReactedColor; } }