Пример #1
0
        private void ribbonControlMain_Paint(object sender, PaintEventArgs e)
        {
            DevExpress.XtraBars.Ribbon.ViewInfo.RibbonViewInfo ribbonViewInfo = ribbonControlMain.ViewInfo;
            if (ribbonViewInfo == null)
            {
                return;
            }

            DevExpress.XtraBars.Ribbon.ViewInfo.RibbonPanelViewInfo panelViewInfo = ribbonViewInfo.Panel;
            if (panelViewInfo == null)
            {
                return;
            }

            Rectangle bounds = panelViewInfo.Bounds;
            int       minX   = bounds.X;

            DevExpress.XtraBars.Ribbon.ViewInfo.RibbonPageGroupViewInfoCollection groups = panelViewInfo.Groups;
            if (groups == null)
            {
                return;
            }
            if (groups.Count > 0)
            {
                minX = groups[groups.Count - 1].Bounds.Right;
            }

            SizeF sizeF = e.Graphics.MeasureString(CommonlyFunctions.loginUser, new Font("仿宋", 16, FontStyle.Bold));

            int offset = (int)((bounds.Height - sizeF.Height) / 2);
            int width  = (int)sizeF.Width + 5;

            bounds.X = bounds.Width - width;
            if (bounds.X < minX)
            {
                return;
            }

            bounds.Width  = width;
            bounds.Y     += offset + 10;
            bounds.Height = (int)sizeF.Height;

            Font       drawFont  = new Font("仿宋", 16, FontStyle.Bold);
            SolidBrush drawBrush = new SolidBrush(Color.Black);

            e.Graphics.DrawString(CommonlyFunctions.loginUser, drawFont, drawBrush, (PointF)bounds.Location);
        }
        private void ribbonControl1_Paint(object sender, PaintEventArgs e)
        {
            //if (IsCurrentAbout)
            // return;
            DevExpress.XtraBars.Ribbon.ViewInfo.RibbonViewInfo ribbonViewInfo = ribbonControl1.ViewInfo;
            if (ribbonViewInfo == null)
            {
                return;
            }
            DevExpress.XtraBars.Ribbon.ViewInfo.RibbonPanelViewInfo panelViewInfo = ribbonViewInfo.Panel;
            if (panelViewInfo == null)
            {
                return;
            }
            Rectangle bounds = panelViewInfo.Bounds;
            int       minX   = bounds.X;

            DevExpress.XtraBars.Ribbon.ViewInfo.RibbonPageGroupViewInfoCollection groups = panelViewInfo.Groups;
            if (groups == null)
            {
                return;
            }
            if (groups.Count > 0)
            {
                minX = groups[groups.Count - 1].Bounds.Right;
            }
            // Image image = DevExpress.Utils.Frames.ApplicationCaption8_1.ImageLogo;
            Image image = (Image)Properties.Resources.ResourceManager.GetObject("Logo");//获取文件

            if (bounds.Height < image.Height)
            {
                return;
            }
            int offset = (bounds.Height - image.Height) / 2;
            int width  = image.Width + 15;

            bounds.X = bounds.Width - width;
            if (bounds.X < minX)
            {
                return;
            }
            bounds.Width  = width;
            bounds.Y     += offset;
            bounds.Height = image.Height;
            e.Graphics.DrawImage(image, bounds.Location);
        }