async void OnOpenAppBarButtonClick(object sender, RoutedEventArgs args)
        {
            FileOpenPicker picker = new FileOpenPicker();

            picker.FileTypeFilter.Add(".txt");
            picker.FileTypeFilter.Add(".rtf");
            StorageFile storageFile = await picker.PickSingleFileAsync();

            // If user presses Cancel, result is null
            if (storageFile == null)
            {
                return;
            }

            TextSetOptions textOptions = TextSetOptions.None;

            if (storageFile.ContentType != "text/plain")
            {
                textOptions = TextSetOptions.FormatRtf;
            }

            string message = null;

            try
            {
                IRandomAccessStream stream = await storageFile.OpenAsync(FileAccessMode.Read);

                richEditBox.Document.LoadFromStream(textOptions, stream);
            }
            catch (Exception exc)
            {
                message = exc.Message;
            }

            if (message != null)
            {
                MessageDialog msgdlg = new MessageDialog("The file could not be opened. " +
                                                         "Windows reports the following error: " +
                                                         message, "RichTextEditor");
                await msgdlg.ShowAsync();
            }
        }
Esempio n. 2
0
 public void SetText(TextSetOptions options, string value)
 {
     throw new NotImplementedException();
 }
Esempio n. 3
0
 public void LoadFromStream(TextSetOptions options, Windows.Storage.Streams.IRandomAccessStream value)
 {
     throw new NotImplementedException();
 }