static private RestoreSelection ( int ich, |
||
ich | int | |
datatree | ||
key | object | |
hvoNewObj | int | |
flidObjProp | int | |
flidStringProp | int | |
ws | int | |
return | void |
static void RestoreSelection(int ich, DataTree datatree, object[] key,
int hvoNewObj, int flidObjProp, int flidStringProp, int ws)
{
// To be written.
foreach (Slice slice in datatree.Slices)
{
if (slice.Key.Length < key.Length + 2)
continue;
if (!StartsWith(slice.Key, key))
continue;
object nextKeyItem = slice.Key[key.Length]; // should be hvoNewObj
if (!(nextKeyItem is int))
continue;
if ((int)nextKeyItem != hvoNewObj)
continue;
XmlNode lastKeyNode = slice.Key[slice.Key.Length - 1] as XmlNode;
if (lastKeyNode == null)
continue;
if (lastKeyNode.Name != "slice")
continue;
if (slice is StringSlice)
{
StringSlice ss = slice as StringSlice;
if (ss.FieldId != flidStringProp)
continue;
if (ss.WritingSystemId != ws)
continue;
// For SelectAt to work, the rootbox must be constructed and visible.
GetSliceReadyToFocus(ss);
ss.SelectAt(ich);
ss.Control.Focus();
break;
}
else if (slice is MultiStringSlice)
{
MultiStringSlice mss = slice as MultiStringSlice;
if (mss.FieldId != flidStringProp)
continue;
// Enhance JohnT: add functions to MultiStringSlice and LabeledMultiStringControl
// so we can check that it's displaying the right writing systems.
// For SelectAt to work, the rootbox must be constructed and visible.
GetSliceReadyToFocus(mss);
mss.SelectAt(ws, ich);
mss.Control.Focus();
break;
}
else if (slice is StTextSlice)
{
var stslice = (StTextSlice) slice;
GetSliceReadyToFocus(stslice);
stslice.SelectAt(ich);
slice.Control.Focus();
break;
}
}
}