In my code I generate a rectangle after a MouseClick (using TriggerCustomEvent).
I use always the same tag for the iRect and therefore with each new mouseclick the rectangle position is updated.
This all works, but there is a problem when the user removes the Rectangle manually from the Chart.
In this case my code will fail and I cannot update the iRect postion any more and I get an error from Ninja in the trace.
Remember the rectangle was drawn programmatically by a call to DrawRect. It is removed by the user.
Actually I am happy with this and I want the user to be able to remove it .
In my code I can also detect if the iRect is visible or not (and or disposed), but once the iRect was removed by the user I cannot use the originally used tag any more to draw a new rectangle.
My questions:
1. Is this by design? So once the user has removed an IRectangle this is flagged as "don't use" and I have to change the tag?
2. The smartest solution would be to use the ChartControl.ChartObjectChanged Event Handler and attach Handler to it. But it nver gets fired.Could you please enlight it' s use. When does it get fired? hank you
Best regards
andreas
below code snipped and trace
MyInteractiveIndicator:Indicator {
IRectangle iRect=null;
MyCustomEventMouseClicked(){
if(CTRL+LMOUSEBUTTON){
iRect=DrawRect(...);
}
}
THIS TRACE BELOW ONLY IF iRECT REMOVED BY USER:
2009-12-20 15:20:38:412 in OnUnhandledThreadException
2009-12-20 15:20:38:412 ********* exception trapped *********
2009-12-20 15:20:38:412 Parameter is not valid.
2009-12-20 15:20:38:412 at System.Drawing.Pen.get_Width()
at NinjaTrader.Gui.Chart.ChartShape.IsOutlineVisible( ChartControl chartControl, Int32 x, Int32 y)
at NinjaTrader.Gui.Chart.ChartRectangle.IsOutlineVisi ble(ChartControl chartControl, Int32 x, Int32 y)
at NinjaTrader.Gui.Chart.ChartControl.GetSelectedChar tObject(MouseEventArgs e)

Comment