示例 1
在本例中接管了 BaseGallery.CustomDrawItemText 事件来人工绘制 Gallery 项内的文本。
完整的源代码可以在 XtraBars 提供的 “Ribbon Simple Pad” 演示中找到。
下面的插图展示了结果:
C# | 复制代码 |
---|---|
using DevExpress.XtraBars.Ribbon.ViewInfo; private void gddFont_Gallery_CustomDrawItemText(object sender, GalleryItemCustomDrawEventArgs e) { GalleryItemViewInfo itemInfo = e.ItemInfo as GalleryItemViewInfo; itemInfo.PaintAppearance.ItemDescription.DrawString(e.Cache, e.Item.Description, itemInfo.DescriptionBounds); AppearanceObject app = itemInfo.PaintAppearance.ItemCaption.Clone() as AppearanceObject; app.Font = (Font)e.Item.Tag; app.DrawString(e.Cache, e.Item.Caption, itemInfo.CaptionBounds); e.Handled = true; } |
Visual Basic | 复制代码 |
---|---|
Imports DevExpress.XtraBars.Ribbon.ViewInfo Private Sub gddFont_Gallery_CustomDrawItemText(ByVal sender As Object, _ ByVal e As GalleryItemCustomDrawEventArgs) Handles gddFont.GalleryCustomDrawItemText Dim itemInfo As GalleryItemViewInfo = CType( _ IIf(TypeOf e.ItemInfo Is GalleryItemViewInfo, e.ItemInfo, Nothing), GalleryItemViewInfo) itemInfo.PaintAppearance.ItemDescription.DrawString(e.Cache, e.Item.Description, _ itemInfo.DescriptionBounds) Dim app As AppearanceObject = _ CType(itemInfo.PaintAppearance.ItemCaption.Clone(), AppearanceObject) app.Font = CType(e.Item.Tag, Font) app.DrawString(e.Cache, e.Item.Caption, itemInfo.CaptionBounds) e.Handled = True End Sub |
示例 2
在本例中接管了 BaseGallery.CustomDrawItemImage 事件来人工绘制 Font Color Gallery 项的图像。 个别项与特定的颜色相对应。
完整的源代码可以在 XtraBars 提供的 “Ribbon Simple Pad” 演示中找到。
下面的插图展示了结果:
C# | 复制代码 |
---|---|
private void gddFontColor_Gallery_CustomDrawItemImage(object sender, GalleryItemCustomDrawEventArgs e) { Color clr = (Color)e.Item.Tag; using(Brush brush = new SolidBrush(clr)) { e.Cache.FillRectangle(brush, e.Bounds); e.Handled = true; } } |
Visual Basic | 复制代码 |
---|---|
Private Sub gddFontColor_Gallery_CustomDrawItemImage(ByVal sender As Object, _ ByVal e As GalleryItemCustomDrawEventArgs) _ Handles gddFontColor.GalleryCustomDrawItemImage, _ rgbiFontColor.GalleryCustomDrawItemImage Dim clr As Color = CType(e.Item.Tag, Color) Dim brush As brush = New SolidBrush(clr) Try e.Cache.FillRectangle(brush, e.Bounds) e.Handled = True Finally CType(brush, IDisposable).Dispose() End Try End Sub |