<commit_before>﻿using AppStudio.Uwp;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.UI.Xaml;

namespace AppStudio.Uwp.Controls
{
    public sealed class VisualBreakpoints : ObservableBase
    {
        private static Dictionary<string, string> _configCache = new Dictionary<string, string>();
        private static SemaphoreSlim readFileSemaphore = new SemaphoreSlim(1);

        private int _lastActive = -1;
        private int[] _breakpointsIndex = new int[0];
        private BreakpointsTable _fallBackBreakPoint = new BreakpointsTable();
        private BreakpointsDictionary _breakpointsTable = new BreakpointsDictionary();

        private string _configFile;
        public string ConfigFile
        {
            get { return _configFile; }
            set
            {
                _configFile = value;

                Initialize();
            }
        }

        public dynamic Active { get; set; }

        public VisualBreakpoints()
        {
            Active = new ExpandoObject();

            Window.Current.SizeChanged += Window_SizeChanged;
        }

        private void Window_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
        {
            TrySetActive(e.Size.Width);
        }

        private void TrySetActive(double width)
        {
            if (_breakpointsIndex != null && _breakpointsIndex.Length > 0)
            {
                var currentActive = _breakpointsIndex.FirstOrDefault(b => width < b);
                if (currentActive != _lastActive)
                {
                    var activeBreakpoint = GetActiveBreakpoint(currentActive);
                    SetActiveProperties(activeBreakpoint);

                    _lastActive = currentActive;
                } 
            }
        }

        private void SetActiveProperties(BreakpointsTable activeBreakpoint)
        {
            if (activeBreakpoint != null)
            {
                var activeDict = Active as IDictionary<string, object>;

                foreach (var props in activeBreakpoint)
                {
                    activeDict[props.Name] = props.Value;
                }
<commit_msg>Add UpdateActive Method to VisualBreakPoints<commit_after>﻿using AppStudio.Uwp;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.UI.Xaml;

namespace AppStudio.Uwp.Controls
{
    public sealed class VisualBreakpoints : ObservableBase
    {
        private static Dictionary<string, string> _configCache = new Dictionary<string, string>();
        private static SemaphoreSlim readFileSemaphore = new SemaphoreSlim(1);

        private int _lastActive = -1;
        private int[] _breakpointsIndex = new int[0];
        private BreakpointsTable _fallBackBreakPoint = new BreakpointsTable();
        private BreakpointsDictionary _breakpointsTable = new BreakpointsDictionary();

        private string _configFile;
        public string ConfigFile
        {
            get { return _configFile; }
            set
            {
                _configFile = value;

                Initialize();
            }
        }

        public dynamic Active { get; set; }

        public VisualBreakpoints()
        {
            Active = new ExpandoObject();

            Window.Current.SizeChanged += Window_SizeChanged;
        }

        public void UpdateActive()
        {
            TrySetActive(Window.Current.Bounds.Width);
        }

        private void Window_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
        {
            TrySetActive(e.Size.Width);
        }

        private void TrySetActive(double width)
        {
            if (_breakpointsIndex != null && _breakpointsIndex.Length > 0)
            {
                var currentActive = _breakpointsIndex.FirstOrDefault(b => width < b);
                if (currentActive != _lastActive)
                {
                    var activeBreakpoint = GetActiveBreakpoint(currentActive);
                    SetActiveProperties(activeBreakpoint);

                    _lastActive = currentActive;
                } 
            }
        }

        private void SetActiveProperties(BreakpointsTable activeBreakpoint)
        {
            if (activeBreakpoint != null)
            {
                var activeDict = Active as IDictionary<string, object>;

                foreach (var props in activeBreakpoint)
                {
                    activeDict[props.Name] = props.Value;
                }

{'fraction_non_alphanumeric': 0.0721402949382224, 'fraction_numerical': 0.0015942606616181746, 'mean_word_length': 2.0253164556962027, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '3227773', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1188, 'n_words': 298}