• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stroke Questions

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

    Stroke Questions

    Theses questions are for creating a Drawing Tool using Stroke.

    Question 1
    How can I retrieve the Color of a Stroke when defined by:
    PHP Code:
    State.Defaults
    MyStroke 
    = new Stroke(Brushes.Blue);

    Properties
    {Display(ResourceType  typeof(Custom.Resource), Name =  "NinjaSCriptDrawingToolTextOutLineStroke"GroupName =  "NinjaScriptGeneral"Order 6)]
    Stroke MyStroke {getset;} 
    Something like Brush myBrush = MyStroke.Brush; This returns "#FF0000FF". I am looking for "Brushes.Blue"

    EDIT:
    Or convert the Hex to RGB so that I can define a Brush using
    PHP Code:
    Brush myBrush = new Brush(Color.FromRgb(numbernumbernumber));
    myBrush.Freeze(); 
    Edit 2:
    I found "A" solution. But I have no idea if I am flirting with disaster.
    PHP Code:
    In OnRender

    fillBrush 
    = new SolidColorBrush((Color)ColorConverter.ConvertFromString(myStroke.Brush.ToString()));
    fillBrush.Opacity fillOpacity 100d;
    fillBrush,Freeze();
    fillBrushDevice.Brush null;
    fillBrushDevice.Brush fillBrush;

    RenderTarget.FillRectangle(rectfillBrushDevice.BrushDX); 
    Basically I am taking a Rectangle OutLine Stoke, getting the color of the stroke, then creating a brush to fill the Rectangle. I am using a Rectangle to learn the code instead of confusing the issue with complex Volume Profile calculations and polygons at this point. Is there a better way to get the Stroke Color and then create a Brush.?


    Question 2
    When drawing a NT standard Rectangle, in the Editing Window is it possible to change the display "OutLine" to something else like "My Super Secret Outline"? If so, how? Any sample code, snippet, or other drawing tools that do that?

    Thanks.
    Last edited by TAJTrades; 07-25-2017, 07:03 AM.

    #2
    Hello TAJTrades,

    Thanks for opening the thread.

    Are you using the Stroke for any other reason than to create a Brush to call FillRectangle()?

    If not, I may suggest to create a parameter for the brush that you wish to use rather than creating a parameter for a stroke. The Shapes DrawingTool source code provides an example creating an parameter for the Brush "areaBrush" as well as the sample here: http://ninjatrader.com/support/forum...ead.php?t=4977

    From Shapes DrawingTool:
    Code:
    [XmlIgnore] 
    [Display(ResourceType = typeof(Custom.Resource), Name = "NinjaScriptDrawingToolShapesAreaBrush", GroupName = "NinjaScriptGeneral", Order = 1)]
    public Brush AreaBrush
    {
    	get { return areaBrush; }
    	set
    	{
    		areaBrush = value;
    		if (areaBrush != null)
    		{
    			if (areaBrush.IsFrozen)
    				areaBrush = areaBrush.Clone();
    			areaBrush.Freeze();
    		}
    		areaBrushDevice.Brush = null;
    	}
    }
    
    [Browsable(false)]
    public string AreaBrushSerialize
    {
    	get { return Serialize.BrushToString(AreaBrush); }
    	set { AreaBrush = Serialize.StringToBrush(value); }
    }
    If you want to use the Stroke as a Brush, I may suggest to use the BrushDX property from the Stroke and avoid making the Brush. You can reference this in the Shapes DrawingTool.

    When drawing a NT standard Rectangle, in the Editing Window is it possible to change the display "OutLine" to something else like "My Super Secret Outline"? If so, how? Any sample code, snippet, or other drawing tools that do that?
    On line 94 of the Shapes DrawingTool, you can assign your own name to the property:
    Code:
    [Display(ResourceType = typeof(Custom.Resource), Name = "My Super Secret Outline", GroupName = "NinjaScriptGeneral", Order = 3)]
    Please let me know if I can be of further help.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by victorsmith, Today, 06:00 AM
    0 responses
    3 views
    0 likes
    Last Post victorsmith  
    Started by sohailashraf, Yesterday, 10:18 PM
    0 responses
    6 views
    0 likes
    Last Post sohailashraf  
    Started by jjnc2006, Yesterday, 07:36 PM
    0 responses
    15 views
    0 likes
    Last Post jjnc2006  
    Started by futurenick, Yesterday, 06:26 AM
    1 response
    15 views
    0 likes
    Last Post nkhoi
    by nkhoi
     
    Started by NinjaCustomer, Yesterday, 12:29 PM
    2 responses
    16 views
    0 likes
    Last Post NinjaCustomer  
    Working...
    X