Here is the story.
I intend to develop an indicator that will require brushes.
The problem is that when I compile the code below, I have no error message. Notice! In the "#region Properties", I have almost the same for each color ( I have represented the properties only for two of ten brushes). Only the names change.
But when I go to the chart and when I want to add this indicator to the chart, the tab gets frozen for couple of seconds and than the platform just crushes.
I have removed nine (9) colors (brushes) and remained with only one. After compiling, while trying to add the indicator to the chart, there is no problem.
Trying to add the indicator on the chart was just a way to see how the window related to the setup on this indicator could look like and also if I have all properties in place. Of course with this code there is nothing to be seen on the chart.
Why does the platform not crash with one color, but when I have all these ten colors the platform crashes?
I would appreciate any help!
Thanks in advance.
Followed is the code.
using System.Globalization; using System.Net; using System.IO; using System.IO.Compression; using System.Net.Cache; using System.Xml; using System.Text; using SharpDX; using SharpDX.DirectWrite; using SharpDX.Direct2D1;
public class MyIndicator : Indicator
{
#region Variables
private System.Windows.Media.Brush color1;
private System.Windows.Media.Brush color2;
private System.Windows.Media.Brush color3;
private System.Windows.Media.Brush color4;
private System.Windows.Media.Brush color5;
private System.Windows.Media.Brush color6;
private System.Windows.Media.Brush color7;
private System.Windows.Media.Brush color8;
private System.Windows.Media.Brush color9;
private System.Windows.Media.Brush color10;
#endregion
}
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Color1 = System.Windows.Media.Brushes.DarkSlateGray;
Color2 = System.Windows.Media.Brushes.SeaGreen;
Color3 = System.Windows.Media.Brushes.Green;
Color4 = System.Windows.Media.Brushes.LimeGreen;
Color5 = System.Windows.Media.Brushes.OliveDrab;
Color6 = System.Windows.Media.Brushes.Indigo;
Color7 = System.Windows.Media.Brushes.Orchid;
Color8 = System.Windows.Media.Brushes.Crimson;
Color9 = System.Windows.Media.Brushes.Red;
Color10 = System.Windows.Media.Brushes.DarkOrange;
}
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
base.OnRender(chartControl, chartScale);
SharpDX.Direct2D1.Brush color1Dx;
SharpDX.Direct2D1.Brush color2Dx;
SharpDX.Direct2D1.Brush color3Dx;
SharpDX.Direct2D1.Brush color4Dx;
SharpDX.Direct2D1.Brush color5Dx;
SharpDX.Direct2D1.Brush color6Dx;
SharpDX.Direct2D1.Brush color7Dx;
SharpDX.Direct2D1.Brush color8Dx;
SharpDX.Direct2D1.Brush color9Dx;
SharpDX.Direct2D1.Brush color10Dx;
color1Dx = color1.ToDxBrush(RenderTarget);
color2Dx = color2.ToDxBrush(RenderTarget);
color3Dx = color3.ToDxBrush(RenderTarget);
color4Dx = color4.ToDxBrush(RenderTarget);
color5Dx = color5.ToDxBrush(RenderTarget);
color6Dx = color6.ToDxBrush(RenderTarget);
color7Dx = color7.ToDxBrush(RenderTarget);
color8Dx = color8.ToDxBrush(RenderTarget);
color9Dx = color9.ToDxBrush(RenderTarget);
color10Dx = color10.ToDxBrush(RenderTarget);
color1Dx.Dispose();
color2Dx.Dispose();
color3Dx.Dispose();
color4Dx.Dispose();
color5Dx.Dispose();
color6Dx.Dispose();
color7Dx.Dispose();
color8Dx.Dispose();
color9Dx.Dispose();
color10Dx.Dispose();
}
#region Properties
[XmlIgnore]
[Display(ResourceType = typeof(Custom.Resource), Name="Color1", Order=1, GroupName = "NinjaScriptGeneral")]
public System.Windows.Media.Brush Color1
{
get { return color1; }
set { color1 = value; }
}
[Browsable(false)]
public string Color1Serialize
{
get { return Serialize.BrushToString(Color1); }
set { Color1 = Serialize.StringToBrush(value); }
}
[XmlIgnore]
[Display(ResourceType = typeof(Custom.Resource), Name="Color2", Order=2, GroupName = "NinjaScriptGeneral")]
public System.Windows.Media.Brush Color2
{
get { return color2; }
set { color2 = value; }
}
[Browsable(false)]
public string Color2Serialize
{
get { return Serialize.BrushToString(Color2); }
set { Color2 = Serialize.StringToBrush(value); }
}
#endregion

Comment