How to: Add and Customize the Ribbon Skin List and Skin Gallery

2024-06-09 07:44

本文主要是介绍How to: Add and Customize the Ribbon Skin List and Skin Gallery,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

皮肤列表和皮肤库允许用户选择皮肤。本文介绍如何在功能区中显示“皮肤列表”或“皮肤库”并对其进行自定义。
DevExpress演示中心中的大多数应用程序都允许您选择皮肤。例如,运行XtraGrid演示并导航到皮肤功能区页面以更改当前皮肤。
在这里插入图片描述

在功能区UI中显示皮肤列表或皮肤库

使用以下栏项将相应的UI元素添加到功能区UI:“Skin List, Skin Gallery”、“Skin Palette List”和“Skin Palette Gallery”。在RibbonPageGroup上单击鼠标右键,然后调用相应的命令在设计时添加“ Skin List ”或“Skin Gallery”。
在这里插入图片描述

Skin List

A Skin List (SkinDropDownButtonItem) is a drop-down menu that displays application skins.
在这里插入图片描述

Skin Gallery

A Skin Gallery (SkinRibbonGalleryBarItem) is an in-ribbon gallery that displays skins. Skins in the gallery are grouped into categories.
在这里插入图片描述

Skin Palette List

A Skin Palette List (SkinPaletteDropDownButtonItem) allows users to select a color palette for a vector skin.
在这里插入图片描述

Skin Palette Gallery

A Skin Palette Gallery (SkinPaletteRibbonGalleryBarItem) allows users to select a color palette in an embedded or dropdown gallery.
在这里插入图片描述

Example

在这里插入图片描述

using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;namespace DXApplication20 {public partial class Form1 : RibbonForm {public Form1() {InitializeComponent();skinPageGroup.ItemLinks.Add(new SkinDropDownButtonItem());skinPageGroup.ItemLinks.Add(new SkinRibbonGalleryBarItem());colorPalettePageGroup.ItemLinks.Add(new SkinPaletteDropDownButtonItem());colorPalettePageGroup.ItemLinks.Add(new SkinPaletteRibbonGalleryBarItem());}}
}

Display Advanced Skin Options

显示高级skin选项

以下示例演示如何显示与高级皮肤设置相对应的预先设计的功能区UI命令:

在这里插入图片描述

