<commit_before>﻿using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Media;
using MSOE.MediaComplete.Lib;
using MSOE.MediaComplete.Lib.Sorting;
using Button = System.Windows.Controls.Button;
using ComboBox = System.Windows.Controls.ComboBox;
using Label = System.Windows.Controls.Label;
using Orientation = System.Windows.Controls.Orientation;

namespace MSOE.MediaComplete
{
    /// <summary>

    /// Interaction logic for Settings.xaml
    /// </summary>
    public partial class Settings
    {
        private readonly List<ComboBox> _comboBoxes;
        private List<string> _sortOrderList;
        private readonly List<bool> _showComboBox; 

        private readonly Dictionary<LayoutType, string> _layoutsDict = new Dictionary<LayoutType, string>
        {
            {LayoutType.Dark, "layout\\Dark.xaml"},
            {LayoutType.Pink, "layout\\Pink.xaml"}
        };
        private LayoutType _changedType;
        private bool _layoutHasChanged;
        public Settings()
        {

            InitializeComponent();
            TxtboxSelectedFolder.Text = SettingWrapper.GetHomeDir();
            LblInboxFolder.Content = SettingWrapper.GetInboxDir();
            ComboBoxPollingTime.SelectedValue = SettingWrapper.GetPollingTime().ToString(CultureInfo.InvariantCulture);
            CheckboxPolling.IsChecked = SettingWrapper.GetIsPolling();
            CheckboxShowImportDialog.IsChecked = SettingWrapper.GetShowInputDialog();
            CheckBoxSorting.IsChecked = SettingWrapper.GetIsSorting();
            PollingCheckBoxChanged(CheckboxPolling, null);
            if (SettingWrapper.GetLayout().Equals(_layoutsDict[LayoutType.Pink]))
            {
                PinkCheck.IsChecked = true;
            }
            else if (SettingWrapper.GetLayout().Equals(_layoutsDict[LayoutType.Dark]))
            {
                DarkCheck.IsChecked = true;
            }
            _comboBoxes = new List<ComboBox>();
            _sortOrderList= SortHelper.ConvertToString(SettingWrapper.GetSortOrder());
            _showComboBox = new List<bool>();
            LoadDictionary();
            LoadSortListBox();
        }

        private void LoadDictionary()
        {
            _showComboBox.Clear();
            for (var i = 0; i < _sortOrderList.Count; i++)
            {
                _showComboBox.Add(true);
            }
        }

