Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="hdc"></param>
        /// <param name="fontDescription"></param>
        /// <param name="orientation"></param>
        /// <param name="text"></param>
        /// <param name="rectangle"></param>
        /// <param name="contentAlignment"></param>
        /// <param name="rect"></param>
        internal static void PrintRotatedText(IntPtr hdc, FontDescription fontDescription, int orientation, string text, Rectangle rectangle, ContentAlignment contentAlignment,
                                              NativeWindowCommon.RECT rect, bool rightToLeft)
        {
            IntPtr hFont;
            Point  point;

            // get the original font and its LOGFONT
            NativeWindowCommon.LOGFONT logfont = fontDescription.LogFont;
            // Set the rotation angle
            logfont.lfEscapement = logfont.lfOrientation = orientation;

            // create the new, rotated font
            hFont = NativeWindowCommon.CreateFontIndirect(logfont);
            NativeWindowCommon.SelectObject(hdc, hFont);

            point = CalculateStartCoordinates(hdc, rectangle, orientation, text, contentAlignment);

            uint fuOptions = NativeWindowCommon.ETO_CLIPPED;

            if (rightToLeft)
            {
                fuOptions = NativeWindowCommon.ETO_RTLREADING;
            }

            NativeWindowCommon.ExtTextOut(hdc, point.X, point.Y, fuOptions, ref rect, text, (uint)text.Length, null);

            NativeWindowCommon.DeleteObject(hFont);
        }