public bool OnConvertAllomorph(object cmd) { Command command = cmd as Command; int toClsid = (int)m_dataEntryForm.Cache.MetaDataCacheAccessor.GetClassId(command.GetParameter("toClassName")); ILexEntry entry = m_dataEntryForm.Root as ILexEntry; Slice slice = m_dataEntryForm.CurrentSlice; IMoForm allomorph = slice.Object as IMoForm; if (entry != null && allomorph != null && toClsid != 0) { if (CheckForFormDataLoss(allomorph, toClsid)) { Form mainWindow = (Form)m_mediator.PropertyTable.GetValue("window"); IMoForm newForm = null; using (new WaitCursor(mainWindow)) { using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(m_dataEntryForm.Cache, cmd as Command)) { newForm = CreateNewForm(toClsid); entry.ReplaceMoForm(allomorph, newForm); } m_dataEntryForm.RefreshList(false); } SelectNewFormSlice(newForm); } } return(true); }
private void SwapAllomorphWithLexeme(ILexEntry entry, IMoForm allomorph, Command cmd) { using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(m_dataEntryForm.Cache, cmd)) { entry.AlternateFormsOS.InsertAt(entry.LexemeFormOA, allomorph.IndexInOwner); entry.LexemeFormOA = allomorph; } }
/// <summary> /// /// </summary> /// <param name="argument">The xCore Command object.</param> /// <returns>true</returns> public bool OnAddApprovedAnalysis(object argument) { using (EditMorphBreaksDlg dlg = new EditMorphBreaksDlg()) { IWfiWordform wf = Wordform; if (wf == null) { return(true); } ITsString tssWord = Wordform.Form.BestVernacularAlternative; string morphs = tssWord.Text; FdoCache cache = Cache; dlg.Initialize(tssWord, morphs, cache.MainCacheAccessor.WritingSystemFactory, cache, m_dataEntryForm.Mediator.StringTbl, m_dataEntryForm.StyleSheet); Form mainWnd = m_dataEntryForm.FindForm(); // Making the form active fixes problems like LT-2619. // I'm (RandyR) not sure what adverse impact might show up by doing this. mainWnd.Activate(); if (dlg.ShowDialog(mainWnd) == DialogResult.OK) { morphs = dlg.GetMorphs().Trim(); if (morphs.Length == 0) { return(true); } string[] prefixMarkers = MoMorphType.PrefixMarkers(cache); string[] postfixMarkers = MoMorphType.PostfixMarkers(cache); List <string> allMarkers = new List <string>(); foreach (string s in prefixMarkers) { allMarkers.Add(s); } foreach (string s in postfixMarkers) { if (!allMarkers.Contains(s)) { allMarkers.Add(s); } } allMarkers.Add(" "); string[] breakMarkers = new string[allMarkers.Count]; for (int i = 0; i < allMarkers.Count; ++i) { breakMarkers[i] = allMarkers[i]; } string fullForm = SandboxBase.MorphemeBreaker.DoBasicFinding(morphs, breakMarkers, prefixMarkers, postfixMarkers); using (UndoRedoCommandHelper undoRedoTask = new UndoRedoCommandHelper(Cache, argument as Command)) { IWfiAnalysis newAnalysis = Wordform.AnalysesOC.Add(new WfiAnalysis()); newAnalysis.ApprovalStatusIcon = 1; // Make it human approved. int vernWS = StringUtils.GetWsAtOffset(tssWord, 0); foreach (string morph in fullForm.Split(Unicode.SpaceChars)) { if (morph != null && morph.Length != 0) { IWfiMorphBundle mb = newAnalysis.MorphBundlesOS.Append(new WfiMorphBundle()); mb.Form.SetAlternative(morph, vernWS); } } int outlineFlid = BaseVirtualHandler.GetInstalledHandlerTag(cache, "WfiAnalysis", "HumanApprovedNumber"); foreach (int haaHvo in Wordform.HumanApprovedAnalyses) { // Do PropChanged for the outline number for all of them. // This fixes LT-5007, as the older ones kept their old number, // which could have been a duplicate number. cache.PropChanged( null, PropChangeType.kpctNotifyAll, haaHvo, outlineFlid, 0, 0, 0); } cache.PropChanged( null, PropChangeType.kpctNotifyAll, Wordform.Hvo, BaseVirtualHandler.GetInstalledHandlerTag(cache, "WfiWordform", "HumanApprovedAnalyses"), 0, 1, 0); } } } return(true); }