Skip to content

Commit

Permalink
v1.9.8
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjdk committed Jan 21, 2024
1 parent 4229fc1 commit 9d8212f
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
*Below is the version history of [TrelloDotNet](https://github.com/rwjdk/TrelloDotNet) (An wrapper of the Trello API)*

## 1.9.8 (21st of January 2024)
#### General
- Added option to get Label Colors as Enum (`LabelColor`) Value and `ColorInfo` that explains the labels color in RBG and #Hex Value

<hr>
## 1.9.7 (23rd of December 2023)
#### TrelloClient
- Added a set of handy Checklist Extensions on single and collection of checklists (`GetNumberOfItems`, `GetNumberOfCompletedItems`,`GetNumberOfIncompleteItems`, `IsAllComplete`,`IsAnyIncomplete`)
Expand Down
9 changes: 9 additions & 0 deletions TrelloDotNet/TrelloDotNet/Control/EnumHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Text.Json.Serialization;
using TrelloDotNet.Model;

namespace TrelloDotNet.Control
{
Expand All @@ -12,5 +13,13 @@ internal static string GetJsonPropertyName(this Enum enumVal)
var attributes = memInfo[0].GetCustomAttributes(typeof(JsonPropertyNameAttribute), false);
return attributes.Length > 0 ? ((JsonPropertyNameAttribute)attributes[0]).Name : null;
}

internal static LabelColorInfo GetColorInfo(this Enum enumVal)
{
var type = enumVal.GetType();
var memInfo = type.GetMember(enumVal.ToString());
var attributes = memInfo[0].GetCustomAttributes(typeof(LabelColorInfo), false);
return attributes.Length > 0 ? (LabelColorInfo)attributes[0] : null;
}
}
}
18 changes: 16 additions & 2 deletions TrelloDotNet/TrelloDotNet/Model/Label.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Text.Json.Serialization;
using TrelloDotNet.Control;

Expand All @@ -26,12 +27,24 @@ public class Label
public string Name { get; set; }

/// <summary>
/// Color of the Label (Valid values: yellow, purple, blue, red, green, orange, black, sky, pink, lime)
/// Color of the Label (Valid values: yellow, purple, blue, red, green, orange, black, sky, pink, lime (+ _light and _dark variants))
/// </summary>
[JsonPropertyName("color")]
[QueryParameter]
public string Color { get; set; }

/// <summary>
/// Color as Enum
/// </summary>
[JsonIgnore]
public LabelColor ColorAsEnum => Enum.GetValues(typeof(LabelColor)).Cast<LabelColor>().FirstOrDefault(x => x.GetJsonPropertyName() == Color);

/// <summary>
/// Color as Info
/// </summary>
[JsonIgnore]
public LabelColorInfo ColorAsInfo => ColorAsEnum.GetColorInfo();

/// <summary>
/// Id of the Board the Label belong to
/// </summary>
Expand All @@ -43,7 +56,8 @@ public class Label
/// <summary>
/// When the Label was created [stored in UTC]
/// </summary>
[JsonIgnore] public DateTimeOffset? Created => IdToCreatedHelper.GetCreatedFromId(Id);
[JsonIgnore]
public DateTimeOffset? Created => IdToCreatedHelper.GetCreatedFromId(Id);

/// <summary>
/// Constructor
Expand Down
196 changes: 196 additions & 0 deletions TrelloDotNet/TrelloDotNet/Model/LabelColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
using System.Text.Json.Serialization;

