TextFromRtf() публичный статический Метод

public static TextFromRtf ( string rtf ) : string
rtf string
Результат string
Пример #1
0
        public static string ShhWrap(string data)
        {
            string rtf = Util.RtfFromText(data);

            if (rtf.StartsWith(@"{\rtf1"))
            {
                rtf = rtf.Remove(5, 1);
            }

            {
                string unrtfData = Util.TextFromRtf(rtf);

                Debug.Assert(unrtfData == data);
            }

            return(rtf);
        }
Пример #2
0
        void imModality_InstantMessageReceived(object sender, MessageSentEventArgs e)
        {
            try
            {
                var modality = (InstantMessageModality)sender;
                IDictionary <InstantMessageContentType, string> messageFormatProperty = e.Contents;

                string source = (string)modality.Participant.Contact.GetContactInformation(ContactInformationType.DisplayName);

                string text = "";
                string raw  = "";
                if (messageFormatProperty.ContainsKey(InstantMessageContentType.PlainText))
                {
                    if (messageFormatProperty.TryGetValue(InstantMessageContentType.PlainText, out raw))
                    {
                        text = raw;
                    }
                }
                else if (messageFormatProperty.ContainsKey(InstantMessageContentType.RichText))
                {
                    if (messageFormatProperty.TryGetValue(InstantMessageContentType.RichText, out raw))
                    {
                        text = Util.TextFromRtf(raw);
                    }
                }
                else if (messageFormatProperty.ContainsKey(InstantMessageContentType.Html))
                {
                    if (messageFormatProperty.TryGetValue(InstantMessageContentType.Html, out raw))
                    {
                        var reg      = new System.Text.RegularExpressions.Regex("<[^>]+>");
                        var stripped = reg.Replace(raw, "");
                        text = System.Web.HttpUtility.HtmlDecode(stripped);
                    }
                }
                //else if (messageFormatProperty.ContainsKey(InstantMessageContentType.Gif))
                //{
                //    if (messageFormatProperty.TryGetValue(InstantMessageContentType.Gif, out raw))
                //    {
                //        // gif, "base64:{data}"
                //    }
                //}
                //else if (messageFormatProperty.ContainsKey(InstantMessageContentType.Ink))
                //{
                //    // InkSerializedFormat (application/x-ms-ink)
                //    if (messageFormatProperty.TryGetValue(InstantMessageContentType.Ink, out raw))
                //    {
                //        // isf, just use Microsoft.Ink to Load/Save
                //    }
                //}

                if (!string.IsNullOrEmpty(text))
                {
                    if (whisperCat.HandleWhisper(modality.Conversation, modality.Participant, text))
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }