zoukankan      html  css  js  c++  java
  • 设置XtraForm标题居中

        public class CustomFormPainter : FormPainter
        {
            public CustomFormPainter(Control owner, DevExpress.Skins.ISkinProvider provider)
                : base(owner, provider)
            {
            }
            protected override void DrawText(DevExpress.Utils.Drawing.GraphicsCache cache)
            {
               
                string text = Text;
                if (text == null || text.Length == 0 || TextBounds.IsEmpty) return;
                using (AppearanceObject appearance = new AppearanceObject(GetDefaultAppearance()))
                {
                    appearance.TextOptions.Trimming = Trimming.EllipsisCharacter;
                    appearance.TextOptions.HAlignment = HorzAlignment.Center;
                    appearance.Font = new Font(appearance.Font.Name, 30, FontStyle.Bold, appearance.Font.Unit, appearance.Font.GdiCharSet, appearance.Font.GdiVerticalFont);
                    if (AllowHtmlDraw)
                    {
                        DrawHtmlText(cache, appearance);
                        return;
                    }
                    Rectangle r = RectangleHelper.GetCenterBounds(TextBounds, new Size(TextBounds.Width, CalcTextHeight(cache.Graphics, appearance)));
                    DrawTextShadow(cache, appearance, r);
                    cache.DrawString(text, appearance.Font, appearance.GetForeBrush(cache), r, appearance.GetStringFormat());
                }
            }
        }
    这样用
        public partial class frmMain : DevExpress.XtraEditors.XtraForm
        {
            static frmMain()
            {
                SkinManager.EnableFormSkins();
            }
            public frmMain()
            {
                InitializeComponent();
            }
            protected override FormPainter CreateFormBorderPainter()
            {
                return new CustomFormPainter(this, LookAndFeel);
            }
        }
    
    
    
     
  • 相关阅读:
    yzoj P2344 斯卡布罗集市 题解
    yzoj P2350 逃离洞穴 题解
    yzoj P2349 取数 题解
    JXOI 2017 颜色 题解
    NOIP 2009 最优贸易 题解
    CH 4302 Interval GCD 题解
    CH4301 Can you answer on these queries III 题解
    Luogu2533[AHOI2012]信号塔
    Luogu3320[SDOI2015]寻宝游戏
    Luogu3187[HNOI2007]最小矩形覆盖
  • 原文地址:https://www.cnblogs.com/cglNet/p/5082712.html
Copyright © 2011-2022 走看看