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 SwapValues(ILexEntry entry, IMoForm origForm, IMoForm newForm, IMoMorphType type, List <IMoMorphSynAnalysis> rgmsaOld) { DataTree dtree = Slice.ContainingDataTree; int idx = Slice.IndexInContainer; dtree.DoNotRefresh = true; // don't let the datatree repeatedly redraw itself... entry.ReplaceMoForm(origForm, newForm); newForm.MorphTypeRA = type; entry.ReplaceObsoleteMsas(rgmsaOld); // Dispose of any obsolete slices: new ones will replace them automatically in a moment // when the datatree is redrawn. foreach (Slice slice in Slice.ContainingDataTree.Slices.ToArray()) { if (slice.IsDisposed) { continue; } if (slice.Object is IMoMorphSynAnalysis && rgmsaOld.Contains(slice.Object as IMoMorphSynAnalysis)) { slice.Dispose(); } else if (slice is MSAReferenceComboBoxSlice) { slice.Dispose(); } } // now fix the record list, since it may be showing MoForm dependent columns (e.g. MorphType, Homograph, etc...) dtree.FixRecordList(); dtree.DoNotRefresh = false; Slice sliceT = dtree.Slices[idx]; if (sliceT != null && sliceT is MorphTypeAtomicReferenceSlice) { // When the new slice is created, the launch button is placed in the middle of // the slice rather than at the end. This fiddling with the slice width seems // to fix that. Then setting the index restores focus to the new slice. sliceT.Width += 1; sliceT.Width -= 1; dtree.GotoNextSliceAfterIndex(idx - 1); } }
private void SwapValues(ILexEntry entry, IMoForm origForm, IMoForm newForm, IMoMorphType type, List<IMoMorphSynAnalysis> rgmsaOld) { DataTree dtree = Slice.ContainingDataTree; int idx = Slice.IndexInContainer; dtree.DoNotRefresh = true; // don't let the datatree repeatedly redraw itself... entry.ReplaceMoForm(origForm, newForm); newForm.MorphTypeRA = type; entry.ReplaceObsoleteMsas(rgmsaOld); // Dispose of any obsolete slices: new ones will replace them automatically in a moment // when the datatree is redrawn. foreach (Slice slice in Slice.ContainingDataTree.Slices.ToArray()) { if (slice.IsDisposed) continue; if (slice.Object is IMoMorphSynAnalysis && rgmsaOld.Contains(slice.Object as IMoMorphSynAnalysis)) slice.Dispose(); else if (slice is MSAReferenceComboBoxSlice) slice.Dispose(); } // now fix the record list, since it may be showing MoForm dependent columns (e.g. MorphType, Homograph, etc...) dtree.FixRecordList(); dtree.DoNotRefresh = false; Slice sliceT = dtree.Slices[idx]; if (sliceT != null && sliceT is MorphTypeAtomicReferenceSlice) { // When the new slice is created, the launch button is placed in the middle of // the slice rather than at the end. This fiddling with the slice width seems // to fix that. Then setting the index restores focus to the new slice. sliceT.Width += 1; sliceT.Width -= 1; dtree.GotoNextSliceAfterIndex(idx - 1); } }