(五十一)c#Winform自定義控制項-文字提示

来源:https://www.cnblogs.com/bfyx/archive/2019/08/29/11430049.html
-Advertisement-
Play Games

前提 入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。 GitHub:https://github.com/kwwwvagaa/NetWinformControl 碼雲:https://gitee.com/kwwwvagaa/net_winform_custom_contr ...


前提

入行已經7,8年了,一直想做一套漂亮點的自定義控制項,於是就有了本系列文章。

GitHub:https://github.com/kwwwvagaa/NetWinformControl

碼雲:https://gitee.com/kwwwvagaa/net_winform_custom_control.git

如果覺得寫的還行,請點個 star 支持一下吧

歡迎前來交流探討: 企鵝群568015492 企鵝群568015492

麻煩博客下方點個【推薦】,謝謝

NuGet

Install-Package HZH_Controls

目錄

https://www.cnblogs.com/bfyx/p/11364884.html

用處及效果

1 HZH_Controls.Forms.FrmAnchorTips.ShowTips(button1, "測試提示信息\nLEFT", AnchorTipsLocation.LEFT);
2             HZH_Controls.Forms.FrmAnchorTips.ShowTips(button1, "測試提示信息\nRIGHT", AnchorTipsLocation.RIGHT);
3             HZH_Controls.Forms.FrmAnchorTips.ShowTips(button1, "測試提示信息\nTOP", AnchorTipsLocation.TOP);
4             HZH_Controls.Forms.FrmAnchorTips.ShowTips(button1, "測試提示信息\nBOTTOM", AnchorTipsLocation.BOTTOM);

 

準備工作

依然是GDI+畫圖,不懂可以自行百度一下

開始

思路是:根據參數畫圖,根據圖顯示不規則窗體

添加一個窗體FrmAnchorTips

重寫一些函數

 1   #region Override
 2 
 3         protected override void OnClosing(CancelEventArgs e)
 4         {
 5             e.Cancel = true;
 6             base.OnClosing(e);
 7             haveHandle = false;
 8             this.Dispose();
 9         }
10 
11         protected override void OnHandleCreated(EventArgs e)
12         {
13             InitializeStyles();
14             base.OnHandleCreated(e);
15             haveHandle = true;
16         }
17 
18         protected override CreateParams CreateParams
19         {
20             get
21             {
22                 CreateParams cParms = base.CreateParams;
23                 cParms.ExStyle |= 0x00080000; // WS_EX_LAYERED
24                 return cParms;
25             }
26         }
27 
28         #endregion
1  private void InitializeStyles()
2         {
3             SetStyle(ControlStyles.AllPaintingInWmPaint, true);
4             SetStyle(ControlStyles.UserPaint, true);
5             UpdateStyles();
6         }

根據圖片顯示窗體,這個是網上copy的

 1  #region 根據圖片顯示窗體    English:Display Forms Based on Pictures
 2         /// <summary>
 3         /// 功能描述:根據圖片顯示窗體    English:Display Forms Based on Pictures
 4         /// 作  者:HZH
 5         /// 創建日期:2019-08-29 15:31:16
 6         /// 任務編號:
 7         /// </summary>
 8         /// <param name="bitmap">bitmap</param>
 9         private void SetBits(Bitmap bitmap)
