protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { /* This section adds dynamic list view - it will be removed at some point */ ListViewStackPanel.Children.Add(listViewIngredientsDetail); listViewIngredientsDetail.SelectionChanged += ListView_SelectionChanged; Thickness margin = listViewIngredientsDetail.Margin; margin.Bottom = 0; margin.Left = 380; margin.Right = 100; margin.Top = 100; listViewIngredientsDetail.Margin = margin; /*-----------------------------------------------------------------------*/ _meal = (MealViewModel)e.Parameter; mealItemsViewModel = new MealItemsViewModel(); _mealItems = mealItemsViewModel.GetMealItems(_meal.MealItemIDsWithWeight); MealItemsGridView.ItemsSource = _mealItems; _contact = new ContactViewModel(); _contact = _contact.GetContact(_meal.ContactId); ContactNameTextBox.Text = _contact.NameAndAddress; this.DataContext = _meal; NumberOfGuestsTextBox.Text = _meal.NumberOfGuests.ToString(); _numberOfGuests = _meal.NumberOfGuests.ToString(); DeliveryDatePicker.Date = _meal.DeliveryDate; DeliveryTimePicker.Time = _meal.DeliveryTime; DeliveryNoteIdTextBox.Text = _meal.DeliveryNoteId; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { var meal = (MealViewModel)e.Parameter; mealItemsViewModel = new MealItemsViewModel(); mealitems = mealItemsViewModel.GetMealItems(meal.MealItemIDsWithWeight); int y = mealitems.Count; MealItemsListView.ItemsSource = mealitems; }
public string GetTextRepresentation(IMealViewModel meal) { StringBuilder result = new StringBuilder(); MealItemsViewModel mealItemsView = new MealItemsViewModel(); IngredientsViewModel ingredientsView = new IngredientsViewModel(); ContactViewModel contact = new ContactViewModel(); contact = contact.GetContact(meal.ContactId); string tmp = contact.NameAndAddress; tmp = tmp.Replace('\n', '|'); tmp = tmp.Replace('\r', '|'); string nameAndAddress = tmp.Replace("||", "\\line "); nameAndAddress = contact.Attention + "\\line " + tmp.Replace("||", "\\line "); result.Append(@"{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset0 Calibri;}}"); result.Append(@"{\*\generator Riched20 10.0.10240}\viewkind4\uc1\pard\tx720\cf1\f0\fs22\lang1031\line\line\line\f1\fs26"); result.Append(" Lieferschein Nr. ").Append(meal.DeliveryNoteId).Append(@"\line \line "); ; result.Append(nameAndAddress).Append(@" \line "); result.Append("Tel. Nr. : ").Append(contact.PhoneNr).Append(@" \line "); result.Append("Handy Nr. : ").Append(contact.CellPhoneNr).Append(@" \line \line "); result.Append("Veranstaltungsort:").Append(@" \line "); result.Append(meal.DeliveryLocation).Append(@" \line \line "); result.Append("Ihr Ansprechpartner: ").Append(@" \line \line "); result.Append(_dateTimeConverter.Convert(meal.DeliveryDate, null, null, "")).Append(" "); result.Append(_timeSpanConverter.Convert(meal.DeliveryTime,null,null,"")).Append(" Uhr Buffetbeginn").Append(@"\line \line \line"); result.Append(@" \highlight2 "); result.Append("Erwachsene: ").Append(meal.NumberOfGuests).Append(@"\line \line "); result.Append(@" \highlight0 "); ObservableCollection<MealItemViewModel> _mealItems = mealItemsView.GetMealItems(meal.MealItemIDsWithWeight); foreach (var mealItem in _mealItems) { float mealItemWeight = meal.MealItemIDsWithWeight[mealItem.Id]; result.Append(@"\b "); result.Append(mealItem.Name.ToString()).Append(" "); UnitOfMeasureViewModel unitOfMeasure = new UnitOfMeasureViewModel(); string unitOfMeasureName = unitOfMeasure.GetUnitOfMeasure(mealItem.TotalAmountUnitOfMeasure).UnitName; string unitOfMeasureAbbreviation = unitOfMeasure.GetUnitOfMeasure(mealItem.TotalAmountUnitOfMeasure).Abbreviation; result.Append(mealItemWeight.ToString()).Append("").Append(unitOfMeasureAbbreviation); result.Append(@"\line\b0 "); result.Append(GetIngredientsAsText(ingredientsView, mealItem, meal.MealItemIDsWithWeight)); result.Append(@" \line "); } result.Append(@" \line }"); return result.ToString(); }