/// <summary> /// Updates currently chosen recipe. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void recipesGrid_CurrentCellChanged(object sender, EventArgs e) { if (recipesDataGrid.CurrentCell.IsValid) { Recipe currentlyChosenRecipe = recipesDataGrid.CurrentCell.Item as Recipe; if (currentlyChosenRecipe != null && (currentlyChosenRecipe != this.currentlyChosenRecipe)) { this.currentlyChosenRecipe = (from r in db.Recipes where r.recipeId == currentlyChosenRecipe.recipeId select r).SingleOrDefault(); youTubeTabButton.IsEnabled = true; startupComment.Visibility = Visibility.Collapsed; if (this.currentlyChosenRecipe != null) { if (this.currentYouTubeWindow != null) { this.currentYouTubeWindow.Close(); rightFrame.Content = null; } if (this.currentRecipesWindow != null) { this.currentRecipesWindow.Close(); recipesFrame.Content = null; } if (this.currentRecipePrepareWindow != null) { this.currentRecipesWindow.Close(); recipePrepareFrame.Content = null; } this.currentRecipesWindow = new RecipesWindow(this.currentlyChosenRecipe.recipeId) { Owner = this }; recipesFrame.Content = this.currentRecipesWindow.Content; if (this.currentRecipePrepareWindow != null) { this.currentRecipePrepareWindow.Close(); } this.currentRecipePrepareWindow = new RecipePrepareWindow(this.currentlyChosenRecipe) { Owner = this }; recipePrepareFrame.Content = this.currentRecipePrepareWindow.Content; } } } }
/// <summary> /// Fills suppliesDataGrid with supplies from database. /// </summary> public void BindSupplies() { var supplies = from supply in db.Supplies select new { supply.measurementQuantity, supply.MeasurementUnit.measurementDescription, supply.Ingredient.ingredientName }; suppliesDataGrid.ItemsSource = supplies.ToArray(); if (this.currentRecipePrepareWindow != null && this.currentlyChosenRecipe != null) { this.currentRecipePrepareWindow = new RecipePrepareWindow(this.currentlyChosenRecipe) { Owner = this }; recipePrepareFrame.Content = this.currentRecipePrepareWindow.Content; } }