示例#1
0
        //public static void Log<T, W>(T value, string property, W message, RichTextColor propertyColor = default, RichTextColor messageColor = default) where T : class
        //{
        //    Log(value, property, message.ToString(), propertyColor, messageColor);
        //}



        /// <summary>
        /// Logs the property.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <param name="property"></param>
        /// <param name="message"></param>
        /// <param name="propertyColor"></param>
        /// <param name="messageColor"></param>
        public static void Log <T>(T value, string property, string message, RichTextColor propertyColor = default, RichTextColor messageColor = default) where T : class
        {
            if (!DebugUIView.Instance.enabled)
            {
                return;
            }

            if (propertyLogs == null)
            {
                propertyLogs = new Dictionary <object, Dictionary <string, string> >();
            }
            //  Add the context object if not in the dictionary.
            if (!propertyLogs.ContainsKey(value))
            {
                propertyLogs.Add(value, new Dictionary <string, string>());
            }


            property = SetTextColor(property, (propertyColor == default) ? defaultColor : propertyColor);
            message  = SetTextColor(message, (propertyColor == default) ? defaultColor : messageColor);



            //  If the context object already contains the property, update the value.
            if (propertyLogs[value].ContainsKey(property))
            {
                propertyLogs[value][property] = message;
            }
            //  If not add the value to the property.
            else
            {
                propertyLogs[value].Add(property, message);
            }
        }
示例#2
0
 public static void Log <T>(T value, string property, string label, RichTextColor textColor = default) where T : class
 {
     Log(value, label, property, textColor, textColor);
 }
示例#3
0
 public static void Log <T, W>(T value, string property, W message, RichTextColor textColor = default) where T : class
 {
     Log(value, property, message.ToString(), textColor, textColor);
 }
示例#4
0
        public static string GetHexValue(RichTextColor color)
        {
            switch (color)
            {
            case RichTextColor.Aqua:
                return("#00ffffff");

            case RichTextColor.Black:
                return("#000000ff");

            case RichTextColor.Blue:
                return("#0000ffff");

            case RichTextColor.Brown:
                return("#a52a2aff");

            case RichTextColor.Cyan:
                return("#00ffffff");

            case RichTextColor.DarkBlue:
                return("#0000a0ff");

            case RichTextColor.DarkGreen:
                return("#008000ff");

            case RichTextColor.Magenta:
                return("#ff00ffff");

            case RichTextColor.Green:
                return("#00ff00ff");

            case RichTextColor.Grey:
                return("#808080ff");

            case RichTextColor.LightBlue:
                return("#add8e6ff");

            case RichTextColor.Lime:
                return("#00ff00ff");

            case RichTextColor.Maroon:
                return("#800000ff");

            case RichTextColor.Navy:
                return("#000080ff");

            case RichTextColor.Olive:
                return("#808000ff");

            case RichTextColor.Orange:
                return("#ffa500ff");

            case RichTextColor.Purple:
                return("#800080ff");

            case RichTextColor.Red:
                return("#ff0000ff");

            case RichTextColor.Silver:
                return("#c0c0c0ff");

            case RichTextColor.Teal:
                return("#008080ff");

            case RichTextColor.White:
                return("#ffffffff");

            case RichTextColor.Yellow:
                return("#ffff00ff");

            default:
                return("#000000ff");
            }
        }
示例#5
0
 public static string SetTextColor(string text, RichTextColor color = RichTextColor.Black)
 {
     return("<color=" + GetHexValue(color) + ">" + text + "</color>");
 }
 /// <summary>
 /// Return this text with rich text changing the color to the specified color option.
 /// </summary>
 /// <param name="text"></param>
 /// <param name="color"></param>
 /// <returns></returns>
 public static string ColorText(this string text, RichTextColor color)
 {
     return("<color=" + color.ToString() + ">" + text + "</color>");
 }
示例#7
0
 /// <summary>Sets the color of a variable number of words.</summary>
 /// <param name="value">The string.</param>
 /// <param name="color">The RichTextColor color.</param>
 /// <param name="highlightedIndices">The variable number of word indicies.</param>
 public static string SetColorForWords(this string value, RichTextColor color, params int[] highlightedIndices)
 {
     return(value.SetColorForWords(color.ToString(), highlightedIndices));
 }
示例#8
0
 /// <summary>Sets the color of each character of the string.</summary>
 /// <param name="value">The string.</param>
 /// <param name="color">The RichTextColor color.</param>
 public static string SetColor(this string value, RichTextColor color)
 {
     return(value.SetColor(color.ToString()));
 }