private UIElement GetImage(string path, int dim, CupSizeEnum flag, string text) { var stackPanel = new StackPanel() { VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(0, 0, 12, 0), }; var border = new Border { VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Center, Width = dim, Height = dim, OpacityMask = new ImageBrush() { ImageSource = new BitmapImage(new Uri("/Images/CupSizes/" + path, UriKind.Relative)) } }; var cupsize = CupSizeEnum.Value; var thisColour = cupsize.HasFlag(flag) ? new SolidColorBrush(BackgroundColour.GetValueOrDefault()) : new SolidColorBrush(Colors.LightGray); border.Background = thisColour; stackPanel.Children.Add(border); var textBlock = new TextBlock { Text = text, HorizontalAlignment = HorizontalAlignment.Center, Foreground = thisColour, FontSize = 14 }; stackPanel.Children.Add(textBlock); return(stackPanel); }
private void AddPod(int strength, string name, string groupName, string uri, bool isDecaf, Color backgroundColour, CupSizeEnum cupSizes, string description) { var newModel = new PodViewModel() { Name = name, Strength = strength, GroupName = groupName, ListImageUri = new Uri("/Images/Small/" + uri, UriKind.Relative), DetailImageUri = new Uri("/Images/Large/" + uri, UriKind.Relative), IsDecaf = isDecaf, Description = description, BackgroundColour = backgroundColour, CupSizes = cupSizes }; Pods.Add(newModel); }