ViewerCellCreated Event

Summary
Occurs after a new Leadtools.MedicalViewer.MedicalViewerMultiCell is created, initialized and added to the ViewerControl to display a series images.
Syntax
C#
C++/CLI
public event EventHandler<MedicalViewerCellCreatedEventArgs> ViewerCellCreated 
public: 
event EventHandler<MedicalViewerCellCreatedEventArgs^>^ ViewerCellCreated 
Event Data

The event handler receives an argument of type MedicalViewerCellCreatedEventArgs containing data related to this event. The following MedicalViewerCellCreatedEventArgs properties provide information specific to this event.

PropertyDescription
SeriesInstanceUID Gets the Series Instance UID for the images to be loaded in the cell.
StudyInstanceUID Gets the Study Instance UID for the images to be loaded in the cell.
ViewerCell Gets the newly created cell.
ViewerControl Gets the control that the created cell is added to.
Example
C#
using LeadtoolsExamples.Common; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Dicom; 
using Leadtools.MedicalViewer; 
using Leadtools.Dicom.Scu.Common; 
using Leadtools.ImageProcessing; 
using Leadtools.Dicom.AddIn.Common; 
using Leadtools.Dicom.Scu; 
using Leadtools.Medical.Workstation.Client; 
using Leadtools.Medical.Workstation.Client.Pacs; 
using Leadtools.Medical.Workstation.Loader; 
 
 
MedicalViewer viewer = new MedicalViewer(); 
public void LoadSeries() 
{ 
   Leadtools.Examples.Support.SetLicense(); 
 
   AeInfo clientInfo = new AeInfo(); 
 
   clientInfo.Address = Dns.GetHostName(); 
   clientInfo.Port = 1000; 
   clientInfo.AETitle = "TEST_CLIENT"; 
 
   DicomScp serverInfo = new DicomScp(); 
   serverInfo.AETitle = "LEAD_SERVER"; 
   serverInfo.Port = 104; 
   serverInfo.PeerAddress = GetLocalServerAddress(); 
   serverInfo.Timeout = 30; 
 
   PacsQueryClient queryClient = new PacsQueryClient(clientInfo, serverInfo); 
 
   DicomDataSet[] queryResult = queryClient.FindSeries(new FindQuery()); 
 
   if (queryResult.Length > 0) 
   { 
      PacsRetrieveClient retrieveClient = new PacsRetrieveClient(clientInfo, serverInfo); 
 
 
      //make sure you have configured the workstation database correctly for the PacsRetrieveClient to store the images. 
      retrieveClient.StoreRetrievedImages = true; //we want to store the images locally so we can view them later. 
 
      MedicalViewerLoader loader = new MedicalViewerLoader(retrieveClient); 
 
      loader.ViewerControl = viewer; 
      loader.Layout.Auto = true; 
      loader.LazyLoading = true; //this will cause to load the images for displayed sub-cells only 
      loader.ViewerPreLoadedImages = 1; //this will allow to load 1 image after and before the displayed sub-cell for fast scrolling. 
 
      loader.ProgressState += new ProgressEventHandler(loader_ProgressState); 
      loader.RequestedImageUpdated += new EventHandler<RequestedImageUpdatedEventArgs>(loader_RequestedImageUpdated); 
 
      string studyInstanceUID = queryResult[0].GetValue<string>(DicomTag.StudyInstanceUID, string.Empty); 
      string seriesInstanceUID = queryResult[0].GetValue<string>(DicomTag.SeriesInstanceUID, string.Empty); 
 
      if (loader.LoadSeries(studyInstanceUID, seriesInstanceUID)) 
      { 
         Console.WriteLine("Number of viewer cells: {0}", viewer.Cells.Count); 
         Console.WriteLine("Number of loader created cells: {0}", loader.SeriesCells.Length); 
 
         foreach (MedicalViewerMultiCell cell in loader.FindSeriesCells(seriesInstanceUID)) 
         { 
            string sopInstanceUID = loader.FindDisplayedCellInstanceInformation(cell, 0).SOPInstanceUID; 
 
            Console.WriteLine("Cell #{0} has first image with SOPInstanceUID={1}", viewer.Cells.IndexOf(cell), sopInstanceUID); 
 
 
            DicomDataSet ds = loader.GetDicom(sopInstanceUID); 
            DicomElement imageElement = ds.FindFirstElement(null, DicomTag.PixelData, true); 
 
            if (null != imageElement && imageElement.Length > 0) 
            { 
               using (RasterCodecs codec = new RasterCodecs()) 
               { 
                  using (RasterImage image = ds.GetImage(imageElement, 0, 24, RasterByteOrder.Gray, DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut)) 
                  { 
                     codec.Save(image, Path.Combine(LEAD_VARS.ImagesDir, sopInstanceUID), RasterImageFormat.Jpeg, image.BitsPerPixel); 
 
                     Console.WriteLine("Image with SOPInstanceUID={0} saved to {1}", sopInstanceUID, Path.Combine(LEAD_VARS.ImagesDir, sopInstanceUID)); 
                  } 
               } 
            } 
 
            string[] imagesPath = loader.GetSeriesImages(cell); 
 
            Console.WriteLine("Cell #{0} is loaded from {1} file(s):", viewer.Cells.IndexOf(cell), imagesPath.Length); 
 
            foreach (string imagePath in imagesPath) 
            { 
               Console.WriteLine(imagesPath); 
            } 
         } 
      } 
 
      loader.Close(); 
   } 
} 
 
void loader_RequestedImageUpdated(object sender, RequestedImageUpdatedEventArgs e) 
{ 
   Console.WriteLine("Image streamer for cell {0}, sub-cell {1}", viewer.Cells.IndexOf(e.Cell), e.SubCellIndex); 
} 
 
void loader_ProgressState(object sender, ProgressEventArgs e) 
{ 
   Console.WriteLine(e.Message); 
} 
 
public IPAddress GetLocalServerAddress() 
{ 
   IPAddress[] addresses; 
 
   //you can use any IP address which a DICOM server is listening to. 
   addresses = Dns.GetHostAddresses(Dns.GetHostName()); 
 
   foreach (IPAddress address in addresses) 
   { 
      if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) 
      { 
         return address; 
      } 
   } 
 
   throw new InvalidOperationException("No IP Address V4 found for this machine."); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Medical.Workstation.Loader Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.