Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

How to get hex string of brush after changing opacity?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • gubbar924
    replied
    Hi Chelsea,

    I think I've figured out what I'm looking for.


    Just in case anybody else needs it, here is an example code:
    Code:
                        Brush OpaceBrush              = this.Stroke.Brush.Clone();
                        Print(OpaceBrush.ToString());
                        OpaceBrush.Opacity              = 0.05;
                        Print(OpaceBrush.Opacity);
                        Print(Environment.NewLine);
                        
                        Color nw  = ((SolidColorBrush)OpaceBrush).Color;
                        Print(nw.ToString());
                        nw.A = (byte)(OpaceBrush.Opacity * 255);
                        Print(nw.A);
                        Print(nw.ToString());
                        
                        OpaceBrush                      = null;
    Now, I get a new hex code value:
    #FF1E90FF
    0.05

    #FF1E90FF
    12
    #0C1E90FF
    Thanks!

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello gubbar924,

    From my understanding, in C# the Brush.ToString() prints the solid fill color hexadecimal. This would not include opacity.

    Leave a comment:


  • gubbar924
    replied
    Chelsea,

    I ran the following code
    Code:
    Brush OpaceBrush              = this.Stroke.Brush.Clone();
                        Print(OpaceBrush.ToString());
                        OpaceBrush.Opacity              = 0.05;
                        Print(OpaceBrush.Opacity);
                        Print(OpaceBrush.ToString());
                        OpaceBrush                      = null;
    and it resulted in
    #FF1E90FF
    0.05
    #FF1E90FF
    However, I do know that after changing the Opacity property, if I set the color of something like:
    Code:
    Something.Background = OpaceBrush;
    It does in fact use the changed opacity correctly, but it still wont give me the new hex value.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello gubbar924,

    From my understanding using System.Windows.Media.Brush.ToString() would print the solid color brush color which is a solid fill color.

    If you print the .Opacity property, are you finding this is not changing to the set value?

    Print(OpaceBrush.Opacity);

    Leave a comment:


  • How to get hex string of brush after changing opacity?

    hello,

    Does anybody know how to retrieve the 8 digit hex string of a brush after changing its opacity?

    for example:
    Code:
    Brush OpaceBrush              = this.Stroke.Brush.Clone();
    Print(OpaceBrush.ToString());
    OpaceBrush.Opacity           = 0.1;
    Print(OpaceBrush.ToString());
    Both print outs return the exact same value. The 2nd print out does not reflect any change in opacity/alpha.


    Thanks!

Latest Posts

Collapse

Topics Statistics Last Post
Started by geotrades1, Today, 10:02 AM
1 response
4 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by ender_wiggum, Today, 09:50 AM
1 response
5 views
0 likes
Last Post NinjaTrader_Gaby  
Started by rajendrasubedi2023, Today, 09:50 AM
1 response
11 views
0 likes
Last Post NinjaTrader_BrandonH  
Started by bmartz, Today, 09:30 AM
1 response
9 views
0 likes
Last Post NinjaTrader_Erick  
Started by geddyisodin, Today, 05:20 AM
3 responses
26 views
0 likes
Last Post NinjaTrader_Gaby  
Working...
X