关于DEV皮肤的换肤 也是系统风格的代码 C#
来源:互联网 发布:js 代码整理 编辑:程序博客网 时间:2024/06/05 08:17
DEV中的系统风格
Add PageGroup ->Add ribbonGalleryBarItem-> Add GalleryGroup
首先在设计窗口加上defaultLookAndFeel1控件
引用有:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.IO;
using System.Windows.Forms;
using DevExpress.XtraBars;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Output;
using DevExpress.XtraEditors;
using DevExpress.Skins;
using DevExpress.XtraBars.Ribbon;
using DevExpress.Utils.Drawing;
(加上这些肯定够 但其中也有别的功能)
在RibbonForm1.Designer.cs中加上:(有定义就不用加了)
private DevExpress.XtraBars.BarSubItem iPaintStyle;
private DevExpress.XtraBars.RibbonGalleryBarItem ribbonGalleryBarItem1;
private DevExpress.LookAndFeel.DefaultLookAndFeel defaultLookAndFeel1;
在private void InitializeComponent()中加上
this.iPaintStyle = new DevExpress.XtraBars.BarSubItem();
//
// iPaintStyle
//
this.iPaintStyle.Caption = "Paint style";
this.iPaintStyle.Description = "Select a paint scheme";
this.iPaintStyle.Hint = "Select a paint scheme";
this.iPaintStyle.Id = 7;
this.iPaintStyle.ImageIndex = 26;
this.iPaintStyle.Name = "iPaintStyle";
this.iPaintStyle.Popup += new System.EventHandler(this.iPaintStyle_Popup);
还有一句 this.iPaintStyle,加在
// ribbon
//
中
在Form1.CS中加入
namespace Test//请注意这里是命名空间 自己的程序自己的命名
{
public partial class RibbonForm1 : DevExpress.XtraBars.Ribbon.RibbonForm
{
// private DevExpress.LookAndFeel.DefaultLookAndFeel defaultLookAndFeel1;(前面有的就不需要这句了)
public RibbonForm1()
{
InitializeComponent();
InitSkinGallery();
}
void InitSkinGallery()
{
SimpleButton imageButton = new SimpleButton();
foreach (SkinContainer cnt in SkinManager.Default.Skins)
{
imageButton.LookAndFeel.SetSkinStyle(cnt.SkinName);
GalleryItem gItem = new GalleryItem();
int groupIndex = 0;
if (cnt.SkinName.IndexOf("Office") > -1) groupIndex = 1;
ribbonGalleryBarItem1.Gallery.Groups[groupIndex].Items.Add(gItem);
gItem.Caption = cnt.SkinName;
gItem.Image = GetSkinImage(imageButton, 32, 17, 2);
gItem.HoverImage = GetSkinImage(imageButton, 70, 36, 5);
gItem.Caption = cnt.SkinName;
gItem.Hint = cnt.SkinName;
ribbonGalleryBarItem1.Gallery.Groups[1].Visible = false;
}
}
Bitmap GetSkinImage(SimpleButton button, int width, int height, int indent)
{
Bitmap image = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(image))
{
StyleObjectInfoArgs info = new StyleObjectInfoArgs(new GraphicsCache(g));
info.Bounds = new Rectangle(0, 0, width, height);
button.LookAndFeel.Painter.GroupPanel.DrawObject(info);
button.LookAndFeel.Painter.Border.DrawObject(info);
info.Bounds = new Rectangle(indent, indent, width - indent * 2, height - indent * 2);
button.LookAndFeel.Painter.Button.DrawObject(info);
}
return image;
}
private void iPaintStyle_Popup(object sender, System.EventArgs e)
{
foreach (BarItemLink link in iPaintStyle.ItemLinks)
((BarCheckItem)link.Item).Checked = link.Item.Caption == defaultLookAndFeel1.LookAndFeel.ActiveSkinName;
}
private void RibbonForm1_Load(object sender, EventArgs e)
{
// 设置绑定控件
axTOCControl1.SetBuddyControl(axMapControl1);(这是绑定控件的在系统风格中不需要这句)
foreach (DevExpress.Skins.SkinContainer skin in DevExpress.Skins.SkinManager.Default.Skins)
{
BarCheckItem item = ribbon.Items.CreateCheckItem(skin.SkinName, false);
item.Tag = skin.SkinName;
item.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(OnPaintStyleClick);
iPaintStyle.ItemLinks.Add(item);
}
}
void OnPaintStyleClick(object sender, ItemClickEventArgs e)
{
defaultLookAndFeel1.LookAndFeel.SetSkinStyle(e.Item.Tag.ToString());
}
}
}
再加两个事件 ribbonGalleryBarItem1_Gallery_InitDropDownGallery(InitDropDownGallery事件)
ribbonGalleryBarItem1_Gallery_ItemClick(ItemClick事件)
请注意 两个事件在属性事件中是挨着的都在(倒数第二和倒数第三个事件)
private void ribbonGalleryBarItem1_Gallery_InitDropDownGallery(object sender, InplaceGalleryEventArgs e)
{
e.PopupGallery.CreateFrom(ribbonGalleryBarItem1.Gallery);
e.PopupGallery.AllowFilter = false;
e.PopupGallery.ShowItemText = true;
e.PopupGallery.ShowGroupCaption = true;
e.PopupGallery.AllowHoverImages = false;
foreach (GalleryItemGroup galleryGroup in e.PopupGallery.Groups)
foreach (GalleryItem item in galleryGroup.Items)
item.Image = item.HoverImage;
e.PopupGallery.ColumnCount = 2;
e.PopupGallery.ImageSize = new Size(70, 36);
}
private void ribbonGalleryBarItem1_Gallery_ItemClick(object sender, GalleryItemClickEventArgs e)
{
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(e.Item.Caption);
}
- 关于DEV皮肤的换肤 也是系统风格的代码 C#
- c#.net简单的换皮肤代码
- DEV皮肤的使用方法
- 网页换皮肤的实现
- Flex-换皮肤的as
- 网页换皮肤的实现
- 关于代码风格的考察。。。
- 关于单片机代码的风格
- 关于代码 风格的思考
- “OutLookBar”工具条不支持皮肤/换肤的问题 (IrisSkin2.dll 皮肤)
- 今天换了个清淡的皮肤
- 换一个不合时节的皮肤
- 新的动画换皮肤设想~
- 可换皮肤的动画--二
- 为你的程序换个皮肤
- javascript实现换皮肤的一种思路
- 给页面换皮肤的思考
- c# 皮肤的添加
- UILabel换行及溢出省略号
- WTL头文件列表及简单介绍
- 让程序在崩溃时体面的退出之Unhandled Exception
- android-bitmap创建设置图片
- 笑对人生的xp
- 关于DEV皮肤的换肤 也是系统风格的代码 C#
- Android low memory killer 详解
- 发送消息,避免数据损失 --数据库维护经验一则
- AT&T汇编与gcc内联汇编
- 提高javascript性能之 条件语句
- Connection Shareable测试
- 在oracle中,用union合并blob类型
- Linux内核实践 - 如何添加网络协议[三]:实现
- Android的对话框----(Dialog)