Пример #1
0
        public override TextPointer GetPositionFromPoint(Point point, bool snapToText)
        {
            TextRange contentRange = null;


            // Using the IContentHost interface we can quickly narrow down our
            // range to a run within the text block
            IContentHost contentHost = this.ContentHost;

            if (contentHost != null)
            {
                TextElement te = contentHost.InputHitTest(point) as TextElement;
                if (te != null)
                {
                    contentRange = new TextRange(te.ContentStart, te.ContentEnd);
                }
            }

            if (contentRange == null)
            {
                contentRange = new TextRange(Start, End);
            }

            TextPointer result = GetPositionFromPoint(point, contentRange, snapToText);

            Assert.Implies(snapToText, result != null);

            return(result);
        }
Пример #2
0
        //-------------------------------------------------------------------
        //
        //  IContentHost Members
        //
        //-------------------------------------------------------------------

        #region IContentHost Members

        /// <summary>
        /// <see cref="IContentHost.InputHitTest"/>
        /// </summary>
        IInputElement IContentHost.InputHitTest(Point point)
        {
            IContentHost host = _owner.Target as IContentHost;

            if (host != null)
            {
                return(host.InputHitTest(point));
            }
            return(null);
        }