用C#实现一种超酷的任务栏滑出式提醒框

marginwidth="0" marginheight="0" src="http://218.16.120.35:65001/PC/Global/images/b.html" frameborder="0" width="728" scrolling="no" height="90">

// C# TaskbarNotifier Class v1.0
// by John O'Byrne - 02 december 2002
// 01 april 2003 : Small fix in the OnMouseUp handler
// 11 january 2003 : Patrick Vanden Driessche <[email protected]> added a few enhancements
//           Small Enhancements/Bugfix
//           Small bugfix: When Content text measures larger than the corresponding ContentRectangle
//                         the focus rectangle was not correctly drawn. This has been solved.
//           Added KeepVisibleOnMouseOver
//           Added ReShowOnMouseOver
//           Added If the Title or Content are too long to fit in the corresponding Rectangles,
//                 the text is truncateed and the ellipses are appended (StringTrimming).

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace CustomUIControls
{
 /// <summary>
 /// TaskbarNotifier allows to display MSN style/Skinned instant messaging popups
 /// </summary>
 public class TaskbarNotifier : System.Windows.Forms.Form
 {
  #region TaskbarNotifier Protected Members
  protected Bitmap BackgroundBitmap = null;
  protected Bitmap CloseBitmap = null;
  protected Point CloseBitmapLocation;
  protected Size CloseBitmapSize;
  protected Rectangle RealTitleRectangle;
  protected Rectangle RealContentRectangle;
  protected Rectangle WorkAreaRectangle;
  protected Timer timer = new Timer();
  protected TaskbarStates taskbarState = TaskbarStates.hidden;
  protected string titleText;
  protected string contentText;
  protected Color normalTitleColor = Color.FromArgb(255,0,0);
  protected Color hoverTitleColor = Color.FromArgb(255,0,0);
  protected Color normalContentColor = Color.FromArgb(0,0,0);
  protected Color hoverContentColor = Color.FromArgb(0,0,0x66);
  protected Font normalTitleFont = new Font("Arial",12,FontStyle.Regular,GraphicsUnit.Pixel);
  protected Font hoverTitleFont = new Font("Arial",12,FontStyle.Bold,GraphicsUnit.Pixel);
  protected Font normalContentFont = new Font("Arial",11,FontStyle.Regular,GraphicsUnit.Pixel);
  protected Font hoverContentFont = new Font("Arial",11,FontStyle.Regular,GraphicsUnit.Pixel);
  protected int nShowEvents;
  protected int nHideEvents;
  protected int nVisibleEvents;
  protected int nIncrementShow;
  protected int nIncrementHide;
  protected bool bIsMouseOverPopup = false;
  protected bool bIsMouseOverClose = false;
  protected bool bIsMouseOverContent = false;
  protected bool bIsMouseOverTitle = false;
  protected bool bIsMouseDown = false;
  protected bool bKeepVisibleOnMouseOver = true;   // Added Rev 002
  protected bool bReShowOnMouseOver = false;    // Added Rev 002
  #endregion
      
  #region TaskbarNotifier Public Members
  public Rectangle TitleRectangle;
  public Rectangle ContentRectangle;
  public bool TitleClickable = false;
  public bool ContentClickable = true;
  public bool CloseClickable = true;
  public bool EnableSelectionRectangle = true;
  public event EventHandler CloseClick = null;
  public event EventHandler TitleClick = null;
  public event EventHandler ContentClick = null;
  #endregion
 
  #region TaskbarNotifier Enums
  /// <summary>
  /// List of the different popup animation status
  /// </summary>
  public enum TaskbarStates
  {
   hidden = 0,
   appearing = 1,
   visible = 2,
   disappearing = 3
  }
  #endregion

  #region TaskbarNotifier Constructor
  /// <summary>
  /// The Constructor for TaskbarNotifier
  /// </summary>
  public TaskbarNotifier()
  {
   // Window Style
   FormBorderStyle = FormBorderStyle.None;
   WindowState = FormWindowState.Minimized;
   base.Show();
   base.Hide();
   WindowState = FormWindowState.Normal;
   ShowInTaskbar = false;
   TopMost = true;
   MaximizeBox = false;
   MinimizeBox = false;
   ControlBox = false;
   
   timer.Enabled = true;
   timer.Tick += new EventHandler(OnTimer);
  }
  #endregion

  #region TaskbarNotifier Properties
  /// <summary>
  /// Get the current TaskbarState (hidden, showing, visible, hiding)
  /// </summary>
  public TaskbarStates TaskbarState
  {
   get
   {
    return taskbarState;
   }
  }

  /// <summary>
  /// Get/Set the popup Title Text
  /// </summary>
  public string TitleText
  {
   get
   {
    return titleText;
   }
   set
   {
    titleText=v

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值