void NavBarControl_CustomDrawGroupCaption(object sender, DevExpress.XtraNavBar.ViewInfo.CustomDrawNavBarElementEventArgs e) { if (!IsCustomDrawNeeded()) { return; } try { isLocked = true; BaseNavGroupPainter painter = NavBarControl.View.CreateGroupPainter(NavBarControl); NavGroupInfoArgs info = e.ObjectInfo as NavGroupInfoArgs; Rectangle originalCaptionBounds = new Rectangle(info.CaptionClientBounds.X, info.CaptionClientBounds.Y, info.CaptionClientBounds.Width - info.ButtonBounds.Width, info.CaptionClientBounds.Height); Rectangle fixedCaptionBounds = GetCaptionBounds(originalCaptionBounds); Rectangle checkBoxBounds = GetCheckBoxBounds(fixedCaptionBounds); info.CaptionBounds = fixedCaptionBounds; painter.DrawObject(info); info.CaptionBounds = originalCaptionBounds; DrawCheckBox(e.Graphics, checkBoxBounds, IsGroupEnabled(info.Group)); e.Handled = true; } finally { isLocked = false; } }
private void navBarControl1_CustomDrawLink(object sender, DevExpress.XtraNavBar.ViewInfo.CustomDrawNavBarElementEventArgs e) { if (e.ObjectInfo.State == ObjectState.Hot || e.ObjectInfo.State == ObjectState.Pressed) { LinearGradientBrush brush; NavLinkInfoArgs linkInfo = e.ObjectInfo as NavLinkInfoArgs; if (e.ObjectInfo.State == ObjectState.Hot) { brush = new LinearGradientBrush(e.RealBounds, Color.Orange, Color.PeachPuff, LinearGradientMode.Horizontal); } else { brush = new LinearGradientBrush(e.RealBounds, Color.PeachPuff, Color.Orange, LinearGradientMode.Horizontal); } e.Graphics.FillRectangle(Brushes.OrangeRed, e.RealBounds); Rectangle rect = e.RealBounds; rect.Inflate(-1, -1); e.Graphics.FillRectangle(brush, rect); if (e.Image != null) { Rectangle imageRect = linkInfo.ImageRectangle; imageRect.X += (imageRect.Width - e.Image.Width) / 2; imageRect.Y += (imageRect.Height - e.Image.Height) / 2; imageRect.Size = e.Image.Size; e.Graphics.DrawImageUnscaled(e.Image, imageRect); } e.Appearance.DrawString(e.Cache, e.Caption, linkInfo.RealCaptionRectangle, Brushes.White); e.Handled = true; } }
private void navBarControl1_CustomDrawLink(object sender, DevExpress.XtraNavBar.ViewInfo.CustomDrawNavBarElementEventArgs e) { NavLinkInfoArgs args = e.ObjectInfo as NavLinkInfoArgs; if (args.Link == navBarControl1.SelectedLink) { e.Graphics.FillRectangle(Brushes.Red, e.RealBounds); } }
private void NavBarControl1_CustomDrawGroupCaption(object sender, DevExpress.XtraNavBar.ViewInfo.CustomDrawNavBarElementEventArgs e) { Console.WriteLine(DateTime.Now.Ticks); var info = e.ObjectInfo as NavGroupInfoArgs; var vInfo = info.ClientInfo.NavBar.GetViewInfo() as SkinNavigationPaneViewInfo; if (vInfo == null) { return; } //custom paint Rectangle rect = vInfo.HeaderBounds; rect.Width -= 1; e.Graphics.DrawRectangle(Pens.Red, rect); e.Graphics.DrawRectangle(Pens.Green, vInfo.HeaderInfo.CaptionBounds); e.Graphics.DrawRectangle(Pens.Black, vInfo.HeaderInfo.ButtonBounds); }