public bool OnMergeReversalPOS(object cmd) { LcmCache cache = Cache; var labels = new List<ObjectLabel>(); foreach (IPartOfSpeech pos in MergeOrMoveCandidates) labels.Add(ObjectLabel.CreateObjectLabelOnly(cache, pos, "ShortNameTSS", "best analysis")); using (SimpleListChooser dlg = new SimpleListChooser(cache, null, m_propertyTable.GetValue<IHelpTopicProvider>("HelpTopicProvider"), labels, null, LexEdStrings.ksCategoryToMergeInto, null)) { dlg.SetHelpTopic("khtpMergeCategories"); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var currentPOS = POS; var survivor = (IPartOfSpeech)dlg.ChosenOne.Object; // Pass false to MergeObject, since we really don't want to merge the string info. UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoMergeRevCategory, LexEdStrings.ksRedoMergeRevCategory, cache.ActionHandlerAccessor, ()=> survivor.MergeObject(currentPOS, false)); // Note: PropChanged should happen on the old owner and the new in the 'Add" method call. // Have to jump to a main PartOfSpeech, as RecordClerk doesn't know anything about subcategories. m_mediator.BroadcastMessageUntilHandled("JumpToRecord", survivor.MainPossibility.Hvo); } } return true; }
public bool OnMoveReversalPOS(object cmd) { FdoCache cache = Cache; ObjectLabelCollection labels = new ObjectLabelCollection(); foreach (IPartOfSpeech pos in MergeOrMoveCandidates) { labels.Add(ObjectLabel.CreateObjectLabelOnly(cache, pos.Hvo, "ShortNameTSS", "best analysis")); } using (SimpleListChooser dlg = new SimpleListChooser(cache, null, labels, 0, LexEdStrings.ksCategoryToMoveTo, null)) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IPartOfSpeech currentPOS = POS; IPartOfSpeech newOwner = PartOfSpeech.CreateFromDBObject(cache, dlg.ChosenOne.Hvo); cache.BeginUndoTask(LexEdStrings.ksUndoMoveRevCategory, LexEdStrings.ksRedoMoveRevCategory); ICmObject newOwningObj = newOwner.MoveIfNeeded(currentPOS); newOwner.SubPossibilitiesOS.Append(currentPOS); cache.EndUndoTask(); // Note: PropChanged should happen on the old owner and the new in the 'Add" method call. // Have to jump to a main PartOfSpeech, as RecordClerk doesn't know anything about subcategories. m_mediator.BroadcastMessageUntilHandled("JumpToRecord", newOwner.MainPossibility.Hvo); } } return(true); }
public bool OnMoveReversalPOS(object cmd) { FdoCache cache = Cache; var labels = new List <ObjectLabel>(); foreach (IPartOfSpeech pos in MergeOrMoveCandidates) { if (!pos.SubPossibilitiesOS.Contains(POS)) { labels.Add(ObjectLabel.CreateObjectLabelOnly(cache, pos, "ShortNameTSS", "best analysis")); } } using (SimpleListChooser dlg = new SimpleListChooser(cache, null, m_mediator.HelpTopicProvider, labels, null, LexEdStrings.ksCategoryToMoveTo, null)) { dlg.SetHelpTopic("khtpChoose-CategoryToMoveTo"); if (dlg.ShowDialog() == DialogResult.OK) { IPartOfSpeech currentPOS = POS; IPartOfSpeech newOwner = (IPartOfSpeech)dlg.ChosenOne.Object; UndoableUnitOfWorkHelper.Do(LexEdStrings.ksUndoMoveRevCategory, LexEdStrings.ksRedoMoveRevCategory, cache.ActionHandlerAccessor, () => { newOwner.MoveIfNeeded(currentPOS); //important when an item is moved into it's own subcategory if (!newOwner.SubPossibilitiesOS.Contains(currentPOS)) //this is also prevented in the interface, but I'm paranoid { newOwner.SubPossibilitiesOS.Add(currentPOS); } }); // Note: PropChanged should happen on the old owner and the new in the 'Add" method call. // Have to jump to a main PartOfSpeech, as RecordClerk doesn't know anything about subcategories. m_mediator.BroadcastMessageUntilHandled("JumpToRecord", newOwner.MainPossibility.Hvo); } } return(true); }