using System;
public class MyWatcher : SimpleSubjectWatcher
{
public MyWatcher(Subject s):base(s,"Override String"){}
protected override void ShowFileName(Subject caller, Event evt){
FileNameEvent fne = FileNameEvent.Cast(evt);
if( fne != null )
{
string fn = fne.GetFileName();
System.Console.WriteLine( "This is my Scanner. Processing FileName: " + fn );
}
else
{
System.Console.WriteLine( "This is my Anonymization. Unhandled Event type: " + evt.GetEventName() );
}
}
}
public class ScanDirectory
{
public static int Main(string[] args)
{
string directory = args[0];
Tag t = new Tag(0x8,0x80);
Directory d = new Directory();
uint nfiles = d.Load( directory );
if(nfiles == 0) return 1;
SmartPtrStrictScan sscan = StrictScanner.New();
StrictScanner s = sscan.__ref__();
MyWatcher watcher = new MyWatcher(s);
s.AddTag( t );
bool b = s.Scan( d.GetFilenames() );
if(!b) return 1;
for(int i = 0; i < (int)nfiles; ++i)
{
if( !s.IsKey( d.GetFilenames()[i] ) )
{
System.Console.WriteLine( "File is not DICOM or could not be read: " + d.GetFilenames()[i] );
}
}
System.Console.WriteLine( "Scan:\n" + s.toString() );
System.Console.WriteLine( "success" );
return 0;
}
}