Esempio n. 1
0
        /// <summary>
        /// Loads the contents of this <see cref="ITextDocument"/> from the specified <see cref="DrxDocument"/>.
        /// </summary>
        public static void LoadFromDrx(this ITextDocument rtf, DrxDocument document)
        {
            if (document.Header.BodyType != DrxBodyType.Rtf)
            {
                throw new Exception("Document is of an unsupported encoding.");
            }

            var bytes = document.GetPlainTextBodyAsType(DrxBodyType.Rtf);

            if (bytes.Length <= 0)
            {
                // Remember to clear the document,
                // as we don't want leftover state for new ones
                rtf.SetText(TextSetOptions.None, string.Empty);
                return;
            }

            using (var stream = new InMemoryRandomAccessStream())
            {
                var writeStream = stream.AsStreamForWrite();
                writeStream.Write(bytes, 0, bytes.Length);
                writeStream.Position = 0;

                stream.Seek(0);
                rtf.LoadFromStream(TextSetOptions.FormatRtf, stream);
            }
        }
Esempio n. 2
0
        public async void GetStar()
        {
            // extract star block from .picasa.ini file
            try
            {
                String      _starFile = PathRoot + "\\" + PathAlbum + "\\.picasa.ini";
                StorageFile _picasIni = await StorageFile.GetFileFromPathAsync(_starFile);

                IRandomAccessStream sourceStream = await _picasIni.OpenAsync(FileAccessMode.Read);

                ITextDocument _doc = null;
                _doc.LoadFromStream(TextSetOptions.None, sourceStream);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }