123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- 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");
- /// <summary>
- /// 鼠标悬停取得图片路径
- /// </summary>
- Dictionary<string, string> mouseEnterDic = new Dictionary<string, string>();
- /// <summary>
- /// 鼠标离开取得图片路径
- /// </summary>
- Dictionary<string, string> mouseLeaveDic = new Dictionary<string, string>();
- /// <summary>
- /// 鼠标离开取得图片路径
- /// </summary>
- //Dictionary<string, PictureBox> pictureDic = new Dictionary<string, PictureBox>();
- /// <summary>
- /// 鼠标点击跳转页面地址
- /// </summary>
- Dictionary<string, string> mouseClickDic = new Dictionary<string, string>();
- 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);
- }
- }
- }
- }
|