Removes the contents of the Directory and reinitializes it.
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As DicomDir
Dim destinationFolder As String
instance.Reset(destinationFolder)
|
Parameters
- destinationFolder
-
The name of an existing destination folder in which to save the DICOMDIR File.
Example
Visual Basic | Copy 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()
DicomEngine.Startup()
Dim dicomDir As MyDicomDir = New MyDicomDir(Nothing, Nothing)
Using (dicomDir)
Dim autoSearch As Boolean = True
dicomDir.Reset("C:\Medical Images\Patient 1")
dicomDir.SetFileSetId("SOME ID")
Dim options As DicomDirOptions = dicomDir.Options
dicomDir.ResetOptions()
options.IncludeSubfolders = True
options.InsertIconImageSequence = False
options.RejectInvalidFileId = True
dicomDir.Options = options
dicomDir.SetDescriptorFile("C:\Medical Images\Patient 1\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
Dim ds As DicomDataSet = New DicomDataSet()
Using (ds)
ds.Load("C:\Medical Images\Patient 1\Image1", DicomDataSetLoadFlags.None)
dicomDir.InsertDataSet(ds, "C:\Medical Images\Patient 1\Image1")
End Using
dicomDir.InsertFile("C:\Medical Images\Patient 1\Image2")
dicomDir.InsertFile("C:\Medical Images\Patient 1\Image3")
dicomDir.InsertFile("C:\Medical Images\Patient 1\Image4")
End If
dicomDir.Save()
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; } }; 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(@"C:\Medical Images\Patient 1"); // 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(@"C:\Medical Images\Patient 1\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(@"C:\Medical Images\Patient 1\Image1", DicomDataSetLoadFlags.None); dicomDir.InsertDataSet(ds, @"C:\Medical Images\Patient 1\Image1"); } // Add some DICOM files to the Directory dicomDir.InsertFile(@"C:\Medical Images\Patient 1\Image2"); dicomDir.InsertFile(@"C:\Medical Images\Patient 1\Image3"); dicomDir.InsertFile(@"C:\Medical Images\Patient 1\Image4"); } // Save the DICOMDIR File dicomDir.Save(); //We can now call something like this to call the DICOMDIR back //dicomDir.Load(@"C:\Medical Images\Patient 1\DICOMDIR",DicomDataSetLoadFlags.LoadAndClose); } DicomEngine.Shutdown(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also