前提 入行已經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 支持一下吧
麻煩博客下方點個【推薦】,謝謝
NuGet
Install-Package HZH_Controls
目錄
https://www.cnblogs.com/bfyx/p/11364884.html
用處及效果
獲取一個image
HZH_Controls.FontImages.GetImage(樣式枚舉, 大小, 前景色,背景色);
獲取一個icon
HZH_Controls.FontImages.GetIcon(樣式枚舉, 大小, 前景色,背景色);
UCBtnImg設置圖標,可以使用屬性ImageFontIcons
準備工作
下載字體文件
http://www.fontawesome.com.cn/faicons/
https://www.elegantthemes.com/blog/resources/elegant-icon-font
如果想直接要字體文件,可以到我源碼裡面去看
開始
添加一個枚舉,用來定義字體對應的值
1 public enum FontIcons 2 { 3 #region Awesome English:Awesome 4 /// <summary> 5 /// a fa 500PX 6 /// </summary> 7 A_fa_500px = 0xf26e, 8 /// <summary> 9 /// a fa address book 10 /// </summary> 11 A_fa_address_book = 0xf2b9, 12 /// <summary> 13 /// a fa address book o 14 /// </summary> 15 A_fa_address_book_o = 0xf2ba, 16 /// <summary> 17 /// a fa address card 18 /// </summary> 19 A_fa_address_card = 0xf2bb, 20 /// <summary> 21 /// a fa address card o 22 /// </summary> 23 A_fa_address_card_o = 0xf2bc, 24 /// <summary> 25 /// a fa adjust 26 /// </summary> 27 A_fa_adjust = 0xf042, 28 /// <summary> 29 /// a fa adn 30 /// </summary> 31 A_fa_adn = 0xf170, 32 /// <summary> 33 /// a fa align center 34 /// </summary> 35 A_fa_align_center = 0xf037, 36 /// <summary> 37 /// a fa align justify 38 /// </summary> 39 A_fa_align_justify = 0xf039, 40 /// <summary> 41 /// a fa align left 42 /// </summary> 43 A_fa_align_left = 0xf036, 44 /// <summary> 45 /// a fa align right 46 /// </summary> 47 A_fa_align_right = 0xf038, 48 /// <summary> 49 /// a fa amazon 50 /// </summary> 51 A_fa_amazon = 0xf270, 52 /// <summary> 53 /// a fa ambulance 54 /// </summary> 55 A_fa_ambulance = 0xf0f9, 56 /// <summary> 57 /// a fa anchor 58 /// </summary> 59 A_fa_anchor = 0xf13d, 60 /// <summary> 61 /// a fa android 62 /// </summary> 63 A_fa_android = 0xf17b, 64 /// <summary> 65 /// a fa angellist 66 /// </summary> 67 A_fa_angellist = 0xf209, 68 /// <summary> 69 /// a fa angle double down 70 /// </summary> 71 A_fa_angle_double_down = 0xf103, 72 /// <summary> 73 /// a fa angle double left 74 /// </summary> 75 A_fa_angle_double_left = 0xf100, 76 /// <summary> 77 /// a fa angle double right 78 /// </summary> 79 A_fa_angle_double_right = 0xf101, 80 /// <summary> 81 /// a fa angle double up 82 /// </summary> 83 A_fa_angle_double_up = 0xf102, 84 /// <summary> 85 /// a fa angle down 86 /// </summary> 87 A_fa_angle_down = 0xf107, 88 /// <summary> 89 /// a fa angle left 90 /// </summary> 91 A_fa_angle_left = 0xf104, 92 /// <summary> 93 /// a fa angle right 94 /// </summary> 95 A_fa_angle_right = 0xf105, 96 /// <summary> 97 /// a fa angle up 98 /// </summary> 99 A_fa_angle_up = 0xf106, 100 /// <summary> 101 /// a fa apple 102 /// </summary> 103 A_fa_apple = 0xf179, 104 /// <summary> 105 /// a fa archive 106 /// </summary> 107 A_fa_archive = 0xf187, 108 /// <summary> 109 /// a fa area chart 110 /// </summary> 111 A_fa_area_chart = 0xf1fe, 112 /// <summary> 113 /// a fa arrow circle down 114 /// </summary> 115 A_fa_arrow_circle_down = 0xf0ab, 116 /// <summary> 117 /// a fa arrow circle left 118 /// </summary> 119 A_fa_arrow_circle_left = 0xf0a8, 120 /// <summary> 121 /// a fa arrow circle o down 122 /// </summary> 123 A_fa_arrow_circle_o_down = 0xf01a, 124 /// <summary> 125 /// a fa arrow circle o left 126 /// </summary> 127 A_fa_arrow_circle_o_left = 0xf190, 128 /// <summary> 129 /// a fa arrow circle o right 130 /// </summary> 131 A_fa_arrow_circle_o_right = 0xf18e, 132 /// <summary> 133 /// a fa arrow circle o up 134 /// </summary> 135 A_fa_arrow_circle_o_up = 0xf01b, 136 /// <summary> 137 /// a fa arrow circle right 138 /// </summary> 139 A_fa_arrow_circle_right = 0xf0a9, 140 /// <summary> 141 /// a fa arrow circle up 142 /// </summary> 143 A_fa_arrow_circle_up = 0xf0aa, 144 /// <summary> 145 /// a fa arrow down 146 /// </summary> 147 A_fa_arrow_down = 0xf063, 148 /// <summary> 149 /// a fa arrow left 150 /// </summary> 151 A_fa_arrow_left = 0xf060, 152 /// <summary> 153 /// a fa arrow right 154 /// </summary> 155 A_fa_arrow_right = 0xf061, 156 /// <summary> 157 /// a fa arrow up 158 /// </summary> 159 A_fa_arrow_up = 0xf062, 160 /// <summary> 161 /// a fa arrows 162 /// </summary> 163 A_fa_arrows = 0xf047, 164 /// <summary> 165 /// a fa arrows alt 166 /// </summary> 167 A_fa_arrows_alt = 0xf0b2, 168 /// <summary> 169 /// a fa arrows h 170 /// </summary> 171 A_fa_arrows_h = 0xf07e, 172 /// <summary> 173 /// a fa arrows v 174 /// </summary> 175 A_fa_arrows_v = 0xf07d, 176 /// <summary> 177 /// a fa asl interpreting 178 /// </summary> 179 A_fa_asl_interpreting = 0xf2a3, 180 /// <summary> 181 /// a fa assistive listening systems 182 /// </summary> 183 A_fa_assistive_listening_systems = 0xf2a2, 184 /// <summary> 185 /// a fa asterisk 186 /// </summary> 187 A_fa_asterisk = 0xf069, 188 /// <summary> 189 /// a fa at 190 /// </summary> 191 A_fa_at = 0xf1fa, 192 /// <summary> 193 /// a fa audio description 194 /// </summary> 195 A_fa_audio_description = 0xf29e, 196 /// <summary> 197 /// a fa backward 198 /// </summary> 199 A_fa_backward = 0xf04a, 200 /// <summary> 201 /// a fa balance scale 202 /// </summary> 203 A_fa_balance_scale = 0xf24e, 204 /// <summary> 205 /// a fa ban 206 /// </summary> 207 A_fa_ban = 0xf05e, 208 /// <summary> 209 /// a fa bandcamp 210 /// </summary> 211 A_fa_bandcamp = 0xf2d5, 212 /// <summary> 213 /// a fa bar chart 214 /// </summary> 215 A_fa_bar_chart = 0xf080, 216 /// <summary> 217 /// a fa barcode 218 /// </summary> 219 A_fa_barcode = 0xf02a, 220 /// <summary> 221 /// a fa bars 222 /// </summary> 223 A_fa_bars = 0xf0c9, 224 /// <summary> 225 /// a fa bath 226 /// </summary> 227 A_fa_bath = 0xf2cd, 228 /// <summary> 229 /// a fa battery 230 /// </summary> 231 A_fa_battery = 0xf240, 232 /// <summary> 233 /// a fa battery 0 234 /// </summary> 235 A_fa_battery_0 = 0xf244, 236 /// <summary> 237 /// a fa battery 1 238 /// </summary> 239 A_fa_battery_1 = 0xf243, 240 /// <summary> 241 /// a fa battery 2 242 /// </summary> 243 A_fa_battery_2 = 0xf242, 244 /// <summary> 245 /// a fa battery 3 246 /// </summary> 247 A_fa_battery_3 = 0xf241, 248 /// <summary> 249 /// a fa beer 250 /// </summary> 251 A_fa_beer = 0xf0fc, 252 /// <summary> 253 /// a fa behance 254 /// </summary> 255 A_fa_behance = 0xf1b4, 256 /// <summary> 257 /// a fa behance square 258 /// </summary> 259 A_fa_behance_square = 0xf1b5, 260 /// <summary> 261 /// a fa bell 262 /// </summary> 263 A_fa_bell = 0xf0f3, 264 /// <summary> 265 /// a fa bell o 266 /// </summary> 267 A_fa_bell_o = 0xf0a2, 268 /// <summary> 269 /// a fa bell slash 270 /// </summary> 271 A_fa_bell_slash = 0xf1f6, 272 /// <summary> 273 /// a fa bell slash o 274 /// </summary> 275 A_fa_bell_slash_o = 0xf1f7, 276 /// <summary> 277 /// a fa bicycle 278 /// </summary> 279 A_fa_bicycle = 0xf206, 280 /// <summary> 281 /// a fa binoculars 282 /// </summary> 283 A_fa_binoculars = 0xf1e5, 284 /// <summary> 285 /// a fa birthday cake 286 /// </summary> 287 A_fa_birthday_cake = 0xf1fd, 288 /// <summary> 289 /// a fa bitbucket 290 /// </summary> 291 A_fa_bitbucket = 0xf171, 292 /// <summary> 293 /// a fa bitbucket square 294 /// </summary> 295 A_fa_bitbucket_square = 0xf172, 296 /// <summary> 297 /// a fa bitcoin 298 /// </summary> 299 A_fa_bitcoin = 0xf15a, 300 /// <summary> 301 /// a fa black tie 302 /// </summary> 303 A_fa_black_tie = 0xf27e, 304 /// <summary> 305 /// a fa blind 306 /// </summary> 307 A_fa_blind = 0xf29d, 308 /// <summary> 309 /// a fa bluetooth 310 /// </summary> 311 A_fa_bluetooth = 0xf293, 312 /// <summary> 313 /// a fa bluetooth b 314 /// </summary> 315 A_fa_bluetooth_b = 0xf294, 316 /// <summary> 317 /// a fa bold 318 /// </summary> 319 A_fa_bold = 0xf032, 320 /// <summary> 321 /// a fa bomb 322 /// </summary> 323 A_fa_bomb = 0xf1e2, 324 /// <summary> 325 /// a fa book 326 /// </summary> 327 A_fa_book = 0xf02d, 328 /// <summary> 329 /// a fa bookmark 330 /// </summary> 331 A_fa_bookmark = 0xf02e, 332 /// <summary> 333 /// a fa bookmark o 334 /// </summary> 335 A_fa_bookmark_o = 0xf097, 336 /// <summary> 337 /// a fa braille 338 /// </summary> 339 A_fa_braille = 0xf2a1, 340 /// <summary> 341 /// a fa briefcase 342 /// </summary> 343 A_fa_briefcase = 0xf0b1, 344 /// <summary> 345 /// a fa bug 346 /// </summary> 347 A_fa_bug = 0xf188, 348 /// <summary> 349 /// a fa building 350 /// </summary> 351 A_fa_building = 0xf1ad, 352 /// <summary> 353 /// a fa building o 354 /// </summary> 355 A_fa_building_o = 0xf0f7, 356 /// <summary> 357 /// a fa bullhorn 358 /// </summary> 359 A_fa_bullhorn = 0xf0a1, 360 /// <summary> 361 /// a fa bullseye 362 /// </summary> 363 A_fa_bullseye = 0xf140, 364 /// <summary> 365 /// a fa bus 366 /// </summary> 367 A_fa_bus = 0xf207, 368 /// <summary> 369 /// a fa buysellads 370 /// </summary> 371 A_fa_buysellads = 0xf20d, 372 /// <summary> 373 /// a fa calculator 374 /// </summary> 375 A_fa_calculator = 0xf1ec, 376 /// <summary> 377 /// a fa calendar 378 /// </summary> 379 A_fa_calendar = 0xf073, 380 /// <summary> 381 /// a fa calendar check o 382 /// </summary> 383 A_fa_calendar_check_o = 0xf274, 384 /// <summary> 385 /// a fa calendar minus o 386 /// </summary> 387 A_fa_calendar_minus_o = 0xf272, 388 /// <summary> 389 /// a fa calendar o 390 /// </summary> 391 A_fa_calendar_o = 0xf133, 392 /// <summary> 393 /// a fa calendar plus o 394 /// </summary> 395 A_fa_calendar_plus_o = 0xf271, 396 /// <summary> 397 /// a fa calendar times o 398 /// </summary> 399 A_fa_calendar_times_o = 0xf273, 400 /// <summary> 401 /// a fa camera 402 /// </summary> 403 A_fa_camera = 0xf030, 404 /// <summary> 405 /// a fa camera retro 406 /// </summary> 407 A_fa_camera_retro = 0xf083, 408 /// <summary> 409 /// a fa car 410 /// </summary> 411 A_fa_car = 0xf1b9, 412 /// <summary> 413 /// a fa caret down 414 /// </summary> 415 A_fa_caret_down = 0xf0d7, 416 /// <summary> 417 /// a fa caret left 418 /// </summary> 419 A_fa_caret_left = 0xf0d9, 420 /// <summary> 421 /// a fa caret right 422 /// </summary> 423 A_fa_caret_right = 0xf0da, 424 /// <summary> 425 /// a fa caret up 426 /// </summary> 427 A_fa_caret_up = 0xf0d8, 428 /// <summary> 429