public void Report(TLInputPeerBase inputPeer, TLVector <TLInt> id = null)
        {
            var spamRadioButton = new RadioButton {
                Content = AppResources.Spam, IsChecked = true, Margin = new Thickness(0.0, 0.0, 12.0, -12.0), Background = new SolidColorBrush(Colors.Transparent), GroupName = "Report"
            };
            var violenceRadioButton = new RadioButton {
                Content = AppResources.Violence, Margin = new Thickness(0.0, -12.0, 12.0, -12.0), Background = new SolidColorBrush(Colors.Transparent), GroupName = "Report"
            };
            var pornographyRadioButton = new RadioButton {
                Content = AppResources.Pornography, Margin = new Thickness(0.0, -12.0, 12.0, -12.0), Background = new SolidColorBrush(Colors.Transparent), GroupName = "Report"
            };
            var copyrightRadioButton = new RadioButton {
                Content = AppResources.Copyright, Margin = new Thickness(0.0, -12.0, 12.0, -12.0), Background = new SolidColorBrush(Colors.Transparent), GroupName = "Report"
            };
            var otherRadioButton = new RadioButton {
                Content = AppResources.Other, Margin = new Thickness(0.0, -12.0, 12.0, -12.0), Background = new SolidColorBrush(Colors.Transparent), GroupName = "Report"
            };

            TiltEffect.SetIsTiltEnabled(spamRadioButton, true);
            TiltEffect.SetIsTiltEnabled(violenceRadioButton, true);
            TiltEffect.SetIsTiltEnabled(pornographyRadioButton, true);
            TiltEffect.SetIsTiltEnabled(otherRadioButton, true);

            var reportContent = new StackPanel();

            reportContent.Children.Add(spamRadioButton);
            reportContent.Children.Add(violenceRadioButton);
            reportContent.Children.Add(pornographyRadioButton);
            reportContent.Children.Add(copyrightRadioButton);
            reportContent.Children.Add(otherRadioButton);

            var confirmation = new CustomMessageBox
            {
                Caption              = AppResources.Report,
                Message              = string.Empty,
                Content              = reportContent,
                LeftButtonContent    = AppResources.Cancel.ToLowerInvariant(),
                RightButtonContent   = AppResources.Ok.ToLowerInvariant(),
                IsLeftButtonEnabled  = true,
                IsRightButtonEnabled = true
            };

#if WP8
            var isFullHD = Application.Current.Host.Content.ScaleFactor == 225 || Environment.OSVersion.Version.Major >= 10;
            if (isFullHD)
            {
                spamRadioButton.FontSize        = 17.667;
                violenceRadioButton.FontSize    = 17.667;
                pornographyRadioButton.FontSize = 17.667;
                copyrightRadioButton.FontSize   = 17.667;
                otherRadioButton.FontSize       = 17.667;
                confirmation.Style = (Style)Application.Current.Resources["CustomMessageBoxFullHDStyle"];
            }
#endif

            confirmation.Dismissed += (sender, args) =>
            {
                if (args.Result == CustomMessageBoxResult.RightButton)
                {
                    TLInputReportReasonBase reason = null;
                    if (spamRadioButton.IsChecked == true)
                    {
                        reason = new TLInputReportReasonSpam();
                    }
                    else if (violenceRadioButton.IsChecked == true)
                    {
                        reason = new TLInputReportReasonViolence();
                    }
                    else if (pornographyRadioButton.IsChecked == true)
                    {
                        reason = new TLInputReportReasonPornography();
                    }
                    else if (copyrightRadioButton.IsChecked == true)
                    {
                        reason = new TLInputReportReasonCopyright();
                    }
                    else if (otherRadioButton.IsChecked == true)
                    {
                        reason = new TLInputReportReasonOther {
                            Text = TLString.Empty
                        };
                    }
                    GetReasonAndReportAsync(inputPeer, id, reason);
                }
            };
            confirmation.Show();
        }
        private void GetReasonAndReportAsync(TLInputPeerBase inputPeer, TLVector <TLInt> id, TLInputReportReasonBase reason)
        {
            if (reason is TLInputReportReasonOther)
            {
                var text = new TextBox {
                    Margin = new Thickness(0.0, 0.0, 12.0, 0.0)
                };
                TiltEffect.SetIsTiltEnabled(text, true);

                var reportContent = new StackPanel();
                reportContent.Children.Add(new TextBlock {
                    Text = AppResources.Description, Margin = new Thickness(12.0, 6.0, 12.0, -5.0), Style = (Style)Application.Current.Resources["PhoneTextSubtleStyle"]
                });
                reportContent.Children.Add(text);

                var confirmation = new CustomMessageBox
                {
                    Caption              = AppResources.Report,
                    Message              = string.Empty,
                    Content              = reportContent,
                    RightButtonContent   = AppResources.Cancel.ToLowerInvariant(),
                    LeftButtonContent    = AppResources.Ok.ToLowerInvariant(),
                    IsLeftButtonEnabled  = true,
                    IsRightButtonEnabled = true
                };

                text.Loaded += (o, e) =>
                {
                    confirmation.IsLeftButtonEnabled = false;
                    text.Focus();
                };
                text.TextChanged += (o, e) =>
                {
                    confirmation.IsLeftButtonEnabled = !string.IsNullOrEmpty(text.Text);
                };
#if WP8
                var isFullHD = Application.Current.Host.Content.ScaleFactor == 225;
                if (isFullHD || Environment.OSVersion.Version.Major >= 10)
                {
                    text.FontSize      = 17.667;
                    confirmation.Style = (Style)Application.Current.Resources["CustomMessageBoxFullHDStyle"];
                }
#endif

                confirmation.Dismissed += (sender, args) =>
                {
                    switch (args.Result)
                    {
                    case CustomMessageBoxResult.RightButton:
                        break;

                    case CustomMessageBoxResult.LeftButton:
                        reason = new TLInputReportReasonOther {
                            Text = new TLString(text.Text)
                        };
                        ReportAsync(inputPeer, id, reason);
                        break;

                    case CustomMessageBoxResult.None:
                        // Do something.
                        break;

                    default:
                        break;
                    }
                };
                confirmation.Show();
            }
            else
            {
                ReportAsync(inputPeer, id, reason);
            }
        }
