Esempio n. 1
0
        private void bExpandIngredients_Click(object sender, RoutedEventArgs e)
        {
            if (this._isExpanded)
            {
                /*-- remove crafting hierarchy for each ingredients dynamically --*/
                this.ClearIngredients();
                this.tbButtonExpandIngredients.Text  = "+";
                this.ingredientsContainer.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                /*-- Add crafting hierarchy for each ingredients dynamically --*/
                this.ingredientItems = new List <IngredientItem>();
                this.ingredientsView = new ListCollectionView(this.ingredientItems);
                this.ingredientsContainer.ItemsSource = this.ingredientsView;

                Data.Recipe _recipe = this._ingredient.CreatedFrom;
                Array.ForEach <Data.Ingredient>(_recipe.Ingredients.ToArray(),
                                                p =>
                {
                    IngredientItem ii = new IngredientItem(p, _parentWindow, this._level + 1);
                    this.ingredientItems.Add(ii);
                });

                this.ingredientsView.Refresh();
                this.ingredientsContainer.UpdateLayout();

                this.tbButtonExpandIngredients.Text  = "-";
                this.ingredientsContainer.Visibility = System.Windows.Visibility.Visible;
            }
            this._isExpanded = !this._isExpanded;
        }
Esempio n. 2
0
 public void ClearIngredients()
 {
     if (this.ingredientsView != null)
     {
         for (int i = 0; i < this.ingredientItems.Count; i++)
         {
             IngredientItem ii = (IngredientItem)this.ingredientsView.GetItemAt(i);
             ii.ClearIngredients();
             ii = null;
         }
         this.ingredientItems.Clear();
         this.ingredientItems = null;
         this.ingredientsView = null;
         this.ingredientsContainer.UpdateLayout();
     }
 }
        private void bExpandRecipe_Click(object sender, RoutedEventArgs e)
        {
            if (this._isExpanded)
            {
                if (this.ingredientsView != null)
                {
                    for (int i = 0; i < this.ingredientItems.Count; i++)
                    {
                        IngredientItem ii = (IngredientItem)this.ingredientsView.GetItemAt(i);
                        ii.ClearIngredients();
                        ii = null;
                    }
                    this.ingredientItems.Clear();
                    this.ingredientItems = null;
                    this.ingredientsView = null;
                    this.ingredientsContainer.UpdateLayout();
                }

                this.tbButtonExpandIngredients.Text  = "+";
                this.ingredientsContainer.Visibility = System.Windows.Visibility.Collapsed;
                this.tbRecipeDescription.Visibility  = System.Windows.Visibility.Collapsed;
            }
            else
            {
                this.ingredientItems = new List <IngredientItem>();
                this.ingredientsView = new ListCollectionView(this.ingredientItems);
                this.ingredientsContainer.ItemsSource = this.ingredientsView;

                this.tbRecipeDescription.Text       = String.Format("{0}", this._recipe);
                this.tbRecipeDescription.Visibility = System.Windows.Visibility.Visible;

                Array.ForEach <Data.Ingredient>(this._recipe.Ingredients.ToArray(),
                                                p =>
                {
                    IngredientItem ii = new IngredientItem(p, _parentWindow, 0);
                    this.ingredientItems.Add(ii);
                });

                this.ingredientsView.Refresh();
                this.ingredientsContainer.UpdateLayout();

                this.tbButtonExpandIngredients.Text  = "-";
                this.ingredientsContainer.Visibility = System.Windows.Visibility.Visible;
            }
            this._isExpanded = !this._isExpanded;
        }