예제 #1
0
        int GetNCFeatsWidth(IPhSimpleContextNC ctxt, IVwEnv vwenv)
        {
            int           maxLen   = 0;
            IPhNCFeatures natClass = ctxt.FeatureStructureRA as IPhNCFeatures;

            foreach (IFsFeatureSpecification spec in natClass.FeaturesOA.FeatureSpecsOC)
            {
                IFsClosedValue curVal   = spec as IFsClosedValue;
                ITsString      featLine = CreateFeatureLine(curVal);
                int            len      = GetStrWidth(featLine, null, vwenv);
                if (len > maxLen)
                {
                    maxLen = len;
                }
            }

            int plusLen = GetVariablesWidth(ctxt, vwenv, true);

            if (plusLen > maxLen)
            {
                maxLen = plusLen;
            }

            int minusLen = GetVariablesWidth(ctxt, vwenv, false);

            if (minusLen > maxLen)
            {
                maxLen = minusLen;
            }
            return(maxLen);
        }
        /// <summary>
        /// Init the dialog with a simple context.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="mediator"></param>
        /// <param name="fs"></param>
        public void SetDlgInfo(FdoCache cache, XCore.Mediator mediator, IPhRegularRule rule, IPhSimpleContextNC ctxt)
        {
            CheckDisposed();

            m_rule = rule;
            m_ctxt = ctxt;
            RestoreWindowPosition(mediator);
            m_cache = cache;

            m_valuesCombo.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_valuesCombo.StyleSheet           = FontHeightAdjuster.StyleSheetFromMediator(mediator);
            m_valuesCombo.WritingSystemCode    = m_cache.DefaultUserWs;
            m_valuesCombo.Items.Add(MEStrings.ksFeatConstrAgree);
            m_valuesCombo.Items.Add(MEStrings.ksFeatConstrDisagree);
            m_valuesCombo.Items.Add(MEStrings.ks_DontCare_);

            List <int>    hvos     = new List <int>();
            IPhNCFeatures natClass = m_ctxt.FeatureStructureRA as IPhNCFeatures;

            foreach (int hvo in m_cache.LangProject.PhFeatureSystemOA.FeaturesOC.HvoArray)
            {
                if (natClass.FeaturesOAHvo == 0 || natClass.FeaturesOA.FindClosedValue(hvo) == null)
                {
                    hvos.Add(hvo);
                }
            }
            LoadPhonFeats(hvos);
            BuildInitialBrowseView(mediator, hvos);
        }
        protected override void HandleChooser()
        {
            // grammar/phonemes/phonological features/[...] (click chooser button)
            using (PhonologicalFeatureChooserDlg dlg = new PhonologicalFeatureChooserDlg())
            {
                IFsFeatStruc originalFs       = null;
                Slice        parentSlice      = Slice;
                int          parentSliceClass = parentSlice.Object.ClassID;
                int          owningFlid       = (parentSlice as PhonologicalFeatureListDlgLauncherSlice).Flid;
                switch (parentSliceClass)
                {
                case PhPhonemeTags.kClassId:
                    IPhPhoneme phoneme = parentSlice.Object as IPhPhoneme;
                    if (phoneme.FeaturesOA != null)
                    {
                        originalFs = phoneme.FeaturesOA;
                    }
                    break;

                case PhNCFeaturesTags.kClassId:
                    IPhNCFeatures features = parentSlice.Object as IPhNCFeatures;
                    if (features.FeaturesOA != null)
                    {
                        originalFs = features.FeaturesOA;
                    }
                    break;
                }

                if (originalFs == null)
                {
                    dlg.SetDlgInfo(m_cache, m_mediator, parentSlice.Object, owningFlid);
                }
                else
                {
                    dlg.SetDlgInfo(m_cache, m_mediator, originalFs);
                }

                DialogResult result = dlg.ShowDialog(parentSlice.FindForm());
                if (result == DialogResult.OK)
                {
                    if (dlg.FS != null)
                    {
                        m_obj = dlg.FS;
                        m_PhonologicalFeatureListDlgLauncherView.UpdateFS(dlg.FS);
                    }
                }
                else if (result != DialogResult.Cancel)
                {
                    dlg.HandleJump();
                }
            }
        }
