//public RelayCommand<TLKeyboardButtonBase> KeyboardButtonCommand => new RelayCommand<TLKeyboardButtonBase>(KeyboardButtonExecute); public async void KeyboardButtonExecute(TLKeyboardButtonBase button, TLMessage message) { if (button is TLKeyboardButtonBuy buyButton) { if (message.Media is TLMessageMediaInvoice invoiceMedia && invoiceMedia.HasReceiptMsgId) { var response = await ProtoService.GetPaymentReceiptAsync(invoiceMedia.ReceiptMsgId.Value); if (response.IsSucceeded) { NavigationService.Navigate(typeof(PaymentReceiptPage), TLTuple.Create(message, response.Result)); } } else { var response = await ProtoService.GetPaymentFormAsync(message.Id); if (response.IsSucceeded) { if (response.Result.Invoice.IsEmailRequested || response.Result.Invoice.IsNameRequested || response.Result.Invoice.IsPhoneRequested || response.Result.Invoice.IsShippingAddressRequested) { NavigationService.NavigateToPaymentFormStep1(message, response.Result); } else if (response.Result.HasSavedCredentials) { if (ApplicationSettings.Current.TmpPassword != null) { if (ApplicationSettings.Current.TmpPassword.ValidUntil < TLUtils.Now + 60) { ApplicationSettings.Current.TmpPassword = null; } } if (ApplicationSettings.Current.TmpPassword != null) { NavigationService.NavigateToPaymentFormStep5(message, response.Result, null, null, null, null, null, true); } else { NavigationService.NavigateToPaymentFormStep4(message, response.Result, null, null, null); } } else { NavigationService.NavigateToPaymentFormStep3(message, response.Result, null, null, null); } } } }
public ReplyMarkupButtonClickEventArgs(TLKeyboardButtonBase button) { Button = button; }
private FrameworkElement CreateButton(TLKeyboardButtonBase keyboardButton, double height, Thickness margin, double padding, int maxTextLength) { var isLightTheme = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible; var background = isLightTheme ? (Brush)Resources["ButtonLightBackground"] : (Brush)Resources["ButtonBackground"]; var text = keyboardButton.Text.ToString(); var buttonBuy = keyboardButton as TLKeyboardButtonBuy; if (buttonBuy != null) { var message = DataContext as TLMessage; if (message != null) { var mediaInvoice = message.Media as TLMessageMediaInvoice; if (mediaInvoice != null) { var receiptMsgId = mediaInvoice.ReceiptMsgId; if (receiptMsgId != null) { text = AppResources.Receipt; } } } } if (text.Length > maxTextLength) { text = text.Substring(0, maxTextLength) + "..."; } else { text = string.Format(" {0} ", text); } var textBox = new TelegramRichTextBox { MaxHeight = height, Margin = new Thickness(0.0, 0.0, 0.0, 0.0), Padding = new Thickness(0.0, 0.0, 0.0, 0.0), FontSize = 22, TextWrapping = TextWrapping.NoWrap }; BrowserNavigationService.SetSuppressParsing(textBox, true); textBox.Text = text; textBox.Margin = new Thickness(-12.0 + padding, 0.0, -12.0, 0 + padding); textBox.FontSize = Inline ? 17.776 : textBox.FontSize; textBox.Foreground = Inline ? new SolidColorBrush(Colors.White) : textBox.Foreground; var button = new Button(); button.Style = (Style)Resources["CommandButtonStyle"]; button.MaxHeight = height; button.Margin = margin; button.Background = Inline ? (Brush)Resources["ButtonInlineBackground"] : background; button.Content = textBox; button.DataContext = keyboardButton; button.Click += OnButtonClick; if (keyboardButton is TLKeyboardButtonUrl) { var imageSource = isLightTheme && !Inline ? "/Images/Messages/inline.openweb.light.png" : "/Images/Messages/inline.openweb.png"; var grid = new Grid(); grid.Children.Add(button); grid.Children.Add(new Image { Width = 11.0, Height = 11.0, Margin = new Thickness(8.0), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, Source = new BitmapImage(new Uri(imageSource, UriKind.Relative)) }); return(grid); } if (keyboardButton is TLKeyboardButtonSwitchInline) { var imageSource = isLightTheme && !Inline ? "/Images/Messages/inline.share.light.png" : "/Images/Messages/inline.share.png"; var grid = new Grid(); grid.Children.Add(button); grid.Children.Add(new Image { Width = 13.0, Height = 12.0, Margin = new Thickness(8.0), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, Source = new BitmapImage(new Uri(imageSource, UriKind.Relative)) }); return(grid); } return(button); }