private void FormHome_FormClosed(object sender, FormClosedEventArgs e) { // お気に入り -> XML // text List <FavoriteData> favoriteDataList = new List <FavoriteData>(); for (int i = 0; i < lstFavorite.Items.Count; i++) { favoriteDataList.Add((FavoriteData)lstFavorite.Items[i]); } // ●お気に入りデータの設定 { FavoriteData data = new FavoriteData(); data.Title = browser.DocumentTitle; data.Url = browser.Url.ToString(); } System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(List <FavoriteData>)); using (System.IO.StreamWriter writer = new System.IO.StreamWriter("favorite.xml", false, Encoding.UTF8)) { serializer.Serialize(writer, favoriteDataList); } }
public async Task <IActionResult> AddToFavorite(FavoriteData data) { if (data == null) { return(RedirectToAction("Index", "Schedule")); } try { var userReference = await ReferencesRepository .FetchAsync(new UserReferenceFilter(x => User.FindFirstValue(Services.Identity.User.IdClaimType).Equals(x.UserId)), RequestWindow.One) .ConfigureAwait(continueOnCapturedContext: false); if (userReference.Count == 0) { return(RedirectToAction("Index", "Schedule")); } await ThreadsRepository .AddAsync(new StarredThreadData(data.ThreadId, data.FromCode, data.ToCode, null, userReference[0])) .ConfigureAwait(continueOnCapturedContext: false); return(RedirectToAction("Index", new { fromCode = data.BaseFromCode, toCode = data.BaseToCode })); } catch (Exception exc) { return(RedirectToAction("Error", new ErrorViewModel { Exception = exc })); } }
public async Task RefreshData() { Favorites.Clear(); var favoritesList = _favoritesManager.GetAll(); foreach (var favoriteData in favoritesList) { try { var result = await FavoriteData.Create(favoriteData, _dataProvider); Favorites.Add(result); } catch (FavoriteCreateException favoriteException) { Crashes.TrackError(favoriteException, new Dictionary <string, string> { { "routeId", favoriteData.RouteId }, { "stopId", favoriteData.StopId } }); _favoritesManager.Delete(favoriteData.RouteId, favoriteData.StopId); } catch (Exception exc) { Crashes.TrackError(exc, new Dictionary <string, string> { { "routeId", favoriteData.RouteId }, { "stopId", favoriteData.StopId } }); } } }
private async void MovieDiscussButton_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; FavoriteData favoritedata = button.DataContext as FavoriteData; var uri = new Uri(favoritedata.MovieDiscuss); await Windows.System.Launcher.LaunchUriAsync(uri); }
/// <summary> /// Update the favorite list, attaching all required event handlers. /// We will load favorites from isolated storage, on the state of the /// input parameter /// </summary> /// <param name="favoritesListView">List view for the favorites</param> /// <param name="favoritesNoItems">Text block for the favorites</param> internal void UpdateFavoriteList( ListBox favoritesListView, TextBlock favoritesNoItems) { FavoriteCollection favCollection = ApplicationState.Favorites == null ? favCollection = FavoriteCollection.LoadFromFile() : ApplicationState.Favorites; if (favCollection.Count > 0) { // show listbox, hide no favorites label favoritesListView.Visibility = Visibility.Visible; favoritesNoItems.Visibility = Visibility.Collapsed; favoritesListView.ItemsSource = favCollection; } else { // hide listbox, show no favorites label favoritesListView.Visibility = Visibility.Collapsed; favoritesNoItems.Visibility = Visibility.Visible; } // We need to instal these handlers in the order below to be sure they don't get // eaten by the ListView control this.lastSelectedFavorite = null; }
/// <summary> /// Clear the list of favorites, remove the selected item from isolated storage, /// and remove installed event handlers /// </summary> internal void DeleteSelectedFavorite() { // Remove favorite and store. FavoriteCollection favCollection = ApplicationState.Favorites; favCollection.Remove(this.lastSelectedFavorite); FavoriteCollection.SaveToFile(favCollection); this.lastSelectedFavorite = null; }
private static Task LoadOptions() { return(Task.Run(() => { ModList = new ModList(); SMAPI = new SmapiIntegration(); Options = ModList.Where(mod => !mod.Value.Disabled && mod.Value.Options != null).SelectMany(mod => mod.Value.Options).ToList(); FavoriteData.LoadOptions(); })); }
public void DeleteItem(FavoriteData favoriteData) { if (Favorites.Contains(favoriteData)) { Favorites.Remove(favoriteData); _favoritesManager.Delete(favoriteData.Route.Route_Id, favoriteData.Stop.Stop_Id); OnPropertyChanged(nameof(HasAnyFavorites)); OnPropertyChanged(nameof(HasNoFavorites)); } }
public override void ReceiveLeftClick(int x, int y) { if (!_boundsStar.Contains(x, y)) { return; } Game1.playSound("drumkit6"); base.ReceiveLeftClick(x, y); Favorite = !Favorite; FavoriteData.ChangeStatus(ModId); }
/// <summary> /// Processes the favorite selection changed. /// </summary> /// <param name="e">Event data.</param> internal void ProcessFavoriteSelectionChanged(SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { FavoriteData favorite = e.AddedItems[0] as FavoriteData; ApplicationState.CategoryPageInformation.UpdateNames( favorite.Category, favorite.SourceUnitName, favorite.TargetUnitName); this.lastSelectedFavorite = favorite; } }
internal int UpadateData(FavoriteData updataFavoriteData) { int result = 0; DbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, DbName); using (var conn = GetCreateConn()) { result = conn.Update(updataFavoriteData); } return(result); }
internal int AddData(FavoriteData AddFavorite) { int result = 0; using (var conn = GetCreateConn()) { result = conn.Insert(AddFavorite); } return(result); }
public async Task <IActionResult> Favorites() { var currentUser = await GetCurrentUserAsync(); FavoriteData vm = new FavoriteData(); var applicationDbContext = _context.ExerciseFavorites .Include(o => o.Exercise) .Where(a => a.ApplicationUserId == currentUser.Id); vm.ExerciseFavorites = applicationDbContext; return(View(vm)); }
private async void Favorite_partners_ItemTapped(object sender, ItemTappedEventArgs e) { FavoriteData selected = (FavoriteData)favorite_partners.SelectedItem; PartnerData partner = PartnerData.Data.First(i => i.PartnerName.ToLower().Equals(selected.PartnerName.ToLower())); var clickedPage = new PartnerActivity { BindingContext = partner }; await Navigation.PushAsync(clickedPage, true); }
/// <summary> /// Add the current set of units to the Favorit list /// </summary> /// <param name="signalCompleted">Delegate to call when the thread pool /// operation has completed</param> /// <returns>True signals that the favorite is already added ( no need to save). /// False indicates that we are in process of saving</returns> internal bool AddToFavorite(Action signalCompleted) { FavoriteCollection favCollection = ApplicationState.Favorites; FavoriteData favorite = new FavoriteData(this.ConversionSettings, 0); bool favoriteExists = favCollection.AddNewItem(favorite); if (!favoriteExists) { // Thread pool queue operation FavoriteCollection.BeginSaveToFile(favCollection, signalCompleted, null); } return(favoriteExists); }
private void Delete_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; FavoriteData favoritedata = button.DataContext as FavoriteData; sqliteHelper.DeleteData(favoritedata); string sql = "delete from sqlite_sequence where name='FavoriteData';"; sqliteHelper.UpadateData(sql); FavoriteList.Remove(favoritedata); if (FavoriteList.Count == 0) { TB.Opacity = 1; } else { TB.Opacity = 0; } }
private async void Favorite_Click(object sender, RoutedEventArgs e) { sqliteHelper.CreateDB(); Button button = sender as Button; Datum1 data = button.DataContext as Datum1; List <FavoriteData> fav = sqliteHelper.CheckData(data.tvTitle); int CheckDataResult = 0; foreach (FavoriteData i in fav) { if (i.tvTitle == data.tvTitle) { CheckDataResult = 1; } } if (CheckDataResult == 1) { var dialog = new MessageDialog("你已经收藏过了厚", "yoho"); dialog.Commands.Add(new UICommand("确定", cmd => { })); var a = await dialog.ShowAsync(); } else { FavoriteData Addfavorite = new FavoriteData(); Addfavorite.tvTitle = data.tvTitle; Addfavorite.iconaddress = data.iconaddress; Addfavorite.grade = data.grade; Addfavorite.gradeNum = data.gradeNum; Addfavorite.data2 = data.playDate.data2; Addfavorite.director1 = data.director.data.a.name; if (data.director.data.b != null) { Addfavorite.director2 = data.director.data.b.name; } Addfavorite.star1 = data.star.data.a.name; if (data.star.data.b != null) { Addfavorite.star2 = data.star.data.b.name; } if (data.star.data.c != null) { Addfavorite.star3 = data.star.data.c.name; } if (data.star.data.d != null) { Addfavorite.star4 = data.star.data.d.name; } Addfavorite.type1 = data.type.data.a.name; if (data.type.data.b != null) { Addfavorite.type2 = data.type.data.b.name; } if (data.type.data.c != null) { Addfavorite.type3 = data.type.data.c.name; } if (data.type.data.d != null) { Addfavorite.type4 = data.type.data.d.name; } if (data.type.data.e != null) { Addfavorite.type5 = data.type.data.e.name; } Addfavorite.storyBrief = data.story.data.storyBrief; Addfavorite.MovieImage = data.more.data[1].link; Addfavorite.MovieDiscuss = data.more.data[2].link; Addfavorite.storyMoreLink = data.story.data.storyMoreLink; sqliteHelper.AddData(Addfavorite); } }
/// <summary> /// Add the current set of units to the Favorit list /// </summary> /// <param name="signalCompleted">Delegate to call when the thread pool /// operation has completed</param> /// <returns>True signals that the favorite is already added ( no need to save). /// False indicates that we are in process of saving</returns> internal bool AddToFavorite(Action signalCompleted) { FavoriteCollection favCollection = ApplicationState.Favorites; FavoriteData favorite = new FavoriteData(this.ConversionSettings, 0); bool favoriteExists = favCollection.AddNewItem(favorite); if (!favoriteExists) { // Thread pool queue operation FavoriteCollection.BeginSaveToFile(favCollection, signalCompleted, null); } return favoriteExists; }
/// <summary> /// Update the favorite list, attaching all required event handlers. /// We will load favorites from isolated storage, on the state of the /// input parameter /// </summary> /// <param name="favoritesListView">List view for the favorites</param> /// <param name="favoritesNoItems">Text block for the favorites</param> internal void UpdateFavoriteList( ListBox favoritesListView , TextBlock favoritesNoItems) { FavoriteCollection favCollection = ApplicationState.Favorites == null ? favCollection = FavoriteCollection.LoadFromFile() : ApplicationState.Favorites; if (favCollection.Count > 0) { // show listbox, hide no favorites label favoritesListView.Visibility = Visibility.Visible; favoritesNoItems.Visibility = Visibility.Collapsed; favoritesListView.ItemsSource = favCollection; } else { // hide listbox, show no favorites label favoritesListView.Visibility = Visibility.Collapsed; favoritesNoItems.Visibility = Visibility.Visible; } // We need to instal these handlers in the order below to be sure they don't get // eaten by the ListView control this.lastSelectedFavorite = null; }