예제 #4
0
		private int GetOutputMaxNumLines()
		{
			int maxNumLines = 1;
			foreach (IMoModifyFromInput modify in m_rule.OutputOS.OfType<IMoModifyFromInput>())
			{
				IPhNCFeatures nc = modify.ModificationRA;
				if (nc != null && nc.FeaturesOA != null)
				{
					int numLines = nc.FeaturesOA.FeatureSpecsOC.Count;
					if (numLines > maxNumLines)
						maxNumLines = numLines;
				}
			}
			return maxNumLines;
		}
        private void RemoveFeatureStructureFromOwner()
        {
            if (m_obj != null)
            {
                switch (m_obj.ClassID)
                {
                case PhPhoneme.kclsidPhPhoneme:
                    IPhPhoneme phoneme = m_obj as IPhPhoneme;
                    phoneme.FeaturesOA = null;
                    break;

                case PhNCFeatures.kclsidPhNCFeatures:
                    IPhNCFeatures features = m_obj as IPhNCFeatures;
                    features.FeaturesOA = null;
                    break;
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Gets the number of lines needed to display the specified context or variable.
        /// </summary>
        /// <param name="ctxtOrVar">The context or variable.</param>
        /// <returns></returns>
        protected int GetNumLines(IPhContextOrVar ctxtOrVar)
        {
            if (ctxtOrVar == null)
            {
                return(1);
            }

            switch (ctxtOrVar.ClassID)
            {
            case PhSequenceContext.kclsidPhSequenceContext:
                IPhSequenceContext seqCtxt = ctxtOrVar as IPhSequenceContext;
                int maxNumLines            = 1;
                foreach (IPhPhonContext cur in seqCtxt.MembersRS)
                {
                    int numLines = GetNumLines(cur);
                    if (numLines > maxNumLines)
                    {
                        maxNumLines = numLines;
                    }
                }
                return(maxNumLines);

            case PhIterationContext.kclsidPhIterationContext:
                IPhIterationContext iterCtxt = ctxtOrVar as IPhIterationContext;
                return(GetNumLines(iterCtxt.MemberRA));

            case PhSimpleContextNC.kclsidPhSimpleContextNC:
                int numFeats = 0;
                IPhSimpleContextNC ncCtxt = ctxtOrVar as IPhSimpleContextNC;
                if (ncCtxt.FeatureStructureRAHvo != 0 && ncCtxt.FeatureStructureRA.ClassID == PhNCFeatures.kclsidPhNCFeatures)
                {
                    IPhNCFeatures natClass = ncCtxt.FeatureStructureRA as IPhNCFeatures;
                    if (natClass.FeaturesOAHvo != 0)
                    {
                        numFeats = natClass.FeaturesOA.FeatureSpecsOC.Count;
                    }
                }
                return(ncCtxt.PlusConstrRS.Count + ncCtxt.MinusConstrRS.Count + numFeats);
            }
            return(1);
        }
예제 #7
0
		private static IEnumerable<XElement> ExportNaturalClassContents(IPhNCFeatures naturalClass)
		{
			return new[] {new XElement("Features", ExportFeatureStructure(naturalClass.FeaturesOA)) };
		}
예제 #8
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();

            switch (frag)
            {
            case kfragContext:
                IPhContextOrVar ctxtOrVar       = PhContextOrVar.CreateFromDBObject(m_cache, hvo);
                bool            isOuterIterCtxt = false;
                // are we inside an iteration context? this is important since we only open a context pile if we are not
                // in an iteration context, since an iteration context does it for us
                if (vwenv.EmbeddingLevel > 0)
                {
                    int outerHvo, outerTag, outerIndex;
                    vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out outerHvo, out outerTag, out outerIndex);
                    isOuterIterCtxt = m_cache.GetClassOfObject(outerHvo) == PhIterationContext.kclsidPhIterationContext;
                }

                switch (ctxtOrVar.ClassID)
                {
                case PhSequenceContext.kclsidPhSequenceContext:
                    if (m_cache.GetVectorSize(hvo, (int)PhSequenceContext.PhSequenceContextTags.kflidMembers) > 0)
                    {
                        vwenv.AddObjVecItems((int)PhSequenceContext.PhSequenceContextTags.kflidMembers, this, kfragContext);
                    }
                    else
                    {
                        OpenContextPile(vwenv, false);
                        vwenv.Props = m_bracketProps;
                        vwenv.AddProp((int)PhSequenceContext.PhSequenceContextTags.kflidMembers, this, kfragEmpty);
                        CloseContextPile(vwenv, false);
                    }
                    break;

                case PhSimpleContextNC.kclsidPhSimpleContextNC:
                    IPhSimpleContextNC ncCtxt = ctxtOrVar as IPhSimpleContextNC;
                    if (ncCtxt.FeatureStructureRAHvo != 0 && ncCtxt.FeatureStructureRA.ClassID == PhNCFeatures.kclsidPhNCFeatures)
                    {
                        // Natural class simple context with a feature-based natural class
                        IPhNCFeatures natClass = ncCtxt.FeatureStructureRA as IPhNCFeatures;

                        int numLines = GetNumLines(ncCtxt);
                        if (numLines == 0)
                        {
                            if (!isOuterIterCtxt)
                            {
                                OpenContextPile(vwenv);
                            }

                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);
                            vwenv.AddProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions);
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                            if (!isOuterIterCtxt)
                            {
                                CloseContextPile(vwenv);
                            }
                        }
                        else if (numLines == 1)
                        {
                            if (!isOuterIterCtxt)
                            {
                                OpenContextPile(vwenv);
                            }

                            // use normal brackets for a single line context
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);

                            // special consonant and vowel natural classes only display the abbreviation
                            if (natClass.Abbreviation.AnalysisDefaultWritingSystem == "C" ||
                                natClass.Abbreviation.AnalysisDefaultWritingSystem == "V")
                            {
                                vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC);
                            }
                            else
                            {
                                if (natClass.FeaturesOAHvo != 0 && natClass.FeaturesOA.FeatureSpecsOC.Count > 0)
                                {
                                    vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC);
                                }
                                else if (ncCtxt.PlusConstrRS.Count > 0)
                                {
                                    vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable);
                                }
                                else
                                {
                                    vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable);
                                }
                            }
                            vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                            if (!isOuterIterCtxt)
                            {
                                CloseContextPile(vwenv);
                            }
                        }
                        else
                        {
                            // multiline context

                            // left bracket pile
                            int maxNumLines = MaxNumLines;
                            vwenv.Props = m_bracketProps;
                            vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv);
                            vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook);
                            for (int i = 1; i < numLines - 1; i++)
                            {
                                vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt);
                            }
                            vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook);
                            vwenv.CloseInnerPile();

                            // feature and variable pile
                            vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, vwenv);
                            vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC);
                            vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable);
                            vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable);
                            vwenv.CloseInnerPile();

                            // right bracket pile
                            vwenv.Props = m_bracketProps;
                            if (!isOuterIterCtxt)
                            {
                                vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
                            }
                            vwenv.OpenInnerPile();
                            AddExtraLines(maxNumLines - numLines, ktagRightNonBoundary, vwenv);
                            vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook);
                            for (int i = 1; i < numLines - 1; i++)
                            {
                                vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt);
                            }
                            vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook);
                            vwenv.CloseInnerPile();
                        }
                    }
                    else
                    {
                        // natural class context with segment-based natural class
                        if (!isOuterIterCtxt)
                        {
                            OpenContextPile(vwenv);
                        }

                        vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket);
                        if (ncCtxt.FeatureStructureRAHvo != 0)
                        {
                            vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC);
                        }
                        else
                        {
                            vwenv.AddProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions);
                        }
                        vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket);

                        if (!isOuterIterCtxt)
                        {
                            CloseContextPile(vwenv);
                        }
                    }
                    break;

                case PhIterationContext.kclsidPhIterationContext:
                    IPhIterationContext iterCtxt = ctxtOrVar as IPhIterationContext;
                    if (iterCtxt.MemberRAHvo != 0)
                    {
                        int numLines = GetNumLines(iterCtxt.MemberRA as IPhSimpleContext);
                        if (numLines > 1)
                        {
                            vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext);
                            DisplayIterCtxt(iterCtxt, numLines, vwenv);
                        }
                        else
                        {
                            OpenContextPile(vwenv);
                            if (iterCtxt.MemberRA.ClassID == PhSimpleContextNC.kclsidPhSimpleContextNC)
                            {
                                vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext);
                            }
                            else
                            {
                                vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftParen);
                                vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext);
                                vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightParen);
                            }
                            DisplayIterCtxt(iterCtxt, 1, vwenv);
                            // Views doesn't handle selection properly when we have an inner pile with strings on either side,
                            // so we don't add a zero-width space at the end
                            CloseContextPile(vwenv, false);
                        }
                    }
                    else
                    {
                        OpenContextPile(vwenv);
                        vwenv.AddProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragQuestions);
                        CloseContextPile(vwenv);
                    }
                    break;

                case PhSimpleContextSeg.kclsidPhSimpleContextSeg:
                    if (!isOuterIterCtxt)
                    {
                        OpenContextPile(vwenv);
                    }

                    if (m_cache.GetObjProperty(hvo, (int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure) != 0)
                    {
                        vwenv.AddObjProp((int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure, this, kfragTerminalUnit);
                    }
                    else
                    {
                        vwenv.AddProp((int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure, this, kfragQuestions);
                    }

                    if (!isOuterIterCtxt)
                    {
                        CloseContextPile(vwenv);
                    }
                    break;

                case PhSimpleContextBdry.kclsidPhSimpleContextBdry:
                    if (!isOuterIterCtxt)
                    {
                        OpenContextPile(vwenv);
                    }

                    if (m_cache.GetObjProperty(hvo, (int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure) != 0)
                    {
                        vwenv.AddObjProp((int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragTerminalUnit);
                    }
                    else
                    {
                        vwenv.AddProp((int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragQuestions);
                    }

                    if (!isOuterIterCtxt)
                    {
                        CloseContextPile(vwenv);
                    }
                    break;

                case PhVariable.kclsidPhVariable:
                    OpenContextPile(vwenv);
                    vwenv.AddProp(ktagXVariable, this, kfragXVariable);
                    CloseContextPile(vwenv);
                    break;
                }
                break;

            case kfragNC:
                int ncWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstAnal, hvo, (int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation);
                if (ncWs != 0)
                {
                    vwenv.AddStringAltMember((int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation, ncWs, this);
                }
                else
                {
                    ncWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstAnal, hvo, (int)PhNaturalClass.PhNaturalClassTags.kflidName);
                    if (ncWs != 0)
                    {
                        vwenv.AddStringAltMember((int)PhNaturalClass.PhNaturalClassTags.kflidName, ncWs, this);
                    }
                    else
                    {
                        vwenv.AddProp((int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation, this, kfragQuestions);
                    }
                }
                break;

            case kfragTerminalUnit:
                int tuWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstVern, hvo, (int)PhTerminalUnit.PhTerminalUnitTags.kflidName);
                if (tuWs != 0)
                {
                    vwenv.AddStringAltMember((int)PhTerminalUnit.PhTerminalUnitTags.kflidName, tuWs, this);
                }
                else
                {
                    vwenv.AddProp((int)PhTerminalUnit.PhTerminalUnitTags.kflidName, this, kfragQuestions);
                }
                break;

            case kfragFeatNC:
                vwenv.AddObjProp((int)PhNCFeatures.PhNCFeaturesTags.kflidFeatures, this, kfragFeats);
                break;

            case kfragFeats:
                vwenv.AddObjVecItems((int)FsFeatStruc.FsFeatStrucTags.kflidFeatureSpecs, this, kfragFeature);
                break;

            case kfragFeature:
                vwenv.AddProp(ktagFeature, this, kfragFeatureLine);
                break;

            case kfragPlusVariable:
                vwenv.AddProp(ktagVariable, this, kfragPlusVariableLine);
                break;

            case kfragMinusVariable:
                vwenv.AddProp(ktagVariable, this, kfragMinusVariableLine);
                break;
            }
        }
예제 #9
0
		protected override void CreateTestData()
		{
			base.CreateTestData();

			Cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Add(Cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem);

			m_noun = AddPartOfSpeech("N");
			m_verb = AddPartOfSpeech("V");
			m_adj = AddPartOfSpeech("A");

			Cache.LanguageProject.MorphologicalDataOA.ParserParameters = "<ParserParameters><ActiveParser>HC</ActiveParser><HC><NoDefaultCompounding>true</NoDefaultCompounding><AcceptUnspecifiedGraphemes>false</AcceptUnspecifiedGraphemes></HC></ParserParameters>";

			IFsFeatureSystem phFeatSys = Cache.LanguageProject.PhFeatureSystemOA;
			AddClosedFeature(phFeatSys, "voc", "+", "-");
			AddClosedFeature(phFeatSys, "cons", "+", "-");
			AddClosedFeature(phFeatSys, "high", "+", "-");
			AddClosedFeature(phFeatSys, "low", "+", "-");
			AddClosedFeature(phFeatSys, "back", "+", "-");
			AddClosedFeature(phFeatSys, "round", "+", "-");
			AddClosedFeature(phFeatSys, "vd", "+", "-");
			AddClosedFeature(phFeatSys, "asp", "+", "-");
			AddClosedFeature(phFeatSys, "del_rel", "+", "-");
			AddClosedFeature(phFeatSys, "strident", "+", "-");
			AddClosedFeature(phFeatSys, "cont", "+", "-");
			AddClosedFeature(phFeatSys, "nasal", "+", "-");
			AddClosedFeature(phFeatSys, "poa", "bilabial", "labiodental", "alveolar", "velar");

			Cache.LanguageProject.PhonologicalDataOA.PhonemeSetsOS.Add(Cache.ServiceLocator.GetInstance<IPhPhonemeSetFactory>().Create());

			AddPhoneme("a", new FS {{"cons", "-"}, {"voc", "+"}, {"high", "-"}, {"low", "+"}, {"back", "+"}, {"round", "-"}, {"vd", "+"}});
			AddPhoneme("i", new FS {{"cons", "-"}, {"voc", "+"}, {"high", "+"}, {"low", "-"}, {"back", "-"}, {"round", "-"}, {"vd", "+"}});
			AddPhoneme("u", new FS {{"cons", "-"}, {"voc", "+"}, {"high", "+"}, {"low", "-"}, {"back", "+"}, {"round", "+"}, {"vd", "+"}});
			AddPhoneme("o", new FS {{"cons", "-"}, {"voc", "+"}, {"high", "-"}, {"low", "-"}, {"back", "+"}, {"round", "+"}, {"vd", "+"}});
			AddPhoneme("y", new FS {{"cons", "-"}, {"voc", "+"}, {"high", "+"}, {"low", "-"}, {"back", "-"}, {"round", "+"}, {"vd", "+"}});
			AddPhoneme("ɯ", new FS {{"cons", "-"}, {"voc", "+"}, {"high", "+"}, {"low", "-"}, {"back", "+"}, {"round", "-"}, {"vd", "+"}});

			AddPhoneme("p", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "bilabial"}, {"vd", "-"}, {"asp", "-"}, {"strident", "-"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("t", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "alveolar"}, {"vd", "-"}, {"asp", "-"}, {"del_rel", "-"}, {"strident", "-"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("k", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "velar"}, {"vd", "-"}, {"asp", "-"}, {"strident", "-"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("ts", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "alveolar"}, {"vd", "-"}, {"asp", "-"}, {"del_rel", "+"}, {"strident", "+"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("pʰ", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "bilabial"}, {"vd", "-"}, {"asp", "+"}, {"strident", "-"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("tʰ", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "alveolar"}, {"vd", "-"}, {"asp", "+"}, {"del_rel", "-"}, {"strident", "-"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("kʰ", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "velar"}, {"vd", "-"}, {"asp", "+"}, {"strident", "-"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("tsʰ", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "alveolar"}, {"vd", "-"}, {"asp", "+"}, {"del_rel", "+"}, {"strident", "+"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("b", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "bilabial"}, {"vd", "+"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("d", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "alveolar"}, {"vd", "+"}, {"strident", "-"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("g", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "velar"}, {"vd", "+"}, {"cont", "-"}, {"nasal", "-"}});
			AddPhoneme("m", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "bilabial"}, {"vd", "+"}, {"cont", "-"}, {"nasal", "+"}});
			AddPhoneme("n", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "alveolar"}, {"vd", "+"}, {"strident", "-"}, {"cont", "-"}, {"nasal", "+"}});
			AddPhoneme("ŋ", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "velar"}, {"vd", "+"}, {"cont", "-"}, {"nasal", "+"}});
			AddPhoneme("s", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "alveolar"}, {"vd", "-"}, {"asp", "-"}, {"del_rel", "-"}, {"strident", "+"}, {"cont", "+"}});
			AddPhoneme("z", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "alveolar"}, {"vd", "+"}, {"asp", "-"}, {"del_rel", "-"}, {"strident", "+"}, {"cont", "+"}});
			AddPhoneme("f", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "labiodental"}, {"vd", "-"}, {"asp", "-"}, {"strident", "+"}, {"cont", "+"}});
			AddPhoneme("v", new FS {{"cons", "+"}, {"voc", "-"}, {"poa", "labiodental"}, {"vd", "+"}, {"asp", "-"}, {"strident", "+"}, {"cont", "+"}});

			AddBdry(LangProjectTags.kguidPhRuleMorphBdry, "+");
			AddBdry(LangProjectTags.kguidPhRuleWordBdry, "#");

			m_vowel = AddNaturalClass("V", new FS {{"cons", "-"}, {"voc", "+"}});
			m_cons = AddNaturalClass("C", new FS {{"cons", "+"}, {"voc", "-"}});

			IFsFeatureSystem msFeatSys = Cache.LanguageProject.MsFeatureSystemOA;
			m_inflType = AddFSType(msFeatSys, "infl",
				AddComplexFeature(msFeatSys, "nounAgr", AddClosedFeature(msFeatSys, "num", "sg", "pl")),
				AddClosedFeature(msFeatSys, "tense", "pres", "past"));
		}
