コード例 #1
0
 bool ToggleFavorite()
 {
     if (FavoritesManager.IsFavorite(session.Key))
     {
         FavoritesManager.RemoveFavoriteSession(session.Key);
         return(false);
     }
     else
     {
         var fav = new Favorite {
             SessionID = session.ID, SessionKey = session.Key
         };
         FavoritesManager.AddFavoriteSession(fav);
         return(true);
     }
 }
コード例 #2
0
 bool ToggleFavorite()
 {
     if (FavoritesManager.IsFavorite(session.Key))
     {
         FavoriteButton.SetImage(new UIImage(AppDelegate.ImageNotFavorite), UIControlState.Normal);
         FavoritesManager.RemoveFavoriteSession(session.Key);
         return(false);
     }
     else
     {
         FavoriteButton.SetImage(new UIImage(AppDelegate.ImageIsFavorite), UIControlState.Normal);
         var fav = new Favorite {
             SessionID = session.ID, SessionKey = session.Key
         };
         FavoritesManager.AddFavoriteSession(fav);
         return(true);
     }
 }
コード例 #3
0
        private void HandleFavoriteClick(object sender, EventArgs e)
        {
            var vm = (SessionDetailsViewModel)DataContext;

            if (FavoritesManager.IsFavorite(vm.Key))
            {
                FavoritesManager.RemoveFavoriteSession(vm.Key);
                UpdateFavoriteButtonIcon(false);
            }
            else
            {
                FavoritesManager.AddFavoriteSession(new Favorite {
                    SessionKey = vm.Key,
                });
                UpdateFavoriteButtonIcon(true);
            }

            vm.UpdateIsFavorite();
        }