Exemple #1
0
        /// <summary>
        ///     Provides the instance related to a location in the textbox
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        protected INamable GetInstance(Point location)
        {
            // ReSharper disable once RedundantAssignment
            INamable retVal = null;

            int index = EditionTextBox.GetCharIndexFromPosition(location);

            // Ensure that the index actually corresponds to the desired location
            Point confirmLocation = EditionTextBox.GetPositionFromCharIndex(index);
            int   dX       = Math.Abs(confirmLocation.X - location.X);
            int   dY       = Math.Abs(confirmLocation.Y - location.Y);
            int   distance = (int)Math.Sqrt(dX * dX + dY * dY);

            if (distance < 30)
            {
                retVal = GetInstance(index);
            }

            return(retVal);
        }