Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exposing Pens as properties ?

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

  • NinjaTrader_Matthew
    replied
    Originally posted by overflowing View Post
    Is that equivalent to the following?

    Code:
    SharpDX.Direct2D1.Brush brush = outlineStroke.BrushDX;
    Is BrushDX SharpDX.Direct2D1.Brush or a System.Windows.Media.Brush?
    Yes.

    BrushDX = SharpDX.Direct2D1.Brush

    Leave a comment:


  • overflowing
    replied
    Originally posted by NinjaTrader_Matthew View Post
    The Stroke.Brush has a ToSharpDX helper method:
    Code:
    SharpDX.Direct2D1.Brush brush = outlineStroke.Brush.ToDxBrush(RenderTarget);
    Is that equivalent to the following?

    Code:
    SharpDX.Direct2D1.Brush brush = outlineStroke.BrushDX;
    Is BrushDX SharpDX.Direct2D1.Brush or a System.Windows.Media.Brush?

    Leave a comment:


  • gomifromparis
    replied
    Yes, sorry, didn't test native serialization... Too used to have to manually serialize graphic objects in NT7 :-)

    Leave a comment:


  • koganam
    replied
    Originally posted by gomifromparis View Post
    Hi,

    What is the method to serialize a stroke ? the Serialize static class, that can be used to serialize Brushes, only contains Pen2String and String2Pen, but there seems to be no Pens any more.

    Thanks
    Answer in this post in this thread.

    ref: http://ninjatrader.com/support/forum...38&postcount=2

    Put simply, you do not need to do anything to serialize a stroke.

    Heck, you even thanked that post!

    Leave a comment:


  • gomifromparis
    replied
    Hi,

    What is the method to serialize a stroke ? the Serialize static class, that can be used to serialize Brushes, only contains Pen2String and String2Pen, but there seems to be no Pens any more.

    Thanks

    Leave a comment:


  • NinjaTrader_Matthew
    replied
    Originally posted by dalebru View Post
    Patrick,

    Yes, you are confirming my problem. In NT7 we could define a Pen as a property to allow the user to input not only Color but Dash style and Width. In NT8 that can't be done, apparently. We must have separate properties for Color (Brush) and width. I don't know whether a 3rd property could allow input of a Dash style.
    Alternatively, we must add a false Plot to allow the user the input this information.
    Thanks,
    Dale
    In your video, you've only declared a Stroke as a property, but it was never initialized. You must create an instance of MyStroke in State.SetDefaults for that to show up.

    Code:
    	public class AStrokeInidcator : Indicator
    	{
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
                                   // this will be created on the indicator/strategy dialog and allow you to further define the color, width, dash style, etc.
    				MyStroke = new Stroke(Brushes.Blue);  
    			}			
    		}
    
    		protected override void OnBarUpdate()
    		{
    			//Add your custom indicator logic here.
    		}
    		
    		[Display(Name = "MyStroke", GroupName = "Display", Order = 1)]
    		public Stroke MyStroke { get; set; }
    	}
    Please let me know if this does not help you achieve what you're looking to customize vs the NT7 Pen functionality.
    Attached Files

    Leave a comment:


  • dalebru
    replied
    Originally posted by NinjaTrader_PatrickH View Post
    Hello dalebru,

    Please refer to my video at the following link: http://screencast.com/t/NKFVBsfuXACz

    You can also find our example at the following link: http://ninjatrader.com/support/forum...43&postcount=2
    Patrick,

    Yes, you are confirming my problem. In NT7 we could define a Pen as a property to allow the user to input not only Color but Dash style and Width. In NT8 that can't be done, apparently. We must have separate properties for Color (Brush) and width. I don't know whether a 3rd property could allow input of a Dash style.
    Alternatively, we must add a false Plot to allow the user the input this information.
    Thanks,
    Dale

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello dalebru,

    Please refer to my video at the following link: http://screencast.com/t/NKFVBsfuXACz

    You can also find our example at the following link: http://ninjatrader.com/support/forum...43&postcount=2

    Leave a comment:


  • dalebru
    replied
    Originally posted by NinjaTrader_Matthew View Post
    The property grid was not designed to display Pens. You can used a Stroke instead which has Brush, Dash Style and Width properties.

    In fact, it is worth mentioning that in Beta 3, the concept of Pens for Plots and other coloring has been removed for simplicity, as any use case that would use a pen can be used by a Stroke. Stroke does not need to be Frozen, and there is no special handling you need to do to serialize a Stroke

    Code:
    [Display(ResourceType = typeof(Custom.Resource), Name = "MyStroke", Order = 4, GroupName = "NinjaScriptParameters")]
    public Stroke MyStroke { get; set; }
    
    protected override void OnStateChange()
    {		 
    	if (State == State.SetDefaults)
    	{											
    		MyStroke = new Stroke(Brushes.Blue, 2);
    	}			
    }
    Here is a very brief screencast showing my inablilty to display Stroke properties in an Indicator Property Grid. What am I missing? http://screencast.com/t/zuoLnZc4
    Thanks! 8.0.0.3

    Leave a comment:


  • gomifromparis
    replied
    Thanks, works.

    Leave a comment:


  • NinjaTrader_Matthew
    replied
    The Stroke.Brush has a ToSharpDX helper method:

    Code:
    SharpDX.Direct2D1.Brush brush = outlineStroke.Brush.ToDxBrush(RenderTarget);
    Let me know if you have any problems with that.

    Leave a comment:


  • koganam
    replied
    Originally posted by NinjaTrader_Matthew View Post
    The property grid was not designed to display Pens. You can used a Stroke instead which has Brush, Dash Style and Width properties.

    In fact, it is worth mentioning that in Beta 3, the concept of Pens for Plots and other coloring has been removed for simplicity, as any use case that would use a pen can be used by a Stroke. Stroke does not need to be Frozen, and there is no special handling you need to do to serialize a Stroke

    Code:
    [Display(ResourceType = typeof(Custom.Resource), Name = "MyStroke", Order = 4, GroupName = "NinjaScriptParameters")]
    public Stroke MyStroke { get; set; }
    
    protected override void OnStateChange()
    {		 
    	if (State == State.SetDefaults)
    	{											
    		MyStroke = new Stroke(Brushes.Blue, 2);
    	}			
    }
    Aaaaargh! More rewriting. Such is the nature of Betas. Thanks for the heads-up.

    Leave a comment:


  • gomifromparis
    replied
    Any clever way to simply get a SharpDX brush with the Stoke color?

    I tried
    SharpDX.Direct2D1.Brush brush=outlineStroke.BrushDX;
    but it crashed Ninja

    So I use

    Color color=((SolidColorBrush)outlineStroke.Brush).Color ;
    using (SharpDX.Direct2D1.SolidColorBrush brush = new SharpDX.Direct2D1.SolidColorBrush(graphics,new SharpDX.Color4((float)color.R/255.0f,(float)color.G/255.0f, (float)color.B/255.0f,(float)color.A/255.0f)))

    but feels kind of clumsy...

    Leave a comment:


  • NinjaTrader_Matthew
    replied
    The property grid was not designed to display Pens. You can used a Stroke instead which has Brush, Dash Style and Width properties.

    In fact, it is worth mentioning that in Beta 3, the concept of Pens for Plots and other coloring has been removed for simplicity, as any use case that would use a pen can be used by a Stroke. Stroke does not need to be Frozen, and there is no special handling you need to do to serialize a Stroke

    Code:
    [Display(ResourceType = typeof(Custom.Resource), Name = "MyStroke", Order = 4, GroupName = "NinjaScriptParameters")]
    public Stroke MyStroke { get; set; }
    
    protected override void OnStateChange()
    {		 
    	if (State == State.SetDefaults)
    	{											
    		MyStroke = new Stroke(Brushes.Blue, 2);
    	}			
    }
    Last edited by NinjaTrader_Matthew; 06-24-2015, 07:28 AM.

    Leave a comment:


  • gomifromparis
    started a topic Exposing Pens as properties ?

    Exposing Pens as properties ?

    Hi,

    I saw in the VolumeProfile indy that you enabled the exposure of Brushes as properties to allow Color choosing.

    I tried to expose a Pen, so there is also thickness and dash style to choose from, like you have for Plots and Lines, but it doesn't work in the indicator property grid (empty field)

    The serialization code is built, though, because
    Code:
            [XmlIgnore]
            [Display(ResourceType = typeof(Custom.Resource), Name = "VolumeNeutralColor", Order = 4, GroupName = "NinjaScriptParameters")]
            public Pen VolumeNeutralPen { get; set; }
    
            [Browsable(false)]
            public string VolumeNeutralPenSerialize
            {
                get { return Serialize.Pen2String(VolumeNeutralPen); }
                set { VolumeNeutralPen = Serialize.String2Pen(value); }
            }
    works, but no Pen chooser appears in the property grid.


    Any way to make it work ?

    Thanks

Latest Posts

Collapse

Topics Statistics Last Post
Started by PaulMohn, Today, 03:49 AM
0 responses
4 views
0 likes
Last Post PaulMohn  
Started by inanazsocial, Today, 01:15 AM
1 response
7 views
0 likes
Last Post NinjaTrader_Jason  
Started by rocketman7, Today, 02:12 AM
0 responses
10 views
0 likes
Last Post rocketman7  
Started by dustydbayer, Today, 01:59 AM
0 responses
2 views
0 likes
Last Post dustydbayer  
Started by trilliantrader, 04-18-2024, 08:16 AM
5 responses
23 views
0 likes
Last Post trilliantrader  
Working...
X