Completed
Last Updated: 07 Jul 2022 14:00 by ADMIN
Release R3 2022
Leigh
Created on: 20 Jun 2022 11:24
Category: SpreadProcessing
Type: Feature Request
1
SpreadProcessing: Expose method converting hex colors to Telerik.Documents.Media.Color

Currently, similar conversions should be manually implemented by the users.

Sample method that could be used:

public static Color HexStringToColor(string hexColor)
{
    // Remove the # at the front.
    if (hexColor.StartsWith("#"))
    {
        hexColor = hexColor.Substring(1, hexColor.Length - 1);
    }

    byte a = 255;
    byte r = 255;
    byte g = 255;
    byte b = 255;

    int start = 0;

    // Handle ARGB strings (8 characters long).
    if (hexColor.Length == 8)
    {
        start = 2;
    }

    //Handle contracted RGB strings (3 characters long)
    if (hexColor.Length == 3)
    {
        hexColor = string.Format("{0}{0}{1}{1}{2}{2}", hexColor[0], hexColor[1], hexColor[2]);
    }
    else if (hexColor.Length < 6)
    {
        hexColor = hexColor.PadLeft(6, '0');
    }

    // Convert RGB characters to bytes.
    r = byte.Parse(hexColor.Substring(start, 2), NumberStyles.HexNumber);
    g = byte.Parse(hexColor.Substring(start + 2, 2), NumberStyles.HexNumber);
    b = byte.Parse(hexColor.Substring(start + 4, 2), NumberStyles.HexNumber);

    return Color.FromArgb(a, r, g, b);
}

3 comments
ADMIN
Peshito
Posted on: 07 Jul 2022 14:00

Hello,

This item will be available in R3 2022 Release. 

It is also available with Telerik UI for WPF's latest internal build - LIB 2022.2.711 (11 Jul 2022) if you need it earlier.

Regards,
Peshito
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

ADMIN
Tanya
Posted on: 24 Jun 2022 13:18

Hello Lucy,

Thank you for sharing your feedback. I totally agree with you that exposing such a method will make working with colors easier. Please, make sure to cast your vote for the implementation of the task and continue following it so we can notify you when its status changes. 

Regards,
Tanya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Lucy
Posted on: 21 Jun 2022 07:34
This would be very useful