//去焦点
btnSet.TabStop = false;
//设置按钮透明,进入后半透明
SetBtnStyle(btnSet);
private void SetBtnStyle(Button btn)
{
btn.FlatStyle = FlatStyle.Flat; //样式
btn.ForeColor = Color.Transparent;//前景
btn.BackColor = Color.Transparent;//去背景
btn.FlatAppearance.BorderSize = 0;//去边线
btn.FlatAppearance.MouseOverBackColor = Color.FromArgb(50, 40, 60, 82);
btn.FlatAppearance.MouseDownBackColor = Color.FromArgb(50, 40, 60, 82);
}
对于image的stretch,一般在控件的sizemode属性中,对于devexpress的pictureEdit控件则如下设置:
pictureEdit1.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Stretch;
form中的backimage,需要strectch时,则设置backgroupImageLayout属性为stretch.
internal static string LoadBackImage(XtraForm sender, string sfile,string sDefaultFile, bool bDirectLoad = false)
{
if (!bDirectLoad)
{
OpenFileDialog fd = new System.Windows.Forms.OpenFileDialog();
fd.Filter = "jpg文件(*.jpg)|*.jpg|png文件(*.png)|*.png";
if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
sfile = fd.FileName;
}
if (string.IsNullOrEmpty(sfile))
{//获得缺省的图片文件
sfile = sDefaultFile;
}
if (!string.IsNullOrEmpty(sfile))
{
Image im = Image.FromFile(sfile);
sender.BackgroundImage = im;
sender.BackgroundImageLayout = ImageLayout.Stretch;
}
else
{
sender.BackgroundImage = null;
}
return sfile;
}