DEV 使用心得

技术文章 10个月前 完美者
1,401 0

标签:add   bsp   样式设置   imagelist   skin   ide   +=   images   ras   

1、设置所有窗体样式

///主程序

static void Main()
{
DevExpress.Skins.SkinManager.EnableFormSkins();

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

string skname = BdConfig.ini.ReadString("Skin", "skname", "Office 2010 Blue");
UserLookAndFeel.Default.SetSkinStyle(skname);//皮肤主题
//UserLookAndFeel.Default.SetSkinStyle("Black");//黑色主题
//有下面这些主题可以选择(具体可以看dev的Demon里)
//"|DevExpress Style|Caramel|Money Twins|DevExpress Dark Style|
//iMaginary|Lilian|Black|Blue|Office 2010 Blue|Office 2010 Black|Office 2010 Silver|
//Office 2007 Blue|Office 2007 Black|Officmetre 2007 Silver|Office 2007 Green|Office 2007 Pink|
//Seven|Seven Classic|Darkroom|McSkin|Sharp|Sharp Plus|Foggy|Dark Side|Xmas (Blue)|
//Springtime|Summer|Pumpkin|Valentine|Stardust|Coffee|Glass Oceans|High Contrast|Liquid Sky|London Liquid Sky|The Asphalt World|Blueprint|"
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainXtraForm());
}

 

2、xtraTabbedMdiManager1 控件使用

 

private Dictionary<Form, int> dicPages = new Dictionary<Form, int>();

 

private void PageChanged(T_Bd_Authority dto)
{
try
{
bool bHave = false;
foreach (Form f in dicPages.Keys)
{
if (f == null)
{
continue;
}
if (dicPages[f]==dto.FId)
{
bHave = true;
xtraTabbedMdiManager1.SelectedPage = xtraTabbedMdiManager1.Pages[f];
break;
}
}
if (bHave == false)
{
Form childForm = getForm(dto.FId);

if (childForm == null)
{
return;
}
//Form1 childForm = new Form1();
childForm.MdiParent = this;
// 子窗体的 Text 就是 Tab页中的标题 ,我这里是直接取 navItem中的标题作为 tab页的标题
childForm.Text = dto.FName;
// 显示
childForm.Show();
ImageList imgs = (ImageList)tlAuthority.SelectImageList;
if (imgs != null && imgs.Images.Count - 1 >= dto.FId - 1)
{
xtraTabbedMdiManager1.Pages[childForm].Image = imgs.Images[dto.FId - 1];
}

xtraTabbedMdiManager1.SelectedPage = xtraTabbedMdiManager1.Pages[childForm];
//xtraTabbedMdiManager1.Pages[childForm].ShowCloseButton = DevExpress.Utils.DefaultBoolean.True;

dicPages.Add(childForm, dto.FId);
//xtraTabControl1.SelectedTabPageIndex = i;
}
}
catch(Exception ex)
{

}

}
private Form getForm(int FId)
{
try
{
//string formtag = "";
//string DllName = "";
//switch (FId)
//{
// case 3:
// formtag = "tlStaff.StaffForm";
// DllName = "tlStaff.dll";
// break;
// case 6:
// formtag = "MaterialsBill.MaterialsForm";
// DllName = "MaterialsBill.dll";
// break;
// default:
// break;
//}
//if (string.IsNullOrEmpty(DllName))
//{
// return null;
//}
//Assembly ass = Assembly.LoadFile(Application.StartupPath+"\\"+DllName);
//var o = ass.CreateInstance(formtag);
//XtraForm f = o as XtraForm;
//return f;

Form F = null;
switch (FId)
{
case 3:
F = new tlStaff.StaffForm();
break;
case 6:
F = new MaterialsBill.MaterialsForm();
break;
case 7:
F = new MaterialsBackBillForm();
break;
default:
break;
}
return F;

}
catch (Exception e)
{
return null;
}
}

 

3、皮肤选择框下拉样式设置

 

volatile bool hasGetItemData = false;
/// <summary>
/// 获取皮肤
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void skinBarSubItem1_GetItemData(object sender, EventArgs e)
{
if (!hasGetItemData)
{
hasGetItemData = true;
BarSubItem barSubItem = (BarSubItem)sender;
BarItemLinkCollection barItemLinks = barSubItem.ItemLinks;
addSkinItemClick(barItemLinks);
}
}
private void addSkinItemClick(BarItemLinkCollection collection)
{
foreach (BarItemLink itemLink in collection)
{
if (itemLink.Item is BarSubItem)
{
addSkinItemClick(((BarSubItem)itemLink.Item).ItemLinks);
}
else
{
itemLink.Item.ItemClick += changeSkin;
}
}
}
void changeSkin(object sender, ItemClickEventArgs e)
{
string skinName = e.Item.Caption;
BdConfig.ini.WriteString("Skin", "skname", skinName);
}

 

DEV 使用心得

标签:add   bsp   样式设置   imagelist   skin   ide   +=   images   ras   

原文地址:https://www.cnblogs.com/dengronghua/p/14127938.html

版权声明:完美者 发表于 2020-12-18 12:28:41。
转载请注明:DEV 使用心得 | 完美导航

暂无评论

暂无评论...