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 NullPointStrategies, Today, 05:17 AM
    0 responses
    46 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    66 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X