예제 #1
0
        public async void OfflineAddToJSON(string rand)
        {
            StorageFile sampleFile = await localFolder.GetFileAsync("OfflinePages.json");

            var JSONData = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);

            OfflineClass OfflineListJSON = JsonConvert.DeserializeObject <OfflineClass>(JSONData);
            Uri          ArgsUri         = new Uri(WebWeb.Source.ToString());
            string       host            = ArgsUri.Host;
            string       x;

            x = await WebWeb.InvokeScriptAsync("eval", new string[] { "document.title;" });

            OfflineListJSON.OfflineWebsites.Add(new OfflineJSON()
            {
                FavIconJSON  = " https://icons.duckduckgo.com/ip2/" + host + ".ico",
                ImageUrlJSON = rand + ".jpg",
                HeaderJSON   = x
            });;
            var SerializedObject = JsonConvert.SerializeObject(OfflineListJSON, Formatting.Indented);
            await Windows.Storage.FileIO.WriteTextAsync(sampleFile, SerializedObject);

            var JSONDatas = await FileIO.ReadTextAsync(sampleFile);

            LoadOffline();
        }
예제 #2
0
        private async void AddFav(object sender, RoutedEventArgs e)
        {
            if (BoolWeb == true)
            {
                StorageFile sampleFile = await localFolder.GetFileAsync("Favorites.json");

                var JSONData = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);

                FavouritesClass FavouritesListJSON = JsonConvert.DeserializeObject <FavouritesClass>(JSONData);
                Uri             ArgsUri            = new Uri(WebWeb.Source.ToString());
                string          host = ArgsUri.Host;
                string          x    = "";
                try
                {
                    x = await WebWeb.InvokeScriptAsync("eval", new string[] { "document.title;" });
                }
                catch
                {
                    x = WebWeb.Source.ToString();
                }
                FavouritesListJSON.Websites.Add(new FavouritesJSON()
                {
                    FavIconJSON = " https://icons.duckduckgo.com/ip2/" + host + ".ico",
                    UrlJSON     = WebWeb.Source.ToString(),
                    HeaderJSON  = x
                });;
                var SerializedObject = JsonConvert.SerializeObject(FavouritesListJSON, Formatting.Indented);
                await Windows.Storage.FileIO.WriteTextAsync(sampleFile, SerializedObject);

                var JSONDatas = await FileIO.ReadTextAsync(sampleFile);

                LoadFav();
            }
            else
            {
                return;
            }
        }