private async void btnSteal_Click(object sender, RoutedEventArgs e) { btnSteal.IsEnabled = false; try { var victimData = await UserApi.GetProfileById(Convert.ToInt32(txtStealId.Value)) .ConfigureAwait(true); if (victimData.Data == null) { throw new Exception(); } await UserApi.EditProfile(SettingsManager.PersistentSettings.CurrentUser.Token, victimData.Data) .ConfigureAwait(true); await DialogManager.ShowDialog("Success", "Profile copied") .ConfigureAwait(true); } catch (Exception ex) { await DialogManager.ShowDialog("Some rtarded shit happened", ex.Message) .ConfigureAwait(true); } finally { btnSteal.IsEnabled = true; } }
private async void EditNumericAge_Click(object sender, RoutedEventArgs e) { UserProfileStat element = sender as UserProfileStat; BindingExpression binding = element?.GetBindingExpression(UserProfileStat.StatValueProperty); if (binding == null) { return; } ProfileSchema sourceClass = (ProfileSchema)binding.ResolvedSource; PropertyInfo sourceProperty = typeof(ProfileSchema).GetProperty(binding.ResolvedSourcePropertyName); if (sourceClass == null || sourceProperty == null) { return; } string title = LocalizationUtils.GetLocalized("ProfileEditingTitle"); string enterName = LocalizationUtils.GetLocalized("EnterTitle"); int oldValue = (int)(sourceProperty.GetValue(sourceClass) ?? 0); double?value = await DialogManager.ShowNumericDialog(title, $"{enterName} '{element.StatTitle}'", Convert.ToDouble(oldValue), 0.0, 255.0, 1.0, "F0") .ConfigureAwait(true); if (value == null) { return; } //sourceProperty.SetValue(sourceClass, value.Length == 0 ? null : value); sourceProperty.SetValue(sourceClass, Convert.ToInt32(value)); var request = await UserApi.EditProfile( SettingsManager.PersistentSettings.CurrentUser.Token, ViewModel.CurrentProfileData) .ConfigureAwait(true); if (request.IsError) { await DialogManager.ShowErrorDialog(request.Message) .ConfigureAwait(true); sourceProperty.SetValue(sourceClass, oldValue); } var statBlock = element.TryFindParent <StackPanel>(); if (statBlock == null) { return; } UpdateStatBlock(statBlock); }
public static async Task ChangeBanner(string url, bool checkEmptyUrl = true) { try { if (checkEmptyUrl && string.IsNullOrWhiteSpace(url)) { return; } var result = await UserApi.GetProfileById( SettingsManager.PersistentSettings.CurrentUser.Id) .ConfigureAwait(true); if (result.IsError) { await DialogManager.ShowErrorDialog(result.Message) .ConfigureAwait(true); return; } if (result.Data == null) { var message = LocalizationUtils.GetLocalized("GettingProfileErrorMessage"); await DialogManager.ShowErrorDialog( $"{message}: " + result.Message) .ConfigureAwait(true); return; } var oldPhoto = result.Data.BannerUrl; result.Data.BannerUrl = url; var request = await UserApi.EditProfile( SettingsManager.PersistentSettings.CurrentUser.Token, result.Data) .ConfigureAwait(true); if (request.IsError) { await DialogManager.ShowErrorDialog(request.Message) .ConfigureAwait(true); return; } OnBannerChanged(null, new UserPhotoChangedEventArgs(oldPhoto, result.Data.BannerUrl, result.Data.Id)); } catch (Exception ex) { await DialogManager.ShowErrorDialog(ex.Message) .ConfigureAwait(true); } }
private async void UserNameEditClick(object sender, RoutedEventArgs e) { UserInfoBanner element = this; BindingExpression binding = element.txtName.GetBindingExpression(Emoji.Wpf.TextBlock.TextProperty); if (binding == null) { return; } ProfileSchema sourceClass = (ProfileSchema)binding.ResolvedSource; PropertyInfo sourceProperty = typeof(ProfileSchema).GetProperty(binding.ResolvedSourcePropertyName); if (sourceClass == null || sourceProperty == null) { return; } string title = LocalizationUtils.GetLocalized("ProfileEditingTitle"); string enterName = LocalizationUtils.GetLocalized("EnterTitle"); string statName = LocalizationUtils.GetLocalized("Nickname"); string oldValue = (string)sourceProperty.GetValue(sourceClass); string value = await DialogManager.ShowSinglelineTextDialog(title, $"{enterName} '{statName}'", oldValue) .ConfigureAwait(true); if (value == null) { return; } sourceProperty.SetValue(sourceClass, value); var request = await UserApi.EditProfile( SettingsManager.PersistentSettings.CurrentUser.Token, UserProfile) .ConfigureAwait(true); if (request.IsError) { await DialogManager.ShowErrorDialog(request.Message) .ConfigureAwait(true); sourceProperty.SetValue(sourceClass, oldValue); return; } ProfileUtils.OnNameChanged(this, new UserNameChangedEventArgs(oldValue, value, UserProfile.Id)); }
private async void EditComboBoxSex_Click(object sender, RoutedEventArgs e) { UserProfileStat element = sender as UserProfileStat; BindingExpression binding = element?.GetBindingExpression(UserProfileStat.StatValueProperty); if (binding == null) { return; } ProfileSchema sourceClass = (ProfileSchema)binding.ResolvedSource; PropertyInfo sourceProperty = typeof(ProfileSchema).GetProperty(binding.ResolvedSourcePropertyName); if (sourceClass == null || sourceProperty == null) { return; } string title = LocalizationUtils.GetLocalized("ProfileEditingTitle"); string enterName = LocalizationUtils.GetLocalized("EnterTitle"); ReadOnlyCollection <string> localizedNames = new ReadOnlyCollection <string>(UserSexType.Unknown.GetLocalizedNames()); UserSexType oldValue = (UserSexType)(sourceProperty.GetValue(sourceClass) ?? UserSexType.Unknown); string valueName = await DialogManager.ShowComboBoxDialog(title, $"{enterName} '{element.StatTitle}'", localizedNames, oldValue.GetLocalizedName()) .ConfigureAwait(true); if (valueName == null) { return; } UserSexType value = UserSexType.Unknown.ParseLocalizedName <UserSexType>(valueName); //sourceProperty.SetValue(sourceClass, value.Length == 0 ? null : value); sourceProperty.SetValue(sourceClass, value); var request = await UserApi.EditProfile( SettingsManager.PersistentSettings.CurrentUser.Token, ViewModel.CurrentProfileData) .ConfigureAwait(true); if (request.IsError) { await DialogManager.ShowErrorDialog(request.Message) .ConfigureAwait(true); sourceProperty.SetValue(sourceClass, oldValue); } var statBlock = element.TryFindParent <StackPanel>(); if (statBlock == null) { return; } UpdateStatBlock(statBlock); }
private async void EditMultilineText_Click(object sender, RoutedEventArgs e) { var profileStat = sender as UserProfileStat; var binding = profileStat? .GetBindingExpression(UserProfileStat.StatValueProperty); if (binding == null) { return; } var sourceClass = (ProfileSchema)binding.ResolvedSource; var sourceProperty = typeof(ProfileSchema).GetProperty( binding.ResolvedSourcePropertyName); if (sourceClass == null || sourceProperty == null) { return; } var title = LocalizationUtils .GetLocalized("ProfileEditingTitle"); var enterName = LocalizationUtils .GetLocalized("EnterTitle"); var oldValue = (string)sourceProperty.GetValue( sourceClass); var value = await DialogManager.ShowMultilineTextDialog( title, $"{enterName} '{profileStat.StatTitle}'", oldValue) .ConfigureAwait(true); if (value == null) { return; } sourceProperty.SetValue( sourceClass, value); var request = await UserApi.EditProfile( SettingsManager.PersistentSettings.CurrentUser.Token, ViewModel.CurrentProfileData) .ConfigureAwait(true); if (request.IsError) { await DialogManager.ShowErrorDialog(request.Message) .ConfigureAwait(true); sourceProperty.SetValue( sourceClass, oldValue); } var statBlock = profileStat .TryFindParent <StackPanel>(); if (statBlock == null) { return; } UpdateStatBlock( statBlock); }
private async void EditName_Click(object sender, RoutedEventArgs e) { var page = this; var binding = page.NicknameTextBox .GetBindingExpression(Emoji.Wpf.TextBlock.TextProperty); if (binding == null) { return; } var sourceClass = (ProfileSchema)binding.ResolvedSource; var sourceProperty = typeof(ProfileSchema).GetProperty( binding.ResolvedSourcePropertyName); if (sourceClass == null || sourceProperty == null) { return; } var title = LocalizationUtils .GetLocalized("ProfileEditingTitle"); var enterName = LocalizationUtils .GetLocalized("EnterTitle"); var statName = LocalizationUtils .GetLocalized("Nickname"); var oldValue = (string)sourceProperty.GetValue( sourceClass); var value = await DialogManager.ShowSinglelineTextDialog( title, $"{enterName} '{statName}'", oldValue) .ConfigureAwait(true); if (value == null) { return; } sourceProperty.SetValue( sourceClass, value); var request = await UserApi.EditProfile( SettingsManager.PersistentSettings.CurrentUser.Token, ViewModel.CurrentProfileData) .ConfigureAwait(true); if (request.IsError) { await DialogManager.ShowErrorDialog(request.Message) .ConfigureAwait(true); sourceProperty.SetValue( sourceClass, oldValue); return; } ProfileUtils.OnNameChanged(this, new UserNameChangedEventArgs(oldValue, value, ViewModel.CurrentProfileData.Id)); }