protected override int InsertBdry(IPhBdryMarker bdry, SelectionHelper sel, out int cellIndex)
        {
            var bdryCtxt = m_cache.ServiceLocator.GetInstance <IPhSimpleContextBdryFactory>().Create();
            var cellId   = InsertContext(bdryCtxt, sel, out cellIndex);

            bdryCtxt.FeatureStructureRA = bdry;
            return(cellId);
        }
Example #2
0
        protected override int InsertBdry(IPhBdryMarker bdry, SelectionHelper sel, out int cellIndex)
        {
            int cellId = GetCell(sel);

            if (cellId == MoAffixProcessTags.kflidOutput)
            {
                var insertPhones = m_cache.ServiceLocator.GetInstance <IMoInsertPhonesFactory>().Create();
                cellIndex = InsertIntoOutput(insertPhones, sel);
                insertPhones.ContentRS.Add(bdry);
            }
            else
            {
                var bdryCtxt = m_cache.ServiceLocator.GetInstance <IPhSimpleContextBdryFactory>().Create();
                cellId = InsertContext(bdryCtxt, sel, out cellIndex);
                bdryCtxt.FeatureStructureRA = bdry;
            }
            return(cellId);
        }
		private static XElement ExportBoundaryMarker(IPhBdryMarker bdryMarker, Icu.UNormalizationMode mode)
		{
			return new XElement("PhBdryMarker",
								new XAttribute("Id", bdryMarker.Hvo),
								new XAttribute("Guid", bdryMarker.Guid.ToString()),
								ExportBestAnalysis(bdryMarker.Name, "Name", mode),
								ExportCodes(bdryMarker.CodesOS, mode));
		}
		protected override int InsertBdry(IPhBdryMarker bdry, SelectionHelper sel, out int cellIndex)
		{
			int cellId = GetCell(sel);
			if (cellId == MoAffixProcessTags.kflidOutput)
			{
				var insertPhones = m_cache.ServiceLocator.GetInstance<IMoInsertPhonesFactory>().Create();
				cellIndex = InsertIntoOutput(insertPhones, sel);
				insertPhones.ContentRS.Add(bdry);
			}
			else
			{
				var bdryCtxt = m_cache.ServiceLocator.GetInstance<IPhSimpleContextBdryFactory>().Create();
				cellId = InsertContext(bdryCtxt, sel, out cellIndex);
				bdryCtxt.FeatureStructureRA = bdry;
			}
			return cellId;
		}
		protected override int InsertBdry(IPhBdryMarker bdry, SelectionHelper sel, out int cellIndex)
		{
			var bdryCtxt = m_cache.ServiceLocator.GetInstance<IPhSimpleContextBdryFactory>().Create();
			var cellId = InsertContext(bdryCtxt, sel, out cellIndex);
			bdryCtxt.FeatureStructureRA = bdry;
			return cellId;
		}
		/// <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>
		/// Inserts an item from a boundary.
		/// </summary>
		/// <param name="bdry">The boundary.</param>
		/// <param name="sel">The sel.</param>
		/// <param name="cellIndex">Index of the new item.</param>
		/// <returns>
		/// The ID of the cell that the item was inserted into
		/// </returns>
		protected virtual int InsertBdry(IPhBdryMarker bdry, SelectionHelper sel, out int cellIndex)
		{
			throw new NotImplementedException();
		}