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; } } /// /// this numlabel控件 /// private DevExpress.XtraEditors.LabelControl _numLabel; public DevExpress.XtraEditors.LabelControl NumLabel { get { _numLabel = this.numLabel; return _numLabel; } set { _numLabel = value; } } private DevExpress.XtraEditors.LabelControl _simpleButton; /// /// this simpleButton控件 /// public DevExpress.XtraEditors.LabelControl SimpleButton { get { _simpleButton = this.simplebButton; return _simpleButton; } set { _simpleButton = value; } } /// /// 默认颜色 /// private Color emptyColor; /// /// 按钮模型 /// public ProductDynamicBtnModel productDynamicBtnModel; public DataRow focusedRow; public ImageButton(DataRow row) { InitializeComponent(); productDynamicBtnModel = new ProductDynamicBtnModel(row); this.focusedRow = row; this.Load += new EventHandler(OnImageButton_Load); this.simplebButton.MouseMove += new MouseEventHandler(OnSimpleButton_MouseMove); this.simplebButton.MouseLeave += new EventHandler(OnSimplebButton_MouseLeave); this.imageLabel.MouseMove += new MouseEventHandler(OnSimpleButton_MouseMove); this.imageLabel.MouseLeave += new EventHandler(OnSimplebButton_MouseLeave); this.numLabel.MouseMove += new MouseEventHandler(OnSimpleButton_MouseMove); this.numLabel.MouseLeave += new EventHandler(OnSimplebButton_MouseLeave); } /// /// 窗体加载时 /// /// /// private void OnImageButton_Load(object sender, EventArgs e) { this.emptyColor = this.BackColor; this.imageLabel.Width = this.Height + 10; if (productDynamicBtnModel != null) { this.simplebButton.Text = productDynamicBtnModel.ProductName; this.numLabel.Text = productDynamicBtnModel.Amount; try { if (!string.IsNullOrEmpty(productDynamicBtnModel.ProductPic)) { Image image = Image.FromFile(Util.PubUtil.ProductDynamic + productDynamicBtnModel.ProductPic); this.imageLabel.Appearance.Image = image; } else { this.imageLabel.Appearance.Image = global::Lskj.ProductDynamic.Properties.Resources.right; } } catch (Exception) { } } } /// /// 鼠标离开事件 /// /// /// private void OnSimplebButton_MouseLeave(object sender, EventArgs e) { this.BackColor = emptyColor; } /// /// 鼠标滑过事件 /// /// /// private void OnSimpleButton_MouseMove(object sender, MouseEventArgs e) { this.BackColor = ColorTranslator.FromHtml("#1872cd"); } } }