        private void LoadSortListBox()
        {
            var withValue = -1;

            for (var i = 0; i < _showComboBox.Count; i++)
            {
                var showValue = _showComboBox[i];
                if (showValue)
                {
                    withValue++;
                }
                var stackPanel = new StackPanel {Orientation = Orientation.Horizontal};
                var folder = new Image
                {
                    Source = (ImageSource)Resources["Settings-Folder-Icon"],
                    Width = 20,
                    Height = 20,
                    Margin = new Thickness(16 * (i + 1), 8, 0, 8)
                };
                var comboBox = new ComboBox
                {
                    Width = 100,
                    Height = 24,
                    ItemsSource = showValue ? SortHelper.GetAllValidAttributes(_sortOrderList, _sortOrderList[withValue]) 
                                                : SortHelper.GetAllUnusedMetaAttributes(_sortOrderList),
                    SelectedValue = showValue ? (object) _sortOrderList[withValue] : -1,
                    Tag = i
                };
                var minus = new Button
                {
                    Content = new Image
                    {
                        Source = (ImageSource) Resources["Settings-MinusConfig-Icon"]
                    },
                    Tag = i,
                    Margin = new Thickness(0, 0, 2, 0)
                };
                minus.SetResourceReference(StyleProperty, "Plus/Minus"); 
                var plus = new Button
                {
                    Content = new Image
                    {
                        Source = (ImageSource)Resources["Settings-AddConfig-Icon"]
                    },
                    Tag = i
                };
                plus.SetResourceReference(StyleProperty, "Plus/Minus"); 

                minus.Click += MinusClicked;
                plus.Click += PlusClicked;
                comboBox.SelectionChanged += SelectChanged;

                _comboBoxes.Add(comboBox);
                stackPanel.Children.Add(folder);
                stackPanel.Children.Add(comboBox);

                stackPanel.Children.Add(minus);
                stackPanel.Children.Add(plus);
                SortConfig.Children.Add(stackPanel);
            }
            if (_sortOrderList.Count != 0 || _comboBoxes.Count != 0) return;
            var stackPanelForNoSort = new StackPanel { Orientation = Orientation.Horizontal };
            var label = new Label { Content = "No Sort" };
            var plusForNoSort = new Button
            {
                Content = new Image
                {
                    Source = (ImageSource)Resources["Settings-AddConfig-Icon"]
                },
                Tag = -1<commit_msg>MC-43 Fixed issue with selecting all the values<commit_after>﻿using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Media;
using MSOE.MediaComplete.Lib;
using MSOE.MediaComplete.Lib.Sorting;
using Button = System.Windows.Controls.Button;
using ComboBox = System.Windows.Controls.ComboBox;
using Label = System.Windows.Controls.Label;
using Orientation = System.Windows.Controls.Orientation;

namespace MSOE.MediaComplete
{
    /// <summary>

    /// Interaction logic for Settings.xaml
    /// </summary>
    public partial class Settings
    {
        private readonly List<ComboBox> _comboBoxes;
        private List<string> _sortOrderList;
        private readonly List<bool> _showComboBox; 

        private readonly Dictionary<LayoutType, string> _layoutsDict = new Dictionary<LayoutType, string>
        {
            {LayoutType.Dark, "layout\\Dark.xaml"},
            {LayoutType.Pink, "layout\\Pink.xaml"}
        };
        private LayoutType _changedType;
        private bool _layoutHasChanged;
        public Settings()
        {

            InitializeComponent();
            TxtboxSelectedFolder.Text = SettingWrapper.GetHomeDir();
            LblInboxFolder.Content = SettingWrapper.GetInboxDir();
            ComboBoxPollingTime.SelectedValue = SettingWrapper.GetPollingTime().ToString(CultureInfo.InvariantCulture);
            CheckboxPolling.IsChecked = SettingWrapper.GetIsPolling();
            CheckboxShowImportDialog.IsChecked = SettingWrapper.GetShowInputDialog();
            CheckBoxSorting.IsChecked = SettingWrapper.GetIsSorting();
            PollingCheckBoxChanged(CheckboxPolling, null);
            if (SettingWrapper.GetLayout().Equals(_layoutsDict[LayoutType.Pink]))
            {
                PinkCheck.IsChecked = true;
            }
            else if (SettingWrapper.GetLayout().Equals(_layoutsDict[LayoutType.Dark]))
            {
                DarkCheck.IsChecked = true;
            }
            _comboBoxes = new List<ComboBox>();
            _sortOrderList= SortHelper.ConvertToString(SettingWrapper.GetSortOrder());
            _showComboBox = new List<bool>();
            LoadDictionary();
            LoadSortListBox();
        }

        private void LoadDictionary()
        {
            _showComboBox.Clear();
            for (var i = 0; i < _sortOrderList.Count; i++)
            {
                _showComboBox.Add(true);
            }
        }

        private void LoadSortListBox()
        {
            var withValue = -1;

            for (var i = 0; i < _showComboBox.Count; i++)
            {
                var showValue = _showComboBox[i];
                if (showValue)
                {
                    withValue++;
                }
                var stackPanel = new StackPanel {Orientation = Orientation.Horizontal};
                var folder = new Image
                {
                    Source = (ImageSource)Resources["Settings-Folder-Icon"],
                    Width = 20,
                    Height = 20,
                    Margin = new Thickness(16 * (i + 1), 8, 0, 8)
                };
                var comboBox = new ComboBox
                {
                    Width = 100,
                    Height = 24,
                    ItemsSource = showValue ? SortHelper.GetAllValidAttributes(_sortOrderList, _sortOrderList[withValue]) 
                                                : SortHelper.GetAllUnusedMetaAttributes(_sortOrderList),
                    SelectedValue = showValue ? (object) _sortOrderList[withValue] : -1,
                    Tag = i
                };
                var minus = new Button
                {
                    Content = new Image
                    {
                        Source = (ImageSource) Resources["Settings-MinusConfig-Icon"]
                    },
                    Tag = i,
                    Margin = new Thickness(0, 0, 2, 0)
                };
                minus.SetResourceReference(StyleProperty, "Plus/Minus"); 
                var plus = new Button
                {
                    Content = new Image
                    {
                        Source = (ImageSource)Resources["Settings-AddConfig-Icon"]
                    },
                    Tag = i
                };
                plus.SetResourceReference(StyleProperty, "Plus/Minus"); 

                minus.Click += MinusClicked;
                plus.Click += PlusClicked;
                comboBox.SelectionChanged += SelectChanged;


                _comboBoxes.Add(comboBox);
                stackPanel.Children.Add(folder);
                stackPanel.Children.Add(comboBox);
                stackPanel.Children.Add(minus);

                if (Enum.GetNames(typeof(MetaAttribute)).Length != _showComboBox.Count )
                {
                    stackPanel.Children.Add(plus);
                }

                SortConfig.Children.Add(stackPanel);
            }
            if (_sortOrderList.Count != 0 || _comboBoxes.Count != 0) return;
            var stackPanelForNoSort = new StackPanel { Orientation = Orientation.Horizontal };
            var label = new Label { Content = "No Sort" };
            var plusForNoSort = new Button
            {
                Content = new Image
                {
                    Source = (ImageSource)Resources["Settings-AddConfig-Icon"]
                },
                Tag = -1
{'fraction_non_alphanumeric': 0.08847604157086361, 'fraction_numerical': 0.004966430607927895, 'mean_word_length': 1.5460079606649497, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4421646', 'n_tokens_mistral': 2806, 'n_tokens_neox': 2546, 'n_words': 527}