<commit_before>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using biz.dfch.CS.CoffeeTracker.Client.CoffeeTrackerService;
using biz.dfch.CS.CoffeeTracker.Client.Wpf.Controls;
using biz.dfch.CS.CoffeeTracker.Client.Wpf.UserControls.CompleteViews.Base;
using MahApps.Metro.Controls;

namespace biz.dfch.CS.CoffeeTracker.Client.Wpf.UserControls.Components
{
    /// <summary>
    /// Interaction logic for CoffeeSelector.xaml
    /// </summary>
    public partial class CoffeeSelector : UserControl
    {
        private readonly ObservableCollection<string> brands = new ObservableCollection<string>();
        private List<Coffee> coffees = new List<Coffee>();

        public CoffeeSelector()
        {
            InitializeComponent();
            var client = ClientContext.GetServiceContext();
            coffees = client.Coffees.ToList();
            var allBrands = coffees.Select(coffee => coffee.Brand).ToList().Distinct().ToList();
            foreach (var brand in allBrands)
            {
                brands.Add(brand);
            }

            CoffeeSelectorBrandSplitButton.ItemsSource = brands;
        }

        private void BrandSplitButton_OnSelection(object sender, RoutedEventArgs e)
        {
            var splitButton = sender as SplitButton;
            var brand = splitButton.SelectedItem as string;
            var allCoffeesOfBrand = coffees.Where(c => c.Brand == brand).ToList<Coffee>();
            var allCoffeesOfBrandObservableCollection = new ObservableCollection<Coffee>();
            foreach (var coffee in allCoffeesOfBrand)
            {
                allCoffeesOfBrandObservableCollection.Add(coffee);
            }

            CoffeeSelectorCoffeeSplitButton.ItemsSource = allCoffeesOfBrandObservableCollection;
            CoffeeSelectorCoffeeSplitButton.IsEnabled = true;
        }
    }
}<commit_msg>added loading and displaying of data<commit_after>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using biz.dfch.CS.CoffeeTracker.Client.CoffeeTrackerService;
using biz.dfch.CS.CoffeeTracker.Client.Wpf.Controls;
using biz.dfch.CS.CoffeeTracker.Client.Wpf.UserControls.CompleteViews.Base;
using MahApps.Metro.Controls;

namespace biz.dfch.CS.CoffeeTracker.Client.Wpf.UserControls.Components
{
    /// <summary>
    /// Interaction logic for CoffeeSelector.xaml
    /// </summary>
    public partial class CoffeeSelector : UserControl
    {
        private readonly ObservableCollection<string> brands = new ObservableCollection<string>();
        private List<Coffee> coffees = new List<Coffee>();

        public CoffeeSelector()
        {
            InitializeComponent();
            var client = ClientContext.GetServiceContext();
            coffees = client.Coffees.ToList();
            var allBrands = coffees.Select(coffee => coffee.Brand).ToList().Distinct().ToList();
            foreach (var brand in allBrands)
            {
                brands.Add(brand);
            }

            CoffeeSelectorBrandSplitButton.ItemsSource = brands;
        }

        private void BrandSplitButton_OnSelection(object sender, RoutedEventArgs e)
        {
            DisplayLoading();
            var worker = new BackgroundWorker();
            worker.DoWork += (o, args) =>
            {
                var splitButton = sender as SplitButton;
                var brand = splitButton.SelectedItem as string;
                var allCoffeesOfBrand = coffees.Where(c => c.Brand == brand).ToList<Coffee>();
                var allCoffeesOfBrandObservableCollection = new ObservableCollection<Coffee>();
                foreach (var coffee in allCoffeesOfBrand)
                {
                    allCoffeesOfBrandObservableCollection.Add(coffee);
                }

                CoffeeSelectorCoffeeSplitButton.ItemsSource = allCoffeesOfBrandObservableCollection;
            };

            worker.RunWorkerCompleted += async (o, args) =>
            {
                await Task.Delay(3000);
                HideLoading();
            };
            worker.RunWorkerAsync();
        }

        private void DisplayLoading()
        {
            CoffeeSelectorCoffeeSplitButton.IsEnabled = false;
            CoffeeSelectorBrandSplitButton.IsEnabled = false;
            CoffeeSelectorProgressRing.IsActive = true;
        }

        private void HideLoading()
        {
            CoffeeSelectorCoffeeSplitButton.IsEnabled = true;
            CoffeeSelectorBrandSplitButton.IsEnabled = true;
            CoffeeSelectorProgressRing.IsActive = false;
        }
    }
}
{'fraction_non_alphanumeric': 0.08905136857892763, 'fraction_numerical': 0.0007499062617172854, 'mean_word_length': 2.6194029850746268, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '380693', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1380, 'n_words': 275}