Ejemplo n.º 1
0
        /// <summary>
        /// StylusInputEnd
        /// </summary>
        /// <param name="commit">commit</param>
        protected override void StylusInputEnd(bool commit)
        {
            // Initialize with empty selection
            StrokeCollection selectedStrokes  = new StrokeCollection();
            List <UIElement> elementsToSelect = new List <UIElement>();

            if (_lassoHelper != null)
            {
                // This is a lasso selection.

                //
                // end dynamic rendering
                //
                selectedStrokes = InkCanvas.EndDynamicSelection(_lassoHelper.Visual);

                //
                // hit test for elements
                //
                // NOTE: HitTestForElements uses the _lassoHelper so it must be alive at this point
                elementsToSelect = HitTestForElements();

                _incrementalLassoHitTester.SelectionChanged -= new LassoSelectionChangedEventHandler(OnSelectionChanged);
                _incrementalLassoHitTester.EndHitTesting();
                _incrementalLassoHitTester = null;
                _lassoHelper = null;
            }
            else
            {
                // This is a tap selection.

                // Now try the tap selection
                Stroke    tappedStroke;
                UIElement tappedElement;

                TapSelectObject(_startPoint, out tappedStroke, out tappedElement);

                // If we have a pre-selected object, we should select it now.
                if (tappedStroke != null)
                {
                    Debug.Assert(tappedElement == null);
                    selectedStrokes = new StrokeCollection();
                    selectedStrokes.Add(tappedStroke);
                }
                else if (tappedElement != null)
                {
                    Debug.Assert(tappedStroke == null);
                    elementsToSelect.Add(tappedElement);
                }
            }

            SelfDeactivate();

            if (commit)
            {
                InkCanvas.ChangeInkCanvasSelection(selectedStrokes, elementsToSelect.ToArray());
            }
        }