• 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 Abilene, Today, 01:27 AM
    0 responses
    4 views
    0 likes
    Last Post Abilene
    by Abilene
     
    Started by simjs, Yesterday, 08:11 PM
    0 responses
    3 views
    0 likes
    Last Post simjs
    by simjs
     
    Started by mrlucky1x, Yesterday, 06:01 PM
    0 responses
    3 views
    0 likes
    Last Post mrlucky1x  
    Started by dedouglas, Yesterday, 03:17 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Jugado, Yesterday, 02:22 PM
    2 responses
    30 views
    0 likes
    Last Post Jugado
    by Jugado
     
    Working...
    X