예제 #1
0
        /// <summary>
        /// Calculates the boundaries of a text string in screen coordinates.
        /// </summary>
        /// <param name="text">the text string</param>
        /// <param name="coord">the world x-coordinate of where the text should be placed</param>
        /// <returns>the screen coordinates</returns>
        internal static WPF.Rect GetTextBounds(string text, WPF::Point coord, Typeface typeface, double emSize)
        {
            var ft     = new FormattedText(text, CultureInfo.CurrentCulture, WPF.FlowDirection.LeftToRight, typeface, emSize, Brushes.Black);
            var bounds = new WPF.Rect(0, 0, ft.Width, ft.Height);

            double widthPad  = 3;
            double heightPad = 1;

            double width  = bounds.Width + widthPad;
            double height = bounds.Height + heightPad;
            var    point  = coord;

            return(new WPF.Rect(point.X - width / 2, point.Y - height / 2, width, height));
        }
예제 #2
0
 void AssertCloseTo(WPF::Point actual, WPF::Point expected, double epsilon)
 {
     Assert.AreEqual(expected.X, actual.X, epsilon);
     Assert.AreEqual(expected.Y, actual.Y, epsilon);
 }