Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to convert from Brush to SharpDX.Direct2D1.SolidColorBrush

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

    How to convert from Brush to SharpDX.Direct2D1.SolidColorBrush

    Hello guys,

    I defined a parameter inside "Properties" on my strategy code to be able to set a specific color for a Rectangle object:

    [XmlIgnore]
    [Display(Name="Color for InfoWindow Background", Description="Set the background color for the InfoWindow", Order=1, GroupName="InfoWindow")]
    public Brush InfoWindowBackgroundColor
    { get; set; }

    [Browsable(false)]
    public string BarColorUpSerializable
    {
    get { return Serialize.BrushToString(InfoWindowBackgroundColor) ; }
    set { InfoWindowBackgroundColor = Serialize.StringToBrush(value); }
    }​


    Now, Im creating this Rectangle inside OnRender() like this:

    using (SharpDX.Direct2D1.SolidColorBrush dxBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.Blue))
    {
    RenderTarget.FillRectangle(new SharpDX.RectangleF(9, ChartPanel.H - 230, 290, 200), dxBrush);
    }


    My question is, how I could use the color defined on InfoWindowBackgroundColor as an input to define the color of the Rectangle that I created with OnRender. How I could make the translation from Brush to the color I defined with SolidColorBrush(RenderTarget, SharpDX.Color.Blue

    Thank you!​

    #2
    Hello facuevasm,

    Thanks for your post.

    Please see the attached example script in the forum post linked below which demonstrates using a user-defined brush property for SharpDX rendering.

    Hi I have a brush property and I need to find a way to convert it to a SharpDx.Color. Below is the brush property and below that is the code from OnRender. Right now the color is hardcoded as Yellow. The object is to replace the hard coded color with the brush color. Hopefully this makes sense. [Display(Name=&quot


    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    47 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    23 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    33 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X