10         {
11             if (!haveHandle) return;
12 
13             if (!Bitmap.IsCanonicalPixelFormat(bitmap.PixelFormat) || !Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat))
14                 throw new ApplicationException("The picture must be 32bit picture with alpha channel.");
15 
16             IntPtr oldBits = IntPtr.Zero;
17             IntPtr screenDC = Win32.GetDC(IntPtr.Zero);
18             IntPtr hBitmap = IntPtr.Zero;
19             IntPtr memDc = Win32.CreateCompatibleDC(screenDC);
20 
21             try
22             {
23                 Win32.Point topLoc = new Win32.Point(Left, Top);
24                 Win32.Size bitMapSize = new Win32.Size(bitmap.Width, bitmap.Height);
25                 Win32.BLENDFUNCTION blendFunc = new Win32.BLENDFUNCTION();
26                 Win32.Point srcLoc = new Win32.Point(0, 0);
27 
28                 hBitmap = bitmap.GetHbitmap(Color.FromArgb(0));
29                 oldBits = Win32.SelectObject(memDc, hBitmap);
30 
31                 blendFunc.BlendOp = Win32.AC_SRC_OVER;
32                 blendFunc.SourceConstantAlpha = 255;
33                 blendFunc.AlphaFormat = Win32.AC_SRC_ALPHA;
34                 blendFunc.BlendFlags = 0;
35 
36                 Win32.UpdateLayeredWindow(Handle, screenDC, ref topLoc, ref bitMapSize, memDc, ref srcLoc, 0, ref blendFunc, Win32.ULW_ALPHA);
37             }
38             finally
39             {
40                 if (hBitmap != IntPtr.Zero)
41                 {
42                     Win32.SelectObject(memDc, oldBits);
43                     Win32.DeleteObject(hBitmap);
44                 }
45                 Win32.ReleaseDC(IntPtr.Zero, screenDC);
46                 Win32.DeleteDC(memDc);
47             }
48         }
49         #endregion

