Embed mIRC Color codes into a C# literal?

后端 未结 4 450
执笔经年
执笔经年 2021-02-04 11:27

I\'m working on a simple irc bot in C#, and I can\'t figure out how to embed the typical mirc control codes for bold/color etc into string literals.

Can someone point me

4条回答
  •  深忆病人
    2021-02-04 11:59

    I create an enum and assign the hex values for the control codes to them.

    enum ColorCode {
        White           =   0,   /**< White */
        Black           =   1,   /**< Black */
        DarkBlue        =   2,   /**< Dark blue */
        DarkGreen       =   3,   /**< Dark green */
        Red         =   4,   /**< Red */
        DarkRed         =   5,   /**< Dark red */
        DarkViolet      =   6,   /**< Dark violet */
        Orange          =   7,   /**< Orange */
        Yellow          =   8,   /**< Yellow */
        LightGreen      =   9,   /**< Light green */
        Cyan            =  10,   /**< Cornflower blue */
        LightCyan       =  11,   /**< Light blue */
        Blue            =  12,   /**< Blue */
        Violet          =  13,   /**< Violet */
        DarkGray            =  14,   /**< Dark gray */
        LightGray       =  15   /**< Light gray */
    };
    
    enum ControlCode {
        Bold            = 0x02,     /**< Bold */
        Color           = 0x03,     /**< Color */
        Italic          = 0x09,     /**< Italic */
        StrikeThrough           = 0x13,     /**< Strike-Through */
        Reset           = 0x0f,     /**< Reset */
        Underline       = 0x15,     /**< Underline */
        Underline2      = 0x1f,     /**< Underline */
        Reverse         = 0x16      /**< Reverse */
    };
    

提交回复
热议问题