Changeset - ca4042a2cbb4
[Not reviewed]
Jason Maltzen (jmaltzen) - 9 years ago 2016-01-23 20:18:34
jason.maltzen@unsanctioned.net
Update recipe information display if the currently-selected recipe changes.
1 file changed with 31 insertions and 12 deletions:
0 comments (0 inline, 0 general)
RecipeGeneratorWindow.cs
Show inline comments
...
 
@@ -404,39 +404,53 @@ namespace DesertPaintLab
 
                    do
 
                    {
 
                        string color = (string)colorStore.GetValue(iter, 0);
 
                        if (color.Equals(recipeColor))
 
                        {
 
                            exists = true;
 
                            break;
 
                        }
 
                    } while (colorStore.IterNext(ref iter));
 
                }
 
                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;
 
                long delta = progressTime - lastProfileSave;
 
                if (delta >= RECIPE_SAVE_INTERVAL)
 
                {
 
                    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);
 
                    }
 
                }
 
            }
 
        }
 

	
 
        protected void OnNewRecipe(object sender, NewRecipeEventArgs args)
 
        {
 
            PaintRecipe recipe = new PaintRecipe(args.Recipe); // copy it, so the worker thread can release
 
            lock(this) {
 
                pendingNewRecipes.Enqueue(recipe);
 
            }
 
            notifyNewRecipe.WakeupMain();
 
            //Gtk.Application.Invoke(delegate {
 
            //    HandleNewRecipe();
...
 
@@ -463,47 +477,52 @@ namespace DesertPaintLab
 
            {
 
                lastCheckpoint = progressTime;
 
                pauseForCheckpoint = true;
 
                generator.Stop();
 
            }
 
        }
 

	
 
        protected void OnProgress(object sender, EventArgs args)
 
        {
 
            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;
 
            Gtk.TreeIter iter;
 
            Gtk.TreeSelection selection = recipeList.Selection;
 
            if ((selection != null) && selection.GetSelected(out model, out iter))
 
            {
 
                string colorName = (string)colorStore.GetValue(iter, 0);
 
                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.";
 
                    ShowColor(recipe);
 
                    }
 
                    foreach (PaintRecipe.RecipeIngredient ingredient in recipe.Ingredients)
 
                    {
 
                        store.AppendValues(ingredient.quantity.ToString(), ingredient.name);
 
                    }
 
                }
 
                paintSwatch.Color = recipe.ReactedColor;
 
            }
 
        }
 

	
 
        protected void OnExportToWiki(object sender, EventArgs e)
 
        {
 
            Gtk.FileChooserDialog fileDialog =
 
                new Gtk.FileChooserDialog("Select destination file.",
 
                        this, Gtk.FileChooserAction.Save,
 
                        Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
 
                        Gtk.Stock.Save, Gtk.ResponseType.Accept);
 
            Gtk.ResponseType resp = (Gtk.ResponseType)fileDialog.Run();
 
            if (resp == Gtk.ResponseType.Accept)
0 comments (0 inline, 0 general)