然後是win32類

 1  class Win32
 2     {
 3         [StructLayout(LayoutKind.Sequential)]
 4         public struct Size
 5         {
 6             public Int32 cx;
 7             public Int32 cy;
 8 
 9             public Size(Int32 x, Int32 y)
10             {
11                 cx = x;
12                 cy = y;
13             }
14         }
15 
16         [StructLayout(LayoutKind.Sequential, Pack = 1)]
17         public struct BLENDFUNCTION
18         {
19             public byte BlendOp;
20             public byte BlendFlags;
21             public byte SourceConstantAlpha;
22             public byte AlphaFormat;
23         }
24 
25         [StructLayout(LayoutKind.Sequential)]
26         public struct Point
27         {
28             public Int32 x;
29             public Int32 y;
30 
31             public Point(Int32 x, Int32 y)
32             {
33                 this.x = x;
34                 this.y = y;
35             }
36         }
37 
38         public const byte AC_SRC_OVER = 0;
39         public const Int32 ULW_ALPHA = 2;
40         public const byte AC_SRC_ALPHA = 1;
41 
42         [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
43         public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
44 
45         [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
46         public static extern IntPtr GetDC(IntPtr hWnd);
47 
48         [DllImport("gdi32.dll", ExactSpelling = true)]
49         public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObj);
50 
51         [DllImport("user32.dll", ExactSpelling = true)]
52         public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
53 
54         [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
55         public static extern int DeleteDC(IntPtr hDC);
56 
57         [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
58         public static extern int DeleteObject(IntPtr hObj);
59 
60         [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
61         public static extern int UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pptSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags);
62 
63         [DllImport("gdi32.dll", ExactSpelling = true, SetLastError = true)]
64         public static extern IntPtr ExtCreateRegion(IntPtr lpXform, uint nCount, IntPtr rgnData);
65     }

然後就是構造函數了,根據傳入參數,畫出圖片並設置窗體

  1  #region 構造函數    English:Constructor
  2         /// <summary>
  3         /// 功能描述:構造函數    English:Constructor
  4         /// 作  者:HZH
  5         /// 創建日期:2019-08-29 15:27:51
  6         /// 任務編號:
  7         /// </summary>
  8         /// <param name="rectControl">停靠區域</param>
  9         /// <param name="strMsg">消息</param>
 10         /// <param name="location">顯示方位</param>
 11         /// <param name="background">背景色</param>
 12         /// <param name="foreColor">文字顏色</param>
 13         /// <param name="fontSize">文字大小</param>
 14         /// <param name="autoCloseTime">自動關閉時間,當<=0時不自動關閉</param>
 15         private FrmAnchorTips(
 16             Rectangle rectControl,
 17             string strMsg,
 18             AnchorTipsLocation location = AnchorTipsLocation.RIGHT,
 19             Color? background = null,
 20             Color? foreColor = null,
 21             int fontSize = 10,
 22             int autoCloseTime = 5000)
 23         {
 24             InitializeComponent();
 25             Graphics g = this.CreateGraphics();
 26             Font _font = new Font("微軟雅黑", fontSize);
 27             Color _background = background == null ? Color.FromArgb(255, 77, 58) : background.Value;
 28             Color _foreColor = foreColor == null ? Color.White : foreColor.Value;
 29             System.Drawing.SizeF sizeText = g.MeasureString(strMsg, _font);
 30             g.Dispose();
 31             var formSize = new Size((int)sizeText.Width + 20, (int)sizeText.Height + 20);
 32             if (formSize.Width < 20)
 33                 formSize.Width = 20;
 34             if (formSize.Height < 20)
 35                 formSize.Height = 20;
 36             if (location == AnchorTipsLocation.LEFT || location == AnchorTipsLocation.RIGHT)
 37             {
 38                 formSize.Width += 20;
 39             }
 40             else
 41             {
 42                 formSize.Height += 20;
 43             }          
 44 
 45             #region 獲取窗體path    English:Get the form path
 46             GraphicsPath path = new GraphicsPath();
 47             Rectangle rect;
 48             switch (location)
 49             {
 50                 case AnchorTipsLocation.TOP:
 51                     rect = new Rectangle(1, 1, formSize.Width - 2, formSize.Height - 20 - 1);
 52                     this.Location = new Point(rectControl.X + (rectControl.Width - rect.Width) / 2, rectControl.Y - rect.Height - 20);
 53                     break;
 54                 case AnchorTipsLocation.RIGHT:
 55                     rect = new Rectangle(20, 1, formSize.Width - 20 - 1, formSize.Height - 2);
 56                     this.Location = new Point(rectControl.Right, rectControl.Y + (rectControl.Height - rect.Height) / 2);
 57                     break;
 58                 case AnchorTipsLocation.BOTTOM:
 59                     rect = new Rectangle(1, 20, formSize.Width - 2, formSize.Height - 20 - 1);
 60                     this.Location = new Point(rectControl.X + (rectControl.Width - rect.Width) / 2, rectControl.Bottom);
 61                     break;
 62                 default:
 63                     rect = new Rectangle(1, 1, formSize.Width - 20 - 1, formSize.Height - 2);
 64                     this.Location = new Point(rectControl.X - rect.Width - 20, rectControl.Y + (rectControl.Height - rect.Height) / 2);
 65                     break;
 66             }
 67             int cornerRadius = 2;
 68 
 69             path.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);//左上角
 70             #region 上邊
 71             if (location == AnchorTipsLocation.BOTTOM)
 72             {
 73                 path.AddLine(rect.X + cornerRadius, rect.Y, rect.Left + rect.Width / 2 - 10, rect.Y);//
 74                 path.AddLine(rect.Left + rect.Width / 2 - 10, rect.Y, rect.Left + rect.Width / 2, rect.Y - 19);//
 75                 path.AddLine(rect.Left + rect.Width / 2, rect.Y - 19, rect.Left + rect.Width / 2 + 10, rect.Y);//
 76                 path.AddLine(rect.Left + rect.Width / 2 + 10, rect.Y, rect.Right - cornerRadius * 2, rect.Y);//
 77             }
 78             else
 79             {
 80                 path.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);//
 81             }
 82             #endregion
 83             path.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);//右上角
 84             #region 右邊
 85             if (location == AnchorTipsLocation.LEFT)
 86             {
 87                 path.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height / 2 - 10);//
 88                 path.AddLine(rect.Right, rect.Y + rect.Height / 2 - 10, rect.Right + 19, rect.Y + rect.Height / 2);//
 89                 path.AddLine(rect.Right + 19, rect.Y + rect.Height / 2, rect.Right, rect.Y + rect.Height / 2 + 10);//
 90                 path.AddLine(rect.Right, rect.Y + rect.Height / 2 + 10, rect.Right, rect.Y + rect.Height - cornerRadius * 2);//
 91             }
 92             else
 93             {
 94                 path.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);//
 95             }
 96             #endregion
 97             path.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);//右下角
 98             #region 下邊
 99             if (location == AnchorTipsLocation.TOP)
