Ribbon右侧显示Logo

方法

重写RibbonControl的Paint事件

效果

RibbonForm使用技巧-LMLPHP

代码

         private void _ribbonControl_Paint(object sender, PaintEventArgs e)
{
var viewInfo = _ribbonControl.ViewInfo;
var panel = viewInfo?.Panel;
var groups = panel?.Groups;
if (groups == null) return;
var bounds = panel.Bounds;
var groupRight = bounds.X;
if (groups.Count > )
{
groupRight = groups[groups.Count - ].Bounds.Right;
}
var logoImage = Properties.Resources.WitswayLogo;
if (bounds.Height < logoImage.Height) return;
var logoTop = (bounds.Height - logoImage.Height) / ;
var logoLeft = logoImage.Width;
bounds.X = bounds.Width - logoLeft - ;
if (bounds.X < groupRight) return;
bounds.Width = logoLeft;
bounds.Y += logoTop;
bounds.Height = logoImage.Height;
e.Graphics.DrawImage(logoImage, bounds);
}

顶部显示带图标文字的下拉框

效果

RibbonForm使用技巧-LMLPHP

代码

            this.barButtonItem6.ActAsDropDown = true;
this.barButtonItem6.ButtonStyle = DevExpress.XtraBars.BarButtonStyle.DropDown;
this.barButtonItem6.Caption = "管理员";
this.barButtonItem6.DropDownControl = this.popupMenu1;
this.barButtonItem6.Id = ;
this.barButtonItem6.ImageOptions.ImageIndex = ;
this.barButtonItem6.Name = "barButtonItem6";
this.barButtonItem6.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph;
this.barButtonItem6.RibbonStyle = DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithText;

注意

需要将BarButtonItem放到一个BarButtonGroup中

RibbonForm使用技巧-LMLPHP

标题栏显示HelpButton

效果

RibbonForm使用技巧-LMLPHP

代码

        private void XtraForm1_HelpButtonClicked(object sender, CancelEventArgs e)
{
popupMenu1.ShowPopup(MousePosition);
e.Cancel = true;
}

设置触摸支持

            DevExpress.XtraEditors.WindowsFormsSettings.SetDPIAware();
DevExpress.XtraEditors.WindowsFormsSettings.EnableFormSkins();
DevExpress.XtraEditors.WindowsFormsSettings.AllowPixelScrolling = DefaultBoolean.True;
DevExpress.XtraEditors.WindowsFormsSettings.ScrollUIMode = DevExpress.XtraEditors.ScrollUIMode.Touch; DevExpress.XtraEditors.WindowsFormsSettings.TouchUIMode = TouchUIMode.True;
DevExpress.XtraEditors.WindowsFormsSettings.TouchScaleFactor =1.5f;

全局设置RadialMenu中心图标

RadialMenu.DefaultGlyph = Resources.collaboration;
05-08 08:34