PDA

View Full Version : مشکل در devexpress



RIG000
یک شنبه 24 بهمن 1389, 23:42 عصر
سلام راستش من یه تاپیک زدم اما حذفش مردن . (جستجو) جسنجو کردم اما به جواب نریسدم . یه چزهایی خودم بلدم اما میخام بدونم چیکار باید کنم که نوار فنوان برنامه مه اسم
پروژه توش هست تغییرات اسکین رو اون هم اعمال بشه . ممنون

mohammad_2039
دوشنبه 25 بهمن 1389, 07:25 صبح
سلام
لطفا این چیز هایی که نوشتی رو بی زحمت یه دور بخون ببین خودت چیزی ازش میفهمی آخه :گیج::اشتباه:

Reza_Yarahmadi
دوشنبه 25 بهمن 1389, 09:29 صبح
سلام راستش من یه تاپیک زدم اما حذفش مردن . (جستجو) جسنجو کردم اما به جواب نریسدم . یه چزهایی خودم بلدم اما میخام بدونم چیکار باید کنم که نوار فنوان برنامه مه اسم
پروژه توش هست تغییرات اسکین رو اون هم اعمال بشه . ممنون
فكر كنم ركورد غلط املايي رو شكونديد!! :چشمک:
من براي مديريت اسكين برنامه هام از كلاس زير استفاده ميكنم. شما هم ميتونيد ازش استفاده كنيد.
قبل از استفاده dllهاي زير به پروژه اضافه كنيد

DevExpress.BonusSkins
DevExpress.OfficeSkins

public class SkinControl
{
static bool mustregisterDevStyle = true;
static void RegisterDevStyles ()
{
if (!mustregisterDevStyle) return;
mustregisterDevStyle = false;
try
{
DevExpress.UserSkins.OfficeSkins.Register();
DevExpress.UserSkins.BonusSkins.Register();
DevExpress.Skins.SkinManager.EnableFormSkins();
}
catch
{
}
}
static string currentSkinName = "";
public const String DefSkinName = "Office 2010 Silver";

static string SkinFileName
{
get
{
return Application.ExecutablePath + "\\SkinNameV02.ini";
}
}
public static String SkinNameForUser
{
get
{
string result;
try
{
if (System.IO.File.Exists(SkinFileName))
{
result = System.IO.File.ReadAllText(SkinFileName, Encoding.Unicode);
result = result.Trim().Replace(Environment.NewLine, "").Replace("\r", "");
if (result == "")
return DefSkinName;
return result;
}

}
catch
{
}
return DefSkinName;
}
set
{
try
{
SetDevFormsStyle(value);
System.IO.File.WriteAllText(SkinFileName,value,Enc oding.Unicode);
}
catch
{
}
}
}
public static void SetSkinForUser ()
{
SetDevFormsStyle(SkinNameForUser);
}

static List<string> _DevSkinNames;
public static List<string> GetDevSkinNames (Boolean ByRefresh)
{
if (_DevSkinNames == null || ByRefresh)
{
RegisterDevStyles();
_DevSkinNames = new List<string>();
foreach (DevExpress.Skins.SkinContainer skin in DevExpress.Skins.SkinManager.Default.Skins)
_DevSkinNames.Add(skin.SkinName);
if (!_DevSkinNames.Contains("WindowsXP"))
_DevSkinNames.Add("WindowsXP");
}
return _DevSkinNames;
}
static void SetDevFormsStyle (String skinName)
{
try
{
RegisterDevStyles();
currentSkinName = DevExpress.Skins.SkinManager.Default.GetValidSkinN ame(skinName);
DevExpress.LookAndFeel.UserLookAndFeel.Default.Set SkinStyle(currentSkinName);
if (skinName == "WindowsXP")
{
DevExpress.LookAndFeel.UserLookAndFeel.Default.Use DefaultLookAndFeel = false;
DevExpress.LookAndFeel.UserLookAndFeel.Default.Use WindowsXPTheme = true;
}
else
{
DevExpress.LookAndFeel.UserLookAndFeel.Default.Use DefaultLookAndFeel = true;
DevExpress.LookAndFeel.UserLookAndFeel.Default.Use WindowsXPTheme = false;
}
}
catch
{
}
}

public static void SetBackgroundImage (Control cont,int indent)
{
DevExpress.XtraEditors.SimpleButton sampleControlForImage = new DevExpress.XtraEditors.SimpleButton();
sampleControlForImage.LookAndFeel.SetSkinStyle(cur rentSkinName);
int width = cont.Width;
int height = cont.Height;
if (width < 200)
width = 200;
if (height < 400)
height = 400;
cont.BackgroundImage = GetSkinImage(sampleControlForImage,width,height,in dent);
cont.BackgroundImageLayout = ImageLayout.Stretch;
}
static System.Drawing.Bitmap GetSkinImage (DevExpress.XtraEditors.SimpleButton sampleCon,int width,int height,int indent)
{
try
{
System.Drawing.Bitmap image = new System.Drawing.Bitmap(width,height);
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image))
{
DevExpress.Utils.Drawing.StyleObjectInfoArgs info = new DevExpress.Utils.Drawing.StyleObjectInfoArgs(new DevExpress.Utils.Drawing.GraphicsCache(g));
info.Bounds = new System.Drawing.Rectangle(0,0,width,height);
sampleCon.LookAndFeel.Painter.GroupPanel.DrawObjec t(info);
}
return image;
}
catch
{
return null;
}

}
}
براي استفاده هم بصورت زير عمل كنيد

SkinControl.SkinNameForUser = "Your Skin Name"