資源簡介
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("http:/// 按鈕高度")]
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("http:/// 按鈕高度")]
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自定義控件
評論
共有 條評論