private void ParseImage(MessagePack msgPack, ImageEx image)
        {
            EmoticonItem tag = image.Tag as EmoticonItem;

            if (tag.IsSysEmoticon)
            {
                SysFaceElement element = (SysFaceElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_SYSFACE);
                element.Index = Convert.ToByte(tag.Id);
            }
            else
            {
                ImageElement element2 = (ImageElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_IMAGE);
                element2.Path = "OSRoot:" + tag.Fileorg;
            }
        }
        /// <summary>
        /// 创建消息包
        /// </summary>
        /// <returns></returns>
        public MessagePack CreateMessagePack()
        {
            MessagePack msgPack = new MessagePack
            {
                Header = { FontName = this.InputBox.FontFamily.ToString(), FontSize = (byte)(this.InputBox.FontSize - 3.0) }
            };
            SolidColorBrush foreground = this.InputBox.Foreground as SolidColorBrush;

            if (foreground != null)
            {
                msgPack.Header.FontColor = foreground.Color;
            }
            byte num = 0;

            if (this.InputBox.FontWeight == FontWeights.Bold)
            {
                num = (byte)(num | 1);
            }
            if (this.InputBox.FontStyle == FontStyles.Italic)
            {
                num = (byte)(num | 2);
            }
            if (true)//Underline
            {
                num = (byte)(num | 4);
            }
            msgPack.Header.FontEffect = num;

            if (!string.IsNullOrEmpty(this.InputBox.Text))
            {
                ((TextElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_TEXT)).SetText(this.InputBox.Text);
            }
            return(new MessagePack(CoreMessenger.Instance.MsgStorage.TransformMsg(msgPack.Key)));
        }
        private void ParseRun(MessagePack msgPack, System.Windows.Documents.Run run)
        {
            string text = run.Text;

            if (!string.IsNullOrEmpty(text))
            {
                ((InstanceAnswerPro.Core.TextElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_TEXT)).SetText(text);
            }
        }
Example #4
0
 public static void ParseImage(MessagePack msgPack, ImageEx image)
 {
     EmoticonItem tag = image.Tag as EmoticonItem;
     if (tag.IsSysEmoticon)
     {
         SysFaceElement element = (SysFaceElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_SYSFACE);
         element.Index = Convert.ToByte(tag.Id);
     }
     else
     {
         ImageElement element2 = (ImageElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_IMAGE);
         element2.Path = "OSRoot:" + tag.Fileorg;
         ImageElementNum++;
     }
 }
Example #5
0
 public MessagePack CreateMessagePack(out int imageCount)
 {
     ImageElementNum = 0;
     imageCount = 0;
     //if (this.IsEmpty()==true)
     //{
     //    return null;
     //}
     BlockCollection blocks = base.Document.Blocks;
     //if (blocks.Count == 0)
     //{
     //    return null;
     //}
     MessagePack msgPack = new MessagePack
     {
         Header = { FontName = base.Document.FontFamily.ToString(), FontSize = (byte)(base.Document.FontSize - 3.0) }
     };
     SolidColorBrush foreground = base.Document.Foreground as SolidColorBrush;
     if (foreground != null)
     {
         msgPack.Header.FontColor = foreground.Color;
     }
     byte num = 0;
     if (base.Document.FontWeight == FontWeights.Bold)
     {
         num = (byte)(num | 1);
     }
     if (base.Document.FontStyle == FontStyles.Italic)
     {
         num = (byte)(num | 2);
     }
     if (this.Underline)
     {
         num = (byte)(num | 4);
     }
     msgPack.Header.FontEffect = num;
     bool flag = false;
     foreach (Block block in blocks)
     {
         if (flag)
         {
             ((TextElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_TEXT)).SetText("\r\n");
         }
         else
         {
             flag = true;
         }
         if (block is Paragraph)
         {
             Paragraph paragraph = block as Paragraph;
             ParseInlines(msgPack, paragraph.Inlines);
         }
         else if (block is BlockUIContainer)
         {
             BlockUIContainer container = block as BlockUIContainer;
             ImageEx child = container.Child as ImageEx;
             if (child != null)
             {
                 ParseImage(msgPack, child);
             }
         }
     }
     ITXMsgPack xcdbca = CoreMessenger.Instance.MsgStorage.TransformMsg(msgPack.Key);
     imageCount = ImageElementNum;
     ImageElementNum = 0;
     return new MessagePack(xcdbca);
 }
Example #6
0
 public static void ParseRun(MessagePack msgPack, Run run)
 {
     string text = run.Text;
     if (!string.IsNullOrEmpty(text))
     {
         ((TextElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_TEXT)).SetText(text);
     }
 }
Example #7
0
 public static void ParseLineBreak(MessagePack msgPack, LineBreak lineBreak)
 {
     ((TextElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_TEXT)).SetText("\r\n");
 }
 private void ParseRun(MessagePack msgPack, System.Windows.Documents.Run run)
 {
     string text = run.Text;
     if (!string.IsNullOrEmpty(text))
     {
         ((InstanceAnswerPro.Core.TextElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_TEXT)).SetText(text);
     }
 }
 private void ParseLineBreak(MessagePack msgPack, LineBreak lineBreak)
 {
     ((InstanceAnswerPro.Core.TextElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_TEXT)).SetText("\r\n");
 }
        /// <summary>
        /// 创建消息包
        /// </summary>
        /// <returns></returns>
        public MessagePack CreateMessagePack()
        {
            MessagePack msgPack = new MessagePack
            {
                Header = { FontName = this.InputBox.FontFamily.ToString(), FontSize = (byte)(this.InputBox.FontSize - 3.0) }
            };
            SolidColorBrush foreground = this.InputBox.Foreground as SolidColorBrush;
            if (foreground != null)
            {
                msgPack.Header.FontColor = foreground.Color;
            }
            byte num = 0;
            if (this.InputBox.FontWeight == FontWeights.Bold)
            {
                num = (byte)(num | 1);
            }
            if (this.InputBox.FontStyle == FontStyles.Italic)
            {
                num = (byte)(num | 2);
            }
            if (true)//Underline
            {
                num = (byte)(num | 4);
            }
            msgPack.Header.FontEffect = num;

            if (!string.IsNullOrEmpty(this.InputBox.Text))
            {
                ((TextElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_TEXT)).SetText(this.InputBox.Text);
            }
            return new MessagePack(CoreMessenger.Instance.MsgStorage.TransformMsg(msgPack.Key));
        }
 private void ParseLineBreak(MessagePack msgPack, LineBreak lineBreak)
 {
     ((InstanceAnswerPro.Core.TextElement)msgPack.CreateElement(MsgPackCat.ELEMTYPE_TEXT)).SetText("\r\n");
 }