Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6354153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:31:53+00:00 2026-05-24T22:31:53+00:00

I like to display some decimal numbers. As many as possible need to have

  • 0

I like to display some decimal numbers. As many as possible need to have a unique brush in WPF.

example

-1.00 (display in Green and Orange)
0.00 (display in Orange)
1.00 (display in Green)
2.00 (display in Red)

no specified pattern is needed.


RBG is to small for my case.

255 * 255 * 255 = 16 581 375


The color for a value have to be always the same.


public Brush GetValueColor(decimal value)
{
    //Generate Brush for value
    return myBrush;
}

I don’t know what is wrong with my question but whatever. Just need a function to return a unique brush for every unique number. It doesn’t mater how the numbers looks like.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:31:54+00:00Added an answer on May 24, 2026 at 10:31 pm

    You could always generate a LinearGradientBrush with GradientStops based on the bytes from value.ToString(). You can also reverse the LinearGradientBrush back to the decimal value if needed.

    GetValueColor

    public LinearGradientBrush GetValueColor(decimal value)
    {
        LinearGradientBrush brush = new LinearGradientBrush();
        byte[] byteArray = Encoding.ASCII.GetBytes(value.ToString());
        for (int i = 0; i < byteArray.Length; i += 3)
        {
            byte red = byteArray[i];
            byte green = i < byteArray.Length - 1 ? byteArray[i + 1] : (byte)0;
            byte blue = i < byteArray.Length - 2 ? byteArray[i + 2] : (byte)0;
            brush.GradientStops.Add(
                new GradientStop(new Color {A = 255, R = red, G = green, B = blue },
                                                (double)(i+1) / byteArray.Length));
        }
        return brush;
    }
    

    Reverse: GetColorValue

    public decimal GetColorValue(LinearGradientBrush brush)
    {
        List<byte> byteList = new List<byte>();
        foreach (GradientStop gradientStop in brush.GradientStops)
        {
            byteList.Add(gradientStop.Color.R);
            byteList.Add(gradientStop.Color.G);
            byteList.Add(gradientStop.Color.B);
        }
        return Convert.ToDecimal(Encoding.ASCII.GetString(byteList.ToArray()));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some text that I always need to display (like a HUD). When
I would like to display some variables in custom dialog box. For example I
I'm developing a Web application. I need to display some decimal data correctly so
I want to format numbers. I have seen some of the regex expression example
I like to display some (X)HTML content in a Qt application using QtWebKit. The
I'd like to use custom fields to display some page specific strings in the
I received the error while trying to display some variable like so: echo id
I would like to display other we pages in my mobile webapp, but some
This has happened since yesterday, some razor views display like this in visual studio:
I have a UILabel that displays some chars. Like x, y or rpm. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.