private void SwitchToReal()
{
// Depending on compile switch for SLICE_IS_SPLITCONTAINER,
// grandParent will be both a Slice and a SplitContainer
// (Slice is a subclass of SplitContainer),
// or just a SplitContainer (SplitContainer is the only child Control of a Slice).
// If grandParent is not a Slice, then we have to move up to the great-grandparent
// to find the Slice.
var slice = Parent.Parent as GhostStringSlice; // Will also be disposed.
if (slice == null)
slice = Parent.Parent.Parent as GhostStringSlice; // Will also be disposed.
// Save info we will need after MakeRealObject destroys this.
object[] parentKey = slice.Key;
int flidEmptyProp = m_flidEmptyProp;
int flidStringProp = m_flidStringProp;
int wsToCreate = m_wsToCreate;
var datatree = slice.ContainingDataTree;
ITsString tssTyped;
int ich, hvo, tag, ws;
bool fAssocPrev;
RootBox.Selection.TextSelInfo(false, out tssTyped, out ich, out fAssocPrev, out hvo, out tag, out ws);
// Make the real object and set the string property we are ghosting. The final PropChanged
// will typically dispose this and create a new string slice whose key is our own key
// followed by the flid of the string property.
int hvoNewObj = MakeRealObject(tssTyped);
// Now try to make a suitable selection in the slice that replaces this.
RestoreSelection(ich, datatree, parentKey, hvoNewObj, flidEmptyProp, flidStringProp, wsToCreate);
}
}