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

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 sidlercom80, 10-28-2023, 08:49 AM
    166 responses
    2,234 views
    0 likes
    Last Post sidlercom80  
    Started by thread, Yesterday, 11:58 PM
    0 responses
    1 view
    0 likes
    Last Post thread
    by thread
     
    Started by jclose, Yesterday, 09:37 PM
    0 responses
    6 views
    0 likes
    Last Post jclose
    by jclose
     
    Started by WeyldFalcon, 08-07-2020, 06:13 AM
    10 responses
    1,414 views
    0 likes
    Last Post Traderontheroad  
    Started by firefoxforum12, Yesterday, 08:53 PM
    0 responses
    11 views
    0 likes
    Last Post firefoxforum12  
    Working...
    X