SelectAt() public méthode

Make a selection at the specified character offset.
public SelectAt ( int ich ) : void
ich int
Résultat void
Exemple #1
0
 /// <summary>
 /// This needs to be a static method because typically the ghost slice has been disposed
 /// by the time it is called.
 ///
 /// Note that DataTree.AddAtomicNode either displays a layout of the object, or
 /// displays the ghost slice. If it displays a layout of the object, it adds
 /// to its input path first itself (the "obj" element), then the HVO of the object,
 /// then creates slices for the object. For ghost slice, it simply adds itself.
 /// Therefore, a slice created as part of a layout replacing a ghost slice will
 /// have a key matching the ghost slice's key, and followed by the ID of the new object.
 /// Next, anything in this layout will have the template used to display the object,
 /// and the particular part ref that invoked the part, then (for an interesting target)
 /// a slice node with editor 'string' or 'multistring' as appropriate.
 /// AddSeqNode is similar, except that it may display layouts of multiple objects.
 /// </summary>
 static void RestoreSelection(int ich, DataTree datatree, object[] key, int hvoNewObj, 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;
         }
     }
 }