资源简介
c# winform右下角弹窗美化控件,实现类似网页JS右下角弹出窗口效果
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Media;
using System.Windows.Forms;
using AnimationLibrary;
namespace ControlLibraryExt
{
/// <summary>
/// 提示信息窗体
/// </summary>
[Description("提示信息窗体")]
public partial class AlertWindowExt : Form
{
#region 新增属性
#region 滚动条
private bool scrollRadius = true;
/// <summary>
/// 滚动条是否为圆角
/// </summary>
[DefaultValue(true)]
[Description("滚动条是否为圆角")]
public bool ScrollRadius
{
get { return this.scrollRadius; }
set
{
if (this.scrollRadius == value)
return;
this.scrollRadius = value;
this.Invalidate();
}
}
private int scrollThickness = 10;
/// <summary>
/// 滚动条厚度
/// </summary>
[DefaultValue(10)]
[Description("滚动条厚度")]
public int ScrollThickness
{
get { return this.scrollThickness; }
set
{
if (this.scrollThickness == value || value < 0)
return;
this.scrollThickness = value;
this.InitializeRectangle();
this.Invalidate();
}
}
private Color scrollNormalBackColor = Color.FromArgb(160, 128, 128, 128);
/// <summary>
/// 滑条背景颜色(正常)
/// </summary>
[DefaultValue(typeof(Color), "160,128, 128, 128")]
[Description("滑条背景颜色(正常)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollNormalBackColor
{
get { return this.scrollNormalBackColor; }
set
{
if (this.scrollNormalBackColor == value)
return;
this.scrollNormalBackColor = value;
this.Invalidate();
}
}
#endregion
#region 滚动条滑块
private int scrollSlideThickness = 6;
/// <summary>
/// 滑块条厚度
/// </summary>
[DefaultValue(6)]
[Description("滑块条厚度")]
public int ScrollSlideThickness
{
get { return this.scrollSlideThickness; }
set
{
if (this.scrollSlideThickness == value || value < 0)
return;
this.scrollSlideThickness = value;
this.InitializeRectangle();
this.Invalidate();
}
}
private Color scrollSlideNormalBackColor = Color.FromArgb(150, 64, 64, 64);
/// <summary>
/// 滑块背景颜色(正常)
/// </summary>
[DefaultValue(typeof(Color), "150, 64, 64, 64")]
[Description("滑块背景颜色(正常)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollSlideNormalBackColor
{
get { return this.scrollSlideNormalBackColor; }
set
{
if (this.scrollSlideNormalBackColor == value)
return;
this.scrollSlideNormalBackColor = value;
this.Invalidate();
}
}
private Color scrollSlideEnterBackColor = Color.FromArgb(200, 64, 64, 64);
/// <summary>
/// 滑块背景颜色(鼠标进入)
/// </summary>
[DefaultValue(typeof(Color), "200, 64, 64, 64")]
[Description("滑块背景颜色(鼠标进入)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollSlideEnterBackColor
{
get { return this.scrollSlideEnterBackColor; }
set
{
if (this.scrollSlideEnterBackColor == value)
return;
this.scrollSlideEnterBackColor = value;
this.Invalidate();
}
}
#endregion
#region 滚动条按钮
private bool scrollBtnShow = false;
/// <summary>
/// 是否显示按钮
/// </summary>
[DefaultValue(false)]
[Description("是否显示按钮")]
public bool ScrollBtnShow
{
get { return this.scrollBtnShow; }
set
{
if (this.scrollBtnShow == value)
return;
this.scrollBtnShow = value;
this.InitializeRectangle();
this.Invalidate();
}
}
private int scrollBtnHeight = 10;
/// <summary>
/// 按钮高度
/// </summary>
[DefaultValue(10)]
[Description("/// 按钮高度")]
public int ScrollBtnHeight
{
get { return this.scrollBtnHeight; }
set
{
if (this.scrollBtnHeight == value || value < 0)
return;
this.scrollBtnHeight = value;
this.InitializeRectangle();
this.Invalidate();
}
}
private Color scrollBtnNormalBackColor = Color.FromArgb(128, 128, 128);
/// <summary>
/// 按钮背景颜色(正常)
/// </summary>
[DefaultValue(typeof(Color), "128, 128, 128")]
[Description("按钮背景颜色(正常)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollBtnNormalBackColor
{
get { return this.scrollBtnNormalBackColor; }
set
{
if (this.scrollBtnNormalBackColor == value)
return;
this.scrollBtnNormalBackColor = value;
this.Invalidate();
}
}
private Color scrollBtnEnterBackColor = Color.FromArgb(128, 128, 128);
/// <summary>
/// 按钮背景颜色(鼠标进入)
/// </summary>
[DefaultValue(typeof(Color), "128, 128, 128")]
[Description("按钮背景颜色(鼠标进入)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollBtnEnterBackColor
{
get { return this.scrollBtnEnterBackColor; }
set
{
if (this.scrollBtnEnterBackColor == value)
return;
this.scrollBtnEnterBackColor = value;
this.Invalidate();
}
}
private Color scrollBtnNormalForeColor = Color.FromArgb(64, 64, 64);
/// <summary>
/// 按钮颜色(正常)
/// </summary>
[DefaultValue(typeof(Color), "64, 64, 64")]
[Description("按钮颜色(正常)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollBtnNormalForeColor
{
get { return this.scrollBtnNormalForeColor; }
set
{
if (this.scrollBtnNormalForeColor == value)
return;
this.scrollBtnNormalForeColor = value;
this.Invalidate();
}
}
private Color scrollBtnEnterForeColor = Color.FromArgb(255, 255, 255);
/// <summary>
/// 按钮颜色(鼠标进入)
/// </summary>
[DefaultValue(typeof(Color), "255, 255, 255")]
[Description("按钮颜色(鼠标进入)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollBtnEnterForeColor
{
get { return this.scrollBtnEnterForeColor; }
set
{
if (this.scrollBtnEnterForeColor == value)
return;
this.scrollBtnEnterForeColor = value;
this.Invalidate();
}
}
#endregion
#endregion
#region 重写属性
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
protected new bool DesignMode
{
get
{
if (this.GetService(typeof(IDesignerHost)) != null || System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
{
return true; //界面设计模式
}
else
{
return false;//运行时模式
}
}
}
#endregion
#region 字段
#region 工具栏
/// <summary>
/// 工具栏高度
/// </summary>
private int tool_height = 18;
/// <summary>
/// 工具栏rect
/// </summary>
private RectangleF tool_rect;
#region 工具栏图标
/// <summary>
/// 工具栏图标宽度
/// </summary>
private float tool_ico_width = 16;
/// <summary>
/// 工具栏图标高度
/// </summary>
private float tool_ico_height = 16;
/// <summary>
/// 工具栏图标rect
/// </summary>
private RectangleF tool_ico_rect;
#endregion
#region 工具栏标题
/// <summary>
/// 工具栏标题rect
/// </summary>
private RectangleF tool_title_rect;
#endregion
#region 工具栏复制按钮
/// <summary>
/// <summary>
/// 复制按钮背景色Enter
/// </summary>
private Color tool_copy_enter_color = Color.FromArgb(70, 0, 0, 0);
/// <summary>
/// 复制按钮鼠标状态
/// </summary>
private MoveStatus tool_copy_status = MoveStatus.Normal;
/// 工具栏复制按钮rect
/// </summary>
private RectangleF tool_copy_rect;
/// <summary>
/// 工具栏复制按钮图片宽度
/// </summary>
private float tool_copy_image_width = 12;
/// <summary>
/// 工具栏复制按钮图片高度
/// </summary>
private float tool_copy_image_height = 12;
/// <summary>
/// 工具栏复制按钮图片
/// </summary>
private static Image tool_copy_image = (Image)Resources.复制;
/// <summary>
/// 工具栏复制按钮图片rect
/// </summary>
private RectangleF tool_copy_image_rect;
#endregion
#region 工具栏关闭按钮
/// <summary>
/// <summary>
/// 关闭按钮背景色Enter
/// </summary>
private Color tool_close_enter_color = Color.FromArgb(70, 0, 0, 0);
/// <summary>
/// 关闭按钮鼠标状态
/// </summary>
private MoveStatus tool_close_status = MoveStatus.Normal;
/// 工具栏关闭按钮rect
/// </summary>
private RectangleF tool_close_rect;
/// <summary>
/// 工具栏关闭按钮图片宽度
/// </summary>
private float tool_close_image_width = 12;
/// <summary>
/// 工具栏关闭按钮图片高度
/// </summary>
private float tool_close_image_height = 12;
/// <summary>
/// 工具栏关闭按钮图片
/// </summary>
private static Image tool_close_image = (Image)Resources.关闭;
/// <summary>
/// 工具栏关闭按钮图片rect
/// </summary>
private RectangleF tool_close_image_rect;
#endregion
#endregion
#region 主容器
/// <summary>
/// 主内容rect
/// </summary>
private RectangleF content_rect;
/// <summary>
/// 提示内容rect
/// </summary>
private RectangleF text_rect;
/// <summary>
/// 提示内容鼠标状态
/// </summary>
private MoveStatus text_status = MoveStatus.Normal;
/// <summary>
/// 提示内容真实rect
/// </summary>
private RectangleF text_reality_rect;
/// <summary>
/// 提示内容左边距
/// </summary>
private int text_left_padding = 5;
#endregion
#region 滚动条
/// <summary>
/// 滚动条
/// </summary>
private ScrollItem scroll = new ScrollItem();
/// <summary>
/// 滚动条滑块
/// </summary>
private ScrollItem scroll_slide = new ScrollItem();
/// <summary>
/// 滚动条上滚按钮
/// </summary>
private ScrollItem scroll_pre = new ScrollItem();
/// <summary>
/// 滚动条下滚按钮
/// </summary>
private ScrollItem scroll_next = new ScrollItem();
#endregion
/// <summary>
/// 是否按下鼠标
/// </summary>
private bool ismovedown = false;
/// <summary>
/// 鼠标按下的坐标
/// </summary>
private Point movedownpoint = Point.Empty;
/// <summary>
/// 提示信息
/// </summary>
private DesktopAlert.AlertItem ai = null;
#endregion
#region 扩展
/// <summary>
/// 移动鼠标,按住或释放鼠标时发生
/// </summary>
public const int WM_NCHITTEST = 0x0084;
private const int HTLEFT = 10;
#endregion
public AlertWindowExt()
{
InitializeComponent();
}
public AlertWindowExt(DesktopAlert.AlertItem ai)
{
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Selectable, true);
this.ai = ai;
InitializeComponent();
this.ControlBox = false;
this.FormBorderStyle = FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = SizeGripStyle.Hide;
this.StartPosition = FormStartPosition.Manual;
this.Size = this.ai.Win_Size;
this.MinimumSize = this.ai.Win_Size;
this.Location = this.ai.Win_Location;
this.InitializeRectangle();
}
#region 重写
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (this.ai == null)
return;
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
SolidBrush back_sb = new SolidBrush(this.ai.BackColor);
#region 背景
g.FillRectangle(back_sb, new RectangleF(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, this.ClientRectangle.Height));
#endregion
#region 提示信息文本
SolidBrush text_sb = new SolidBrush(this.ai.TextColor);
StringFormat text_sf = new StringFormat() { Trimming = StringTrimming.Character };
g.DrawString(this.ai.Text, this.Font, text_sb, this.GetDisplayRectangle(), text_sf);
text_sf.Dispose();
text_sb.Dispose();
#endregion
#region 滚动条
if (this.scroll.Rect.Height > this.scroll_slide.Rect.Height)
{
#region 画笔
Pen scroll_normal_back_pen = new Pen(this.ScrollNormalBackColor, this.ScrollThickness);
if (this.ScrollRadius && !this.ScrollBtnShow)
{
scroll_normal_back_pen.StartCap = LineCap.Round;
scroll_normal_back_pen.EndCap = LineCap.Round;
}
Pen scroll_slide_back_pen = new Pen(this.scroll_slide.Status == MoveStatus.Normal ? this.ScrollSlideNormalBackColor : this.ScrollSlideEnterBackColor, this.ScrollSlideThickness);
if (this.ScrollRadius)
{
scroll_slide_back_pen.StartCap = LineCap.Round;
scroll_slide_back_pen.EndCap = LineCap.Round;
}
SolidBrush scroll_pre_back_sb = null;
Pen scroll_pre_pen = null;
SolidBrush scroll_next_back_sb = null;
Pen scroll_next_pen = null;
if (this.ScrollRadius && !this.ScrollBtnShow)
{
scroll_pre_back_sb = new SolidBrush(this.scroll_pre.Status == MoveStatus.Normal ? this.ScrollBtnNormalBackColor : this.ScrollBtnEnterBackColor);
scroll_pre_pen = new Pen(this.scroll_pre.Status == MoveStatus.Normal ? this.ScrollBtnNormalForeColor : this.ScrollBtnEnterForeColor, this.ScrollThickness - 2) { EndCap = LineCap.Triangle };
scroll_next_back_sb = new SolidBrush(this.scroll_next.Status == MoveStatus.Normal ? this.ScrollBtnNormalBackColor : this.ScrollBtnEnterBackColor);
scroll_next_pen = new Pen(this.scroll_next.Status == MoveStatus.Normal ? this.ScrollBtnNormalForeColor : this.ScrollBtnEnterForeColor, this.ScrollThickness - 2) { EndCap = LineCap.Triangle };
}
#endregion
#region 滚动条背景
Point scroll_start_point = new Point((int)this.scroll.Rect.X (int)(this.scroll.Rect.Width / 2f), (int)this.scroll.Rect.Y);
Point scroll_end_point = new Point((int)this.scroll.Rect.X (int)(this.scroll.Rect.Width / 2f), (int)this.scroll.Rect.Bottom);
if (this.ScrollRadius && !this.ScrollBtnShow)
{
scroll_start_point = new Point((int)this.scroll.Rect.X (int)(this.scroll.Rect.Width / 2f), (int)(this.scroll.Rect.Y this.ScrollThickness / 2f));
scroll_end_point = new Point((int)this.scroll.Rect.X (int)(this.scroll.Rect.Width / 2f), (int)(this.scroll.Rect.Bottom - this.ScrollThickness / 2f));
}
g.DrawLine(scroll_normal_back_pen, scroll_start_point, scroll_end_point);
#endregion
#region 滚动条按钮
g.FillRectangle(scroll_pre_back_sb, this.scroll_pre.Rect);
g.DrawLine(scroll_pre_pen, new PointF(this.scroll_pre.Rect.X this.scroll_pre.Rect.Width / 2f, this.scroll_pre.Rect.Bottom - this.scroll_pre.Rect.Height / 3f), new PointF(this.scroll_pre.Rect.X this.scroll_pre.Rect.Width / 2f, this.scroll_pre.Rect.Bottom - this.scroll_pre.Rect.Height / 3f - 1));
g.FillRectangle(scroll_next_back_sb, this.scroll_next.Rect);
g.DrawLine(scroll_next_pen, new PointF(this.scroll_next.Rect.X this.scroll_next.Rect.Width / 2f, this.scroll_next.Rect.Y this.scroll_pre.Rect.Height / 3f), new PointF(this.scroll_next.Rect.X this.scroll_next.Rect.Width / 2f, this.scroll_next.Rect.Y this.scroll_pre.Rect.Height / 3f 1));
#endregion
#region 滚动条滑块
Point scroll_slide_start_point = new Point((int)this.scroll_slide.Rect.X (int)(this.scroll_slide.Rect.Width / 2f), (int)this.scroll_slide.Rect.Y);
Point scroll_slide_end_point = new Point((int)this.scroll_slide.Rect.X (int)(this.scroll_slide.Rect.Width / 2f), (int)this.scroll_slide.Rect.Bottom);
if (this.ScrollRadius)
{
scroll_slide_start_point = new Point((int)this.scroll_slide.Rect.X (int)(this.scroll_slide.Rect.Width / 2f), (int)this.scroll_slide.Rect.Y this.ScrollSlideThickness / 2);
scroll_slide_end_point = new Point((int)this.scroll_slide.Rect.X (int)(this.scroll_slide.Rect.Width / 2f), (int)this.scroll_slide.Rect.Bottom - this.ScrollSlideThickness / 2);
}
g.DrawLine(scroll_slide_back_pen, scroll_slide_start_point, scroll_slide_end_point);
#endregion
#region 释放画笔
scroll_normal_back_pen.Dispose();
scroll_slide_back_pen.Dispose();
if (scroll_pre_back_sb != null)
scroll_pre_back_sb.Dispose();
if (scroll_pre_pen != null)
scroll_pre_pen.Dispose();
if (scroll_next_back_sb != null)
scroll_next_back_sb.Dispose();
if (scroll_next_pen != null)
scroll_next_pen.Dispose();
#endregion
}
#endregion
#region 工具栏
#region 工具栏背景
g.FillRectangle(back_sb, this.tool_rect);
#endregion
#region 工具栏图标
if (this.ai.Image != null)
{
g.DrawImage(this.ai.Image, this.tool_ico_rect);
}
#endregion
#region 工具栏标题
if (!String.IsNullOrWhiteSpace(this.ai.Title))
{
SolidBrush title_sb = new SolidBrush(this.ai.TextColor);
StringFormat title_sf = new StringFormat(StringFormatFlags.NoWrap | StringFormatFlags.MeasureTrailingSpaces) { LineAlignment = StringAlignment.Center };
g.DrawString(this.ai.Title, this.Font, title_sb, this.tool_title_rect, title_sf);
title_sf.Dispose();
title_sb.Dispose();
}
#endregion
#region 工具栏复制按钮
if (this.tool_copy_status == MoveStatus.Enter)
{
SolidBrush tool_copy_enter_sb = new SolidBrush(this.tool_copy_enter_color);
g.FillRectangle(tool_copy_enter_sb, this.tool_copy_rect);
tool_copy_enter_sb.Dispose();
}
g.DrawImage(tool_copy_image, this.tool_copy_image_rect);
#endregion
#region 工具栏关闭按钮
if (this.tool_close_status == MoveStatus.Enter)
{
SolidBrush tool_close_enter_sb = new SolidBrush(this.tool_close_enter_color);
g.FillRectangle(tool_close_enter_sb, this.tool_close_rect);
tool_close_enter_sb.Dispose();
}
g.DrawImage(tool_close_image, this.tool_close_image_rect);
#endregion
#endregion
back_sb.Dispose();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
if (this.DesignMode)
return;
#region 关闭
if (this.tool_close_status != MoveStatus.Normal)
{
this.tool_close_status = MoveStatus.Normal;
}
#endregion
#region 复制
if (this.tool_copy_status != MoveStatus.Normal)
{
this.tool_copy_status = MoveStatus.Normal;
}
#endregion
#region 滚动条
if (this.scroll_pre.Status != MoveStatus.Normal)
{
this.scroll_pre.Status = MoveStatus.Normal;
}
if (this.scroll_next.Status != MoveStatus.Normal)
{
this.scroll_next.Status = MoveStatus.Normal;
}
if (this.scroll_slide.Status != MoveStatus.Normal)
{
this.scroll_slide.Status = MoveStatus.Normal;
}
#endregion
this.ismovedown = false;
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (this.DesignMode)
return;
this.ismovedown = true;
this.movedownpoint = this.PointToClient(Control.MousePosition);
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
if (this.DesignMode)
return;
this.ismovedown = false;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (this.DesignMode)
return;
bool isreset = false;
Point point = this.PointToClient(Control.MousePosition);
if (!ismovedown)
{
#region 关闭
if (this.tool_close_rect.Contains(point))
{
if (this.tool_close_status != MoveStatus.Enter)
{
this.tool_close_status = MoveStatus.Enter;
this.Cursor = Cursors.Hand;
isreset = true;
}
}
else
{
if (this.tool_close_status != MoveStatus.Normal)
{
this.tool_close_status = MoveStatus.Normal;
this.Cursor = Cursors.Default;
isreset = true;
}
}
#endregion
#region 复制
if (this.tool_copy_rect.Contains(point))
{
if (this.tool_copy_status != MoveStatus.Enter)
{
this.tool_copy_status = MoveStatus.Enter;
this.Cursor = Cursors.Hand;
isreset = true;
}
}
else
{
if (this.tool_copy_status != MoveStatus.Normal)
{
this.tool_copy_status = MoveStatus.Normal;
this.Cursor = Cursors.Default;
isreset = true;
}
}
#endregion
#region 滚动条
#region scroll
if (this.scroll.Rect.Contains(point))
{
if (this.scroll.Status != MoveStatus.Enter)
{
this.scroll.Status = MoveStatus.Enter;
isreset = true;
this.Focus();
}
}
else
{
if (this.scroll.Status != MoveStatus.Normal)
{
this.scroll.Status = MoveStatus.Normal;
isreset = true;
this.Focus();
}
}
#endregion
#region scroll_pre
if (this.scroll_pre.Rect.Contains(point))
{
if (this.scroll_pre.Status != MoveStatus.Enter)
{
this.scroll_pre.Status = MoveStatus.Enter;
isreset = true;
}
}
else
{
if (this.scroll_pre.Status != MoveStatus.Normal)
{
this.scroll_pre.Status = MoveStatus.Normal;
isreset = true;
}
}
#endregion
#region scroll_next
if (this.scroll_next.Rect.Contains(point))
{
if (this.scroll_next.Status != MoveStatus.Enter)
{
this.scroll_next.Status = MoveStatus.Enter;
isreset = true;
}
}
else
{
if (this.scroll_next.Status != MoveStatus.Normal)
{
this.scroll_next.Status = MoveStatus.Normal;
isreset = true;
}
}
#endregion
#region scroll_slide
if (this.scroll_slide.Rect.Contains(point))
{
if (this.scroll_slide.Status != MoveStatus.Enter)
{
this.scroll_slide.Status = MoveStatus.Enter;
isreset = true;
}
}
else
{
if (this.scroll_slide.Status != MoveStatus.Normal)
{
this.scroll_slide.Status = MoveStatus.Normal;
isreset = true;
}
}
#endregion
#endregion
#region 文本
if (this.text_rect.Contains(point))
{
if (this.text_status != MoveStatus.Enter)
{
this.text_status = MoveStatus.Enter;
}
}
else
{
if (this.text_status != MoveStatus.Normal)
{
this.text_status = MoveStatus.Normal;
}
}
#endregion
}
if (this.ismovedown && this.scroll.Status == MoveStatus.Enter)
{
int offset = (int)((point.Y - this.movedownpoint.Y));
if (this.IsResetScroll(offset))
{
this.movedownpoint = point;
isreset = true;
}
}
if (isreset)
{
this.Invalidate();
}
}
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
if (this.DesignMode)
return;
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
#region 关闭
if (this.tool_close_status == MoveStatus.Enter)
{
this.ai.Status = this.ai.Status | DesktopAlert.AnimationStatuss.Closeing;
this.ai.Close_origin = this.Opacity;
this.ai.Close_transform = -this.Opacity;
this.ai.Close_usedTime = 0;
this.ai.Close_allTime = DesktopAlert.DefaultAllTime;
this.ai.Slide_transform = 0;
this.ai.Slide_usedTime = 0;
this.ai.Slide_allTime = 0;
if (!DesktopAlert.AnimationTime.Enabled)
{
DesktopAlert.AnimationTime.Enabled = true;
}
}
#endregion
#region 复制
else if (this.tool_copy_status == MoveStatus.Enter)
{
Clipboard.SetDataObject(this.ai.Text);
}
#endregion
#region 上滚动
else if (this.scroll_pre.Status == MoveStatus.Enter)
{
if (this.IsResetScroll(-1))
{
this.Invalidate();
}
}
#endregion
#region 下滚动
else if (this.scroll_next.Status == MoveStatus.Enter)
{
if (this.IsResetScroll(1))
{
this.Invalidate();
}
}
#endregion
}
}
protected override void OnMouseWheel(MouseEventArgs e)
{
base.OnMouseWheel(e);
if (this.DesignMode)
return;
if (this.scroll.Status == MoveStatus.Enter || this.text_status == MoveStatus.Enter)
{
int offset = e.Delta > 1 ? -1 : 1;
if (this.IsResetScroll(offset))
{
this.Invalidate();
}
}
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_NCHITTEST:
&nbs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Media;
using System.Windows.Forms;
using AnimationLibrary;
namespace ControlLibraryExt
{
/// <summary>
/// 提示信息窗体
/// </summary>
[Description("提示信息窗体")]
public partial class AlertWindowExt : Form
{
#region 新增属性
#region 滚动条
private bool scrollRadius = true;
/// <summary>
/// 滚动条是否为圆角
/// </summary>
[DefaultValue(true)]
[Description("滚动条是否为圆角")]
public bool ScrollRadius
{
get { return this.scrollRadius; }
set
{
if (this.scrollRadius == value)
return;
this.scrollRadius = value;
this.Invalidate();
}
}
private int scrollThickness = 10;
/// <summary>
/// 滚动条厚度
/// </summary>
[DefaultValue(10)]
[Description("滚动条厚度")]
public int ScrollThickness
{
get { return this.scrollThickness; }
set
{
if (this.scrollThickness == value || value < 0)
return;
this.scrollThickness = value;
this.InitializeRectangle();
this.Invalidate();
}
}
private Color scrollNormalBackColor = Color.FromArgb(160, 128, 128, 128);
/// <summary>
/// 滑条背景颜色(正常)
/// </summary>
[DefaultValue(typeof(Color), "160,128, 128, 128")]
[Description("滑条背景颜色(正常)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollNormalBackColor
{
get { return this.scrollNormalBackColor; }
set
{
if (this.scrollNormalBackColor == value)
return;
this.scrollNormalBackColor = value;
this.Invalidate();
}
}
#endregion
#region 滚动条滑块
private int scrollSlideThickness = 6;
/// <summary>
/// 滑块条厚度
/// </summary>
[DefaultValue(6)]
[Description("滑块条厚度")]
public int ScrollSlideThickness
{
get { return this.scrollSlideThickness; }
set
{
if (this.scrollSlideThickness == value || value < 0)
return;
this.scrollSlideThickness = value;
this.InitializeRectangle();
this.Invalidate();
}
}
private Color scrollSlideNormalBackColor = Color.FromArgb(150, 64, 64, 64);
/// <summary>
/// 滑块背景颜色(正常)
/// </summary>
[DefaultValue(typeof(Color), "150, 64, 64, 64")]
[Description("滑块背景颜色(正常)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollSlideNormalBackColor
{
get { return this.scrollSlideNormalBackColor; }
set
{
if (this.scrollSlideNormalBackColor == value)
return;
this.scrollSlideNormalBackColor = value;
this.Invalidate();
}
}
private Color scrollSlideEnterBackColor = Color.FromArgb(200, 64, 64, 64);
/// <summary>
/// 滑块背景颜色(鼠标进入)
/// </summary>
[DefaultValue(typeof(Color), "200, 64, 64, 64")]
[Description("滑块背景颜色(鼠标进入)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollSlideEnterBackColor
{
get { return this.scrollSlideEnterBackColor; }
set
{
if (this.scrollSlideEnterBackColor == value)
return;
this.scrollSlideEnterBackColor = value;
this.Invalidate();
}
}
#endregion
#region 滚动条按钮
private bool scrollBtnShow = false;
/// <summary>
/// 是否显示按钮
/// </summary>
[DefaultValue(false)]
[Description("是否显示按钮")]
public bool ScrollBtnShow
{
get { return this.scrollBtnShow; }
set
{
if (this.scrollBtnShow == value)
return;
this.scrollBtnShow = value;
this.InitializeRectangle();
this.Invalidate();
}
}
private int scrollBtnHeight = 10;
/// <summary>
/// 按钮高度
/// </summary>
[DefaultValue(10)]
[Description("/// 按钮高度")]
public int ScrollBtnHeight
{
get { return this.scrollBtnHeight; }
set
{
if (this.scrollBtnHeight == value || value < 0)
return;
this.scrollBtnHeight = value;
this.InitializeRectangle();
this.Invalidate();
}
}
private Color scrollBtnNormalBackColor = Color.FromArgb(128, 128, 128);
/// <summary>
/// 按钮背景颜色(正常)
/// </summary>
[DefaultValue(typeof(Color), "128, 128, 128")]
[Description("按钮背景颜色(正常)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollBtnNormalBackColor
{
get { return this.scrollBtnNormalBackColor; }
set
{
if (this.scrollBtnNormalBackColor == value)
return;
this.scrollBtnNormalBackColor = value;
this.Invalidate();
}
}
private Color scrollBtnEnterBackColor = Color.FromArgb(128, 128, 128);
/// <summary>
/// 按钮背景颜色(鼠标进入)
/// </summary>
[DefaultValue(typeof(Color), "128, 128, 128")]
[Description("按钮背景颜色(鼠标进入)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollBtnEnterBackColor
{
get { return this.scrollBtnEnterBackColor; }
set
{
if (this.scrollBtnEnterBackColor == value)
return;
this.scrollBtnEnterBackColor = value;
this.Invalidate();
}
}
private Color scrollBtnNormalForeColor = Color.FromArgb(64, 64, 64);
/// <summary>
/// 按钮颜色(正常)
/// </summary>
[DefaultValue(typeof(Color), "64, 64, 64")]
[Description("按钮颜色(正常)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollBtnNormalForeColor
{
get { return this.scrollBtnNormalForeColor; }
set
{
if (this.scrollBtnNormalForeColor == value)
return;
this.scrollBtnNormalForeColor = value;
this.Invalidate();
}
}
private Color scrollBtnEnterForeColor = Color.FromArgb(255, 255, 255);
/// <summary>
/// 按钮颜色(鼠标进入)
/// </summary>
[DefaultValue(typeof(Color), "255, 255, 255")]
[Description("按钮颜色(鼠标进入)")]
[Editor(typeof(ColorEditorExt), typeof(System.Drawing.Design.UITypeEditor))]
public Color ScrollBtnEnterForeColor
{
get { return this.scrollBtnEnterForeColor; }
set
{
if (this.scrollBtnEnterForeColor == value)
return;
this.scrollBtnEnterForeColor = value;
this.Invalidate();
}
}
#endregion
#endregion
#region 重写属性
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
protected new bool DesignMode
{
get
{
if (this.GetService(typeof(IDesignerHost)) != null || System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
{
return true; //界面设计模式
}
else
{
return false;//运行时模式
}
}
}
#endregion
#region 字段
#region 工具栏
/// <summary>
/// 工具栏高度
/// </summary>
private int tool_height = 18;
/// <summary>
/// 工具栏rect
/// </summary>
private RectangleF tool_rect;
#region 工具栏图标
/// <summary>
/// 工具栏图标宽度
/// </summary>
private float tool_ico_width = 16;
/// <summary>
/// 工具栏图标高度
/// </summary>
private float tool_ico_height = 16;
/// <summary>
/// 工具栏图标rect
/// </summary>
private RectangleF tool_ico_rect;
#endregion
#region 工具栏标题
/// <summary>
/// 工具栏标题rect
/// </summary>
private RectangleF tool_title_rect;
#endregion
#region 工具栏复制按钮
/// <summary>
/// <summary>
/// 复制按钮背景色Enter
/// </summary>
private Color tool_copy_enter_color = Color.FromArgb(70, 0, 0, 0);
/// <summary>
/// 复制按钮鼠标状态
/// </summary>
private MoveStatus tool_copy_status = MoveStatus.Normal;
/// 工具栏复制按钮rect
/// </summary>
private RectangleF tool_copy_rect;
/// <summary>
/// 工具栏复制按钮图片宽度
/// </summary>
private float tool_copy_image_width = 12;
/// <summary>
/// 工具栏复制按钮图片高度
/// </summary>
private float tool_copy_image_height = 12;
/// <summary>
/// 工具栏复制按钮图片
/// </summary>
private static Image tool_copy_image = (Image)Resources.复制;
/// <summary>
/// 工具栏复制按钮图片rect
/// </summary>
private RectangleF tool_copy_image_rect;
#endregion
#region 工具栏关闭按钮
/// <summary>
/// <summary>
/// 关闭按钮背景色Enter
/// </summary>
private Color tool_close_enter_color = Color.FromArgb(70, 0, 0, 0);
/// <summary>
/// 关闭按钮鼠标状态
/// </summary>
private MoveStatus tool_close_status = MoveStatus.Normal;
/// 工具栏关闭按钮rect
/// </summary>
private RectangleF tool_close_rect;
/// <summary>
/// 工具栏关闭按钮图片宽度
/// </summary>
private float tool_close_image_width = 12;
/// <summary>
/// 工具栏关闭按钮图片高度
/// </summary>
private float tool_close_image_height = 12;
/// <summary>
/// 工具栏关闭按钮图片
/// </summary>
private static Image tool_close_image = (Image)Resources.关闭;
/// <summary>
/// 工具栏关闭按钮图片rect
/// </summary>
private RectangleF tool_close_image_rect;
#endregion
#endregion
#region 主容器
/// <summary>
/// 主内容rect
/// </summary>
private RectangleF content_rect;
/// <summary>
/// 提示内容rect
/// </summary>
private RectangleF text_rect;
/// <summary>
/// 提示内容鼠标状态
/// </summary>
private MoveStatus text_status = MoveStatus.Normal;
/// <summary>
/// 提示内容真实rect
/// </summary>
private RectangleF text_reality_rect;
/// <summary>
/// 提示内容左边距
/// </summary>
private int text_left_padding = 5;
#endregion
#region 滚动条
/// <summary>
/// 滚动条
/// </summary>
private ScrollItem scroll = new ScrollItem();
/// <summary>
/// 滚动条滑块
/// </summary>
private ScrollItem scroll_slide = new ScrollItem();
/// <summary>
/// 滚动条上滚按钮
/// </summary>
private ScrollItem scroll_pre = new ScrollItem();
/// <summary>
/// 滚动条下滚按钮
/// </summary>
private ScrollItem scroll_next = new ScrollItem();
#endregion
/// <summary>
/// 是否按下鼠标
/// </summary>
private bool ismovedown = false;
/// <summary>
/// 鼠标按下的坐标
/// </summary>
private Point movedownpoint = Point.Empty;
/// <summary>
/// 提示信息
/// </summary>
private DesktopAlert.AlertItem ai = null;
#endregion
#region 扩展
/// <summary>
/// 移动鼠标,按住或释放鼠标时发生
/// </summary>
public const int WM_NCHITTEST = 0x0084;
private const int HTLEFT = 10;
#endregion
public AlertWindowExt()
{
InitializeComponent();
}
public AlertWindowExt(DesktopAlert.AlertItem ai)
{
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Selectable, true);
this.ai = ai;
InitializeComponent();
this.ControlBox = false;
this.FormBorderStyle = FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = SizeGripStyle.Hide;
this.StartPosition = FormStartPosition.Manual;
this.Size = this.ai.Win_Size;
this.MinimumSize = this.ai.Win_Size;
this.Location = this.ai.Win_Location;
this.InitializeRectangle();
}
#region 重写
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (this.ai == null)
return;
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
SolidBrush back_sb = new SolidBrush(this.ai.BackColor);
#region 背景
g.FillRectangle(back_sb, new RectangleF(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, this.ClientRectangle.Height));
#endregion
#region 提示信息文本
SolidBrush text_sb = new SolidBrush(this.ai.TextColor);
StringFormat text_sf = new StringFormat() { Trimming = StringTrimming.Character };
g.DrawString(this.ai.Text, this.Font, text_sb, this.GetDisplayRectangle(), text_sf);
text_sf.Dispose();
text_sb.Dispose();
#endregion
#region 滚动条
if (this.scroll.Rect.Height > this.scroll_slide.Rect.Height)
{
#region 画笔
Pen scroll_normal_back_pen = new Pen(this.ScrollNormalBackColor, this.ScrollThickness);
if (this.ScrollRadius && !this.ScrollBtnShow)
{
scroll_normal_back_pen.StartCap = LineCap.Round;
scroll_normal_back_pen.EndCap = LineCap.Round;
}
Pen scroll_slide_back_pen = new Pen(this.scroll_slide.Status == MoveStatus.Normal ? this.ScrollSlideNormalBackColor : this.ScrollSlideEnterBackColor, this.ScrollSlideThickness);
if (this.ScrollRadius)
{
scroll_slide_back_pen.StartCap = LineCap.Round;
scroll_slide_back_pen.EndCap = LineCap.Round;
}
SolidBrush scroll_pre_back_sb = null;
Pen scroll_pre_pen = null;
SolidBrush scroll_next_back_sb = null;
Pen scroll_next_pen = null;
if (this.ScrollRadius && !this.ScrollBtnShow)
{
scroll_pre_back_sb = new SolidBrush(this.scroll_pre.Status == MoveStatus.Normal ? this.ScrollBtnNormalBackColor : this.ScrollBtnEnterBackColor);
scroll_pre_pen = new Pen(this.scroll_pre.Status == MoveStatus.Normal ? this.ScrollBtnNormalForeColor : this.ScrollBtnEnterForeColor, this.ScrollThickness - 2) { EndCap = LineCap.Triangle };
scroll_next_back_sb = new SolidBrush(this.scroll_next.Status == MoveStatus.Normal ? this.ScrollBtnNormalBackColor : this.ScrollBtnEnterBackColor);
scroll_next_pen = new Pen(this.scroll_next.Status == MoveStatus.Normal ? this.ScrollBtnNormalForeColor : this.ScrollBtnEnterForeColor, this.ScrollThickness - 2) { EndCap = LineCap.Triangle };
}
#endregion
#region 滚动条背景
Point scroll_start_point = new Point((int)this.scroll.Rect.X (int)(this.scroll.Rect.Width / 2f), (int)this.scroll.Rect.Y);
Point scroll_end_point = new Point((int)this.scroll.Rect.X (int)(this.scroll.Rect.Width / 2f), (int)this.scroll.Rect.Bottom);
if (this.ScrollRadius && !this.ScrollBtnShow)
{
scroll_start_point = new Point((int)this.scroll.Rect.X (int)(this.scroll.Rect.Width / 2f), (int)(this.scroll.Rect.Y this.ScrollThickness / 2f));
scroll_end_point = new Point((int)this.scroll.Rect.X (int)(this.scroll.Rect.Width / 2f), (int)(this.scroll.Rect.Bottom - this.ScrollThickness / 2f));
}
g.DrawLine(scroll_normal_back_pen, scroll_start_point, scroll_end_point);
#endregion
#region 滚动条按钮
g.FillRectangle(scroll_pre_back_sb, this.scroll_pre.Rect);
g.DrawLine(scroll_pre_pen, new PointF(this.scroll_pre.Rect.X this.scroll_pre.Rect.Width / 2f, this.scroll_pre.Rect.Bottom - this.scroll_pre.Rect.Height / 3f), new PointF(this.scroll_pre.Rect.X this.scroll_pre.Rect.Width / 2f, this.scroll_pre.Rect.Bottom - this.scroll_pre.Rect.Height / 3f - 1));
g.FillRectangle(scroll_next_back_sb, this.scroll_next.Rect);
g.DrawLine(scroll_next_pen, new PointF(this.scroll_next.Rect.X this.scroll_next.Rect.Width / 2f, this.scroll_next.Rect.Y this.scroll_pre.Rect.Height / 3f), new PointF(this.scroll_next.Rect.X this.scroll_next.Rect.Width / 2f, this.scroll_next.Rect.Y this.scroll_pre.Rect.Height / 3f 1));
#endregion
#region 滚动条滑块
Point scroll_slide_start_point = new Point((int)this.scroll_slide.Rect.X (int)(this.scroll_slide.Rect.Width / 2f), (int)this.scroll_slide.Rect.Y);
Point scroll_slide_end_point = new Point((int)this.scroll_slide.Rect.X (int)(this.scroll_slide.Rect.Width / 2f), (int)this.scroll_slide.Rect.Bottom);
if (this.ScrollRadius)
{
scroll_slide_start_point = new Point((int)this.scroll_slide.Rect.X (int)(this.scroll_slide.Rect.Width / 2f), (int)this.scroll_slide.Rect.Y this.ScrollSlideThickness / 2);
scroll_slide_end_point = new Point((int)this.scroll_slide.Rect.X (int)(this.scroll_slide.Rect.Width / 2f), (int)this.scroll_slide.Rect.Bottom - this.ScrollSlideThickness / 2);
}
g.DrawLine(scroll_slide_back_pen, scroll_slide_start_point, scroll_slide_end_point);
#endregion
#region 释放画笔
scroll_normal_back_pen.Dispose();
scroll_slide_back_pen.Dispose();
if (scroll_pre_back_sb != null)
scroll_pre_back_sb.Dispose();
if (scroll_pre_pen != null)
scroll_pre_pen.Dispose();
if (scroll_next_back_sb != null)
scroll_next_back_sb.Dispose();
if (scroll_next_pen != null)
scroll_next_pen.Dispose();
#endregion
}
#endregion
#region 工具栏
#region 工具栏背景
g.FillRectangle(back_sb, this.tool_rect);
#endregion
#region 工具栏图标
if (this.ai.Image != null)
{
g.DrawImage(this.ai.Image, this.tool_ico_rect);
}
#endregion
#region 工具栏标题
if (!String.IsNullOrWhiteSpace(this.ai.Title))
{
SolidBrush title_sb = new SolidBrush(this.ai.TextColor);
StringFormat title_sf = new StringFormat(StringFormatFlags.NoWrap | StringFormatFlags.MeasureTrailingSpaces) { LineAlignment = StringAlignment.Center };
g.DrawString(this.ai.Title, this.Font, title_sb, this.tool_title_rect, title_sf);
title_sf.Dispose();
title_sb.Dispose();
}
#endregion
#region 工具栏复制按钮
if (this.tool_copy_status == MoveStatus.Enter)
{
SolidBrush tool_copy_enter_sb = new SolidBrush(this.tool_copy_enter_color);
g.FillRectangle(tool_copy_enter_sb, this.tool_copy_rect);
tool_copy_enter_sb.Dispose();
}
g.DrawImage(tool_copy_image, this.tool_copy_image_rect);
#endregion
#region 工具栏关闭按钮
if (this.tool_close_status == MoveStatus.Enter)
{
SolidBrush tool_close_enter_sb = new SolidBrush(this.tool_close_enter_color);
g.FillRectangle(tool_close_enter_sb, this.tool_close_rect);
tool_close_enter_sb.Dispose();
}
g.DrawImage(tool_close_image, this.tool_close_image_rect);
#endregion
#endregion
back_sb.Dispose();
}
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
if (this.DesignMode)
return;
#region 关闭
if (this.tool_close_status != MoveStatus.Normal)
{
this.tool_close_status = MoveStatus.Normal;
}
#endregion
#region 复制
if (this.tool_copy_status != MoveStatus.Normal)
{
this.tool_copy_status = MoveStatus.Normal;
}
#endregion
#region 滚动条
if (this.scroll_pre.Status != MoveStatus.Normal)
{
this.scroll_pre.Status = MoveStatus.Normal;
}
if (this.scroll_next.Status != MoveStatus.Normal)
{
this.scroll_next.Status = MoveStatus.Normal;
}
if (this.scroll_slide.Status != MoveStatus.Normal)
{
this.scroll_slide.Status = MoveStatus.Normal;
}
#endregion
this.ismovedown = false;
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (this.DesignMode)
return;
this.ismovedown = true;
this.movedownpoint = this.PointToClient(Control.MousePosition);
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
if (this.DesignMode)
return;
this.ismovedown = false;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (this.DesignMode)
return;
bool isreset = false;
Point point = this.PointToClient(Control.MousePosition);
if (!ismovedown)
{
#region 关闭
if (this.tool_close_rect.Contains(point))
{
if (this.tool_close_status != MoveStatus.Enter)
{
this.tool_close_status = MoveStatus.Enter;
this.Cursor = Cursors.Hand;
isreset = true;
}
}
else
{
if (this.tool_close_status != MoveStatus.Normal)
{
this.tool_close_status = MoveStatus.Normal;
this.Cursor = Cursors.Default;
isreset = true;
}
}
#endregion
#region 复制
if (this.tool_copy_rect.Contains(point))
{
if (this.tool_copy_status != MoveStatus.Enter)
{
this.tool_copy_status = MoveStatus.Enter;
this.Cursor = Cursors.Hand;
isreset = true;
}
}
else
{
if (this.tool_copy_status != MoveStatus.Normal)
{
this.tool_copy_status = MoveStatus.Normal;
this.Cursor = Cursors.Default;
isreset = true;
}
}
#endregion
#region 滚动条
#region scroll
if (this.scroll.Rect.Contains(point))
{
if (this.scroll.Status != MoveStatus.Enter)
{
this.scroll.Status = MoveStatus.Enter;
isreset = true;
this.Focus();
}
}
else
{
if (this.scroll.Status != MoveStatus.Normal)
{
this.scroll.Status = MoveStatus.Normal;
isreset = true;
this.Focus();
}
}
#endregion
#region scroll_pre
if (this.scroll_pre.Rect.Contains(point))
{
if (this.scroll_pre.Status != MoveStatus.Enter)
{
this.scroll_pre.Status = MoveStatus.Enter;
isreset = true;
}
}
else
{
if (this.scroll_pre.Status != MoveStatus.Normal)
{
this.scroll_pre.Status = MoveStatus.Normal;
isreset = true;
}
}
#endregion
#region scroll_next
if (this.scroll_next.Rect.Contains(point))
{
if (this.scroll_next.Status != MoveStatus.Enter)
{
this.scroll_next.Status = MoveStatus.Enter;
isreset = true;
}
}
else
{
if (this.scroll_next.Status != MoveStatus.Normal)
{
this.scroll_next.Status = MoveStatus.Normal;
isreset = true;
}
}
#endregion
#region scroll_slide
if (this.scroll_slide.Rect.Contains(point))
{
if (this.scroll_slide.Status != MoveStatus.Enter)
{
this.scroll_slide.Status = MoveStatus.Enter;
isreset = true;
}
}
else
{
if (this.scroll_slide.Status != MoveStatus.Normal)
{
this.scroll_slide.Status = MoveStatus.Normal;
isreset = true;
}
}
#endregion
#endregion
#region 文本
if (this.text_rect.Contains(point))
{
if (this.text_status != MoveStatus.Enter)
{
this.text_status = MoveStatus.Enter;
}
}
else
{
if (this.text_status != MoveStatus.Normal)
{
this.text_status = MoveStatus.Normal;
}
}
#endregion
}
if (this.ismovedown && this.scroll.Status == MoveStatus.Enter)
{
int offset = (int)((point.Y - this.movedownpoint.Y));
if (this.IsResetScroll(offset))
{
this.movedownpoint = point;
isreset = true;
}
}
if (isreset)
{
this.Invalidate();
}
}
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
if (this.DesignMode)
return;
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
#region 关闭
if (this.tool_close_status == MoveStatus.Enter)
{
this.ai.Status = this.ai.Status | DesktopAlert.AnimationStatuss.Closeing;
this.ai.Close_origin = this.Opacity;
this.ai.Close_transform = -this.Opacity;
this.ai.Close_usedTime = 0;
this.ai.Close_allTime = DesktopAlert.DefaultAllTime;
this.ai.Slide_transform = 0;
this.ai.Slide_usedTime = 0;
this.ai.Slide_allTime = 0;
if (!DesktopAlert.AnimationTime.Enabled)
{
DesktopAlert.AnimationTime.Enabled = true;
}
}
#endregion
#region 复制
else if (this.tool_copy_status == MoveStatus.Enter)
{
Clipboard.SetDataObject(this.ai.Text);
}
#endregion
#region 上滚动
else if (this.scroll_pre.Status == MoveStatus.Enter)
{
if (this.IsResetScroll(-1))
{
this.Invalidate();
}
}
#endregion
#region 下滚动
else if (this.scroll_next.Status == MoveStatus.Enter)
{
if (this.IsResetScroll(1))
{
this.Invalidate();
}
}
#endregion
}
}
protected override void OnMouseWheel(MouseEventArgs e)
{
base.OnMouseWheel(e);
if (this.DesignMode)
return;
if (this.scroll.Status == MoveStatus.Enter || this.text_status == MoveStatus.Enter)
{
int offset = e.Delta > 1 ? -1 : 1;
if (this.IsResetScroll(offset))
{
this.Invalidate();
}
}
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_NCHITTEST:
&nbs
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace AnimationLibrary
{
///
/// 线性动画函数(算法基本由Silverlight提取出来)
///
[Description(“线性动画函数(算法基本由Silverlight提取出来)“)]
public static class AnimationCore
{
#region UniformMotion
///
/// 匀速
///
/// 要变换的起始值
/// 要变换的总值
/// 已进行动画时间
/// 总动画时间
///
public static double UniformMotion(double origin double transform double usedTime double allTime)
{
return origin + transform * UniformMotionCore(usedTime allTime);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-06-27 22:55 右下角弹窗美化控件\
目录 0 2020-06-27 22:55 右下角弹窗美化控件\AnimationLibrary\
文件 21704 2020-06-19 21:10 右下角弹窗美化控件\AnimationLibrary\AnimationCore.cs
文件 2652 2020-06-22 11:49 右下角弹窗美化控件\AnimationLibrary\AnimationLibrary.csproj
文件 21699 2020-06-19 21:10 右下角弹窗美化控件\AnimationLibrary\AnimationTimer.cs
目录 0 2020-06-27 22:55 右下角弹窗美化控件\AnimationLibrary\bin\
目录 0 2020-06-27 22:56 右下角弹窗美化控件\AnimationLibrary\bin\Debug\
文件 19968 2020-06-27 22:56 右下角弹窗美化控件\AnimationLibrary\bin\Debug\AnimationLibrary.dll
文件 44544 2020-06-27 22:56 右下角弹窗美化控件\AnimationLibrary\bin\Debug\AnimationLibrary.pdb
目录 0 2020-06-27 22:55 右下角弹窗美化控件\AnimationLibrary\Design\
文件 1005 2020-06-19 21:10 右下角弹窗美化控件\AnimationLibrary\Design\EmptyExpandableob
目录 0 2020-06-27 22:55 右下角弹窗美化控件\AnimationLibrary\obj\
目录 0 2020-06-27 22:56 右下角弹窗美化控件\AnimationLibrary\obj\Debug\
文件 500 2020-06-27 22:56 右下角弹窗美化控件\AnimationLibrary\obj\Debug\AnimationLibrary.csproj.FileListAbsolute.txt
文件 19968 2020-06-27 22:56 右下角弹窗美化控件\AnimationLibrary\obj\Debug\AnimationLibrary.dll
文件 44544 2020-06-27 22:56 右下角弹窗美化控件\AnimationLibrary\obj\Debug\AnimationLibrary.pdb
文件 5904 2020-06-27 22:56 右下角弹窗美化控件\AnimationLibrary\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2020-06-22 12:43 右下角弹窗美化控件\AnimationLibrary\obj\Debug\TempPE\
目录 0 2020-06-27 22:55 右下角弹窗美化控件\AnimationLibrary\Properties\
文件 1410 2020-06-22 01:55 右下角弹窗美化控件\AnimationLibrary\Properties\AssemblyInfo.cs
目录 0 2020-06-27 22:55 右下角弹窗美化控件\ControlLibraryExt\
目录 0 2020-06-27 22:55 右下角弹窗美化控件\ControlLibraryExt\bin\
目录 0 2020-06-27 22:56 右下角弹窗美化控件\ControlLibraryExt\bin\Debug\
文件 19968 2020-06-27 22:56 右下角弹窗美化控件\ControlLibraryExt\bin\Debug\AnimationLibrary.dll
文件 44544 2020-06-27 22:56 右下角弹窗美化控件\ControlLibraryExt\bin\Debug\AnimationLibrary.pdb
文件 96768 2020-07-01 00:35 右下角弹窗美化控件\ControlLibraryExt\bin\Debug\ControlLibraryExt.dll
文件 79360 2020-07-01 00:35 右下角弹窗美化控件\ControlLibraryExt\bin\Debug\ControlLibraryExt.pdb
目录 0 2020-06-22 12:43 右下角弹窗美化控件\ControlLibraryExt\bin\Release\
文件 5253 2020-07-01 00:35 右下角弹窗美化控件\ControlLibraryExt\ControlLibraryExt.csproj
目录 0 2020-06-27 22:56 右下角弹窗美化控件\ControlLibraryExt\Design\
文件 9063 2020-06-27 22:56 右下角弹窗美化控件\ControlLibraryExt\Design\ColorEditorExt.cs
............此处省略81个文件信息
- 上一篇:MyKtv后台管理系统(附数据库)
- 下一篇:c#Winform自定义控件
相关资源
- c#入门经典 第七版 中文版 非扫描版
- .netc#新手菜鸟mvc5的仓库管理系统 so
- C# NPOI生成word插入图片和表格
- C#程序设计基础C#程序设计及应用教程
- 深入.NET平台和C#编程
- .net 美萍超市管理系统源码C#
- WinForm GeckoFx33 Demo JS与C#互交 窗口浏览
- 《ASP.NET程序设计项目教程》周虎,王
- 计算机图形学 三维模型处理算法初步
- C# KTV 点歌系统,C#项目源码带数据库
- C#实验--A.1 视频动态绘制练习.
- c#实现动态规划法——求解矩阵连乘问
- c#winform中完美代替WebBrowser最新的控件
- C#高级编程第9版:C#5.0 & .NET 4.5.1 par
- Illustrated C# 2010 C# 4.0图解教程
- C# WINFORM框架源碼
- C# WinForm实践开发教程清晰版
- 3D打印机上位机源码Reprap Host 是C#写的
- C#设计模式+源码JamesW.Cooper.zip
- C#程序开发范例宝典(第3版).(配套
- C#写的年会抽奖软件包含源代码.zip
- 大型ERP C#源码
- asp.net完整项目带数据库
- 一种开源业务系统框架winform源码
- 清大出版社 段德亮 《C#课程设计案例
- C#人事管理系统/人力资源管理系统
- C# 7 and .NET Core: Modern Cross-Platform Deve
- C# 5.0 in a Nutshell 5th Edition.pdf
-
C# 6.0 and the .NET 4.6 fr
amework(7th). - C# .NET webservices简单使用
评论
共有 条评论