private void MoveItem(object sender, TreeNode destNode, TreeNode sourceItem) { int hvoMove = (int)sourceItem.Tag; int hvoDest; int flidDest; FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache"); string moveLabel = sourceItem.Text; TreeNodeCollection newSiblings; TreeView tree = sender as TreeView; if (destNode == null) { for (hvoDest = cache.GetOwnerOfObject(hvoMove); hvoDest != 0; hvoDest = cache.GetOwnerOfObject(hvoDest)) { if (cache.GetClassOfObject(hvoDest) == CmPossibilityList.kclsidCmPossibilityList) { break; } } if (hvoDest == 0) { return; } flidDest = (int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities; newSiblings = tree.Nodes; } else { hvoDest = (int)destNode.Tag; flidDest = (int)CmPossibility.CmPossibilityTags.kflidSubPossibilities; newSiblings = destNode.Nodes; } if (CheckAndReportForbiddenMove(hvoMove, hvoDest)) { return; } int hvoOldOwner = cache.GetOwnerOfObject(hvoMove); if (hvoOldOwner == hvoDest) { return; // nothing to do. } int flidSrc = cache.GetOwningFlidOfObject(hvoMove); int srcIndex = cache.GetObjIndex(hvoOldOwner, flidSrc, hvoMove); int ihvoDest = 0; for (; ihvoDest < newSiblings.Count; ihvoDest++) { if (newSiblings[ihvoDest].Text.CompareTo(moveLabel) > 0) // Enhance JohnT: use ICU comparison... { break; } } using (new RecordClerk.ListUpdateHelper(m_list, tree.TopLevelControl)) using (UndoRedoTaskHelper urth = new UndoRedoTaskHelper(cache, xWorksStrings.UndoMoveItem, xWorksStrings.RedoMoveItem)) { // Note: use MoveOwningSequence off FdoCache, so we get propchanges that can be picked up by SyncWatcher (CLE-76) // (Hopefully the propchanges won't cause too much intermediant flicker, // before ListUpdateHelper calls ReloadList()) cache.MoveOwningSequence(hvoOldOwner, flidSrc, srcIndex, srcIndex, hvoDest, flidDest, ihvoDest); ICmObject obj = CmObject.CreateFromDBObject(cache, hvoMove); obj.MoveSideEffects(hvoOldOwner); } }