Developers using the WorkstationViewer with either a WinForms application or the rich client in the MedicalWebViewer may wish to customize the information that is displayed on the image within the viewer. This can be done through the MedicalViewerLoader's OverlayTags property. This property is a handle to OverlayTagCollection. Through this collection, you can add/remove/modify the tags that are to be displayed within the MedicalViewerMultiCells.
Below is some sample code illustrating adding tags for the content time and acquisition time tags from the datasets.
OverlayTagCollection collection = loader.OverlayTags;
OverlayTag tag1 = new OverlayTag(DicomTag.AcquisitionTime, "ACC TM: {0}", MedicalViewerTagAlignment.BottomRight, 7);
OverlayTag tag2 = new OverlayTag(DicomTag.ContentTime, "CTN TM: {0}", MedicalViewerTagAlignment.BottomRight, 8);
//This is for checking tag for each image in a series
tag1.GeneralTag = false;
tag2.GeneralTag = false;
collection.Add(tag1);
collection.Add(tag2);
This can alternatively be handled in the WorkstationViewer's SeriesLoadingCompleted event handler. Within this event, we can use the provided event arguments to use the get access to the dataset where the file was loaded from & get access to the cell where the tags will be displayed. The MedicalViewerLoader's FindDisplayedCellInstanceInformation() method returns an instance of the DicomInstanceInformation class. This gives us access to the file where the required information is located. The arguments give us the MedicalViewer where the image is loaded, so we can use this to display the tags. Here is the code for the alternative implementation:
void _viewer_SeriesLoadingCompleted(object sender, Leadtools.Medical.Workstation.UI.LoadSeriesEventArgs e)
{
lstLog.Items.Add("_viewer_SeriesLoadingCompleted");
foreach (MedicalViewer medicalViewer in e.LoadedSeries.Viewer.Viewers)
{
foreach (MedicalViewerCell cell in medicalViewer.Cells)
{
try
{
if (chboxAcquisitionTime.Checked && loader != null)
{
if (cell is MedicalViewerMultiCell)
{
DicomInstanceInformation instanceInfo = loader.FindDisplayedCellInstanceInformation((MedicalViewerMultiCell)cell, cell.ActiveSubCell);
using (DicomDataSet dataSet = new DicomDataSet())
{
dataSet.Load(instanceInfo.FilePath, DicomDataSetLoadFlags.LoadAndClose);
DicomElement contentTimeElement,
acquisitionTimeElement;
string contentTimeStr = string.Empty,
acquisitionTimeStr = string.Empty;
contentTimeElement = dataSet.FindFirstElement(null, DicomTag.ContentTime, false);
if (contentTimeElement != null)
contentTimeStr = dataSet.GetConvertValue(contentTimeElement);
acquisitionTimeElement = dataSet.FindFirstElement(null, DicomTag.AcquisitionTime, false);
if (acquisitionTimeElement != null)
acquisitionTimeStr = dataSet.GetConvertValue(acquisitionTimeElement);
//Show Content Time
cell.SetTag(7, MedicalViewerTagAlignment.BottomRight, MedicalViewerTagType.UserData, "Content Time: " + contentTimeStr);
//Show Acquisition Time
cell.SetTag(8, MedicalViewerTagAlignment.BottomRight, MedicalViewerTagType.UserData, "Acquisition Time: " + acquisitionTimeStr);
}
}
}
}
catch (Exception ex)
{
lstLog.Items.Add("Exception in _viewer_SeriesLoadingCompleted: " + ex.Message);
}
}
}
}
While these are essentially equivalent, the former is easier to implement. It handles the conversion of the tag data for you, and doesn't require searching for the necessary elements either.
Attached is a modified stand alone WorkstationViewer project
This example is built with Visual Studio 2008 using the LEADTOOLS v17.5 DotNet 3.5 binaries.
Edited by moderator Friday, August 9, 2019 8:48:02 AM(UTC)
| Reason: Not specified
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.