Ejemplo n.º 1
0
        private void SelectRandomComment_OnClick(object sender, RoutedEventArgs e)
        {
            var list = (Comments.ItemsSource as List <Comment>);

            if (list != null)
            {
                if (RemoveDuplicates.IsChecked == true)
                {
                    list = list.GroupBy(a => a.AuthorDisplayName).Select(a => a.FirstOrDefault()).ToList();
                }

                var exclude = ExcludeAuthors.Text;
                if (!String.IsNullOrWhiteSpace(exclude))
                {
                    var excludeArray = exclude.Split(',').Select(a => a.Trim());
                    foreach (var author in excludeArray)
                    {
                        list.RemoveAll(a => a.AuthorDisplayName == author);
                    }
                }

                var final    = new List <Comment>();
                var keywords = IncludeKeyword.Text.Split('|');
                foreach (var key in keywords)
                {
                    if (!String.IsNullOrWhiteSpace(key))
                    {
                        final.AddRange(list.Where(a => a.Content.ToLower().Contains(key)).ToList());
                    }
                }
                MessageBox.Show(final.Count.ToString());
                var dialog = new SimpleSelectionDialog(final, randomProvider);
                dialog.ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private void SelectRandomComment_OnClick(object sender, RoutedEventArgs e)
        {
            var list = (Comments.ItemsSource as List<Comment>);
            if (list != null)
            {
                if (RemoveDuplicates.IsChecked == true)
                    list = list.GroupBy(a => a.AuthorDisplayName).Select(a => a.FirstOrDefault()).ToList();

                var exclude = ExcludeAuthors.Text;
                if (!String.IsNullOrWhiteSpace(exclude))
                {
                    var excludeArray = exclude.Split(',').Select(a => a.Trim());
                    foreach (var author in excludeArray)
                    {
                        list.RemoveAll(a => a.AuthorDisplayName == author);
                    }
                }

                var final = new List<Comment>();
                var keywords = IncludeKeyword.Text.Split('|');
                foreach (var key in keywords)
                {
                    if (!String.IsNullOrWhiteSpace(key))
                    {
                        final.AddRange(list.Where(a => a.Content.ToLower().Contains(key)).ToList());
                    }
                }
                MessageBox.Show(final.Count.ToString());
                var dialog = new SimpleSelectionDialog(final, randomProvider);
                dialog.ShowDialog();
            }
        }