namespace TrelloDotNet.Model
{
/// <summary>
/// The Label Colors
/// </summary>
public enum LabelColor
{
/// <summary>
/// None
/// </summary>
[LabelColorInfo(-1, -1, -1, "", -1, -1, -1, "")] [JsonPropertyName("")]
None = 0,

/// <summary>
/// green_light
/// </summary>
[LabelColorInfo(22, 75, 53, "#164B35", 186, 243, 219, "#BAF3DB")] [JsonPropertyName("green_light")]
LightGreen,

/// <summary>
/// green
/// </summary>
[LabelColorInfo(22, 75, 53, "#164B35", 75, 206, 151, "#4BCE97")] [JsonPropertyName("green")]
Green,

/// <summary>
/// green_dark
/// </summary>
[LabelColorInfo(255, 255, 255, "#FFFFFF", 31, 132, 90, "#1F845A")] [JsonPropertyName("green_dark")]
DarkGreen,

/// <summary>
/// yellow_light
/// </summary>
[LabelColorInfo(83, 63, 4, "#533F04", 248, 230, 160, "#F8E6A0")] [JsonPropertyName("yellow_light")]
LightYellow,

/// <summary>
/// yellow
/// </summary>
[LabelColorInfo(83, 63, 4, "#533F04", 245, 205, 71, "#F5CD47")] [JsonPropertyName("yellow")]
Yellow,

/// <summary>
/// yellow_dark
/// </summary>
[LabelColorInfo(255, 255, 255, "#FFFFFF", 148, 111, 0, "#946F00")] [JsonPropertyName("yellow_dark")]
DarkYellow,

/// <summary>
/// orange_light
/// </summary>
[LabelColorInfo(112, 46, 0, "#702E00", 254, 222, 200, "#FEDEC8")] [JsonPropertyName("orange_light")]
LightOrange,

/// <summary>
/// orange
/// </summary>
[LabelColorInfo(112, 46, 0, "#702E00", 254, 163, 98, "#FEA362")] [JsonPropertyName("orange")]
Orange,

/// <summary>
/// orange_dark
/// </summary>
[LabelColorInfo(255, 255, 255, "#FFFFFF", 194, 81, 0, "#C25100")] [JsonPropertyName("orange_dark")]
DarkOrange,

/// <summary>
/// red_light
/// </summary>
[LabelColorInfo(93, 31, 26, "#5D1F1A", 255, 213, 210, "#FFD5D2")] [JsonPropertyName("red_light")]
LightRed,

/// <summary>
/// red
/// </summary>
[LabelColorInfo(93, 31, 26, "#5D1F1A", 248, 113, 104, "#F87168")] [JsonPropertyName("red")]
Red,

/// <summary>
/// red_dark
/// </summary>
[LabelColorInfo(255, 255, 255, "#FFFFFF", 201, 55, 44, "#C9372C")] [JsonPropertyName("red_dark")]
DarkRed,

/// <summary>
/// purple_light
/// </summary>
[LabelColorInfo(53, 44, 99, "#352C63", 223, 216, 253, "#DFD8FD")] [JsonPropertyName("purple_light")]
LightPurple,

/// <summary>
/// purple
/// </summary>
[LabelColorInfo(53, 44, 99, "#352C63", 159, 143, 239, "#9F8FEF")] [JsonPropertyName("purple")]
Purple,

/// <summary>
/// purple_dark
/// </summary>
[LabelColorInfo(255, 255, 255, "#FFFFFF", 110, 93, 198, "#6E5DC6")] [JsonPropertyName("purple_dark")]
DarkPurple,

/// <summary>
/// blue_light
/// </summary>
[LabelColorInfo(9, 50, 108, "#09326C", 204, 224, 255, "#CCE0FF")] [JsonPropertyName("blue_light")]
LightBlue,

/// <summary>
/// blue
/// </summary>
[LabelColorInfo(9, 50, 108, "#09326C", 87, 157, 255, "#579DFF")] [JsonPropertyName("blue")]
Blue,

/// <summary>
/// blue_dark
/// </summary>
[LabelColorInfo(255, 255, 255, "#FFFFFF", 12, 102, 228, "#0C66E4")] [JsonPropertyName("blue_dark")]
DarkBlue,

/// <summary>
/// sky_light
/// </summary>
[LabelColorInfo(22, 69, 85, "#164555", 198, 237, 251, "#C6EDFB")] [JsonPropertyName("sky_light")]
LightSky,

/// <summary>
/// sky
/// </summary>
[LabelColorInfo(22, 69, 85, "#164555", 108, 195, 224, "#6CC3E0")] [JsonPropertyName("sky")]
Sky,

/// <summary>
/// sky_dark
/// </summary>
[LabelColorInfo(255, 255, 255, "#FFFFFF", 34, 125, 155, "#227D9B")] [JsonPropertyName("sky_dark")]
DarkSky,

/// <summary>
/// lime_light
/// </summary>
[LabelColorInfo(55, 71, 31, "#37471F", 211, 241, 167, "#D3F1A7")] [JsonPropertyName("lime_light")]
LightLime,

/// <summary>
/// lime
/// </summary>
[LabelColorInfo(55, 71, 31, "#37471F", 148, 199, 72, "#94C748")] [JsonPropertyName("lime")]
Lime,

/// <summary>
/// lime_dark
/// </summary>
[LabelColorInfo(255, 255, 255, "#FFFFFF", 91, 127, 36, "#5B7F24")] [JsonPropertyName("lime_dark")]
DarkLime,

/// <summary>
/// pink_light
/// </summary>
[LabelColorInfo(80, 37, 63, "#50253F", 253, 208, 236, "#FDD0EC")] [JsonPropertyName("pink_light")]
LightPink,

/// <summary>
/// pink
/// </summary>
[LabelColorInfo(80, 37, 63, "#50253F", 231, 116, 187, "#E774BB")] [JsonPropertyName("pink")]
Pink,

/// <summary>
/// pink_dark
/// </summary>
[LabelColorInfo(255, 255, 255, "#FFFFFF", 174, 71, 135, "#AE4787")] [JsonPropertyName("pink_dark")]
DarkPink,

/// <summary>
/// black_light
/// </summary>
[LabelColorInfo(9, 30, 66, "#091E42", 220, 223, 228, "#DCDFE4")] [JsonPropertyName("black_light")]
LightBlack,

/// <summary>
/// black
/// </summary>
[LabelColorInfo(9, 30, 66, "#091E42", 133, 144, 162, "#8590A2")] [JsonPropertyName("black")]
Black,

/// <summary>
/// black_dark
/// </summary>
[LabelColorInfo(255, 255, 255, "#FFFFFF", 98, 111, 134, "#626F86")] [JsonPropertyName("black_dark")]
DarkBlack,
}
}
73 changes: 73 additions & 0 deletions TrelloDotNet/TrelloDotNet/Model/LabelColorInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;

