I have simply copied and pasted the codes from NT8 help guide for testing like below, but it returns null exception for OnRenderTargetChanged(). Can you advise?
private SharpDX.Direct2D1.Brush dxBrush = null; // the SharpDX brush used for rendering
private System.Windows.Media.SolidColorBrush brush Color; // used to determine the color of the brush conditionally
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Name = "OnRenderTargetChanged Example";
IsOverlay = false;
}
}
protected override void OnBarUpdate()
{
if (Close[0] > Open[0])
{
brushColor = Brushes.Green;
}
else if (Close[0] < Open[0])
{
brushColor = Brushes.Red;
}
else brushColor = Brushes.Blue;
}
public override void OnRenderTargetChanged()
{
// if dxBrush exists on first render target change, dispose of it
if (dxBrush != null)
{
dxBrush.Dispose();
}
// recalculate dxBrush from value calculated in OnBarUpdated when RenderTarget is recreated
if (RenderTarget != null)
dxBrush = brushColor.ToDxBrush(RenderTarget);
}
protected override void OnRender(ChartControl char tControl, ChartScale chartScale)
{
// fill a custom SharpDX rectangle using the dx brush
RenderTarget.FillRectangle(new SharpDX.Rectangle F(ChartPanel.X, ChartPanel.Y, ChartPanel.W, ChartP anel.H), dxBrush);
}

Comment