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 kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    59 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    41 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    46 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    37 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    157 views
    0 likes
    Last Post SalmaTrader  
    Working...
    X