100             {
101                 path.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.Left + rect.Width / 2 + 10, rect.Bottom);
102                 path.AddLine(rect.Left + rect.Width / 2 + 10, rect.Bottom, rect.Left + rect.Width / 2, rect.Bottom + 19);
103                 path.AddLine(rect.Left + rect.Width / 2, rect.Bottom + 19, rect.Left + rect.Width / 2 - 10, rect.Bottom);
104                 path.AddLine(rect.Left + rect.Width / 2 - 10, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
105             }
106             else
107             {
108                 path.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
109             }
110             #endregion
111             path.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);//左下角
112             #region 左邊
113             if (location == AnchorTipsLocation.RIGHT)
114             {
115                 path.AddLine(rect.Left, rect.Y + cornerRadius * 2, rect.Left, rect.Y + rect.Height / 2 - 10);//
116                 path.AddLine(rect.Left, rect.Y + rect.Height / 2 - 10, rect.Left - 19, rect.Y + rect.Height / 2);//
117                 path.AddLine(rect.Left - 19, rect.Y + rect.Height / 2, rect.Left, rect.Y + rect.Height / 2 + 10);//
118                 path.AddLine(rect.Left, rect.Y + rect.Height / 2 + 10, rect.Left, rect.Y + rect.Height - cornerRadius * 2);//
119             }
120             else
121             {
122                 path.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);//
123             }
124             #endregion
125             path.CloseFigure();
126             #endregion
127 
128             Bitmap bit = new Bitmap(formSize.Width, formSize.Height);
129             this.Size = formSize;
130 
131             #region 畫圖    English:Drawing
132             Graphics gBit = Graphics.FromImage(bit);
133             gBit.SetGDIHigh();
134             gBit.FillPath(new SolidBrush(_background), path);
135             gBit.DrawString(strMsg, _font, new SolidBrush(_foreColor), rect.Location + new Size(10, 10));
136             gBit.Dispose();
137             #endregion
138 
139             SetBits(bit);
140             if (autoCloseTime > 0)
141             {
142                 Timer t = new Timer();
143                 t.Interval = autoCloseTime;
144                 t.Tick += (a, b) =>
145                 {
146                     this.Close();
147                 };
148                 t.Enabled = true;
149             }
150         }
151         #endregion

再來2個靜態函數以供調用

 1  #region 顯示一個提示    English:Show a hint
 2         /// <summary>
 3         /// 功能描述:顯示一個提示    English:Show a hint
 4         /// 作  者:HZH
 5         /// 創建日期:2019-08-29 15:28:58
 6         /// 任務編號:
 7         /// </summary>
 8         /// <param name="parentControl">停靠控制項</param>
 9         /// <param name="strMsg">消息</param>
