// static List<string> favorites; async public void populateFavorites() { List <string> favorites = new List <string>(); List <WebData> favorite = new List <WebData>(); String filePath = "FavoriteData.csv"; // write file StorageFolder roamingFolder = ApplicationData.Current.RoamingFolder; try { StorageFile file = await roamingFolder.GetFileAsync(filePath); IList <String> strList = await FileIO.ReadLinesAsync(file); foreach (String str in strList) { string[] msg1 = str.Split('\t'); //favorite.Add(new WebData(msg1[0], msg1[1], msg1[2])); string msg2 = string.Join("\n", msg1); favorites.Add(msg2); } var p1 = new Logic.FavoriteDataStore(favorites); } catch (FileNotFoundException ex) { // ファイル無し // favorites.Add("null"); // var p1 = new Logic.FavoriteDataStore(favorites); } }
async private void PopulateFavorites() { try { String filePath = "FavoriteData.csv"; // write file StorageFolder roamingFolder = ApplicationData.Current.RoamingFolder; StorageFile file = await roamingFolder.GetFileAsync(filePath); IList <String> strList = await FileIO.ReadLinesAsync(file); foreach (String str in strList) { string[] msg1 = str.Split('\t'); string msg2 = string.Join("\n", msg1); favorites.Add(msg2); } var p1 = new Logic.FavoriteDataStore(favorites); } catch (FileNotFoundException ex) { // ファイル無し stock.Add("null"); //ListViewItem item = new ListViewItem(); //item.Content = "null"; //favorites.Add("null"); } }
async private void buttonFavorite_Tapped(object sender, TappedRoutedEventArgs e) { this.dlg1.Title = "お気に入りの登録"; dlgText.Text = "お気に入りの登録を行いますか?"; var result = await this.dlg1.ShowAsync(); if (result == ContentDialogResult.Primary) { String filePath = "FavoriteData.csv"; // write file StorageFolder roamingFolder = ApplicationData.Current.RoamingFolder; StorageFile file = await roamingFolder.CreateFileAsync(filePath, CreationCollisionOption.OpenIfExists); await FileIO.AppendTextAsync(file, (string)webView1.DocumentTitle + "\t" + URIBlock.Text + "\t" + DateTime.Now + "\n"); s2.populateFavorites2((string)webView1.DocumentTitle + "\t" + URIBlock.Text + "\t" + DateTime.Now + "\n"); var p2 = new Logic.FavoriteDataStore(ref favorites_load); cvs2.Source = favorites_load; } else if (result == ContentDialogResult.Secondary) { } else { } }
public void populateFavorites2(string url_info) { List <string> stock = new List <string>(); var p1 = new Logic.FavoriteDataStore(ref stock); string[] msg1 = url_info.Split('\t'); string msg2 = string.Join("\n", msg1); stock.Add(msg2);//初回時にファイルが作られてない場合があるよ var p2 = new Logic.FavoriteDataStore(stock); }
private void pageRoot_Loaded(object sender, RoutedEventArgs e) { s1.populateHistories(); var p1 = new Logic.HistoryDataStore(ref histories); cvs1.Source = histories; //var s2 = new Logic.PopulateFavorites(); s2.populateFavorites(); var p2 = new Logic.FavoriteDataStore(ref favorites_load); cvs2.Source = favorites_load; }
async void webView1_ContentLoading(WebView sender, WebViewContentLoadingEventArgs args) { string url = (args.Uri != null) ? args.Uri.ToString() : "<null>"; String filePath = "HistoryData.csv"; //String filePath2 = "LastViewData.csv"; // write file StorageFolder roamingFolder = ApplicationData.Current.RoamingFolder; StorageFile file = await roamingFolder.CreateFileAsync(filePath, CreationCollisionOption.OpenIfExists); // StorageFile file2 = await roamingFolder.CreateFileAsync(filePath2, // CreationCollisionOption.OpenIfExists); try { await FileIO.AppendTextAsync(file, (string)webView1.DocumentTitle + "\t" + url + "\t" + DateTime.Now + "\n"); // await FileIO.AppendTextAsync(file, (string)webView1.DocumentTitle + "\t" + url + "\t" + DateTime.Now + "\n"); } catch (Exception ex) { } var s1 = new Logic.PopulateHistories(); s1.populateHistories(); var p1 = new Logic.HistoryDataStore(ref histories); cvs1.Source = histories; var p2 = new Logic.FavoriteDataStore(ref favorites_load); cvs2.Source = favorites_load; var s2 = new Logic.PopulateLastview(); s2.populateLastview(); }
/// <summary> /// このページには、移動中に渡されるコンテンツを設定します。前のセッションからページを /// 再作成する場合は、保存状態も指定されます。 /// </summary> /// <param name="sender"> /// イベントのソース (通常、<see cref="NavigationHelper"/>)> /// </param> /// <param name="e">このページが最初に要求されたときに /// <see cref="Frame.Navigate(Type, Object)"/> に渡されたナビゲーション パラメーターと、 /// 前のセッションでこのページによって保存された状態の辞書を提供する /// セッション。ページに初めてアクセスするとき、状態は null になります。</param> async private void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { var p1 = new Logic.HistoryDataStore(ref histories); cvs1.Source = histories; var s2 = new Logic.PopulateFavorites(); s2.populateFavorites(); var s1 = new Logic.PopulateHistories(); s1.populateHistories(); var p2 = new Logic.FavoriteDataStore(ref favorites_load); cvs2.Source = favorites_load; if (e.NavigationParameter != null) { string msg = e.NavigationParameter.ToString(); string[] msg2 = msg.Split('\n'); if (UrlBox.Text == "") { try { UrlBox.Text = msg2[1]; } catch { string URL = ""; Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings; try { UrlBox.Text = (string)roamingSettings.Values["exampleSetting"]; } catch (Exception ex) { UrlBox.Text = "http://yahoo.co.jp/"; } //UrlBox.Text = URL; //UrlBox.Text = ""; } await NavigateAsync(); } } else { if (UrlBox.Text == "") { Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings; try { UrlBox.Text = (string)roamingSettings.Values["exampleSetting"]; } catch (Exception ex) { UrlBox.Text = "http://yahoo.co.jp/"; } await NavigateAsync(); } } }