一直在网上找类似的效果.在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 > )
minX = groups[groups.Count - ].Bounds.Right;
if (bounds.Height < Image.Height)
return;
int offset = (bounds.Height - Image.Height) / ;
int width = Image.Width + ;
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 + , captionViewInfo.ContentBounds.Y,
captionViewInfo.ContentBounds.Width - , captionViewInfo.ContentBounds.Height);
Image image = DevExpress.Utils.Frames.ApplicationCaption8_1.GetImageLogoEx(LookAndFeel); e.Graphics.DrawImage(image, bounds.Location);

最新文章

  1. November 2nd Week 45th Wednesday 2016
  2. JavaWeb:EL表达式
  3. Struts2注解 特别注意
  4. Hadoop学习之--Fair Scheduler作业调度分析
  5. 【C#学习笔记】获得系统时间
  6. [置顶] Flex中Tree组件无刷新删除节点
  7. 【HDOJ】4985 Little Pony and Permutation
  8. 通过项目逐步深入了解Mybatis&lt;四&gt;
  9. WinForm----DataGridview---连接数据库,以及双击一条数据,显示信息到Label控件,也可以是TextBox控件。
  10. Web项目或WCF发布IIS后,如何通过VS2010调试
  11. 负载均衡软件LVS分析一(概念)
  12. 浅谈javascript继承体系
  13. Alpha第七天
  14. 交换机设置IP
  15. Koa 中的错误处理
  16. 使用 Helm 包管理工具简化 Kubernetes 应用部署
  17. Keepalived详解之 - LVS(IPVS)管理工具ipvsadm使用指南
  18. FreeSWITCH快速录音
  19. jQuery之自定义pagination控件
  20. oracle配置ODBC

热门文章

  1. EntityFramework的多种记录日志方式,记录错误并分析执行时间过长原因(系列4)
  2. bzoj3208--记忆化搜索
  3. 【转】 FineBI:自助式BI工具打造业务分析的“快与准”
  4. AFNetworking图片上传
  5. Android 扫描条形码(Zxing插件)
  6. WebStorm 2016 最新版激活(activation code方式)
  7. 使用win10远程控制ubuntu16.04
  8. SpringMVC(关于HandlerMapping执行流程原理分析)
  9. Ubuntu Server(Ubuntu 14.04 LTS 64位)安装libgdiplus2.10.9出错问题记录
  10. MyBatis5:MyBatis集成Spring事物管理(上篇)