Пример #1
0
        // Converts an rtf content to xaml content.
        internal static MemoryStream ConvertRtfToXaml(string rtfContent)
        {
            MemoryStream memoryStream = new MemoryStream();
            WpfPayload   wpfPayload   = WpfPayload.CreateWpfPayload(memoryStream);

            using (wpfPayload.Package)
            {
                using (Stream xamlStream = wpfPayload.CreateXamlStream())
                {
                    // Create XamlRtfConverter to process the converting from Rtf to Xaml
                    XamlRtfConverter xamlRtfConverter = new XamlRtfConverter();
                    xamlRtfConverter.WpfPayload = wpfPayload;

                    string xamlContent = xamlRtfConverter.ConvertRtfToXaml(rtfContent);
                    if (xamlContent != string.Empty)
                    {
                        StreamWriter streamWriter = new StreamWriter(xamlStream);
                        using (streamWriter)
                        {
                            streamWriter.Write(xamlContent);
                        }
                    }
                    else
                    {
                        memoryStream = null;
                    }
                } // This closes xamlStream
            }     // This closes the package

            return(memoryStream);
        }
        // Token: 0x06003855 RID: 14421 RVA: 0x000FBE94 File Offset: 0x000FA094
        internal static MemoryStream ConvertRtfToXaml(string rtfContent)
        {
            MemoryStream memoryStream = new MemoryStream();
            WpfPayload   wpfPayload   = WpfPayload.CreateWpfPayload(memoryStream);

            using (wpfPayload.Package)
            {
                using (Stream stream = wpfPayload.CreateXamlStream())
                {
                    string text = new XamlRtfConverter
                    {
                        WpfPayload = wpfPayload
                    }.ConvertRtfToXaml(rtfContent);
                    if (text != string.Empty)
                    {
                        StreamWriter streamWriter = new StreamWriter(stream);
                        using (streamWriter)
                        {
                            streamWriter.Write(text);
                            return(memoryStream);
                        }
                    }
                    memoryStream = null;
                }
            }
            return(memoryStream);
        }