private void AddActivitySummaryToGrid(int i) { var activity = activities[i]; if (activity == null) { return; } RowDefinition row = new RowDefinition(); row.Height = new GridLength(9, GridUnitType.Star); RowDefinition row2 = new RowDefinition(); row2.Height = new GridLength(1, GridUnitType.Star); inner.RowDefinitions.Add(row); inner.RowDefinitions.Add(row2); Button reward = new Button { Content = "Reward Crystals for this activity", Background = ButtonColorBrush, Foreground = ButtonTextColorBrush, HorizontalAlignment = HorizontalAlignment.Center, FontSize = 15, Tag = i, }; reward.Click += new RoutedEventHandler(RewardActivity); reward.VerticalAlignment = VerticalAlignment.Center; inner.Children.Add(reward); Grid.SetRow(reward, 2 * i + 2); Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); AddTitle(grid, ActivityTypeExtensions.ToFriendlyString(activity.ActivityType), activity.DayId); AddTextBlockToGrid(grid, "Start Time", activity.StartTime.ToString("HH:mm:ss"), 2); AddTextBlockToGrid(grid, "End Time", activity.EndTime.ToString("HH:mm:ss"), 3); AddTextBlockToGrid(grid, "Duration", TimeUtil.GetDuration(activity.Duration).ToString(), 4); AddTextBlockToGrid(grid, "Total Distance", Math.Round((double)activity.TotalDistance / 100000, 2).ToString() + " KM", 5); AddTextBlockToGrid(grid, "Total Calories", activity.TotalCalories.ToString(), 6); AddTextBlockToGrid(grid, "Average Heart Rate", activity.AverageHeartRate.ToString(), 7); AddTextBlockToGrid(grid, "Lowest Heart Rate", activity.LowestHeartRate.ToString(), 8); AddTextBlockToGrid(grid, "Highest Heart Rate", activity.PeakHeartRate.ToString(), 9); inner.Children.Add(grid); Grid.SetRow(grid, 2 * i + 1); grids[i] = grid; }
private void AddActivitySummaryToGrid(Activity activity, int i) { RowDefinition row = new RowDefinition(); row.Height = new GridLength(9, GridUnitType.Star); RowDefinition row2 = new RowDefinition(); row2.Height = new GridLength(1, GridUnitType.Star); inner.RowDefinitions.Add(row); inner.RowDefinitions.Add(row2); TextBlock type = new TextBlock { Text = "\n" }; type.VerticalAlignment = VerticalAlignment.Center; inner.Children.Add(type); type.SetValue(Grid.RowProperty, 2 * i + 1); //Grid.SetRow(type, 2 * i + 1); Grid grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); AddTitle(grid, ActivityTypeExtensions.ToFriendlyString(activity.ActivityType), activity.DayId); AddTextBlockToGrid(grid, "Start Time", activity.StartTime.ToString("HH:mm:ss"), 2); AddTextBlockToGrid(grid, "End Time", activity.EndTime.ToString("HH:mm:ss"), 3); AddTextBlockToGrid(grid, "Duration", TimeUtil.GetDuration(activity.Duration).ToString(), 4); AddTextBlockToGrid(grid, "Total Distance", Math.Round((double)activity.TotalDistance / 100000, 2).ToString() + " KM", 5); AddTextBlockToGrid(grid, "Total Calories", activity.TotalCalories.ToString(), 6); AddTextBlockToGrid(grid, "Average Heart Rate", activity.AverageHeartRate.ToString(), 7); AddTextBlockToGrid(grid, "Lowest Heart Rate", activity.LowestHeartRate.ToString(), 8); AddTextBlockToGrid(grid, "Highest Heart Rate", activity.PeakHeartRate.ToString(), 9); inner.Children.Add(grid); grid.SetValue(Grid.RowProperty, 2 * i); //Grid.SetRow(grid, 2 * i); }