public ProfileViewModel(Profile profile = null) { this.Profile = profile; if (this.Profile != null) { this.BattleTag = this.Profile.BattleTag; this.Number = "#" + this.BattleTag.Number.ToString(); this.LastUpdated = string.Format("{0}: {1}", AppRes.LastUpdated, this.Profile.LastUpdated); this.NormalHeroes = new ObservableCollection<NormalHeroViewModel>(profile.Heroes.Select(h => new NormalHeroViewModel(h))); this.LargeHeroes = new ObservableCollection<LargeHeroViewModel>(profile.Heroes.Select(h => new LargeHeroViewModel(h))); this.SetTimePlayed(this.Profile.TimePlayed); this.SetArtisans(this.Profile.Artisans, this.Profile.HardcoreArtisans); this.NormalProgression = GetHighestProgression(this.Profile.Progression); this.HardcoreProgression = GetHighestProgression(this.Profile.HardcoreProgression); } }
private void FindProfile() { Action<Profile> action = delegate(Profile profile) { this.Dispatcher.BeginInvoke(delegate { try { if (!string.IsNullOrEmpty(profile.ErrorCode)) { App.ShowAlert(string.Format("{0}: {1}", profile.ErrorCode, profile.ErrorReason)); this.MyViewModel.ProfileViewModel = null; this.AppButtons[1].IsEnabled = false; this.tbBattleTag.Focus(); } else { this.MyViewModel.ProfileViewModel = new ProfileViewModel(profile); this.AppButtons[1].IsEnabled = true; this.lbHero.Focus(); } } catch (Exception ex) { App.ShowAlert(ex.Message); } this.MyViewModel.ShowProgressBar = false; this.profile = profile; }); }; this.Dispatcher.BeginInvoke(delegate { this.MyViewModel.ShowProgressBar = true; var battleTag = new BattleTag(this.tbBattleTag.Text.Trim()); new D3Client().GetProfile(this.lpRealm.SelectedItem as Realm, battleTag.Tag, action); }); }