Beispiel #1
0
		/// <summary>
		/// Handle launching of the phonological feature editor.
		/// </summary>
		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, m_propertyTable, parentSlice.Object, owningFlid);
				else
					dlg.SetDlgInfo(m_cache, m_mediator, m_propertyTable, 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();
				}
			}
		}
Beispiel #2
0
        public void SetMappingFeatures()
        {
            SelectionHelper.Create(m_view);
            bool reconstruct = false;
            int  index       = -1;

            UndoableUnitOfWorkHelper.Do(MEStrings.ksAffixRuleUndoSetMappingFeatures,
                                        MEStrings.ksAffixRuleRedoSetMappingFeatures, m_cache.ActionHandlerAccessor, () =>
            {
                using (var featChooser = new SIL.FieldWorks.LexText.Controls.PhonologicalFeatureChooserDlg())
                {
                    var obj = CurrentObject;
                    switch (obj.ClassID)
                    {
                    case MoCopyFromInputTags.kClassId:
                        featChooser.SetDlgInfo(m_cache, m_mediator, m_propertyTable);
                        if (featChooser.ShowDialog() == DialogResult.OK)
                        {
                            // create a new natural class behind the scenes
                            var featNC = m_cache.ServiceLocator.GetInstance <IPhNCFeaturesFactory>().Create();
                            m_cache.LangProject.PhonologicalDataOA.NaturalClassesOS.Add(featNC);
                            featNC.Name.SetUserWritingSystem(string.Format(MEStrings.ksRuleNCFeatsName,
                                                                           Rule.Form.BestVernacularAnalysisAlternative.Text));
                            featNC.FeaturesOA = m_cache.ServiceLocator.GetInstance <IFsFeatStrucFactory>().Create();
                            featChooser.FS    = featNC.FeaturesOA;
                            featChooser.UpdateFeatureStructure();

                            var copy      = (IMoCopyFromInput)obj;
                            var newModify = m_cache.ServiceLocator.GetInstance <IMoModifyFromInputFactory>().Create();
                            Rule.OutputOS.Insert(copy.IndexInOwner, newModify);
                            newModify.ModificationRA = featNC;
                            newModify.ContentRA      = copy.ContentRA;
                            index = newModify.IndexInOwner;

                            Rule.OutputOS.Remove(copy);
                            reconstruct = true;
                        }
                        break;

                    case MoModifyFromInputTags.kClassId:
                        var modify = (IMoModifyFromInput)obj;
                        featChooser.SetDlgInfo(m_cache, m_mediator, m_propertyTable, modify.ModificationRA.FeaturesOA);
                        if (featChooser.ShowDialog() == DialogResult.OK)
                        {
                            if (modify.ModificationRA.FeaturesOA.FeatureSpecsOC.Count == 0)
                            {
                                var newCopy = m_cache.ServiceLocator.GetInstance <IMoCopyFromInputFactory>().Create();
                                Rule.OutputOS.Insert(modify.IndexInOwner, newCopy);
                                newCopy.ContentRA = modify.ContentRA;
                                index             = newCopy.IndexInOwner;

                                Rule.OutputOS.Remove(modify);
                            }
                            else
                            {
                                index = modify.IndexInOwner;
                            }
                            reconstruct = true;
                        }
                        break;
                    }
                }
            });

            m_view.Select();
            if (reconstruct)
            {
                ReconstructView(MoAffixProcessTags.kflidOutput, index, true);
            }
        }