namespace TrelloDotNet.Model
{
/// <summary>
/// Info about a Color
/// </summary>
public class LabelColorInfo : Attribute
{
/// <summary>
/// Text Color (Red)
/// </summary>
public int TextR { get; }

/// <summary>
/// Text Color (Green)
/// </summary>
public int TextG { get; }

/// <summary>
/// Text Color (Blue)
/// </summary>
public int TextB { get; }

/// <summary>
/// Text Color (Hex)
/// </summary>
public string TextHex { get; }

/// <summary>
/// Background Color (Red)
/// </summary>
public int BackgroundR { get; }

/// <summary>
/// Background Color (Green)
/// </summary>
public int BackgroundG { get; }

/// <summary>
/// Background Color (Blue)
/// </summary>
public int BackgroundB { get; }

/// <summary>
/// Background Color (Hex)
/// </summary>
public string BackgroundHex { get; }

/// <summary>
/// Constructor
/// </summary>
/// <param name="textR">Text Color (Red)</param>
/// <param name="textG">Text Color (Green)</param>
/// <param name="textB">Text Color (Blue)</param>
/// <param name="textHex">Text Color (Hex)</param>
/// <param name="backgroundR">Background Color (Red)</param>
/// <param name="backgroundG">Background Color (Green)</param>
/// <param name="backgroundB">Background Color (Blue)</param>
/// <param name="backgroundHex">Background Color (Hex)</param>
public LabelColorInfo(int textR, int textG, int textB, string textHex, int backgroundR, int backgroundG, int backgroundB, string backgroundHex)
{
TextR = textR;
TextG = textG;
TextB = textB;
TextHex = textHex;
BackgroundR = backgroundR;
BackgroundG = backgroundG;
BackgroundB = backgroundB;
BackgroundHex = backgroundHex;
}
}
}
2 changes: 1 addition & 1 deletion TrelloDotNet/TrelloDotNet/TrelloDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageProjectUrl>https://github.com/rwjdk/TrelloDotNet/wiki</PackageProjectUrl>
<PackageIcon>trello.png</PackageIcon>
<PackageTags>trello api rest .NET8 .NET7 .NET6 dotNet crud wrapper webhook automation</PackageTags>
<Version>1.9.7</Version>
<Version>1.9.8</Version>
<Company>RWJDK</Company>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>https://github.com/rwjdk/TrelloDotNet/blob/main/Changelog.md</PackageReleaseNotes>
Expand Down

0 comments on commit 9d8212f

Please sign in to comment.