public static Brush EnumToColor(Models.Colors color) { if (color == Models.Colors.None) { return(Brushes.Black); } if (color == Models.Colors.Blue) { return(Brushes.Blue); } if (color == Models.Colors.Gray) { return(Brushes.Gray); } if (color == Models.Colors.Green) { return(Brushes.Green); } if (color == Models.Colors.Orange) { return(Brushes.Orange); } if (color == Models.Colors.Red) { return(Brushes.Red); } if (color == Models.Colors.Yellow) { return(Brushes.Yellow); } return(null); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (targetType != typeof(Brush)) { throw new InvalidOperationException("The target must be Brush."); } Models.Colors color = (Models.Colors)value; return(EnumToColor(color)); }
private byte[] getIconCategory(Models.Category category) { Models.Colors enumColor = Models.Colors.None; if (category != null) { enumColor = category.Color; } Brush color = EnumToColorConverter.EnumToColor(enumColor); string iconPath = System.Windows.Application.Current.TryFindResource("TaskIncompleteIconPath") as string; return(getImageBytes(createImageSource(iconPath, color) as DrawingImage)); }
private Image getIconCategory(Category category) { Models.Colors enumColor = Models.Colors.None; if (category != null) { enumColor = category.Color; } Brush color = EnumToColorConverter.EnumToColor(enumColor); string iconPath = Application.Current.TryFindResource("TaskIncompleteIconPath") as string; return(createImage(iconPath, color));; }
private Image getIconTask(Models.Task task) { Models.Colors enumColor = Models.Colors.None; if (task.Category != null) { enumColor = task.Category.Color; } Brush color = EnumToColorConverter.EnumToColor(enumColor); string iconPath = Application.Current.TryFindResource("TaskIncompleteIconPath") as string; if (task.IsCompleted) { iconPath = Application.Current.TryFindResource("TaskCompletedIconPath") as string; } return(createImage(iconPath, color)); }