程序员的资源宝库

网站首页 > gitee 正文

Winform 使用图标字体Awesome

sanyeah 2024-04-13 16:19:20 gitee 7 ℃ 0 评论

网上看了不少帖子关于winform如何使用的,尤其是冰封一夏 https://www.cnblogs.com/bfyx/和sunny-ui https://www.cnblogs.com/yhuse/

但是都没有详细说明为什么。

回头想想,字体图标嘛,根本的核心还是字体,所以在winform中使用awesome核心无非就是

  • 第一步是指定目标控件的awesome字体,这里分几个步骤:
  1. 为了保持通用性,不太可能要求客户端都安装awesome字体,所以必须让应用自带字体,也就是自己装载字体。装载很简单,两句话搞定:
PrivateFontCollection ImageFont = new PrivateFontCollection();
ImageFont.AddFontFile(@"font\FontAwesome.ttf");
这里需要注意的是在设计模式下会找不到字体,所以手动将这里拷贝到VS的安装目录,我的是这个:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE。

 

然后定义字体,自此字体准备完毕,剩下的就很简单了,只要指定目标的字体为iconfont即可

  • 第二部输入要显示的内容,因为是字体,所有我们要输入的内容一定是string,所以这一步的核心就是输入什么string,这里分几步:
    1. 因为我们要显示的内容是图标,而不是文字,而图标字体不像其他字体要显示什么就输入什么,我们必须把要显示的图标和我们输入的string对应起来,也就是跟某种属性关联起来,我才能通过这个属性调出指定的图标,其他字体比如要显示"电脑“,不管你用什么字体都是输入”电脑“二字,但是图标字体你得根据人家定义好的来,awesome是用unicode定义的,其实就是一个ushort,所以问题就变得很简单了,这个关联属性就是ushort。总共几百个图标,对应几百个ushort值,官方网站上都把这些值给你对应好了,不过记得是16进制的。官网地址: https://fontawesome.com/icons?d=listing&s=solid&m=free,如果想偷懒,这些在sunni-ui和冰封一夏那里也都整理好了,不过他们用的是4.7版本,如果需要最新版那就直接去官网,拷贝一下放到excel里,稍微整理一下就都有了,后来发现官网下载的otf文件,在win10可以直接调用没有问题,但是win7却会报错,然后就想办法转换程ttf,这个网站可以:https://www.font-converter.net/en
      官网拷贝到excel是下图这样的,很容易辨认,前面是名字,后四位是16进制的值,自己处理一下,然后做成一个枚举 ad=0xf641,address-book=0xf2b9,address-card=0xf2bb...

    2. 这里我做一个简单的处理awesome拷贝下来的代码,在awesome官网拷贝到awesone.txt文件,然后用这代码处理一下,然后创建枚举
    3. 第一步把所有的图标做成枚举后,我们就能得到关联的两个值,名字-ushort的值,我们可以把这个枚举作为属性的类型,然后调用这个属性的时候,只需要指定名字,就能得到关联的ushort值。为什么需要名字呢,因为ushort干巴巴的一个数字实在是难以辨认。
    4. 最后一步就是得到我们所需要的string了,这个时候很简单,只需要把上一步得到的int用这方法转换程string 
      char.ConvertFromUtf32((int)_Value)
  • 第三步也就是最后一步,这一步就变得非常简单了。因为已经准备好字体和要显示的string了,所以只需要将他们赋值给指定的控件就可以了,比如label,button,textbox,设置他们的font和text即可,最后附上一个自定义控件的例子!
  •   1 using System;
      2 using System.Collections.Generic;
      3 using System.ComponentModel;
      4 using System.Drawing;
      5 using System.Data;
      6 using System.Linq;
      7 using System.Text;
      8 using System.Threading.Tasks;
      9 using System.Windows.Forms;
     10 using System.Drawing.Text;
     11 using System.IO;
     12 using System.Drawing.Drawing2D;
     13 
     14 namespace PlcControl
     15 {
     16     public partial class Awesome : UserControl
     17     {
     18         public Awesome()
     19         {
     20             InitializeComponent();
     21             if (ImageFont == null)
     22             {
     23                 ImageFont = new PrivateFontCollection();
     24 
     25             }
     26             if (ImageFont.Families.Length == 0)
     27             {
     28                 if (File.Exists(@"font\FontAwesome.ttf"))
     29                 {
     30                     ImageFont.AddFontFile(@"font\FontAwesome.ttf");
     31                 }
     32                 else
     33                 {
     34                     //MessageBox.Show(Environment.CurrentDirectory);
     35                     MessageBox.Show(@"file font\FontAwesome.ttf missing");
     36                 }
     37             }
     38             if (ImageFont.Families.Length == 0)
     39             {
     40                 return;
     41             }
     42             else
     43             {
     44                 iconfont= new Font(ImageFont.Families[0], Font.Size, FontStyle.Bold, Font.Unit);
     45             }
     46         }
     47         PrivateFontCollection ImageFont = new PrivateFontCollection();
     48         Font iconfont;
     49         public enum AwesomeValues
     50         {
     51             fa_500px = 0xf26e,
     52             fa_address_book = 0xf2b9,
     53             fa_address_book_o = 0xf2ba,
     54             fa_address_card = 0xf2bb,
     55             fa_address_card_o = 0xf2bc,
     56             fa_adjust = 0xf042,
     57             fa_adn = 0xf170,
     58             fa_align_center = 0xf037,
     59             fa_align_justify = 0xf039,
     60             fa_align_left = 0xf036,
     61             fa_align_right = 0xf038,
     62             fa_amazon = 0xf270,
     63             fa_ambulance = 0xf0f9,
     64             fa_american_sign_language_interpreting = 0xf2a3,
     65             fa_anchor = 0xf13d,
     66             fa_android = 0xf17b,
     67             fa_angellist = 0xf209,
     68             fa_angle_double_down = 0xf103,
     69             fa_angle_double_left = 0xf100,
     70             fa_angle_double_right = 0xf101,
     71             fa_angle_double_up = 0xf102,
     72             fa_angle_down = 0xf107,
     73             fa_angle_left = 0xf104,
     74             fa_angle_right = 0xf105,
     75             fa_angle_up = 0xf106,
     76             fa_apple = 0xf179,
     77             fa_archive = 0xf187,
     78             fa_area_chart = 0xf1fe,
     79             fa_arrow_circle_down = 0xf0ab,
     80             fa_arrow_circle_left = 0xf0a8,
     81             fa_arrow_circle_o_down = 0xf01a,
     82             fa_arrow_circle_o_left = 0xf190,
     83             fa_arrow_circle_o_right = 0xf18e,
     84             fa_arrow_circle_o_up = 0xf01b,
     85             fa_arrow_circle_right = 0xf0a9,
     86             fa_arrow_circle_up = 0xf0aa,
     87             fa_arrow_down = 0xf063,
     88             fa_arrow_left = 0xf060,
     89             fa_arrow_right = 0xf061,
     90             fa_arrow_up = 0xf062,
     91             fa_arrows = 0xf047,
     92             fa_arrows_alt = 0xf0b2,
     93             fa_arrows_h = 0xf07e,
     94             fa_arrows_v = 0xf07d,
     95             fa_asl_interpreting = 0xf2a3,
     96             fa_assistive_listening_systems = 0xf2a2,
     97             fa_asterisk = 0xf069,
     98             fa_at = 0xf1fa,
     99             fa_audio_description = 0xf29e,
    100             fa_automobile = 0xf1b9,
    101 
    102             fa_backward = 0xf04a,
    103             fa_balance_scale = 0xf24e,
    104             fa_ban = 0xf05e,
    105             fa_bandcamp = 0xf2d5,
    106             fa_bank = 0xf19c,
    107             fa_bar_chart = 0xf080,
    108             fa_bar_chart_o = 0xf080,
    109             fa_barcode = 0xf02a,
    110             fa_bars = 0xf0c9,
    111             fa_bath = 0xf2cd,
    112             fa_bathtub = 0xf2cd,
    113             fa_battery = 0xf240,
    114             fa_battery_0 = 0xf244,
    115             fa_battery_1 = 0xf243,
    116             fa_battery_2 = 0xf242,
    117             fa_battery_3 = 0xf241,
    118             fa_battery_4 = 0xf240,
    119             fa_battery_empty = 0xf244,
    120             fa_battery_full = 0xf240,
    121             fa_battery_half = 0xf242,
    122             fa_battery_quarter = 0xf243,
    123             fa_battery_three_quarters = 0xf241,
    124             fa_bed = 0xf236,
    125             fa_beer = 0xf0fc,
    126             fa_behance = 0xf1b4,
    127             fa_behance_square = 0xf1b5,
    128             fa_bell = 0xf0f3,
    129             fa_bell_o = 0xf0a2,
    130             fa_bell_slash = 0xf1f6,
    131             fa_bell_slash_o = 0xf1f7,
    132             fa_bicycle = 0xf206,
    133             fa_binoculars = 0xf1e5,
    134             fa_birthday_cake = 0xf1fd,
    135             fa_bitbucket = 0xf171,
    136             fa_bitbucket_square = 0xf172,
    137             fa_bitcoin = 0xf15a,
    138             fa_black_tie = 0xf27e,
    139             fa_blind = 0xf29d,
    140             fa_bluetooth = 0xf293,
    141             fa_bluetooth_b = 0xf294,
    142             fa_bold = 0xf032,
    143             fa_bolt = 0xf0e7,
    144             fa_bomb = 0xf1e2,
    145             fa_book = 0xf02d,
    146             fa_bookmark = 0xf02e,
    147             fa_bookmark_o = 0xf097,
    148             fa_braille = 0xf2a1,
    149             fa_briefcase = 0xf0b1,
    150             fa_btc = 0xf15a,
    151             fa_bug = 0xf188,
    152             fa_building = 0xf1ad,
    153             fa_building_o = 0xf0f7,
    154             fa_bullhorn = 0xf0a1,
    155             fa_bullseye = 0xf140,
    156             fa_bus = 0xf207,
    157             fa_buysellads = 0xf20d,
    158 
    159             fa_cab = 0xf1ba,
    160             fa_calculator = 0xf1ec,
    161             fa_calendar = 0xf073,
    162             fa_calendar_check_o = 0xf274,
    163             fa_calendar_minus_o = 0xf272,
    164             fa_calendar_o = 0xf133,
    165             fa_calendar_plus_o = 0xf271,
    166             fa_calendar_times_o = 0xf273,
    167             fa_camera = 0xf030,
    168             fa_camera_retro = 0xf083,
    169             fa_car = 0xf1b9,
    170             fa_caret_down = 0xf0d7,
    171             fa_caret_left = 0xf0d9,
    172             fa_caret_right = 0xf0da,
    173             fa_caret_square_o_down = 0xf150,
    174             fa_caret_square_o_left = 0xf191,
    175             fa_caret_square_o_right = 0xf152,
    176             fa_caret_square_o_up = 0xf151,
    177             fa_caret_up = 0xf0d8,
    178             fa_cart_arrow_down = 0xf218,
    179             fa_cart_plus = 0xf217,
    180             fa_cc = 0xf20a,
    181             fa_cc_amex = 0xf1f3,
    182             fa_cc_diners_club = 0xf24c,
    183             fa_cc_discover = 0xf1f2,
    184             fa_cc_jcb = 0xf24b,
    185             fa_cc_mastercard = 0xf1f1,
    186             fa_cc_paypal = 0xf1f4,
    187             fa_cc_stripe = 0xf1f5,
    188             fa_cc_visa = 0xf1f0,
    189             fa_certificate = 0xf0a3,
    190             fa_chain = 0xf0c1,
    191             fa_chain_broken = 0xf127,
    192             fa_check = 0xf00c,
    193             fa_check_circle = 0xf058,
    194             fa_check_circle_o = 0xf05d,
    195             fa_check_square = 0xf14a,
    196             fa_check_square_o = 0xf046,
    197             fa_chevron_circle_down = 0xf13a,
    198             fa_chevron_circle_left = 0xf137,
    199             fa_chevron_circle_right = 0xf138,
    200             fa_chevron_circle_up = 0xf139,
    201             fa_chevron_down = 0xf078,
    202             fa_chevron_left = 0xf053,
    203             fa_chevron_right = 0xf054,
    204             fa_chevron_up = 0xf077,
    205             fa_child = 0xf1ae,
    206             fa_chrome = 0xf268,
    207             fa_circle = 0xf111,
    208             fa_circle_o = 0xf10c,
    209             fa_circle_o_notch = 0xf1ce,
    210             fa_circle_thin = 0xf1db,
    211             fa_clipboard = 0xf0ea,
    212             fa_clock_o = 0xf017,
    213             fa_clone = 0xf24d,
    214             fa_close = 0xf00d,
    215             fa_cloud = 0xf0c2,
    216             fa_cloud_download = 0xf0ed,
    217             fa_cloud_upload = 0xf0ee,
    218             fa_cny = 0xf157,
    219             fa_code = 0xf121,
    220             fa_code_fork = 0xf126,
    221             fa_codepen = 0xf1cb,
    222             fa_codiepie = 0xf284,
    223             fa_coffee = 0xf0f4,
    224             fa_cog = 0xf013,
    225             fa_cogs = 0xf085,
    226             fa_columns = 0xf0db,
    227             fa_comment = 0xf075,
    228             fa_comment_o = 0xf0e5,
    229             fa_commenting = 0xf27a,
    230             fa_commenting_o = 0xf27b,
    231             fa_comments = 0xf086,
    232             fa_comments_o = 0xf0e6,
    233             fa_compass = 0xf14e,
    234             fa_compress = 0xf066,
    235             fa_connectdevelop = 0xf20e,
    236             fa_contao = 0xf26d,
    237             fa_copy = 0xf0c5,
    238             fa_copyright = 0xf1f9,
    239             fa_creative_commons = 0xf25e,
    240             fa_credit_card = 0xf09d,
    241             fa_credit_card_alt = 0xf283,
    242             fa_crop = 0xf125,
    243             fa_crosshairs = 0xf05b,
    244             fa_css3 = 0xf13c,
    245             fa_cube = 0xf1b2,
    246             fa_cubes = 0xf1b3,
    247             fa_cut = 0xf0c4,
    248             fa_cutlery = 0xf0f5,
    249 
    250             fa_dashboard = 0xf0e4,
    251             fa_dashcube = 0xf210,
    252             fa_database = 0xf1c0,
    253             fa_deaf = 0xf2a4,
    254             fa_deafness = 0xf2a4,
    255             fa_dedent = 0xf03b,
    256             fa_delicious = 0xf1a5,
    257             fa_desktop = 0xf108,
    258             fa_deviantart = 0xf1bd,
    259             fa_diamond = 0xf219,
    260             fa_digg = 0xf1a6,
    261             fa_dollar = 0xf155,
    262             fa_dot_circle_o = 0xf192,
    263             fa_download = 0xf019,
    264             fa_dribbble = 0xf17d,
    265             fa_drivers_license = 0xf2c2,
    266             fa_drivers_license_o = 0xf2c3,
    267             fa_dropbox = 0xf16b,
    268             fa_drupal = 0xf1a9,
    269 
    270             fa_edge = 0xf282,
    271             fa_edit = 0xf044,
    272             fa_eercast = 0xf2da,
    273             fa_eject = 0xf052,
    274             fa_ellipsis_h = 0xf141,
    275             fa_ellipsis_v = 0xf142,
    276             fa_empire = 0xf1d1,
    277             fa_envelope = 0xf0e0,
    278             fa_envelope_o = 0xf003,
    279             fa_envelope_open = 0xf2b6,
    280             fa_envelope_open_o = 0xf2b7,
    281             fa_envelope_square = 0xf199,
    282             fa_envira = 0xf299,
    283             fa_eraser = 0xf12d,
    284             fa_etsy = 0xf2d7,
    285             fa_eur = 0xf153,
    286             fa_euro = 0xf153,
    287             fa_exchange = 0xf0ec,
    288             fa_exclamation = 0xf12a,
    289             fa_exclamation_circle = 0xf06a,
    290             fa_exclamation_triangle = 0xf071,
    291             fa_expand = 0xf065,
    292             fa_expeditedssl = 0xf23e,
    293             fa_external_link = 0xf08e,
    294             fa_external_link_square = 0xf14c,
    295             fa_eye = 0xf06e,
    296             fa_eye_slash = 0xf070,
    297             fa_eyedropper = 0xf1fb,
    298 
    299             fa_fa = 0xf2b4,
    300             fa_facebook = 0xf09a,
    301             fa_facebook_f = 0xf09a,
    302             fa_facebook_official = 0xf230,
    303             fa_facebook_square = 0xf082,
    304             fa_fast_backward = 0xf049,
    305             fa_fast_forward = 0xf050,
    306             fa_fax = 0xf1ac,
    307             fa_feed = 0xf09e,
    308             fa_female = 0xf182,
    309             fa_fighter_jet = 0xf0fb,
    310             fa_file = 0xf15b,
    311             fa_file_archive_o = 0xf1c6,
    312             fa_file_audio_o = 0xf1c7,
    313             fa_file_code_o = 0xf1c9,
    314             fa_file_excel_o = 0xf1c3,
    315             fa_file_image_o = 0xf1c5,
    316             fa_file_movie_o = 0xf1c8,
    317             fa_file_o = 0xf016,
    318             fa_file_pdf_o = 0xf1c1,
    319             fa_file_photo_o = 0xf1c5,
    320             fa_file_picture_o = 0xf1c5,
    321             fa_file_powerpoint_o = 0xf1c4,
    322             fa_file_sound_o = 0xf1c7,
    323             fa_file_text = 0xf15c,
    324             fa_file_text_o = 0xf0f6,
    325             fa_file_video_o = 0xf1c8,
    326             fa_file_word_o = 0xf1c2,
    327             fa_file_zip_o = 0xf1c6,
    328             fa_files_o = 0xf0c5,
    329             fa_film = 0xf008,
    330             fa_filter = 0xf0b0,
    331             fa_fire = 0xf06d,
    332             fa_fire_extinguisher = 0xf134,
    333             fa_firefox = 0xf269,
    334             fa_first_order = 0xf2b0,
    335             fa_flag = 0xf024,
    336             fa_flag_checkered = 0xf11e,
    337             fa_flag_o = 0xf11d,
    338             fa_flash = 0xf0e7,
    339             fa_flask = 0xf0c3,
    340             fa_flickr = 0xf16e,
    341             fa_floppy_o = 0xf0c7,
    342             fa_folder = 0xf07b,
    343             fa_folder_o = 0xf114,
    344             fa_folder_open = 0xf07c,
    345             fa_folder_open_o = 0xf115,
    346             fa_font = 0xf031,
    347             fa_font_awesome = 0xf2b4,
    348             fa_fonticons = 0xf280,
    349             fa_fort_awesome = 0xf286,
    350             fa_forumbee = 0xf211,
    351             fa_forward = 0xf04e,
    352             fa_foursquare = 0xf180,
    353             fa_free_code_camp = 0xf2c5,
    354             fa_frown_o = 0xf119,
    355             fa_futbol_o = 0xf1e3,
    356 
    357             fa_gamepad = 0xf11b,
    358             fa_gavel = 0xf0e3,
    359             fa_gbp = 0xf154,
    360             fa_ge = 0xf1d1,
    361             fa_gear = 0xf013,
    362             fa_gears = 0xf085,
    363             fa_genderless = 0xf22d,
    364             fa_get_pocket = 0xf265,
    365             fa_gg = 0xf260,
    366             fa_gg_circle = 0xf261,
    367             fa_gift = 0xf06b,
    368             fa_git = 0xf1d3,
    369             fa_git_square = 0xf1d2,
    370             fa_github = 0xf09b,
    371             fa_github_alt = 0xf113,
    372             fa_github_square = 0xf092,
    373             fa_gitlab = 0xf296,
    374             fa_gittip = 0xf184,
    375             fa_glass = 0xf000,
    376             fa_glide = 0xf2a5,
    377             fa_glide_g = 0xf2a6,
    378             fa_globe = 0xf0ac,
    379             fa_google = 0xf1a0,
    380             fa_google_plus = 0xf0d5,
    381             fa_google_plus_circle = 0xf2b3,
    382             fa_google_plus_official = 0xf2b3,
    383             fa_google_plus_square = 0xf0d4,
    384             fa_google_wallet = 0xf1ee,
    385             fa_graduation_cap = 0xf19d,
    386             fa_gratipay = 0xf184,
    387             fa_grav = 0xf2d6,
    388             fa_group = 0xf0c0,
    389 
    390             fa_h_square = 0xf0fd,
    391             fa_hacker_news = 0xf1d4,
    392             fa_hand_grab_o = 0xf255,
    393             fa_hand_lizard_o = 0xf258,
    394             fa_hand_o_down = 0xf0a7,
    395             fa_hand_o_left = 0xf0a5,
    396             fa_hand_o_right = 0xf0a4,
    397             fa_hand_o_up = 0xf0a6,
    398             fa_hand_paper_o = 0xf256,
    399             fa_hand_peace_o = 0xf25b,
    400             fa_hand_pointer_o = 0xf25a,
    401             fa_hand_rock_o = 0xf255,
    402             fa_hand_scissors_o = 0xf257,
    403             fa_hand_spock_o = 0xf259,
    404             fa_hand_stop_o = 0xf256,
    405             fa_handshake_o = 0xf2b5,
    406             fa_hard_of_hearing = 0xf2a4,
    407             fa_hashtag = 0xf292,
    408             fa_hdd_o = 0xf0a0,
    409             fa_header = 0xf1dc,
    410             fa_headphones = 0xf025,
    411             fa_heart = 0xf004,
    412             fa_heart_o = 0xf08a,
    413             fa_heartbeat = 0xf21e,
    414             fa_history = 0xf1da,
    415             fa_home = 0xf015,
    416             fa_hospital_o = 0xf0f8,
    417             fa_hotel = 0xf236,
    418             fa_hourglass = 0xf254,
    419             fa_hourglass_1 = 0xf251,
    420             fa_hourglass_2 = 0xf252,
    421             fa_hourglass_3 = 0xf253,
    422             fa_hourglass_end = 0xf253,
    423             fa_hourglass_half = 0xf252,
    424             fa_hourglass_o = 0xf250,
    425             fa_hourglass_start = 0xf251,
    426             fa_houzz = 0xf27c,
    427             fa_html5 = 0xf13b,
    428 
    429             fa_i_cursor = 0xf246,
    430             fa_id_badge = 0xf2c1,
    431             fa_id_card = 0xf2c2,
    432             fa_id_card_o = 0xf2c3,
    433             fa_ils = 0xf20b,
    434             fa_image = 0xf03e,
    435             fa_imdb = 0xf2d8,
    436             fa_inbox = 0xf01c,
    437             fa_indent = 0xf03c,
    438             fa_industry = 0xf275,
    439             fa_info = 0xf129,
    440             fa_info_circle = 0xf05a,
    441             fa_inr = 0xf156,
    442             fa_instagram = 0xf16d,
    443             fa_institution = 0xf19c,
    444             fa_internet_explorer = 0xf26b,
    445             fa_intersex = 0xf224,
    446             fa_ioxhost = 0xf208,
    447             fa_italic = 0xf033,
    448 
    449             fa_joomla = 0xf1aa,
    450             fa_jpy = 0xf157,
    451             fa_jsfiddle = 0xf1cc,
    452 
    453             fa_key = 0xf084,
    454             fa_keyboard_o = 0xf11c,
    455             fa_krw = 0xf159,
    456 
    457             fa_language = 0xf1ab,
    458             fa_laptop = 0xf109,
    459             fa_lastfm = 0xf202,
    460             fa_lastfm_square = 0xf203,
    461             fa_leaf = 0xf06c,
    462             fa_leanpub = 0xf212,
    463             fa_legal = 0xf0e3,
    464             fa_lemon_o = 0xf094,
    465             fa_level_down = 0xf149,
    466             fa_level_up = 0xf148,
    467             fa_life_bouy = 0xf1cd,
    468             fa_life_buoy = 0xf1cd,
    469             fa_life_ring = 0xf1cd,
    470             fa_life_saver = 0xf1cd,
    471             fa_lightbulb_o = 0xf0eb,
    472             fa_line_chart = 0xf201,
    473             fa_link = 0xf0c1,
    474             fa_linkedin = 0xf0e1,
    475             fa_linkedin_square = 0xf08c,
    476             fa_linode = 0xf2b8,
    477             fa_linux = 0xf17c,
    478             fa_list = 0xf03a,
    479             fa_list_alt = 0xf022,
    480             fa_list_ol = 0xf0cb,
    481             fa_list_ul = 0xf0ca,
    482             fa_location_arrow = 0xf124,
    483             fa_lock = 0xf023,
    484             fa_long_arrow_down = 0xf175,
    485             fa_long_arrow_left = 0xf177,
    486             fa_long_arrow_right = 0xf178,
    487             fa_long_arrow_up = 0xf176,
    488             fa_low_vision = 0xf2a8,
    489 
    490             fa_magic = 0xf0d0,
    491             fa_magnet = 0xf076,
    492             fa_mail_forward = 0xf064,
    493             fa_mail_reply = 0xf112,
    494             fa_mail_reply_all = 0xf122,
    495             fa_male = 0xf183,
    496             fa_map = 0xf279,
    497             fa_map_marker = 0xf041,
    498             fa_map_o = 0xf278,
    499             fa_map_pin = 0xf276,
    500             fa_map_signs = 0xf277,
    501             fa_mars = 0xf222,
    502             fa_mars_double = 0xf227,
    503             fa_mars_stroke = 0xf229,
    504             fa_mars_stroke_h = 0xf22b,
    505             fa_mars_stroke_v = 0xf22a,
    506             fa_maxcdn = 0xf136,
    507             fa_meanpath = 0xf20c,
    508             fa_medium = 0xf23a,
    509             fa_medkit = 0xf0fa,
    510             fa_meetup = 0xf2e0,
    511             fa_meh_o = 0xf11a,
    512             fa_mercury = 0xf223,
    513             fa_microchip = 0xf2db,
    514             fa_microphone = 0xf130,
    515             fa_microphone_slash = 0xf131,
    516             fa_minus = 0xf068,
    517             fa_minus_circle = 0xf056,
    518             fa_minus_square = 0xf146,
    519             fa_minus_square_o = 0xf147,
    520             fa_mixcloud = 0xf289,
    521             fa_mobile = 0xf10b,
    522             fa_mobile_phone = 0xf10b,
    523             fa_modx = 0xf285,
    524             fa_money = 0xf0d6,
    525             fa_moon_o = 0xf186,
    526             fa_mortar_board = 0xf19d,
    527             fa_motorcycle = 0xf21c,
    528             fa_mouse_pointer = 0xf245,
    529             fa_music = 0xf001,
    530 
    531             fa_navicon = 0xf0c9,
    532             fa_neuter = 0xf22c,
    533             fa_newspaper_o = 0xf1ea,
    534 
    535             fa_object_group = 0xf247,
    536             fa_object_ungroup = 0xf248,
    537             fa_odnoklassniki = 0xf263,
    538             fa_odnoklassniki_square = 0xf264,
    539             fa_opencart = 0xf23d,
    540             fa_openid = 0xf19b,
    541             fa_opera = 0xf26a,
    542             fa_optin_monster = 0xf23c,
    543             fa_outdent = 0xf03b,
    544 
    545             fa_pagelines = 0xf18c,
    546             fa_paint_brush = 0xf1fc,
    547             fa_paper_plane = 0xf1d8,
    548             fa_paper_plane_o = 0xf1d9,
    549             fa_paperclip = 0xf0c6,
    550             fa_paragraph = 0xf1dd,
    551             fa_paste = 0xf0ea,
    552             fa_pause = 0xf04c,
    553             fa_pause_circle = 0xf28b,
    554             fa_pause_circle_o = 0xf28c,
    555             fa_paw = 0xf1b0,
    556             fa_paypal = 0xf1ed,
    557             fa_pencil = 0xf040,
    558             fa_pencil_square = 0xf14b,
    559             fa_pencil_square_o = 0xf044,
    560             fa_percent = 0xf295,
    561             fa_phone = 0xf095,
    562             fa_phone_square = 0xf098,
    563             fa_photo = 0xf03e,
    564             fa_picture_o = 0xf03e,
    565             fa_pie_chart = 0xf200,
    566             fa_pied_piper = 0xf2ae,
    567             fa_pied_piper_alt = 0xf1a8,
    568             fa_pied_piper_pp = 0xf1a7,
    569             fa_pinterest = 0xf0d2,
    570             fa_pinterest_p = 0xf231,
    571             fa_pinterest_square = 0xf0d3,
    572             fa_plane = 0xf072,
    573             fa_play = 0xf04b,
    574             fa_play_circle = 0xf144,
    575             fa_play_circle_o = 0xf01d,
    576             fa_plug = 0xf1e6,
    577             fa_plus = 0xf067,
    578             fa_plus_circle = 0xf055,
    579             fa_plus_square = 0xf0fe,
    580             fa_plus_square_o = 0xf196,
    581             fa_podcast = 0xf2ce,
    582             fa_power_off = 0xf011,
    583             fa_print = 0xf02f,
    584             fa_product_hunt = 0xf288,
    585             fa_puzzle_piece = 0xf12e,
    586 
    587             fa_qq = 0xf1d6,
    588             fa_qrcode = 0xf029,
    589             fa_question = 0xf128,
    590             fa_question_circle = 0xf059,
    591             fa_question_circle_o = 0xf29c,
    592             fa_quora = 0xf2c4,
    593             fa_quote_left = 0xf10d,
    594             fa_quote_right = 0xf10e,
    595 
    596             fa_ra = 0xf1d0,
    597             fa_random = 0xf074,
    598             fa_ravelry = 0xf2d9,
    599             fa_rebel = 0xf1d0,
    600             fa_recycle = 0xf1b8,
    601             fa_reddit = 0xf1a1,
    602             fa_reddit_alien = 0xf281,
    603             fa_reddit_square = 0xf1a2,
    604             fa_refresh = 0xf021,
    605             fa_registered = 0xf25d,
    606             fa_remove = 0xf00d,
    607             fa_renren = 0xf18b,
    608             fa_reorder = 0xf0c9,
    609             fa_repeat = 0xf01e,
    610             fa_reply = 0xf112,
    611             fa_reply_all = 0xf122,
    612             fa_resistance = 0xf1d0,
    613             fa_retweet = 0xf079,
    614             fa_rmb = 0xf157,
    615             fa_road = 0xf018,
    616             fa_rocket = 0xf135,
    617             fa_rotate_left = 0xf0e2,
    618             fa_rotate_right = 0xf01e,
    619             fa_rouble = 0xf158,
    620             fa_rss = 0xf09e,
    621             fa_rss_square = 0xf143,
    622             fa_rub = 0xf158,
    623             fa_ruble = 0xf158,
    624             fa_rupee = 0xf156,
    625 
    626             fa_s15 = 0xf2cd,
    627             fa_safari = 0xf267,
    628             fa_save = 0xf0c7,
    629             fa_scissors = 0xf0c4,
    630             fa_scribd = 0xf28a,
    631             fa_search = 0xf002,
    632             fa_search_minus = 0xf010,
    633             fa_search_plus = 0xf00e,
    634             fa_sellsy = 0xf213,
    635             fa_send = 0xf1d8,
    636             fa_send_o = 0xf1d9,
    637             fa_server = 0xf233,
    638             fa_share = 0xf064,
    639             fa_share_alt = 0xf1e0,
    640             fa_share_alt_square = 0xf1e1,
    641             fa_share_square = 0xf14d,
    642             fa_share_square_o = 0xf045,
    643             fa_shekel = 0xf20b,
    644             fa_sheqel = 0xf20b,
    645             fa_shield = 0xf132,
    646             fa_ship = 0xf21a,
    647             fa_shirtsinbulk = 0xf214,
    648             fa_shopping_bag = 0xf290,
    649             fa_shopping_basket = 0xf291,
    650             fa_shopping_cart = 0xf07a,
    651             fa_shower = 0xf2cc,
    652             fa_sign_in = 0xf090,
    653             fa_sign_language = 0xf2a7,
    654             fa_sign_out = 0xf08b,
    655             fa_signal = 0xf012,
    656             fa_signing = 0xf2a7,
    657             fa_simplybuilt = 0xf215,
    658             fa_sitemap = 0xf0e8,
    659             fa_skyatlas = 0xf216,
    660             fa_skype = 0xf17e,
    661             fa_slack = 0xf198,
    662             fa_sliders = 0xf1de,
    663             fa_slideshare = 0xf1e7,
    664             fa_smile_o = 0xf118,
    665             fa_snapchat = 0xf2ab,
    666             fa_snapchat_ghost = 0xf2ac,
    667             fa_snapchat_square = 0xf2ad,
    668             fa_snowflake_o = 0xf2dc,
    669             fa_soccer_ball_o = 0xf1e3,
    670             fa_sort = 0xf0dc,
    671             fa_sort_alpha_asc = 0xf15d,
    672             fa_sort_alpha_desc = 0xf15e,
    673             fa_sort_amount_asc = 0xf160,
    674             fa_sort_amount_desc = 0xf161,
    675             fa_sort_asc = 0xf0de,
    676             fa_sort_desc = 0xf0dd,
    677             fa_sort_down = 0xf0dd,
    678             fa_sort_numeric_asc = 0xf162,
    679             fa_sort_numeric_desc = 0xf163,
    680             fa_sort_up = 0xf0de,
    681             fa_soundcloud = 0xf1be,
    682             fa_space_shuttle = 0xf197,
    683             fa_spinner = 0xf110,
    684             fa_spoon = 0xf1b1,
    685             fa_spotify = 0xf1bc,
    686             fa_square = 0xf0c8,
    687             fa_square_o = 0xf096,
    688             fa_stack_exchange = 0xf18d,
    689             fa_stack_overflow = 0xf16c,
    690             fa_star = 0xf005,
    691             fa_star_half = 0xf089,
    692             fa_star_half_empty = 0xf123,
    693             fa_star_half_full = 0xf123,
    694             fa_star_half_o = 0xf123,
    695             fa_star_o = 0xf006,
    696             fa_steam = 0xf1b6,
    697             fa_steam_square = 0xf1b7,
    698             fa_step_backward = 0xf048,
    699             fa_step_forward = 0xf051,
    700             fa_stethoscope = 0xf0f1,
    701             fa_sticky_note = 0xf249,
    702             fa_sticky_note_o = 0xf24a,
    703             fa_stop = 0xf04d,
    704             fa_stop_circle = 0xf28d,
    705             fa_stop_circle_o = 0xf28e,
    706             fa_street_view = 0xf21d,
    707             fa_strikethrough = 0xf0cc,
    708             fa_stumbleupon = 0xf1a4,
    709             fa_stumbleupon_circle = 0xf1a3,
    710             fa_subscript = 0xf12c,
    711             fa_subway = 0xf239,
    712             fa_suitcase = 0xf0f2,
    713             fa_sun_o = 0xf185,
    714             fa_superpowers = 0xf2dd,
    715             fa_superscript = 0xf12b,
    716             fa_support = 0xf1cd,
    717 
    718             fa_table = 0xf0ce,
    719             fa_tablet = 0xf10a,
    720             fa_tachometer = 0xf0e4,
    721             fa_tag = 0xf02b,
    722             fa_tags = 0xf02c,
    723             fa_tasks = 0xf0ae,
    724             fa_taxi = 0xf1ba,
    725             fa_telegram = 0xf2c6,
    726             fa_television = 0xf26c,
    727             fa_tencent_weibo = 0xf1d5,
    728             fa_terminal = 0xf120,
    729             fa_text_height = 0xf034,
    730             fa_text_width = 0xf035,
    731             fa_th = 0xf00a,
    732             fa_th_large = 0xf009,
    733             fa_th_list = 0xf00b,
    734             fa_themeisle = 0xf2b2,
    735             fa_thermometer = 0xf2c7,
    736             fa_thermometer_0 = 0xf2cb,
    737             fa_thermometer_1 = 0xf2ca,
    738             fa_thermometer_2 = 0xf2c9,
    739             fa_thermometer_3 = 0xf2c8,
    740             fa_thermometer_4 = 0xf2c7,
    741             fa_thermometer_empty = 0xf2cb,
    742             fa_thermometer_full = 0xf2c7,
    743             fa_thermometer_half = 0xf2c9,
    744             fa_thermometer_quarter = 0xf2ca,
    745             fa_thermometer_three_quarters = 0xf2c8,
    746             fa_thumb_tack = 0xf08d,
    747             fa_thumbs_down = 0xf165,
    748             fa_thumbs_o_down = 0xf088,
    749             fa_thumbs_o_up = 0xf087,
    750             fa_thumbs_up = 0xf164,
    751             fa_ticket = 0xf145,
    752             fa_times = 0xf00d,
    753             fa_times_circle = 0xf057,
    754             fa_times_circle_o = 0xf05c,
    755             fa_times_rectangle = 0xf2d3,
    756             fa_times_rectangle_o = 0xf2d4,
    757             fa_tint = 0xf043,
    758             fa_toggle_down = 0xf150,
    759             fa_toggle_left = 0xf191,
    760             fa_toggle_off = 0xf204,
    761             fa_toggle_on = 0xf205,
    762             fa_toggle_right = 0xf152,
    763             fa_toggle_up = 0xf151,
    764             fa_trademark = 0xf25c,
    765             fa_train = 0xf238,
    766             fa_transgender = 0xf224,
    767             fa_transgender_alt = 0xf225,
    768             fa_trash = 0xf1f8,
    769             fa_trash_o = 0xf014,
    770             fa_tree = 0xf1bb,
    771             fa_trello = 0xf181,
    772             fa_tripadvisor = 0xf262,
    773             fa_trophy = 0xf091,
    774             fa_truck = 0xf0d1,
    775             fa_try = 0xf195,
    776             fa_tty = 0xf1e4,
    777             fa_tumblr = 0xf173,
    778             fa_tumblr_square = 0xf174,
    779             fa_turkish_lira = 0xf195,
    780             fa_tv = 0xf26c,
    781             fa_twitch = 0xf1e8,
    782             fa_twitter = 0xf099,
    783             fa_twitter_square = 0xf081,
    784 
    785             fa_umbrella = 0xf0e9,
    786             fa_underline = 0xf0cd,
    787             fa_undo = 0xf0e2,
    788             fa_universal_access = 0xf29a,
    789             fa_university = 0xf19c,
    790             fa_unlink = 0xf127,
    791             fa_unlock = 0xf09c,
    792             fa_unlock_alt = 0xf13e,
    793             fa_unsorted = 0xf0dc,
    794             fa_upload = 0xf093,
    795             fa_usb = 0xf287,
    796             fa_usd = 0xf155,
    797             fa_user = 0xf007,
    798             fa_user_circle = 0xf2bd,
    799             fa_user_circle_o = 0xf2be,
    800             fa_user_md = 0xf0f0,
    801             fa_user_o = 0xf2c0,
    802             fa_user_plus = 0xf234,
    803             fa_user_secret = 0xf21b,
    804             fa_user_times = 0xf235,
    805             fa_users = 0xf0c0,
    806 
    807             fa_vcard = 0xf2bb,
    808             fa_vcard_o = 0xf2bc,
    809             fa_venus = 0xf221,
    810             fa_venus_double = 0xf226,
    811             fa_venus_mars = 0xf228,
    812             fa_viacoin = 0xf237,
    813             fa_viadeo = 0xf2a9,
    814             fa_viadeo_square = 0xf2aa,
    815             fa_video_camera = 0xf03d,
    816             fa_vimeo = 0xf27d,
    817             fa_vimeo_square = 0xf194,
    818             fa_vine = 0xf1ca,
    819             fa_vk = 0xf189,
    820             fa_volume_control_phone = 0xf2a0,
    821             fa_volume_down = 0xf027,
    822             fa_volume_off = 0xf026,
    823             fa_volume_up = 0xf028,
    824 
    825             fa_warning = 0xf071,
    826             fa_wechat = 0xf1d7,
    827             fa_weibo = 0xf18a,
    828             fa_weixin = 0xf1d7,
    829             fa_whatsapp = 0xf232,
    830             fa_wheelchair = 0xf193,
    831             fa_wheelchair_alt = 0xf29b,
    832             fa_wifi = 0xf1eb,
    833             fa_wikipedia_w = 0xf266,
    834             fa_window_close = 0xf2d3,
    835             fa_window_close_o = 0xf2d4,
    836             fa_window_maximize = 0xf2d0,
    837             fa_window_minimize = 0xf2d1,
    838             fa_window_restore = 0xf2d2,
    839             fa_windows = 0xf17a,
    840             fa_won = 0xf159,
    841             fa_wordpress = 0xf19a,
    842             fa_wpbeginner = 0xf297,
    843             fa_wpexplorer = 0xf2de,
    844             fa_wpforms = 0xf298,
    845             fa_wrench = 0xf0ad,
    846 
    847             fa_xing = 0xf168,
    848             fa_xing_square = 0xf169,
    849 
    850             fa_y_combinator = 0xf23b,
    851             fa_y_combinator_square = 0xf1d4,
    852             fa_yahoo = 0xf19e,
    853             fa_yc = 0xf23b,
    854             fa_yc_square = 0xf1d4,
    855             fa_yelp = 0xf1e9,
    856             fa_yen = 0xf157,
    857             fa_yoast = 0xf2b1,
    858             fa_youtube = 0xf167,
    859             fa_youtube_play = 0xf16a,
    860             fa_youtube_square = 0xf166,
    861         }
    862 
    863         AwesomeValues _Value=AwesomeValues.fa_address_book;
    864         public AwesomeValues Value
    865         {
    866             get => _Value;
    867             set
    868             {
    869                 _Value = value;
    870                 FontValue = char.ConvertFromUtf32((int)_Value);
    871                 Invalidate();
    872             }
    873         }
    874         private string FontValue = "";
    875         public override string Text
    876         {
    877             get;set;
    878         }
    879         SizeF FontSize = new SizeF();
    880         SolidBrush foreSB = new SolidBrush(DefaultForeColor);
    881         private void Awesome_Paint(object sender, PaintEventArgs e)
    882         {
    883             if (ImageFont.Families.Length < 1) return;
    884             e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //使绘图质量最高,即消除锯齿
    885             e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
    886             e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
    887             e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;        
    888             
    889             foreSB.Color = ForeColor;
    890             iconfont = new Font(ImageFont.Families[0], Font.Size, FontStyle.Bold, Font.Unit);
    891             FontSize = e.Graphics.MeasureString(FontValue, iconfont);
    892             e.Graphics.DrawString(FontValue, iconfont, foreSB, (Width - FontSize.Width) / 2, (Height - FontSize.Height) / 2); } ~Awesome() { foreSB?.Dispose(); iconfont?.Dispose(); 
    893 } } }
    View Code

     

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表