private FrameworkElement CreateButton(TLKeyboardButton keyboardButton, double height, double margin) { var isLightTheme = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible; var background = isLightTheme ? (Brush)Resources["ButtonLightBackground"] : (Brush)Resources["ButtonBackground"]; var text = keyboardButton.Text.ToString(); var textBox = new TelegramRichTextBox { Text = text, MaxHeight = height, Margin = new Thickness(0.0, -4.0, 0.0, 0.0), FontSize = 22, FontFamily = new FontFamily("Segoe WP Semibold") }; BrowserNavigationService.SetSuppressParsing(textBox, true); var button = new Button(); button.Style = (Style)Resources["CommandButtonStyle"]; button.Height = height; button.Margin = new Thickness(margin); button.Background = background; button.Content = textBox; button.DataContext = keyboardButton; button.Click += OnButtonClick; return(button); }
public void ShowTermsOfService(TLTermsOfService termsOfService) { var termsOfService80 = termsOfService as TLTermsOfService80; var entities = termsOfService80 != null ? termsOfService80.Entities : null; var content = new TelegramRichTextBox { FontSize = 17.776, Margin = new Thickness(0.0, 11.0, 0.0, 0.0), TextWrapping = TextWrapping.Wrap, DataContext = new TLMessage73 { Flags = new TLInt(0), Message = termsOfService.Text, Entities = entities }, Text = termsOfService.Text.ToString() }; ShellViewModel.ShowCustomMessageBox( string.Empty, AppResources.TermsOfService, AppResources.Ok.ToLowerInvariant(), null, dismissed => { }, content); }
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); }