public GeneratedAchievementViewModel(GameViewModel owner, Achievement generatedAchievement) { _owner = owner; Generated = new AchievementViewModel(owner, "Generated"); if (generatedAchievement != null) { Generated.LoadAchievement(generatedAchievement); Id = Generated.Id; } Local = new AchievementViewModel(owner, "Local"); Unofficial = new AchievementViewModel(owner, "Unofficial"); Core = new AchievementViewModel(owner, "Core"); if (String.IsNullOrEmpty(owner.RACacheDirectory)) { UpdateLocalCommand = DisabledCommand.Instance; DeleteLocalCommand = DisabledCommand.Instance; } else { UpdateLocalCommand = new DelegateCommand(() => UpdateLocal(owner)); DeleteLocalCommand = new DelegateCommand(() => DeleteLocal(owner)); } }
private void UpdateLocal(GameViewModel owner) { var achievement = Generated.Achievement; if (achievement.Id == 0 && Local.Id > 0) { achievement.Id = Local.Id; } if (!String.IsNullOrEmpty(Local.BadgeName)) { achievement.BadgeName = Local.BadgeName; } owner.UpdateLocal(achievement, Local.Achievement); Local = new AchievementViewModel(owner, "Local"); Local.LoadAchievement(achievement); OnPropertyChanged(() => Local); UpdateModified(); }
internal void UpdateCommonProperties(GameViewModel owner) { if (Local.Modified == ModifiedState.Unmodified) { var localAchievement = Local.Achievement; Local = new AchievementViewModel(owner, "Local"); Local.LoadAchievement(localAchievement); } if (Unofficial.Modified == ModifiedState.Unmodified) { var unofficialAchievement = Unofficial.Achievement; Unofficial = new AchievementViewModel(owner, "Unofficial"); Unofficial.LoadAchievement(unofficialAchievement); } if (Core.Modified == ModifiedState.Unmodified) { var coreAchievement = Core.Achievement; Core = new AchievementViewModel(owner, "Core"); Core.LoadAchievement(coreAchievement); } if (Generated.Achievement != null) { Id = Generated.Id; SetBinding(TitleProperty, new ModelBinding(Generated.Title, TextFieldViewModel.TextProperty, ModelBindingMode.OneWay)); SetBinding(DescriptionProperty, new ModelBinding(Generated.Description, TextFieldViewModel.TextProperty, ModelBindingMode.OneWay)); SetBinding(PointsProperty, new ModelBinding(Generated.Points, IntegerFieldViewModel.ValueProperty, ModelBindingMode.OneWay)); } else if (Core.Achievement != null) { Title = Core.Title.Text; Description = Core.Description.Text; Points = Core.Points.Value.GetValueOrDefault(); } else if (Unofficial.Achievement != null) { Title = Unofficial.Title.Text; Description = Unofficial.Description.Text; Points = Unofficial.Points.Value.GetValueOrDefault(); } else if (Local.Achievement != null) { Title = Local.Title.Text; Description = Local.Description.Text; Points = Local.Points.Value.GetValueOrDefault(); } if (Core.Achievement != null) { Id = Core.Id; } else if (Unofficial.Achievement != null) { Id = Unofficial.Id; } else if (Local.Achievement != null) { Id = Local.Id; } UpdateModified(); }