using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
//< add
namespaces >
using Windows.Storage; //*file access
using Windows.UI.Popups; //*Messagebox
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
//</ add
namespaces >
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace uwp_Advertiser
{
public sealed partial class TextPage : Page
{
#region page
public TextPage()
{
this.InitializeComponent();
}
#endregion /page
#region Buttons
private void
btnBack_Click(object sender, RoutedEventArgs e)
{
//----<
btnBack_Click() >----
//*navigate
back to mainpage
this.Frame.GoBack();
//----</
btnBack_Click() >----
}
private void btnLoad_XAML_Click(object sender, RoutedEventArgs e)
{
//load
xaml file
load_RichText_Editor("_files/Code_AdControl.xaml.txt");
}
private void
btnLoad_C_Code_Click(object sender, RoutedEventArgs e)
{
//load
C# File
load_RichText_Editor("_files/Code_AdControl.xaml.cs.txt");
}
#endregion /Buttons
private async void load_RichText_Editor(string sFilename)
{
//----<
load_RichText_Editor() >----
//*load
text-file into a RichText Editor
//<
get File >
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(this.BaseUri,
sFilename ));
//</
get File >
if (file != null)
{
try
{
//< open file >
Windows.Storage.Streams.IRandomAccessStream
randAccStream = await
file.OpenAsync(Windows.Storage.FileAccessMode.Read);
//</ open file >
//< load File into Text-Editor >
ctlEdit_Text.Document.LoadFromStream(Windows.UI.Text.TextSetOptions.FormatRtf,
randAccStream);
//</ load File into Text-Editor >
}
catch (Exception)
{
MessageDialog dialog = new MessageDialog("could not load the
file", "Load
File into Text Editor");
await dialog.ShowAsync();
}
}
//----</
load_RichText_Editor() >----
}
}
}
|