示例#1
0
        //return the current enum entries
        protected override IReadOnlyDictionary <string, object> GetEntries()
        {
            var haarPaths = new Dictionary <string, object>();
            // Get the paths for available HAAR cascade files
            var haarcascadeDir = HAARCascadeResolver.ResolveHaarcascadesDirectory();

            if (haarcascadeDir != null)
            {
                var haarDir   = new DirectoryInfo(haarcascadeDir);
                var haarFiles = haarDir.EnumerateFiles("*.xml");
                foreach (var haarFile in haarFiles)
                {
                    haarPaths[haarFile.Name] = haarFile.FullName;
                }
            }
            return(haarPaths);
        }
        static DirectoryChangedEvents()
        {
            var haarcascadesDir = HAARCascadeResolver.ResolveHaarcascadesDirectory();

            if (haarcascadesDir != null)
            {
                fsw = new FileSystemWatcher(haarcascadesDir);
                fsw.EnableRaisingEvents = true;

                FileCreatedObservable = Observable.FromEventPattern <FileSystemEventArgs>(fsw, "Created");
                FileCreatedObservable.Subscribe();

                FileDeletedObservable = Observable.FromEventPattern <FileSystemEventArgs>(fsw, "Deleted");
                FileDeletedObservable.Subscribe();

                DirectoryChangedObservable = Observable.Merge(FileCreatedObservable, FileDeletedObservable);
            }
            else
            {
                DirectoryChangedObservable = Observable.Never <EventPattern <FileSystemEventArgs> >();
            }
        }