Example :
public class Helper
{
public Brush thisBrush = Brushes.Red;
public SharpDX.Direct2D1.Brush thisBrushDx = null;
}
In my indicator properties section :
[XmlIgnore]
public Brush thisBrush
{
get { return helper.thisBrush; }
set
{
helper.thisBrush = value;
if( helper.thisBrush == null )
return;
if( helper.thisBrush.IsFrozen)
helper.thisBrush= helper.thisBrush.Clone();
helper.thisBrush.Freeze();
}
}
[Browsable(false)]
public string ThisBrushSerialize
{
get { return Serialize.BrushToString(thisBrush); }
set { thisBrush = Serialize.StringToBrush(value); }
}
public override void OnRenderTargetChanged()
{
if(helper.thisBrushDx != null)
helper.thisBrushDx.Dispose();
if(RenderTarget != null)
{
helper.thisBrushDx = helper.thisBrush.ToDxBrush(RenderTarget);
}
}
And on StateChange
if(State == State.Terminated)
{
if(helper.thisBrushDx != null)
{
helper.thisBrushDx.Dispose();
helper.thisBrushDx = null;
}
}
I am not using State.SetDefaults from OnStateChange() at all to set Brush and SharpDx.Direct2D1.Brush.
Is that the right pattern to use ?
Am I wrong in some way ?

Comment