示例#1
0
        /// ------------------------------------------------------------------------------------
        protected override bool SaveChanges()
        {
            if (!AmbiguousSequencesChanged)
            {
                _grid.IsDirty = false;
                return(false);
            }

            var ambigSeqList = new AmbiguousSequences();

            foreach (var row in _grid.GetRows().Where(r => r.Index != _grid.NewRowIndex))
            {
                var phone    = row.Cells["seq"].Value as string;
                var basechar = row.Cells["base"].Value as string;

                // Don't bother saving anything if there isn't
                // a phone (sequence) or base character.
                if (phone != null && phone.Trim().Length > 0 &&
                    basechar != null && basechar.Trim().Length > 0)
                {
                    var seq = new AmbiguousSeq(phone.Trim());
                    seq.BaseChar    = basechar.Trim();
                    seq.Convert     = (row.Cells["convert"].Value != null && (bool)row.Cells["convert"].Value);
                    seq.IsGenerated = (bool)row.Cells["generated"].Value;
                    ambigSeqList.Add(seq);
                }
            }

            App.MsgMediator.SendMessage("BeforeAmbiguousSequencesSaved", ambigSeqList);
            _project.SaveAndLoadAmbiguousSequences(ambigSeqList);
            App.MsgMediator.SendMessage("AfterAmbiguousSequencesSaved", ambigSeqList);
            _project.ReloadDataSources();
            return(true);
        }
        ///// ------------------------------------------------------------------------------------
        ///// <summary>
        /////
        ///// </summary>
        ///// ------------------------------------------------------------------------------------
        //protected bool OnAfterLoadingDataSources(object args)
        //{
        //    PaProject project = args as PaProject;

        //    if (project != null && project.DataSources != null && project.DataSources.Count > 0)
        //    {
        //        // Go through all the data sources and if any one is not an SA data source, then
        //        // do not bother fixing up the project so it treats references specially for SA
        //        // data sources.
        //        bool fixRefs = true;
        //        foreach (PaDataSource source in project.DataSources)
        //        {
        //            if (source.DataSourceType != DataSourceType.SA)
        //            {
        //                fixRefs = false;
        //                break;
        //            }
        //        }

        //        if (fixRefs)
        //            FixReferenceForSAProject(project);
        //    }

        //    return false;
        //}

        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void FixReferenceForSAProject(PaProject project)
        {
            PaFieldInfo refFieldInfo = project.FieldInfo.ReferenceField;

            if (!refFieldInfo.IsParsed || refFieldInfo.SaFieldName != "Reference")
            {
                refFieldInfo.IsParsed    = true;
                refFieldInfo.SaFieldName = "Reference";
                project.FieldInfo.Save(project);
                project.ReloadDataSources();
            }

            // Setting the parse type for each of the SA data sources has no bearing on how
            // the data is parsed, but it is a back-handed way of keeping the PaWordListGrid
            // from displaying all the reference fields for a transcription for those entries
            // that don't have a reference specified.
            foreach (PaDataSource source in project.DataSources)
            {
                source.ParseType = DataSourceParseType.OneToOne;
            }

            FixedAudioDocReader reader = new FixedAudioDocReader();

            foreach (RecordCacheEntry recEntry in PaApp.RecordCache)
            {
                if (recEntry.DataSource.DataSourceType == DataSourceType.SA)
                {
                    reader.Read(recEntry);
                }
            }

            PaApp.RecordCache.BuildWordCache(null);
        }