예제 #10
0
		/// <summary>
		/// Handles the Insert event of the m_insertionControl control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="InsertEventArgs"/> instance containing the event data.</param>
		private void m_insertionControl_Insert(object sender, InsertEventArgs e)
		{
			var option = (InsertOption) e.Option;

			var undo = string.Format(MEStrings.ksRuleUndoInsert, option);
			var redo = string.Format(MEStrings.ksRuleRedoInsert, option);

			SelectionHelper sel = SelectionHelper.Create(m_view);
			int cellId = -1;
			int cellIndex = -1;
			switch (option.Type)
			{
				case RuleInsertType.Phoneme:
					IEnumerable<IPhPhoneme> phonemes = m_cache.LangProject.PhonologicalDataOA.PhonemeSetsOS[0].PhonemesOC.OrderBy(ph => ph.ShortName);
					ICmObject phonemeObj = DisplayChooser(MEStrings.ksRulePhonemeOpt, MEStrings.ksRulePhonemeChooserLink,
						"phonemeEdit", "RulePhonemeFlatList", phonemes);
					var phoneme = phonemeObj as IPhPhoneme;
					if (phoneme == null)
						return;
					UndoableUnitOfWorkHelper.Do(undo, redo, m_cache.ActionHandlerAccessor, () =>
						{
							cellId = InsertPhoneme(phoneme, sel, out cellIndex);
						});
					break;

				case RuleInsertType.NaturalClass:
					IEnumerable<IPhNaturalClass> natClasses = m_cache.LangProject.PhonologicalDataOA.NaturalClassesOS.OrderBy(natc => natc.ShortName);
					ICmObject ncObj = DisplayChooser(MEStrings.ksRuleNCOpt, MEStrings.ksRuleNCChooserLink,
						"naturalClassedit", "RuleNaturalClassFlatList", natClasses);
					var nc = ncObj as IPhNaturalClass;
					if (nc == null)
						return;
					UndoableUnitOfWorkHelper.Do(undo, redo, m_cache.ActionHandlerAccessor, () =>
						{
							cellId = InsertNC(nc, sel, out cellIndex);
						});
					break;

				case RuleInsertType.Features:
					using (var featChooser = new PhonologicalFeatureChooserDlg())
					{
						SetupPhonologicalFeatureChoooserDlg(featChooser);
						featChooser.SetHelpTopic(FeatureChooserHelpTopic);
						DialogResult res = featChooser.ShowDialog();
						if (res == DialogResult.OK)
						{
							UndoableUnitOfWorkHelper.Do(undo, redo, m_cache.ActionHandlerAccessor, () =>
								{
									IPhNCFeatures featNC = m_cache.ServiceLocator.GetInstance<IPhNCFeaturesFactory>().Create();
									m_cache.LangProject.PhonologicalDataOA.NaturalClassesOS.Add(featNC);
									featNC.Name.SetUserWritingSystem(string.Format(MEStrings.ksRuleNCFeatsName, RuleName));
									featNC.FeaturesOA = m_cache.ServiceLocator.GetInstance<IFsFeatStrucFactory>().Create();
									IPhSimpleContextNC ctxt;
									cellId = InsertNC(featNC, sel, out cellIndex, out ctxt);
									featChooser.Context = ctxt;
									featChooser.UpdateFeatureStructure();
								});
						}
						else if (res != DialogResult.Cancel)
						{
							featChooser.HandleJump();
						}
					}
					break;

				case RuleInsertType.WordBoundary:
					IPhBdryMarker wordBdry = m_cache.ServiceLocator.GetInstance<IPhBdryMarkerRepository>().GetObject(LangProjectTags.kguidPhRuleWordBdry);
					UndoableUnitOfWorkHelper.Do(undo, redo, m_cache.ActionHandlerAccessor, () =>
						{
							cellId = InsertBdry(wordBdry, sel, out cellIndex);
						});
					break;

				case RuleInsertType.MorphemeBoundary:
					IPhBdryMarker morphBdry = m_cache.ServiceLocator.GetInstance<IPhBdryMarkerRepository>().GetObject(LangProjectTags.kguidPhRuleMorphBdry);
					UndoableUnitOfWorkHelper.Do(undo, redo, m_cache.ActionHandlerAccessor, () =>
						{
							cellId = InsertBdry(morphBdry, sel, out cellIndex);
						});
					break;

				case RuleInsertType.Index:
					// put the clicked index in the data field
					UndoableUnitOfWorkHelper.Do(undo, redo, m_cache.ActionHandlerAccessor, () =>
						{
							cellId = InsertIndex((int) e.Suboption, sel, out cellIndex);
						});
					break;

				case RuleInsertType.Column:
					UndoableUnitOfWorkHelper.Do(undo, redo, m_cache.ActionHandlerAccessor, () =>
						{
							cellId = InsertColumn(sel);
						});
					break;

				case RuleInsertType.Variable:
					UndoableUnitOfWorkHelper.Do(undo, redo, m_cache.ActionHandlerAccessor, () =>
						{
							cellId = InsertVariable(sel, out cellIndex);
						});
					break;
			}

			m_view.Select();
			if (cellId != -1)
			{
				// reconstruct the view and place the cursor after the newly added item
				ReconstructView(cellId, cellIndex, false);
			}
		}
        /// <summary>
        /// Handle launching of the phonological feature editor.
        /// </summary>
        protected override void HandleChooser()
        {
            VectorReferenceLauncher vrl = null;

            using (PhonologicalFeatureChooserDlg dlg = new PhonologicalFeatureChooserDlg())
            {
                IFsFeatStruc originalFs       = null;
                Slice        parentSlice      = Slice;
                int          parentSliceClass = parentSlice.Object.ClassID;
                int          owningFlid       = (parentSlice as PhonologicalFeatureListDlgLauncherSlice).Flid;
                switch (parentSliceClass)
                {
                case PhPhoneme.kclsidPhPhoneme:
                    IPhPhoneme phoneme = parentSlice.Object as IPhPhoneme;
                    if (phoneme.FeaturesOAHvo != 0)
                    {
                        originalFs = phoneme.FeaturesOA;
                    }
                    break;

                case PhNCFeatures.kclsidPhNCFeatures:
                    IPhNCFeatures features = parentSlice.Object as IPhNCFeatures;
                    if (features.FeaturesOAHvo != 0)
                    {
                        originalFs = features.FeaturesOA;
                    }
                    break;
                }

                int longNameOldLen = 0;
                if (originalFs != null && originalFs.LongName != null)
                {
                    longNameOldLen = originalFs.LongName.Length;
                }

                if (originalFs == null)
                {
                    dlg.SetDlgInfo(m_cache, m_mediator, parentSlice.Object, owningFlid);
                }
                else
                {
                    dlg.SetDlgInfo(m_cache, m_mediator, originalFs);
                }

                DialogResult result = dlg.ShowDialog(parentSlice.FindForm());
                if (result == DialogResult.OK)
                {
                    if (dlg.FS != null)
                    {
                        int tagLongName = m_cache.VwCacheDaAccessor.GetVirtualHandlerName("FsFeatStruc", "LongNameTSS").Tag;
                        m_obj = dlg.FS;
                        m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, parentSlice.Object.Hvo, owningFlid,
                                            0, 1, 0);
                        m_PhonologicalFeatureListDlgLauncherView.UpdateFS(dlg.FS);
                        dlg.FS.UpdateFeatureLongName(tagLongName, longNameOldLen);
                    }
                }
                else if (result != DialogResult.Cancel)
                {
                    if (vrl == null)
                    {
                        dlg.HandleJump();
                    }
                    else
                    {
                        vrl.HandleExternalChooser();
                    }
                }
            }
        }