Exemplo n.º 1
0
        internal List <stMsgRichFormat> BuildRichImg(out int listLength, int imgPos)
        {
            listLength = 0;
            List <stMsgRichFormat> outRichList = new List <stMsgRichFormat>();
            stMsgRichFormat        outMsgRich  = new stMsgRichFormat();

            outMsgRich.Position = (short)imgPos;  // or 1 ??? // todo
            outMsgRich.Font     = FONT_IMAGE;
            listLength         += 13;
            outRichList.Add(outMsgRich);
            return(outRichList);
        }
Exemplo n.º 2
0
        internal List <stMsgRichFormat> BuildRichText(ref SortedDictionary <short, string> msgFormat, out int listLength)
        {
            listLength = 0;
            if (msgFormat == null)
            {
                return(new List <stMsgRichFormat>());
            }
            List <stMsgRichFormat> outRichList = new List <stMsgRichFormat>();
            IDictionaryEnumerator  msgFEnum    = msgFormat.GetEnumerator();

            while (msgFEnum.MoveNext())
            {
                stMsgRichFormat outMsgRich = new stMsgRichFormat();
                string          formatTags = msgFEnum.Value.ToString();
                outMsgRich.Position = short.Parse(msgFEnum.Key.ToString());;
                outMsgRich.Font     = FONT_NONE;
                if (formatTags.Contains(FONT_TAG_BOLD))
                {
                    outMsgRich.Font |= FONT_BOLD;
                }
                if (formatTags.Contains(FONT_TAG_ITALIC))
                {
                    outMsgRich.Font |= FONT_ITALIC;
                }
                if (formatTags.Contains(FONT_TAG_UNDERLINE))
                {
                    outMsgRich.Font |= FONT_UNDERLINE;
                }
                listLength += 3;
                IDictionaryEnumerator fontColorEnumerator = FONT_COLOR_CODES.GetEnumerator();
                while (fontColorEnumerator.MoveNext())
                {
                    if (formatTags.Contains(fontColorEnumerator.Key.ToString()))
                    {
                        outMsgRich.Font  |= FONT_COLOR;
                        outMsgRich.RGB    = new byte[3];
                        outMsgRich.RGB[0] = byte.Parse(fontColorEnumerator.Value.ToString().Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                        outMsgRich.RGB[1] = byte.Parse(fontColorEnumerator.Value.ToString().Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
                        outMsgRich.RGB[2] = byte.Parse(fontColorEnumerator.Value.ToString().Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
                        listLength       += 3;
                    }
                }
                outRichList.Add(outMsgRich);
            }
            return(outRichList);
        }