示例#1
0
        public ReadFileWorker(
            object sender,
            ProgressReporterInterface progress,
            string filename,
            ref FamilyTreeStoreBaseClass tree,
            CompletedCallback callback)
        {
            trace = new TraceSource("ReadFileWorker", SourceLevels.Warning);

            familyTree = tree;

            progressReporter = progress;

            backgroundWorker = new BackgroundWorker();

            backgroundWorker.WorkerReportsProgress = true;
            backgroundWorker.DoWork             += new DoWorkEventHandler(DoWork);
            backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Completed);
            backgroundWorker.ProgressChanged    += new ProgressChangedEventHandler(ProgressChanged);
            completedCallback = callback;

            codec = new FamilyFileTypeCollection();

            if (codec.IsKnownFileType(filename))
            {
                trace.TraceInformation("ReadFileWorker.DoWork(" + filename + "): OK!" + DateTime.Now);

                if (familyTree == null)
                {
                    familyTree = codec.CreateFamilyTreeStore(filename, completedCallback);
                }
                codec.SetProgressTarget(backgroundWorker);

                familyTree.SetSourceFileName(filename);
            }
            else
            {
                trace.TraceInformation("ReadFileWorker(" + workerFileName + "): Filetype unknown!" + DateTime.Now);
            }
            workerFileName = filename;
            backgroundWorker.RunWorkerAsync(filename);
        }