/// ----------------------------------------------------------------------------------- /// <summary> /// Notifies the site that something about the selection has changed. /// </summary> /// <param name="prootb"></param> /// <param name="vwselNew">Selection</param> /// <remarks>When overriding you should call the base class first.</remarks> /// ----------------------------------------------------------------------------------- protected override void HandleSelectionChange(IVwRootBox prootb, IVwSelection vwselNew) { CheckDisposed(); base.HandleSelectionChange(prootb, vwselNew); if (vwselNew == null) { return; } int clev = vwselNew.CLevels(false); // anchor int clevEnd = vwselNew.CLevels(true); if (clev < 2 || clevEnd < 2) { return; // paranoia } int hvoRoot, tag, ihvo, ihvoEnd, cpropPrevious; IVwPropertyStore vps; vwselNew.PropInfo(true, clevEnd - 1, out hvoRoot, out tag, out ihvoEnd, out cpropPrevious, out vps); vwselNew.PropInfo(false, clev - 1, out hvoRoot, out tag, out ihvo, out cpropPrevious, out vps); // Give up if the selection doesn't indicate any top-level object; I think this can happen with pictures. // selection larger than a top-level object, maybe select all, side effects are confusing. if (ihvo != ihvoEnd || ihvo < 0) { return; } if (hvoRoot == 0) { return; } Debug.Assert(hvoRoot == m_hvoRoot); int hvoObjNewSel = m_sdaSource.get_VecItem(hvoRoot, tag, ihvo); if (hvoObjNewSel != 0) { // Notify any delegates that the selection of the main object in the vector // may have changed. if (SelectionChangedEvent != null) { SelectionChangedEvent(this, new FwObjectSelectionEventArgs(hvoObjNewSel, ihvo)); } } }