using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using IntelligentControlForsx.Code; using log4net; namespace IntelligentControlForsx.MyControls { public partial class Title2 : UserControl { private ILog logger = LogManager.GetLogger("AppInfoLog"); /// /// 鼠标悬停取得图片路径 /// Dictionary mouseEnterDic = new Dictionary(); /// /// 鼠标离开取得图片路径 /// Dictionary mouseLeaveDic = new Dictionary(); /// /// 鼠标离开取得图片路径 /// //Dictionary pictureDic = new Dictionary(); /// /// 鼠标点击跳转页面地址 /// Dictionary mouseClickDic = new Dictionary(); string path = UserTools.Path; public Title2() { InitializeComponent(); if (!this.DesignMode) { //string controlStr = path + @"\images\导航4.png"; //string controlStr2 = path + @"\images\导航14.png"; string controlStr = path + @"\images\ZDQT1.png"; string controlStr2 = path + @"\images\ZDQT2.png"; mouseLeaveDic.Add(this.pictureBoxControl.Name, controlStr); mouseEnterDic.Add(this.pictureBoxControl.Name, controlStr2); this.pictureBoxControl.Cursor = System.Windows.Forms.Cursors.Hand; //this.defaultPicture.Cursor = System.Windows.Forms.Cursors.Default; } } PictureBox defaultPicture; [Browsable(true), Category("Appearance")] public PictureBox DefaultPicture { get { return defaultPicture; } set { if (!this.DesignMode && defaultPicture != value) { value.Image = Image.FromFile(mouseEnterDic[value.Name]); value.Cursor = System.Windows.Forms.Cursors.Default; } defaultPicture = value; } } private void pictureBox_MouseEnter(object sender, EventArgs e) { if (!this.DesignMode) { PictureBox box = (PictureBox)sender; //if (defaultPicture.Name != box.Name) //{ // box.Image = Image.FromFile(mouseEnterDic[box.Name]); //} } } private void pictureBox_MouseLeave(object sender, EventArgs e) { if (!this.DesignMode) { PictureBox box = (PictureBox)sender; //MessageBox.Show(defaultPicture.Name + ":" + box.Name); //if (defaultPicture.Name != box.Name) //{ // box.Image = Image.FromFile(mouseLeaveDic[box.Name]); //} } } public event EventHandler MyClick; private void pictureBox_Click(object sender, EventArgs e) { if (!this.DesignMode) { PictureBox box = (PictureBox)sender; MyClick(box.Name, e); DefaultPicture = box; } } public void StyleImgChange(string functionName) { if (functionName == "pictureBoxSYZ") { this.pictureBoxControl.Visible = false; } try { PictureBox picBox = (PictureBox)this.Controls.Find(functionName, true).FirstOrDefault(); if (picBox != null) DefaultPicture = picBox; } catch (Exception ex) { logger.Info("标题切换失败" + ex.Message); } } } }