<commit_before>﻿using System;
using System.Collections.Generic;
using System.Windows;
using Microsoft.VisualStudio.PlatformUI;
using GitHub.VisualStudio.Helpers;
using GitHub.Helpers;

namespace GitHub.VisualStudio.UI.Helpers
{
    public class SharedDictionaryManager : SharedDictionaryManagerBase
    {
#if !XAML_DESIGNER // XAML Designer doesn't work if `Source` property has been replaced.
        public SharedDictionaryManager()
        {
            currentTheme = Colors.DetectTheme();
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
        string currentTheme;

        static readonly Dictionary<Uri, ResourceDictionary> resourceDicts = new Dictionary<Uri, ResourceDictionary>();
        static string baseThemeUri = "pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/";

        Uri sourceUri;
        bool themed = false;
        public new Uri Source
        {
            get { return sourceUri; }
            set
            {
                if (value.ToString() == "pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/ThemeDesignTime.xaml")
                {
                    if (!themed)
                    {
                        themed = true;
                        VSColorTheme.ThemeChanged += OnThemeChange;
                    }
                    value = new Uri(baseThemeUri + "Theme" + currentTheme + ".xaml");
                }

                sourceUri = value;
                ResourceDictionary ret;
                if (resourceDicts.TryGetValue(value, out ret))
                {
                    if (ret != this)
                    {
                        MergedDictionaries.Add(ret);
                        return;
                    }
                }
                base.Source = value;
                if (ret == null)
                    resourceDicts.Add(value, this);
            }
        }

        void OnThemeChange(ThemeChangedEventArgs e)
        {
            var uri = new Uri(baseThemeUri + "Theme" + currentTheme + ".xaml");
            ResourceDictionary ret;
            if (resourceDicts.TryGetValue(uri, out ret))
                MergedDictionaries.Remove(ret);
            currentTheme = Colors.DetectTheme();
            Source = uri;
        }
#endif
    }
}<commit_msg>Disable VS themes in design mode<commit_after>﻿using System;
using System.Windows;
using System.ComponentModel;
using System.Collections.Generic;
using Microsoft.VisualStudio.PlatformUI;
using GitHub.VisualStudio.Helpers;
using GitHub.Helpers;

namespace GitHub.VisualStudio.UI.Helpers
{
    public class SharedDictionaryManager : SharedDictionaryManagerBase
    {
        static bool isInDesignMode;

        static SharedDictionaryManager()
        {
            isInDesignMode = DesignerProperties.GetIsInDesignMode(new DependencyObject());
        }

#if !XAML_DESIGNER // XAML Designer doesn't work if `Source` property has been replaced.
        public SharedDictionaryManager()
        {
            if (!isInDesignMode)
            {
                currentTheme = Colors.DetectTheme();
            }
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
        string currentTheme;

        static readonly Dictionary<Uri, ResourceDictionary> resourceDicts = new Dictionary<Uri, ResourceDictionary>();
        static string baseThemeUri = "pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/";

        Uri sourceUri;
        bool themed = false;
        public new Uri Source
        {
            get { return sourceUri; }
            set
            {
                if (!isInDesignMode)
                {
                    if (value.ToString() == "pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/ThemeDesignTime.xaml")
                    {
                        if (!themed)
                        {
                            themed = true;
                            VSColorTheme.ThemeChanged += OnThemeChange;
                        }
                        value = new Uri(baseThemeUri + "Theme" + currentTheme + ".xaml");
                    }
                }

                sourceUri = value;
                ResourceDictionary ret;
                if (resourceDicts.TryGetValue(value, out ret))
                {
                    if (ret != this)
                    {
                        MergedDictionaries.Add(ret);
                        return;
                    }
                }
                base.Source = value;
                if (ret == null)
                    resourceDicts.Add(value, this);
            }
        }

        void OnThemeChange(ThemeChangedEventArgs e)
        {
            var uri = new Uri(baseThemeUri + "Theme" + currentTheme + ".xaml");
            ResourceDictionary ret;
            if (resourceDicts.TryGetValue(uri, out ret))
                MergedDictionaries.Remove(ret);
            currentTheme = Colors.DetectTheme();
            Source = uri;
        }
#endif
    }
}
{'fraction_non_alphanumeric': 0.0875684128225176, 'fraction_numerical': 0.001563721657544957, 'mean_word_length': 1.5623435152729093, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5105869', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1208, 'n_words': 259}