using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Lskj.ProductDynamic.Controls { public partial class ImageButton : UserControl { /// /// this label控件 /// private DevExpress.XtraEditors.LabelControl _imageLabel; public DevExpress.XtraEditors.LabelControl ImageLabel { get { _imageLabel = this.imageLabel; return _imageLabel; } set { _imageLabel = value; } } private DevExpress.XtraEditors.LabelControl _simpleButton; /// /// this simpleButton控件 /// public DevExpress.XtraEditors.LabelControl SimpleButton { get { _simpleButton = this.simplebButton; return _simpleButton; } set { _simpleButton = value; } } /// /// 按钮模型 /// public ProductDynamicBtnModel productDynamicBtnModel; public ImageButton(DataRow row) { InitializeComponent(); productDynamicBtnModel = new ProductDynamicBtnModel(row); this.Load += new EventHandler(OnImageButton_Load); this.SimpleButton.MouseMove += new MouseEventHandler(OnSimpleButton_MouseMove); this.simplebButton.MouseLeave += new EventHandler(OnSimplebButton_MouseLeave); } /// /// 窗体加载时 /// /// /// private void OnImageButton_Load(object sender, EventArgs e) { this.imageLabel.Width = this.Height; this.simplebButton.BackColor = this.BackColor; if (productDynamicBtnModel != null) { this.simplebButton.Text = productDynamicBtnModel.ProductName; try { //this.imageLabel.Appearance.Image = productDynamicBtnModel.ProductPic; } catch (Exception) { } } } /// /// 鼠标离开事件 /// /// /// private void OnSimplebButton_MouseLeave(object sender, EventArgs e) { DevExpress.XtraEditors.LabelControl labelBtn = (DevExpress.XtraEditors.LabelControl)sender; labelBtn.BackColor = Color.Transparent; } /// /// 鼠标滑过事件 /// /// /// private void OnSimpleButton_MouseMove(object sender, MouseEventArgs e) { DevExpress.XtraEditors.LabelControl labelBtn = (DevExpress.XtraEditors.LabelControl)sender; labelBtn.BackColor = ColorTranslator.FromHtml("#eac205"); } } }