private void TryTapToSelect(Stroke stroke) { // We interpret strokes with fewer than 25 packets, // starting and ending on the same body, as tap gestures. int np = stroke.PacketCount; Point head = stroke.GetPoint(0), tail = stroke.GetPoint(np - 1); RigidBodyBase[] headhits = doc.HitTestBodies(head); RigidBodyBase[] tailhits = doc.HitTestBodies(tail); if (np <= 25 && headhits.Length > 0 && tailhits.Length > 0 && Object.ReferenceEquals(headhits[0], tailhits[0])) { tappedbody = headhits[0]; // Ensure we didn't just tap what's already selected. ArrayList selbodies = new ArrayList( doc.GetBodiesFor(inkoverlay.Selection)); if (selbodies.Contains(tappedbody)) { return; } // We must delay the call to set_Selection, until after InkOverlay is // finished looking at this stroke. BeginInvoke seems to work nicely // for this purpose. dbg.WriteLine("-------TTS--------"); base.BeginInvoke(new MethodInvoker(DelayTapToSelect)); } }