Devexpress Ribbon Add Logo
2024-08-24 18:18:31
一直在网上找类似的效果.在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);
最新文章
- November 2nd Week 45th Wednesday 2016
- JavaWeb:EL表达式
- Struts2注解 特别注意
- Hadoop学习之--Fair Scheduler作业调度分析
- 【C#学习笔记】获得系统时间
- [置顶] Flex中Tree组件无刷新删除节点
- 【HDOJ】4985 Little Pony and Permutation
- 通过项目逐步深入了解Mybatis<;四>;
- WinForm----DataGridview---连接数据库,以及双击一条数据,显示信息到Label控件,也可以是TextBox控件。
- Web项目或WCF发布IIS后,如何通过VS2010调试
- 负载均衡软件LVS分析一(概念)
- 浅谈javascript继承体系
- Alpha第七天
- 交换机设置IP
- Koa 中的错误处理
- 使用 Helm 包管理工具简化 Kubernetes 应用部署
- Keepalived详解之 - LVS(IPVS)管理工具ipvsadm使用指南
- FreeSWITCH快速录音
- jQuery之自定义pagination控件
- oracle配置ODBC
热门文章
- EntityFramework的多种记录日志方式,记录错误并分析执行时间过长原因(系列4)
- bzoj3208--记忆化搜索
- 【转】 FineBI:自助式BI工具打造业务分析的“快与准”
- AFNetworking图片上传
- Android 扫描条形码(Zxing插件)
- WebStorm 2016 最新版激活(activation code方式)
- 使用win10远程控制ubuntu16.04
- SpringMVC(关于HandlerMapping执行流程原理分析)
- Ubuntu Server(Ubuntu 14.04 LTS 64位)安装libgdiplus2.10.9出错问题记录
- MyBatis5:MyBatis集成Spring事物管理(上篇)