LEADTOOLS Support
Medical
Medical SDK Questions
cell.SetTag() throws StachOverflowException by dynamic labels
#1
Posted
:
Wednesday, February 22, 2017 11:16:04 AM(UTC)
Groups: Registered
Posts: 15
Hello,
I have followed this example :
https://www.leadtools.co...withmprviewtutorial.htmlI am adding the following line to it :
Code:
control3D.AxialFrame.Data3DRequested += new EventHandler<MedicalViewerData3DRequestedEventArgs>(AxialFrame_Data3DRequested);
And I am adding this function :
Code:
private void AxialFrame_Data3DRequested(object sender, MedicalViewerData3DRequestedEventArgs e)
{
MedicalViewerBaseCell cell = sender as MedicalViewerBaseCell;
string labelName = DateTime.Now + " *";
cell.SetTag(3, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.UserData, labelName);
}
After running; StachOverflowException is throwen by
AxialFrame_Data3DRequested() method and label can't be set.
Do you know why?
#2
Posted
:
Wednesday, February 22, 2017 2:54:20 PM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 71
Was thanked: 4 time(s) in 3 post(s)
Hi,
The issue here is that the Data3DRequested event fires any time the cell itself requests any data, so you are actually calling SetTag many times when the form attempts to load. You could see this by either putting a breakpoint on the cell.SetTag method call and stepping through the code or simply putting a counter in the AxialFrame_Data3DRequested. Calling the SetTag method over and over again is what is causing the stack overflow exception. It looks like you may be just setting the time in the tag overlay text. If so, you could do that when the form loads just once after all the cells have been added to the viewer. I added the following to the end of the InitClass method from the tutorial link you provided:
Code:
string labelName = DateTime.Now + " *";
foreach (var cell in viewer.Cells)
{
cell.SetTag(3, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.UserData, labelName);
}
Which will set the current time as an overlay tag on each cell:
If this is not what you are trying to achieve, could you give me any further information on why you are wanting to use the Data3DRequested event to set the cell tag overlays? Or maybe some further information on what functionality you are attempting to achieve with the Data3DRequested event and the SetTag method call so that I can assist you further in implementing the functionality that you want?
Edited by moderator Monday, February 24, 2020 10:32:03 AM(UTC)
| Reason: Not specified
Aaron Brasington
Developer Support Engineer
LEAD Technologies, Inc.
#3
Posted
:
Thursday, February 23, 2017 3:14:09 AM(UTC)
Groups: Registered
Posts: 15
Thanks for your quick reply.
We are using several dynamic labels [specific description per image] and we need to refresh them every time when related cells are changed or scrolled.
So Data3DRequested event was at this time a good option to use for our dynamic labels.
#4
Posted
:
Thursday, February 23, 2017 11:30:36 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 71
Was thanked: 4 time(s) in 3 post(s)
I think I understand now. However, the Data3DRequested is just firing too many times to be able to update the cell tag in this manner (which is causing the StackOverflowException on the SetTag call). A better option may be to try using the UIChanged event. This event would fire any time the user interacts with the cell. I hooked into this event in the tutorial you mentioned and the tag seems to update correctly any time the user interacts with the cell:
Code:
control3D.AxialFrame.UIChanged += new EventHandler<MedicalViewerUIChangedEventArgs>(AxialFrame_UIChanged);
Code:
private void AxialFrame_UIChanged(object sender, MedicalViewerUIChangedEventArgs e)
{
MedicalViewerBaseCell cell = sender as MedicalViewerBaseCell;
string labelName = DateTime.Now + " *";
cell.SetTag(3, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.UserData, labelName);
}
Aaron Brasington
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Medical
Medical SDK Questions
cell.SetTag() throws StachOverflowException by dynamic labels
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.