Пример #1
0
        void Service_FillInformation(object sender, GetMovieCommentsCompletedEventArgs e)
        {
            SingletonQuery.QueryClient.GetMovieCommentsCompleted -= this.Service_FillInformation;

            if (e.Error == null)
            {
                ObservableCollection <Comment> comments = e.Result;

                if (comments.Count == 0)
                {
                    TextBlock textBlock = new TextBlock();
                    textBlock.Text       = "There are no comments to this movie.";
                    textBlock.Foreground = new SolidColorBrush(Colors.Yellow);
                    this.commentsPanel.Children.Add(textBlock);
                }
                else
                {
                    foreach (var comment in comments)
                    {
                        StackPanel          sp             = new StackPanel();
                        LinearGradientBrush linearGradient = new LinearGradientBrush();
                        linearGradient.StartPoint = new Point(0, 0);
                        linearGradient.EndPoint   = new Point(0, 1);
                        linearGradient.Opacity    = 0.8;

                        GradientStop whiteGS = new GradientStop();
                        whiteGS.Color  = Colors.White;
                        whiteGS.Offset = 0.0;
                        linearGradient.GradientStops.Add(whiteGS);

                        GradientStop blackGS = new GradientStop();
                        blackGS.Color  = Colors.Black;
                        blackGS.Offset = 0.2;
                        linearGradient.GradientStops.Add(blackGS);

                        TextBlock label = new TextBlock();
                        label.Text                = string.Format("commented on {0} by {1}", comment.Date, comment.Username);
                        label.FontSize            = 14;
                        label.Foreground          = new SolidColorBrush(Colors.Yellow);
                        label.HorizontalAlignment = HorizontalAlignment.Right;

                        TextBlock textBlock = new TextBlock();
                        textBlock.Text         = comment.Text;
                        textBlock.FontSize     = 20;
                        textBlock.Foreground   = new SolidColorBrush(Colors.Yellow);
                        textBlock.Width        = 430;
                        textBlock.TextWrapping = TextWrapping.Wrap;

                        sp.Margin     = new Thickness(0, 0, 0, 20);
                        sp.Background = linearGradient;

                        sp.Children.Add(textBlock);
                        sp.Children.Add(label);

                        this.commentsPanel.Children.Add(sp);
                    }
                }
            }
        }
Пример #2
0
        void Service_FillInformation(object sender, GetMovieCommentsCompletedEventArgs e)
        {
            SingletonQuery.QueryClient.GetMovieCommentsCompleted -= this.Service_FillInformation;

            if (e.Error == null)
            {
                ObservableCollection<Comment> comments = e.Result;

                if (comments.Count == 0)
                {
                    TextBlock textBlock = new TextBlock();
                    textBlock.Text = "There are no comments to this movie.";
                    textBlock.Foreground = new SolidColorBrush(Colors.Yellow);
                    this.commentsPanel.Children.Add(textBlock);
                }
                else
                {
                    foreach (var comment in comments)
                    {
                        StackPanel sp = new StackPanel();
                        LinearGradientBrush linearGradient = new LinearGradientBrush();
                        linearGradient.StartPoint = new Point(0, 0);
                        linearGradient.EndPoint = new Point(0, 1);
                        linearGradient.Opacity = 0.8;

                        GradientStop whiteGS = new GradientStop();
                        whiteGS.Color = Colors.White;
                        whiteGS.Offset = 0.0;
                        linearGradient.GradientStops.Add(whiteGS);

                        GradientStop blackGS = new GradientStop();
                        blackGS.Color = Colors.Black;
                        blackGS.Offset = 0.2;
                        linearGradient.GradientStops.Add(blackGS);

                        TextBlock label = new TextBlock();
                        label.Text = string.Format("commented on {0} by {1}", comment.Date, comment.Username);
                        label.FontSize = 14;
                        label.Foreground = new SolidColorBrush(Colors.Yellow);
                        label.HorizontalAlignment = HorizontalAlignment.Right;

                        TextBlock textBlock = new TextBlock();
                        textBlock.Text = comment.Text;
                        textBlock.FontSize = 20;
                        textBlock.Foreground = new SolidColorBrush(Colors.Yellow);
                        textBlock.Width = 430;
                        textBlock.TextWrapping = TextWrapping.Wrap;

                        sp.Margin = new Thickness(0, 0, 0, 20);
                        sp.Background = linearGradient;

                        sp.Children.Add(textBlock);
                        sp.Children.Add(label);

                        this.commentsPanel.Children.Add(sp);
                    }
                }
            }
        }