When programmatically drawing objects to a chart, it would be nice if every draw object had a unique ID. So far this can be implemented by using a tag count and increasing its value upon each additional draw object that is created. The problem is that upon refreshing the chart, the tag count variable get's reset. Here's a workaround to run upon startup:
tagCount = 1;
foreach (DrawingTool draw in DrawObjects.ToList())
{
if ((draw.Tag).Contains("TextButton")) tagCount++; // tag would be set as "TextButton" + TagCount... "TextButton1"
}
tagCount = 1;
int tempTagCount = 0;
int highestTempTagCount = 0;
foreach (DrawingTool draw in DrawObjects.ToList())
{
if ((draw.Tag).Contains("TextButton"))
{
tempTagCount = int.Parse((draw.Tag).Remove(0, 10));
if (tempTagCount > highestTempTagCount) highestTempTagCount = tempTagCount;
}
}
tagCount = highestTempTagCount + 1;
I also noticed that the count for draw objects using the IDrawingTool appears to be tracked globally. Is there any way an indicator could implement that?
Honestly, it's not that big of a deal as the indicator has no need to grab object's by ID. With that said, IDs should be unique to every draw object. Perhaps if NT provided an in-house tagging system for indicators to use that would be solid. It's very possible that my solution is not fool proof.
Thanks

Comment