BrushDX = SharpDX.Direct2D1.Brush
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Exposing Pens as properties ?
Collapse
X
-
Originally posted by NinjaTrader_Matthew View PostThe Stroke.Brush has a ToSharpDX helper method:
Code:SharpDX.Direct2D1.Brush brush = outlineStroke.Brush.ToDxBrush(RenderTarget);
Code:SharpDX.Direct2D1.Brush brush = outlineStroke.BrushDX;
Leave a comment:
-
Yes, sorry, didn't test native serialization... Too used to have to manually serialize graphic objects in NT7 :-)
Leave a comment:
-
Originally posted by gomifromparis View PostHi,
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
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:
-
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:
-
Originally posted by dalebru View PostPatrick,
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
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; } }
Leave a comment:
-
Originally posted by NinjaTrader_PatrickH View PostHello 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
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:
-
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:
-
Originally posted by NinjaTrader_Matthew View PostThe 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); } }
Thanks! 8.0.0.3
Leave a comment:
-
The Stroke.Brush has a ToSharpDX helper method:
Code:SharpDX.Direct2D1.Brush brush = outlineStroke.Brush.ToDxBrush(RenderTarget);
Leave a comment:
-
Originally posted by NinjaTrader_Matthew View PostThe 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); } }
Leave a comment:
-
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:
-
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:
-
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); } }
Any way to make it work ?
ThanksTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by PaulMohn, Today, 03:49 AM
|
0 responses
4 views
0 likes
|
Last Post
by PaulMohn
Today, 03:49 AM
|
||
Started by inanazsocial, Today, 01:15 AM
|
1 response
7 views
0 likes
|
Last Post Today, 02:18 AM | ||
Started by rocketman7, Today, 02:12 AM
|
0 responses
10 views
0 likes
|
Last Post
by rocketman7
Today, 02:12 AM
|
||
Started by dustydbayer, Today, 01:59 AM
|
0 responses
2 views
0 likes
|
Last Post
by dustydbayer
Today, 01:59 AM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
5 responses
23 views
0 likes
|
Last Post Today, 12:32 AM |
Leave a comment: