Assembly assembly = GetType().GetTypeInfo().Assembly;
string resource = "BlackCat.Texts.TheBlackCat.txt";
using (Stream stream = assembly.GetManifestResourceStream (resource))
{
using (StreamReader reader = new StreamReader (stream))
{
bool gotTitle = false;
string line;
// Read in a line (which is actually a paragraph).
while (null != (line = reader.ReadLine()))
{
Label label = new Label
{
Text = line,
// Black text for ebooks!
TextColor = Color.Black
};
if (!gotTitle)
{
// Add first label (the title) to mainStack.
label.HorizontalOptions = LayoutOptions.Center;
label.FontSize = Device.GetNamedSize(NamedSize.Medium, label);
label.FontAttributes = FontAttributes.Bold;
mainStack.Children.Add(label);
gotTitle = true;
}
else
{
// Add subsequent labels to textStack.
textStack.Children.Add(label);
}
}
}
}
网友评论