Пример #1
0
        private int GetLeadingTextPaddingFromTextFormatFlags()
        {
            int iLeftMargin;

            if (!base.IsHandleCreated)
            {
                return(0);
            }
            if (this.UseCompatibleTextRendering && (this.FlatStyle != System.Windows.Forms.FlatStyle.System))
            {
                return(0);
            }
            using (WindowsGraphics graphics = WindowsGraphics.FromHwnd(base.Handle))
            {
                TextFormatFlags flags = this.CreateTextFormatFlags();
                if ((flags & TextFormatFlags.NoPadding) == TextFormatFlags.NoPadding)
                {
                    graphics.TextPadding = TextPaddingOptions.NoPadding;
                }
                else if ((flags & TextFormatFlags.LeftAndRightPadding) == TextFormatFlags.LeftAndRightPadding)
                {
                    graphics.TextPadding = TextPaddingOptions.LeftAndRightPadding;
                }
                using (WindowsFont font = WindowsGraphicsCacheManager.GetWindowsFont(this.Font))
                {
                    iLeftMargin = graphics.GetTextMargins(font).iLeftMargin;
                }
            }
            return(iLeftMargin);
        }