/// ------------------------------------------------------------------------------------
        public AnnotationComponentFile(ProjectElement parentElement,
                                       string pathToAnnotationFile, ComponentFile associatedComponentFile,
                                       List <FileType> fileTypes, IEnumerable <ComponentRole> componentRoles) :
            base(parentElement, pathToAnnotationFile,
                 fileTypes.Single(t => t is AnnotationFileType), null, null, null)
        {
            Tiers = new TierCollection();

            AssociatedComponentFile = associatedComponentFile;
            _componentRoles         = componentRoles;
            InitializeFileInfo();
            Load();

            SmallIcon = ResourceImageCache.ElanIcon;

            var oralAnnotationFilePath = GetSuggestedPathToOralAnnotationFile();

            if (File.Exists(oralAnnotationFilePath))
            {
                OralAnnotationFile = new OralAnnotationComponentFile(parentElement,
                                                                     oralAnnotationFilePath, associatedComponentFile, fileTypes, _componentRoles);
            }
            else
            {
                associatedComponentFile.PostGenerateOralAnnotationFileAction += generated =>
                {
                    OralAnnotationFile = new OralAnnotationComponentFile(parentElement,
                                                                         oralAnnotationFilePath, associatedComponentFile, fileTypes, _componentRoles);
                };
            }
        }
        /// ------------------------------------------------------------------------------------
        protected internal override bool Delete()
        {
            // If the annotation file has an associated ELAN preference file, then delete it.
            var prefFilePath       = Path.ChangeExtension(PathToAnnotatedFile, ".pfsx");
            var oralAnnotationFile = OralAnnotationFile;

            if (!base.Delete())
            {
                return(false);
            }

            if (File.Exists(prefFilePath))
            {
                ConfirmRecycleDialog.Recycle(prefFilePath);
            }

            if (oralAnnotationFile != null)
            {
                oralAnnotationFile.Delete();
                _oralAnnotationFile = null;
            }

            var           segmentAnnotationFileFolder = SegmentAnnotationFileFolder;
            DirectoryInfo dirInfo = new DirectoryInfo(segmentAnnotationFileFolder);

            if (dirInfo.Exists)
            {
                try
                {
                    foreach (FileInfo file in dirInfo.EnumerateFiles())
                    {
                        ConfirmRecycleDialog.Recycle(file.FullName);
                    }
                    Directory.Delete(segmentAnnotationFileFolder, true);
                }
                catch (Exception e)
                {
                    Logger.WriteEvent("Handled Exception in AnnotationComponentFile.Delete:\r\n{0}", e.ToString());
                }
            }

            return(true);
        }