文件

作者: 落地成佛 | 来源:发表于2017-12-07 22:39 被阅读8次
           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);
                            }
                        }
                    }
                }
    

    相关文章

      网友评论

        本文标题:文件

        本文链接:https://www.haomeiwen.com/subject/ycajixtx.html