Exemple #3
0
        private async void ReportExecute()
        {
            var user = Item as TLUser;

            if (user != null)
            {
                var opt1 = new RadioButton {
                    Content = "Spam", Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch
                };
                var opt2 = new RadioButton {
                    Content = "Violence", Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch
                };
                var opt3 = new RadioButton {
                    Content = "Pornography", Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch
                };
                var opt4 = new RadioButton {
                    Content = "Other", Margin = new Thickness(0, 8, 0, 8), HorizontalAlignment = HorizontalAlignment.Stretch, IsChecked = true
                };
                var stack = new StackPanel();
                stack.Children.Add(opt1);
                stack.Children.Add(opt2);
                stack.Children.Add(opt3);
                stack.Children.Add(opt4);
                stack.Margin = new Thickness(0, 16, 0, 0);
                var dialog = new ContentDialog();
                dialog.Content = stack;
                dialog.Title   = "Resources.Report";
                dialog.IsPrimaryButtonEnabled   = true;
                dialog.IsSecondaryButtonEnabled = true;
                dialog.PrimaryButtonText        = "Resources.OK";
                dialog.SecondaryButtonText      = "Resources.Cancel";

                var dialogResult = await dialog.ShowQueuedAsync();

                if (dialogResult == ContentDialogResult.Primary)
                {
                    var reason = opt1.IsChecked == true
                        ? new TLInputReportReasonSpam()
                        : (opt2.IsChecked == true
                            ? new TLInputReportReasonViolence()
                            : (opt3.IsChecked == true
                                ? new TLInputReportReasonPornography()
                                : (TLReportReasonBase) new TLInputReportReasonOther()));

                    if (reason.TypeId == TLType.InputReportReasonOther)
                    {
                        var input = new InputDialog();
                        input.Title                    = "Resources.Report";
                        input.PlaceholderText          = "Resources.Description";
                        input.IsPrimaryButtonEnabled   = true;
                        input.IsSecondaryButtonEnabled = true;
                        input.PrimaryButtonText        = "Resources.OK";
                        input.SecondaryButtonText      = "Resources.Cancel";

                        var inputResult = await input.ShowQueuedAsync();

                        if (inputResult == ContentDialogResult.Primary)
                        {
                            reason = new TLInputReportReasonOther {
                                Text = input.Text
                            };
                        }
                        else
                        {
                            return;
                        }
                    }

                    var result = await ProtoService.ReportPeerAsync(user.ToInputPeer(), reason);

                    if (result.IsSucceeded && result.Result)
                    {
                        await new TLMessageDialog("Resources.ReportSpamNotification", "Unigram").ShowQueuedAsync();
                    }
                }
            }
        }