using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace MYQQ { public partial class FrmUserInformation : Form { public Point point; public FrmUserInformation() { InitializeComponent(); } //悬浮至好友Q名时 private void lblChatName_MouseEnter(object sender, EventArgs e) { lblName.Font = new Font("微软雅黑", 16F, FontStyle.Underline); } //离开好友Q名时 private void lblChatName_MouseLeave(object sender, EventArgs e) { lblName.Font = new Font("宋体", 9F); } //窗口加载时 private void FrmInformation_Load(object sender, EventArgs e) { //初始化窗口出现位置 this.Location = point; lblName.Text = UserHelper.myNickName; } //窗体重绘时 private void FrmUserInformation_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; SolidBrush sb = new SolidBrush(Color.FromArgb(100, 255, 255, 255)); g.FillRectangle(sb, new Rectangle(new Point(1, Height - 103), new Size(Width - 2, 80))); } #region 渐变效果 public bool isOpend = false; /// <summary> /// 隐藏 /// </summary> public new void Hide() { timHide.Enabled = true; } public new void Show() { this.Location = point; timShow.Enabled = true; } #endregion /* 代码思路:隐藏的时候,让窗体渐渐的隐藏,开始的时候,窗体渐渐显示; */ #region 总计时器 //计时器 private void timShow_Tick(object sender, EventArgs e) { base.Show(); if (this.Opacity <1) { this.Opacity = this.Opacity + 0.1; } if (this.Opacity == 1.0) { timShow.Enabled = false; } } #endregion private void timHide_Tick(object sender, EventArgs e) { if (this.Opacity > 0) { this.Opacity = this.Opacity - 0.1; } if (this.Opacity == 0.0) { timHide.Enabled = false; base.Hide(); } } } }