using DevExpress.XtraBars;
using DevExpress.XtraBars.Helpers;namespace DXRibbonSkinSekector {public partial class Form1 : DevExpress.XtraBars.Ribbon.RibbonForm {BarCheckItem bciTrackWindowsAppMode, bciOriginalPalette, bciTrackWindowsAccentColor;BarButtonItem bbiSystemAccentColor, bbiAccentCustomColor2;public Form1() {InitializeComponent();bciTrackWindowsAppMode = new BarCheckItem();bciOriginalPalette = new BarCheckItem();bciTrackWindowsAccentColor = new BarCheckItem();bbiSystemAccentColor = new BarButtonItem();bbiAccentCustomColor2 = new BarButtonItem();advancedOptionsGroup.ItemLinks.Add(bciTrackWindowsAppMode);advancedOptionsGroup.ItemLinks.Add(bciOriginalPalette);advancedOptionsGroup.ItemLinks.Add(bciTrackWindowsAccentColor);advancedOptionsGroup.ItemLinks.Add(bbiSystemAccentColor);/** "The Bezier" skin supports the second accent color.* Other skins do not support the second accent color.*/advancedOptionsGroup.ItemLinks.Add(bbiAccentCustomColor2);// Initializes corresponding skin settings/selectors.SkinHelper.InitTrackWindowsAppMode(bciTrackWindowsAppMode);SkinHelper.InitResetToOriginalPalette(bciOriginalPalette);SkinHelper.InitTrackWindowsAccentColor(bciTrackWindowsAccentColor);SkinHelper.InitCustomAccentColor(Ribbon.Manager, bbiSystemAccentColor);SkinHelper.InitCustomAccentColor2(Ribbon.Manager, bbiAccentCustomColor2);}}
}

Hide Specific Items And Groups

隐藏特定项目和组
下面的步骤描述了如何隐藏单个皮肤。

  • Create a string array that contains unwanted skin names. These names can be full (e.g., “Office 2016 Colorful”) or partial (e.g., “2007”).
string[] skinsToHide = { "Seven Classic", "DevExpress Style", "Dark", "2010", "2007", "Sharp" };
  • Define a custom method that will iterate through skin items and hide unwanted ones.
private void HideGalleryItemsByCaptions(RibbonGalleryBarItem galleryItem, string[] skinsToHide) {var allItems = galleryItem.Gallery.GetAllItems();foreach (GalleryItem item in allItems) {if (skinsToHide.Contains(item.Caption))item.Visible = false;}
}
  • Use the form or UserControl Load event handler to call your method.
this.Load += ucRibbon_Load;void ucRibbon_Load(object sender, EventArgs e) {HideGalleryItemsByCaptions(skinRibbonGalleryBarItem1, skinsToHide);
}

To hide an entire skin group, use the code sample below.
要隐藏整个皮肤组,请使用下面的代码示例。

void ucRibbon_Load(object sender, EventArgs e) {skinRibbonGalleryBarItem1.Gallery.Groups.Remove(skinRibbonGalleryBarItem1.Gallery.Groups.OfType<GalleryItemGroup>().First(x => String.Equals(x.Caption, "Bonus Skins")));
}

The following example demonstrates how to rename and hide gallery groups in SkinDropDownButtonItem:
以下示例演示如何在SkinDropDownButtonItem中重命名和隐藏图库组:

using System.Linq;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Ribbon.Gallery;
using DevExpress.XtraBars.Helpers;namespace DXApplication20 {public partial class Form1 : RibbonForm {SkinDropDownButtonItem skinDropDownButtonItem;public Form1() {InitializeComponent();skinDropDownButtonItem = new SkinDropDownButtonItem(ribbonControl1.Manager);skinPageGroup.ItemLinks.Add(skinDropDownButtonItem);}private void Form1_Load(object sender, System.EventArgs e) {HideItems(skinDropDownButtonItem);}void HideItems(SkinDropDownButtonItem skinItem) {GalleryControlGallery gallery = ((skinItem.DropDownControl as SkinPopupControlContainer).Controls.OfType<GalleryControl>().FirstOrDefault()).Gallery;gallery.Groups[0].Caption = "My Custom Caption";gallery.Groups[1].Visible = false;gallery.Groups[2].Visible = false;}}
}

The following example demonstrates how to hide the specified groups from SkinPaletteDropDownButtonItem:
以下示例演示如何从SkinPartiteDropDownButtonItem中隐藏指定的组:

void HideSkins2(SkinPaletteDropDownButtonItem skinItem, string[] palettesToHide) {var groups = (skinItem.DropDownControl as GalleryDropDown).Gallery.Groups;for(var i = 0; i < groups.Count; i++) {var group = groups[i];if(group == null) {continue;}for(var j = 0; j < group.Items.Count; j++) {var item = group.Items[j];if(item == null) {continue;}foreach(var palette in palettesToHide) {if(item.Caption.Contains(palette)) {item.Visible = false;}}if(!group.HasVisibleItems())group.Visible = false;}}
}

Remove Item Grouping

To remove item grouping, add a new gallery group and populate it with all existing gallery items. Then, you can remove all gallery groups except for your new custom group – as illustrated in the code sample below.
若要删除项目分组,请添加一个新的库组,并用所有现有库项目填充该组。然后,您可以删除除新的自定义组之外的所有库组,如下面的代码示例所示。

void ucRibbon_Load(object sender, EventArgs e) {RemoveGrouping();
}void RemoveGrouping() {GalleryItemGroup group = new GalleryItemGroup() { Caption = "Available Skins" };skinRibbonGalleryBarItem1.Gallery.Groups.Insert(0, group);foreach(var item in skinRibbonGalleryBarItem1.Gallery.GetAllItems()) {skinRibbonGalleryBarItem1.Gallery.Groups[0].Items.Add(item);}while(skinRibbonGalleryBarItem1.Gallery.Groups.Count > 1)skinRibbonGalleryBarItem1.Gallery.Groups.Remove(skinRibbonGalleryBarItem1.Gallery.Groups.Last());
}

Change Captions and Icons Manually

手动更改标题和图标
To change captions and glyphs of items within a Ribbon skin gallery, iterate through gallery items and modify the following properties:
要更改功能区皮肤库中项目的标题和图示符,请遍历库项目并修改以下属性:

  • GalleryItem.Caption — Gets or sets the item’s caption. 获取或设置项的标题
  • GalleryItem.Hint — Gets a hint associated with the gallery item. 获取与库项目关联的提示。
  • GalleryItem.Description — Gets or sets the item’s description.获取或设置项的描述。
  • GalleryItem.ImageOptions.SvgImage — Gets or sets a vector image. The vector image has priority over the raster image.获取或设置矢量图像。矢量图像的优先级高于光栅图像。
  • GalleryItem.ImageOptions.Image — Gets or sets a raster image. To display a custom raster image, nullify the default vector image. 获取或设置光栅图像。若要显示自定义光栅图像,请使默认矢量图像无效。
  • GalleryItem.ImageOptions.HoverImage — Gets or sets a raster image displayed when the mouse pointer hovers the item. 获取或设置鼠标指针悬停项目时显示的光栅图像。
void ucRibbon_Load(object sender, EventArgs e) {CustomizeItems(skinRibbonGalleryBarItem1);
}
void CustomizeItems(SkinRibbonGalleryBarItem target) {foreach(var item in target.Gallery.GetAllItems()) {if(item.Caption == "DevExpress Dark Style") {item.Caption = item.Hint = "Default Skin";item.Description = "The default skin";// We recommend that you use vector images.item.ImageOptions.SvgImage = SvgImage.FromResources("DXApplication1.Resources.Driving.svg", typeof(Form1).Assembly);// The vector image has priority over the raster image.// To assign a raster image, nullify the default vector image.item.ImageOptions.SvgImage = null;item.ImageOptions.Image = DevExpress.Images.ImageResourceCache.Default.GetImage("office2013/miscellaneous/colors_16x16.png");item.ImageOptions.HoverImage = DevExpress.Images.ImageResourceCache.Default.GetImage("office2013/miscellaneous/colors_32x32.png");}}
}

在这里插入图片描述

Obtain Active Skin

The following example demonstrates how to get the active skin name:

string activeSkinName = DevExpress.UserLookAndFeel.Default.ActiveSkinName;

这篇关于How to: Add and Customize the Ribbon Skin List and Skin Gallery的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1044574

相关文章

【C++】_list常用方法解析及模拟实现

相信自己的力量,只要对自己始终保持信心,尽自己最大努力去完成任何事,就算事情最终结果是失败了,努力了也不留遗憾。💓💓💓 目录   ✨说在前面 🍋知识点一:什么是list? •🌰1.list的定义 •🌰2.list的基本特性 •🌰3.常用接口介绍 🍋知识点二:list常用接口 •🌰1.默认成员函数 🔥构造函数(⭐) 🔥析构函数 •🌰2.list对象

Collection List Set Map的区别和联系

Collection List Set Map的区别和联系 这些都代表了Java中的集合,这里主要从其元素是否有序,是否可重复来进行区别记忆,以便恰当地使用,当然还存在同步方面的差异,见上一篇相关文章。 有序否 允许元素重复否 Collection 否 是 List 是 是 Set AbstractSet 否

【Python报错已解决】AttributeError: ‘list‘ object has no attribute ‘text‘

🎬 鸽芷咕:个人主页  🔥 个人专栏: 《C++干货基地》《粉丝福利》 ⛺️生活的理想,就是为了理想的生活! 文章目录 前言一、问题描述1.1 报错示例1.2 报错分析1.3 解决思路 二、解决方法2.1 方法一:检查属性名2.2 步骤二:访问列表元素的属性 三、其他解决方法四、总结 前言 在Python编程中,属性错误(At

【微服务】Ribbon(负载均衡,服务调用)+ OpenFeign(服务发现,远程调用)【详解】

文章目录 1.Ribbon(负载均衡,服务调用)1.1问题引出1.2 Ribbon负载均衡1.3 RestTemplate整合Ribbon1.4 指定Ribbon负载均衡策略1.4.1 配置文件1.4.2 配置类1.4.3 定义Ribbon客户端配置1.4.4 自定义负载均衡策略 2.OpenFeign面向接口的服务调用(服务发现,远程调用)2.1 OpenFeign的使用2.1 .1创建

Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.B

一个bug日志 FATAL EXCEPTION: main03-25 14:24:07.724: E/AndroidRuntime(4135): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.syyx.jingubang.ky/com.anguotech.android.activity.Init

ubuntu16.04 Git add 使用tab键卡死

以前使用Ubuntu14.04 进行git add 操作时使用TAB键可以很快自动补全,但自从使用16.04使用TAB半天没有反应。 一开始以为是Git版本问题,后验证与Git无关。 搜索发现与Dash有关,以下是博客原文: http://www.51testing.com/html/50/n-1245050.html 今天碰到一个问题git 后面的参数用Tab键无法补全

List list = new ArrayList();和ArrayList list=new ArrayList();的区别?

List是一个接口,而ArrayList 是一个类。 ArrayList 继承并实现了List。 List list = new ArrayList();这句创建了一个ArrayList的对象后把上溯到了List。此时它是一个List对象了,有些ArrayList有但是List没有的属性和方法,它就不能再用了。而ArrayList list=new ArrayList();创建一对象则保留了A

处理List采用并行流处理时,通过ForkJoinPool来控制并行度失控的问题

在使用parallelStream进行处理list时,如不指定线程池,默认的并行度采用cpu核数进行并行,这里采用ForJoinPool来控制,但循环中使用了redis获取key时,出现失控。具体上代码。 @RunWith(SpringRunner.class)@SpringBootTest(classes = Application.class)@Slf4jpublic class Fo

Add All -uva优先队列的应用

题目的解法属于贪心,因为cost=a1+a2,所以要保证每次的cost最小,所以说,每次将队列中最小的两个相加,得出来的数放入队列中,再取2个最小的相加,直到全部加完,所以这就涉及了一个取2个最小数的问题,我说一下我一开始的做法 #include<stdio.h>#include<iostream>#include<stdlib.h>using namespace std;#define

Java中集合类Set、List和Map的区别

Java中的集合包括三大类,它们是Set、List和Map,它们都处于java.util包中,Set、List和Map都是接口,它们有各自的实现类。Set的实现类主要有HashSet和TreeSet,List的实现类主要有ArrayList,Map的实现类主要有HashMap和TreeMap。那么它们有什么区别呢? Set中的对象不按特定方式排序,并且没有重复对象。但它的有些实现类能对集合中的对