LEADTOOLS Medical (Leadtools.Dicom assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
Reset Method
See Also 
Leadtools.Dicom Namespace > DicomDir Class : Reset Method



destinationFolder
The name of an existing destination folder in which to save the DICOMDIR File.
destinationFolder
The name of an existing destination folder in which to save the DICOMDIR File.
Removes the contents of the Directory and reinitializes it.

Syntax

Visual Basic (Declaration) 
Public Sub Reset( _
   ByVal destinationFolder As String _
) 
Visual Basic (Usage)Copy Code
Dim instance As DicomDir
Dim destinationFolder As String
 
instance.Reset(destinationFolder)
C# 
public void Reset( 
   string destinationFolder
)
C++/CLI 
public:
void Reset( 
   String^ destinationFolder
) 

Parameters

destinationFolder
The name of an existing destination folder in which to save the DICOMDIR File.

Example

Visual BasicCopy Code
Public Class MyDicomDir : Inherits DicomDir
  Public Sub New(ByVal destinationFolder As String, ByVal path As String)
     MyBase.New(destinationFolder, path)
  End Sub
  Public Overrides Function OnInsertFile(ByVal fileName As String, ByVal ds As DicomDataSet, ByVal status As DicomDirInsertFileStatus, ByVal code As DicomExceptionCode) As DicomDirInsertFileCommand
       If status = DicomDirInsertFileStatus.PreAdd Then
          Dim msg As String = String.Format("About to add the file '{0}'{1}{1}Proceed?", fileName, Environment.NewLine)
          Dim result As DialogResult = MessageBox.Show(msg, "Sample", MessageBoxButtons.YesNoCancel)
          If result = DialogResult.Yes Then
             Return DicomDirInsertFileCommand.Continue
          ElseIf result = DialogResult.No Then
             Return DicomDirInsertFileCommand.Skip
          ElseIf result = DialogResult.Cancel Then
             Return DicomDirInsertFileCommand.Stop
          End If
       ElseIf status = DicomDirInsertFileStatus.Success Then
          Dim msg As String = String.Format("The file '{0}' has been added successfully.", fileName)
       End If
    Return DicomDirInsertFileCommand.Continue
  End Function
End Class
<Test> _
Private Sub CreateDicomDirectory()
  'Make sure to initialize the DICOM engine, this needs to be done only once 
  'In the whole application
  DicomEngine.Startup()
  Dim dicomDir As MyDicomDir = New MyDicomDir(Nothing, Nothing)
    Using (dicomDir)

       Dim autoSearch As Boolean = True
       ' Set the destination folder
       dicomDir.Reset(LeadtoolsExamples.Common.ImagesPath.Path + "TEMP\DCMTEST\PATIENT1")
       ' Set the File-set Identifier
       dicomDir.SetFileSetId("SOME ID")
       ' Set some options
       Dim options As DicomDirOptions = dicomDir.Options
       dicomDir.ResetOptions()
       options.IncludeSubfolders = True
       options.InsertIconImageSequence = False
       options.RejectInvalidFileId = True
       dicomDir.Options = options

       ' Set the File-set descriptor file
       dicomDir.SetDescriptorFile(LeadtoolsExamples.Common.ImagesPath.Path + "TEMP\DCMTEST\PATIENT1\README", Nothing)

       If autoSearch Then
          Try
             dicomDir.InsertFile(Nothing)
          Catch ex As Exception
             MessageBox.Show(ex.GetType().ToString(), ex.Message, MessageBoxButtons.YesNoCancel)
          End Try
       Else
          ' Load a Data Set and add it to the Directory

          Dim ds As DicomDataSet = New DicomDataSet()
          Using (ds)
             ds.Load(LeadtoolsExamples.Common.ImagesPath.Path + "TEMP\DCMTEST\PATIENT1\Image1", DicomDataSetLoadFlags.None)
             dicomDir.InsertDataSet(ds, LeadtoolsExamples.Common.ImagesPath.Path + "TEMP\DCMTEST\PATIENT1\IMAGE1")
          End Using

          ' Add some DICOM files to the Directory
          dicomDir.InsertFile(LeadtoolsExamples.Common.ImagesPath.Path + "TEMP\DCMTEST\PATIENT1\IMAGE2")
          dicomDir.InsertFile(LeadtoolsExamples.Common.ImagesPath.Path + "TEMP\DCMTEST\PATIENT1\IMAGE3")
          dicomDir.InsertFile(LeadtoolsExamples.Common.ImagesPath.Path + "TEMP\DCMTEST\PATIENT1\IMAGE4")
       End If

       ' Test the DataSet
       Dim first As DicomElement = dicomDir.DataSet.FindFirstElement(Nothing, DicomTag.PatientID, False)
       MessageBox.Show(first.Length.ToString())

       ' Save the DICOMDIR File
       dicomDir.Save()
       'We can now call something like this to call the DICOMDIR back
       'dicomDir.Load(@LeadtoolsExamples.Common.ImagesPath.Path + "TEMP\DCMTEST\PATIENT1\DICOMDIR",DicomDataSetLoadFlags.LoadAndClose);
    End Using
    DicomEngine.Shutdown()
 End Sub
C#Copy Code
public class MyDicomDir : DicomDir
{
   public MyDicomDir(string destinationFolder, string path) : base(destinationFolder, path) { }
   public override DicomDirInsertFileCommand OnInsertFile(string fileName, DicomDataSet ds, DicomDirInsertFileStatus status, DicomExceptionCode code)
   {
      if (status == DicomDirInsertFileStatus.PreAdd)
      {
         string msg = string.Format("About to add the file '{0}'{1}{1}Proceed?", fileName, Environment.NewLine);
         DialogResult result = MessageBox.Show(msg, "Sample", MessageBoxButtons.YesNoCancel);
         if (result == DialogResult.Yes)
            return DicomDirInsertFileCommand.Continue;
         else if (result == DialogResult.No)
            return DicomDirInsertFileCommand.Skip;
         else if (result == DialogResult.Cancel)
            return DicomDirInsertFileCommand.Stop;
      }
      else if (status == DicomDirInsertFileStatus.Success)
      {
         string msg = string.Format("The file '{0}' has been added successfully.", fileName);
      }
      return DicomDirInsertFileCommand.Continue;
   }
};


public void CreateDicomDirectory()
{
   //Make sure to initialize the DICOM engine, this needs to be done only once 
   //In the whole application
   DicomEngine.Startup();
   using (MyDicomDir dicomDir = new MyDicomDir(null, null))
   {
      bool autoSearch = true;
      // Set the destination folder
      dicomDir.Reset(LeadtoolsExamples.Common.ImagesPath.Path + @"TEMP\DCMTEST\PATIENT1");
      // Set the File-set Identifier
      dicomDir.SetFileSetId("SOME ID");
      // Set some options
      DicomDirOptions options = dicomDir.Options;
      dicomDir.ResetOptions();
      options.IncludeSubfolders = true;
      options.InsertIconImageSequence = false;
      options.RejectInvalidFileId = true;
      dicomDir.Options = options;

      // Set the File-set descriptor file
      dicomDir.SetDescriptorFile(LeadtoolsExamples.Common.ImagesPath.Path + @"TEMP\DCMTEST\PATIENT1\README", null);

      if (autoSearch)
      {
         try
         {
            dicomDir.InsertFile(null);
         }
         catch (Exception ex)
         {
            MessageBox.Show(ex.GetType().ToString(), ex.Message, MessageBoxButtons.YesNoCancel);
         }
      }
      else
      {
         // Load a Data Set and add it to the Directory
         using (DicomDataSet ds = new DicomDataSet())
         {
            ds.Load(LeadtoolsExamples.Common.ImagesPath.Path + @"TEMP\DCMTEST\PATIENT1\Image1", DicomDataSetLoadFlags.None);
            dicomDir.InsertDataSet(ds, LeadtoolsExamples.Common.ImagesPath.Path + @"TEMP\DCMTEST\PATIENT1\IMAGE1");
         }

         // Add some DICOM files to the Directory
         dicomDir.InsertFile(LeadtoolsExamples.Common.ImagesPath.Path + @"TEMP\DCMTEST\PATIENT1\IMAGE2");
         dicomDir.InsertFile(LeadtoolsExamples.Common.ImagesPath.Path + @"TEMP\DCMTEST\PATIENT1\IMAGE3");
         dicomDir.InsertFile(LeadtoolsExamples.Common.ImagesPath.Path + @"TEMP\DCMTEST\PATIENT1\IMAGE4");
      }

      // Test the DataSet
      DicomElement first = dicomDir.DataSet.FindFirstElement(null, DicomTag.PatientID, false);
      MessageBox.Show(first.Length.ToString());

      // Save the DICOMDIR File
      dicomDir.Save();
      //We can now call something like this to call the DICOMDIR back
      //dicomDir.Load(LeadtoolsExamples.Common.ImagesPath.Path + @"TEMP\DCMTEST\PATIENT1\DICOMDIR",DicomDataSetLoadFlags.LoadAndClose);
   }
   DicomEngine.Shutdown();
}
SilverlightCSharpCopy Code
SilverlightVBCopy Code

Remarks

When an object of the DicomDir class is created, the DICOM Directory, as specified by the object, is empty. To revert to this case at any time, call the method DicomDir.Reset. If the same object is to be used to create the DICOM Directory of a new file-set, this method must be called first.

This method also sets the destination folder of the DICOMDIR File. Please note that although the method can be passed a null reference (Nothing in Visual Basic), no DICOM file can be added to the DICOM Directory unless this folder is specified.

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also

Leadtools.Dicom requires a Medical toolkit server license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features