10         /// <param name="location">顯示方位</param>
11         /// <param name="background">背景色</param>
12         /// <param name="foreColor">文字顏色</param>
13         /// <param name="deviation">偏移量</param>
14         /// <param name="fontSize">文字大小</param>
15         /// <param name="autoCloseTime">自動關閉時間,當<=0時不自動關閉</param>
16         public static FrmAnchorTips ShowTips(
17             Control parentControl,
18             string strMsg,
19             AnchorTipsLocation location = AnchorTipsLocation.RIGHT,
20             Color? background = null,
21             Color? foreColor = null,
22             Size? deviation = null,
23             int fontSize = 10,
24             int autoCloseTime = 5000)
25         {
26             Point p;
27             if (parentControl is Form)
28             {
29                 p = parentControl.Location;
30             }
31             else
32             {
33                 p = parentControl.Parent.PointToScreen(parentControl.Location);
34             }
35             if (deviation != null)
36             {
37                 p = p + deviation.Value;
38             }
39             return ShowTips(parentControl.FindForm(), new Rectangle(p, parentControl.Size), strMsg, location, background, foreColor, fontSize, autoCloseTime);
40         }
41         #endregion
42 
43         #region 顯示一個提示    English:Show a hint
44         /// <summary>
45         /// 功能描述:顯示一個提示    English:Show a hint
46         /// 作  者:HZH
47         /// 創建日期:2019-08-29 15:29:07
48         /// 任務編號:
49         /// </summary>
50         /// <param name="parentForm">父窗體</param>
51         /// <param name="rectControl">停靠區域</param>
52         /// <param name="strMsg">消息</param>
53         /// <param name="location">顯示方位</param>
54         /// <param name="background">背景色</param>
55         /// <param name="foreColor">文字顏色</param>
56         /// <param name="fontSize">文字大小</param>
57         /// <param name="autoCloseTime">自動關閉時間,當<=0時不自動關閉</param>
58         /// <returns>返回值</returns>
59         public static FrmAnchorTips ShowTips(
60             Form parentForm,
61             Rectangle rectControl,
62             string strMsg,
63             AnchorTipsLocation location = AnchorTipsLocation.RIGHT,
64             Color? background = null,
65             Color? foreColor = null,
66             int fontSize = 10,
67             int autoCloseTime = 5000)
68         {
69             FrmAnchorTips frm = new FrmAnchorTips(rectControl, strMsg, location, background, foreColor, fontSize, autoCloseTime);
70             frm.TopMost = true;
71             frm.Show(parentForm);
72             return frm;
73         }
74         #endregion

全部代碼

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 先看看netcore有哪些特性,哪些優點,與.net frameworkd 差異吧: l 跨平臺: 可以在 Windows、macOS 和 Linux 操作系統上運行。 l 跨體繫結構保持一致: 在多個體繫結構(包括 x64、x86 和 ARM)上以相同的行為運行代碼。 l 命令行工具: 包括可用於 ...
  • 1. 前言 近兩年來,很多前端的同學都開始將 VSCode 作為前端主力開發工具,其豐富的擴展給程式開發尤其是前端開髮帶來了很多便利,但是作為微軟主力語言的 .NET,卻由於有宇宙第一編輯器 Visual Studio存在,很少有看到有後端同學使用,筆者自己在 VSCode 剛出來時就折騰過將主力開 ...
  • 這是一個DotNet輕量級ORM框架,解決C#.Net開發過程中重覆繁瑣的資料庫CURD操作。 前言 因工作中接手的.net項目,源碼裡面都用了動軟代碼生成的源碼做為資料庫操作類庫。其中,有些根本就沒有用到,今後也不會用到的冗餘代碼——垃圾代碼。而每次如果有表結構修改,就得重新生成表實體/手動修改實 ...
  • 工作需求,開發釘釘微應用和小程式,之前有接觸過支付寶小程式和生活號的開發,流程沒有很大的差別,這裡記錄下我用ASP.NET MVC實現釘釘微應用的開發,並實現獲取用戶的userid。小弟我技術有限,本文中的一些命名或方法寫的不好的,還請指點。 釘釘開發者平臺上有各個平臺的SDK,我也有下載對應的.N ...
  • 參考資料 【1】 《Unity 3D腳本編程 使用C 語言開發跨平臺游戲》陳嘉棟著 【2】 @張子陽【C 中的委托和事件 Part.1】 http://www.tracefact.net/tech/009.html 【3】 @張子陽【C 中的委托和事件 Part.2】 http://www.trac ...
  • 首先新建一個窗體應用程式,在項目屬性中點擊右鍵->添加->添加新項,選擇Windows窗體->添加。 在Form1和Form2視窗中各添加一個按鈕,並雙擊添加事件處理函數: 父視窗Form1的按鈕處理函數,打開子視窗Form2,另外定義一個顯示消息框的方法供子視窗調用(定義為public才能被調用) ...
  • 場景 在Winform的窗體A中打開另一個窗體B。 實現 效果 以上代碼的實現參照: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100140716 ...
  • 場景 Winform中實現ZedGraph中曲線右鍵顯示為中文: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100115292 在上面實現將ZedGraph的右鍵顯示為中文後,再實現自定義菜單的添加。 效果 源碼下載 http ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...