zoukankan      html  css  js  c++  java
  • How to customize Skin Gallery

    1. REMOVE (HIDE) A SPECIFIC SKIN 
    Traverse through the gallery group collection, then through its gallery item collection and hide a corresponding item:

    private void InitRibbonSkinGallery() {
                SkinHelper.InitSkinGallery(skinGalleryBarItem);
    }
    
    string[] skinsToHide = {"Black","Blue","Seven","Sharp" }; // populate with names of unnecessary skins
    private void HideSkins(string[] skinsToHide) {
                for(var i = 0; i < skinGalleryBarItem.Gallery.Groups.Count; i++) {
                    var group = skinGalleryBarItem.Gallery.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 skin in skinsToHide) {
                            if(String.Equals(item.Caption, skin)) {
                                item.Visible = false;
                            }
                        }
                    }
                }
    }
    Private Sub InitRibbonSkinGallery()
                SkinHelper.InitSkinGallery(skinGalleryBarItem)
    End Sub
    
    Private skinsToHide() As String = {"Black","Blue","Seven","Sharp" } 'populate with names of unnecessary skins
    Private Sub HideSkins(ByVal skinsToHide() As String)
                For i = 0 To skinGalleryBarItem.Gallery.Groups.Count - 1
                    Dim group = skinGalleryBarItem.Gallery.Groups(i)
                    If group Is Nothing Then
                        Continue For
                    End If
                    For j = 0 To group.Items.Count - 1
                        Dim item = group.Items(j)
                        If item Is Nothing Then
                            Continue For
                        End If
                        For Each skin In skinsToHide
                                If String.Equals(item.Caption, skin) Then
                                item.Visible = False
                            End If
                        Next skin
                    Next j
                Next i
    End Sub

    This is discussed in the How to remove certain skins from the bonus skins collection  ticket.

    2. REMOVE  A SPECIFIC SKIN GROUP 
    Remove a required group from the collection:

    string skinGroup = "Standard Skins";
    RemoveSkinGroups(skinGroup);
    
    void RemoveSkinGroups(string skinGroup) {
                skinGalleryBarItem.Gallery.Groups.Remove(skinGalleryBarItem.Gallery.Groups.OfType<GalleryItemGroup>().First(x => String.Equals(x.Caption, skinGroup)));                       
    }
    Private skinGroup As String = "Standard Skins"
    RemoveSkinGroups(skinGroup)
    
    void RemoveSkinGroups(String skinGroup)
                skinGalleryBarItem.Gallery.Groups.Remove(skinGalleryBarItem.Gallery.Groups.OfType(Of GalleryItemGroup)().First(Function(x) String.Equals(x.Caption, skinGroup)))

    This issue is discussed in the How to remove the "Theme Skin" skin group from the In-Ribbon gallery populated with available skins  thread.

    3. REMOVE GROUPING 

    Fill the In-Ribbon and In-Dropdown gallery with required skins manually. 
    To obtain all available skins in your project, use the SkinManager.Skins property. To populate the In-Dropdown gallery, handle theRibbonGalleryBarItem.GalleryInitDropDownGallery event:

    DevExpress.XtraBars.RibbonGalleryBarItem skinGalleryBarItem;
    SkinContainerCollection skins;
    
    void InitSkinGallery() {
                //SkinHelper.InitSkinGallery(skinGalleryBarItem, true);
                skins = SkinManager.Default.Skins;
    
                for (int i = 0; i < 14; i++) {
                    int index = rgbiSkins.Gallery.Groups[0].Items.Add(new GalleryItem());
                    GalleryItem item = skinGalleryBarItem.Gallery.Groups[0].Items[index];
                    item.Description = skins[index].SkinName;
                    item.Image = galleryImageCollection.Images[i];               
                }
    }
    
    private void skinGalleryBarItem_GalleryInitDropDownGallery(object sender, InplaceGalleryEventArgs e) {
                e.PopupGallery.AllowHoverImages = false;
                e.PopupGallery.ItemClick += new GalleryItemClickEventHandler(PopupGallery_ItemClick);
                for (int i = 0; i < e.PopupGallery.Groups[0].Items.Count; i++) {
                    GalleryItem item = e.PopupGallery.Groups[0].Items[i];
                    item.Description = skins[i].SkinName;
                    item.Caption = skins[i].SkinName;
                }
    }
    void PopupGallery_ItemClick(object sender, GalleryItemClickEventArgs e) {
                defaultBarAndDockingController1.Controller.LookAndFeel.SkinName = e.Item.Description;
    }
    Private skinGalleryBarItem As DevExpress.XtraBars.RibbonGalleryBarItem
    Private skins As SkinContainerCollection
    
    Private Sub InitSkinGallery()
                'SkinHelper.InitSkinGallery(skinGalleryBarItem, true);
                skins = SkinManager.Default.Skins
    
                For i As Integer = 0 To 13
                    Dim index As Integer = rgbiSkins.Gallery.Groups(0).Items.Add(New GalleryItem())
                    Dim item As GalleryItem = skinGalleryBarItem.Gallery.Groups(0).Items(index)
                    item.Description = skins(index).SkinName
                    item.Image = galleryImageCollection.Images(i)
                Next i
    End Sub
    
    Private Sub skinGalleryBarItem_GalleryInitDropDownGallery(ByVal sender As Object, ByVal e As InplaceGalleryEventArgs)
                e.PopupGallery.AllowHoverImages = False
                AddHandler e.PopupGallery.ItemClick, AddressOf PopupGallery_ItemClick
                For i As Integer = 0 To e.PopupGallery.Groups(0).Items.Count - 1
                    Dim item As GalleryItem = e.PopupGallery.Groups(0).Items(i)
                    item.Description = skins(i).SkinName
                    item.Caption = skins(i).SkinName
                Next i
    End Sub
    Private Sub PopupGallery_ItemClick(ByVal sender As Object, ByVal e As GalleryItemClickEventArgs)
                defaultBarAndDockingController1.Controller.LookAndFeel.SkinName = e.Item.Description
    End Sub

    See Skin Gallery - How to remove skin grouping  ticket to learn more. 

    4. CHANGE A SKIN NAME 
    Traverse through the gallery group collection, then through its gallery item collection, obtain a required GalleryItem  and change the GalleryItem.Caption property for this purpose. 
    See How to change/remove the DevExpress Style caption from the Skin Menu/Drop-down gallery  for more information.

    5. CHANGE A SKIN ICON 

    Traverse through the gallery group  collection, then through its gallery item  collection, obtain a required GalleryItem  and set the Image and HoverImage properties. 
    See Skin Gallery - How to change a skin icon (image) and name (caption)  for more information.

  • 相关阅读:
    XML之四种解析dom,sax,jdom,dom4j原理及性能比较
    uni-app 下小程序bindgetuserinfo不回调原因
    微信小程序 -- 真机不打开调试无法正常使用小程序的坑
    如何申请腾讯位置服务的密钥
    使用Promise封装小程序wx.request的实现方法
    关于vue-router当中addRoutes的使用
    前端Promise总结笔记
    css怎么设置超出几行显示省略号?
    大数据Spark和Hadoop以及区别(干货)
    Spark和Hadoop的区别和比较
  • 原文地址:https://www.cnblogs.com/joysky/p/4831288.html
Copyright © 2011-2022 走看看