public void ReportPeerAsync(TLInputPeerBase peer, TLInputReportReasonBase reason, Action <TLBool> callback, Action <TLRPCError> faultCallback = null)
        {
            var obj = new TLReportPeer {
                Peer = peer, Reason = reason
            };

            SendInformativeMessage("account.reportPeer", obj, callback, faultCallback);
        }
Exemplo n.º 2
0
        private void ReportAsync(TLInputPeerBase inputPeer, TLVector <TLInt> id, TLInputReportReasonBase reason)
        {
            if (inputPeer == null)
            {
                return;
            }
            if (reason == null)
            {
                return;
            }

            if (id == null)
            {
                IsWorking = true;
                MTProtoService.ReportPeerAsync(inputPeer, reason,
                                               result => Execute.BeginOnUIThread(() =>
                {
                    IsWorking = false;
                    MessageBox.Show(AppResources.ReportSpamNotification, AppResources.AppName, MessageBoxButton.OK);
                }),
                                               error => Execute.BeginOnUIThread(() =>
                {
                    IsWorking = false;
                }));
            }
            else
            {
                IsWorking = true;
                MTProtoService.ReportAsync(inputPeer, id, reason,
                                           result => Execute.BeginOnUIThread(() =>
                {
                    IsWorking = false;
                    MessageBox.Show(AppResources.ReportSpamNotification, AppResources.AppName, MessageBoxButton.OK);
                }),
                                           error => Execute.BeginOnUIThread(() =>
                {
                    IsWorking = false;
                }));
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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();
        }