/// <summary> /// Initializes a new instance of the <see cref="FavoriteWrapper"/> class. /// </summary> /// <param name="favorite">The favorite map pin.</param> /// <param name="viewModel">The reference to the current view model.</param> public FavoriteWrapper(MapExPin favorite, FavoritesViewModel viewModel) { // Store the current favorite this.favorite = favorite; this.viewModel = viewModel; // Setup commands this.SetAsPrimaryCommand = new Command(this.SetAsPrimary); this.RemoveFavoriteCommand = new Command(this.RemoveFavorite); }
/// <summary> /// Determines whether the specified <see cref="MapExPin"/> is equal to the current <see cref="MapExPin"/>. /// </summary> /// <param name="obj">The <see cref="MapExPin"/> to compare with the current object.</param> /// <returns> /// <b>true</b> if the specified <see cref="MapExPin"/> is equal to the current <see cref="MapExPin"/>; /// otherwise, <b>false</b>. /// </returns> // ReSharper disable once MemberCanBePrivate.Global public bool Equals(MapExPin obj) { // If parameter is null return false if ((object)obj == null) { return(false); } // Compare value types return((this.Type == obj.Type) && (this.Position == obj.Position) && (this.Address == obj.Address) && (this.Label == obj.Label)); }
/// <summary> /// Initializes a new instance of the <see cref="FavoritesViewModel"/> class. /// </summary> /// <param name="favorites">The user favorites.</param> /// <param name="primaryFavorite">The primary user favorite.</param> public FavoritesViewModel(IEnumerable <MapExPin> favorites, MapExPin primaryFavorite) { // Get the favorites collection this.Favorites = new ObservableCollection <FavoriteWrapper>(); foreach (var favorite in favorites) { // Create the favorite wrapper for UI var wrapper = new FavoriteWrapper(favorite, this); this.Favorites.Add(wrapper); wrapper.PropertyChanged += this.OnFavoritePropertyChanged; // If the favorite is a primary favorite if (favorite == primaryFavorite) { wrapper.IsPrimary = true; } } // Setup commands this.CancelCommand = new Command(this.Cancel); }