OK, so I want to be able to use my custom drawing tools to (1) mark up a chart then (2) upload it to the cloud so that my friend can (3) download, (4) edit and upload from his machine.
So, I worked all weekend and made it work but I feel that I hacked it too much and ran into a few problems and can't find answers in the code, forum or documentation.
Question #1. Is there a way to create a drawing tool on that is marked as being created by the user? [i.e. IsUserDrawn = true]
The reason I want this is so that the drawing object can be automatically serialized and saved when the page loads.
I'm fine with some unsupported method that uses reflection but couldn't find one and wasn't even sure which object to look at. I checked both ChartManager and DrawingTool but didn't figure out how it gets hooked up.
My hack#1 for this one was to serialize all downloaded tools to xml and save them on the file system and then recreate them in the OnStateChange / State.Configure.
My hack#2 for this required me to move all the the user drawn tools that I wanted to upload/download to be owned by my own indicator and therefore removed -- found a reflective hack to do that.
From https://ninjatrader.com/support/foru...-delete-itself
using System.Reflection; typeof(ChartControl) .GetMethod("RemoveDrawingTool") .Invoke(ChartControlOfDrawObject, new Object[] { DrawingObjectToDelete, false, false });
Question #2. Is there a way I can hook into the serialization and control creation that NT uses?
It would be great if I could serialize my custom object to a string then deserialize it so that it comes back, already attached to my chart.
It would also be great if I could just create the drawing tool then hook it to the chart (even better if it was marked as a user-created tool like I wrote in Question #1).
Instead the only way I found to do this was to create a new tool that is hooked to its owner when created. One thing that's not ideal is that my newly created drawing tool is hooked to my indicator and not to the chart because I won't be able to redraw with hack#1 without that.
My hack #3 was to do this by hand. I wrote code to work like the static Draw.Rectangle class which creates a new tool by calling DrawingTool.GetByTagOrNew() and then fills it in and makes it active with the values that I got back from the object that I serialized and stored in my SQL database that lives in the cloud.
Is there another or better way?
I have more questions but I'll limit my 2nd question to 2 questions.

Comment