博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Devexpress Ribbon Add Logo
阅读量:4915 次
发布时间:2019-06-11

本文共 3416 字,大约阅读时间需要 11 分钟。

  一直在网上找类似的效果.在Devpexress控件里面的这个是一个Demo的.没法查看源代码.也不知道怎么写的.所以就在网上搜索了半天的.

 终于找到类似的解决办法.

 可以使用重绘制的办法的来解决.

[DesignerCategory("")]    [Designer("")]    public class RibbonLogoHelper : Component    {        private Image _Image;        private RibbonControl _RibbonControl;        public RibbonControl RibbonControl        {            get { return _RibbonControl; }            set            {                if (value == _RibbonControl)                    return;                RibbonControl prevValue = _RibbonControl;                _RibbonControl = value;                OnRibbonChanged(prevValue, _RibbonControl);            }        }        private void OnRibbonChanged(RibbonControl prevValue, RibbonControl ribbonControl)        {            if (prevValue != null)                prevValue.Paint -= ribbonControl_Paint;            if (ribbonControl != null)            {                ribbonControl.Paint += ribbonControl_Paint;                ribbonControl.Invalidate();            }               }        void ribbonControl_Paint(object sender, System.Windows.Forms.PaintEventArgs e)        {            DrawRibbonLogo(e.Graphics);        }        public Image Image        {            get { return _Image; }            set            {                if (value == _Image)                    return;                _Image = value;                OnImageChanged();            }        }        private void OnImageChanged()        {            if (RibbonControl != null)                RibbonControl.Invalidate();        }        private void DrawRibbonLogo(Graphics graphics)        {            if (Image == null)                return;            RibbonViewInfo ribbonViewInfo = RibbonControl.ViewInfo;            if (ribbonViewInfo == null)                return;            RibbonPanelViewInfo panelViewInfo = ribbonViewInfo.Panel;            if (panelViewInfo == null)                return;            Rectangle bounds = panelViewInfo.Bounds;            int minX = bounds.X;            RibbonPageGroupViewInfoCollection groups = panelViewInfo.Groups;            if (groups == null)                return;            if (groups.Count > 0)                minX = groups[groups.Count - 1].Bounds.Right;            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;            graphics.DrawImage(Image, bounds.Location);        }      }

最终达到自己想要效果的.

 

或者在标题栏上添加类似的Logo

DevExpress.XtraBars.Ribbon.ViewInfo.RibbonViewInfo ribbonViewInfo = ribbonControl1.ViewInfo;            if (ribbonViewInfo == null)                return;            DevExpress.XtraBars.Ribbon.ViewInfo.RibbonCaptionViewInfo captionViewInfo = ribbonViewInfo.Caption;            if (captionViewInfo == null)                return;            Rectangle bounds = new Rectangle(captionViewInfo.ContentBounds.X + 120, captionViewInfo.ContentBounds.Y, captionViewInfo.ContentBounds.Width - 22, captionViewInfo.ContentBounds.Height);            Image image = DevExpress.Utils.Frames.ApplicationCaption8_1.GetImageLogoEx(LookAndFeel);            e.Graphics.DrawImage(image, bounds.Location);

 

转载于:https://www.cnblogs.com/w2011/p/3747203.html

你可能感兴趣的文章
[MySQl]MySQL忘记密码
查看>>
Android的minSdkVersion,targetSdkVersion,maxSdkVersion
查看>>
Xceed WinForm数据表格控件Xceed Grid For .NET控件详细介绍及下载地址
查看>>
ecos启动流程分析
查看>>
Oracle CASE WHEN 用法介绍
查看>>
linux 下连接mysql服务器
查看>>
DOMContentLoad 首屏渲染
查看>>
rpm检验是否被改动过
查看>>
Sphinx-简介及原理
查看>>
【Linux】深入理解Linux中内存管理
查看>>
WEB 移动网站 手机点击 打电话 发短信
查看>>
2019CSUST集训队选拔赛题解(一)
查看>>
李晓菁201771010114《面向对象程序设计(Java)》第三周学习总结
查看>>
Typedef与Struct
查看>>
Linux常用网络命令整理
查看>>
JMeter学习笔记--使用URL回写来处理用户会话
查看>>
Error creating bean with name 'documentationPluginsBootstrapper' defined in URL
查看>>
Javascript样例之文档章节滚动全版(DOM)
查看>>
C++ 面向对象
查看>>
Maven Nexus
查看>>