Beispiel #1
0
        public static Book GetBook(string url, UriKind urikind)
        {
            Book result = new Book();
            string content = AtFile.GetContent(url, 4);
            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(content));
            StreamReader reader = null;
            try
            {
                reader = new StreamReader(stream);
                string str2 = null;
                while ((str2 = reader.ReadLine()) != null)
                {
                    string[] strArray = str2.Replace("&&", "&").Split(new char[] { '&' });
                    if (strArray.Length >= 3)
                    {
                        Chapter item = new Chapter();
                        item.Title = strArray[0];
                        item.FileName = strArray[1];
                        item.Size = int.Parse(strArray[2]);
                        result.Chapters.Add(item);
                    }
                }
                reader.Close();
            }
            catch (NullReferenceException ex)
            {

            }
            return result;
        }
Beispiel #2
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            this.loader.Start();

            IsolatedStorageSettings.ApplicationSettings.TryGetValue<Book>("bookinfo", out this.book);
            if (this.book == null)
            {
                this.book = TextParser.GetBook(OkrBookContext.Current.Config.Data +"/category.txt", UriKind.Relative);
                IsolatedStorageSettings.ApplicationSettings["bookinfo"] = this.book;
            }

            Progress progress = null;

            IsolatedStorageSettings.ApplicationSettings.TryGetValue<Progress>("current", out progress);
            if (progress == null)
            {
                progress = new Progress();
                progress.Chapter = 0;
                progress.Page = 0;
                progress.Percent = 0.0;
                IsolatedStorageSettings.ApplicationSettings["current"] = progress;
            }

            this.Init();
        }