<commit_before>﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
using ControlzEx;

namespace MahApps.Metro.Controls
{
    [TemplatePart(Name = BadgeContainerPartName, Type = typeof(UIElement))]
    public class Badged : BadgedEx
    {
        /// <summary>Identifies the <see cref="BadgeChangedStoryboard"/> dependency property.</summary>
        public static readonly DependencyProperty BadgeChangedStoryboardProperty
            = DependencyProperty.Register(nameof(BadgeChangedStoryboard),
                                          typeof(Storyboard),
                                          typeof(Badged),
                                          new PropertyMetadata(default(Storyboard)));

        /// <summary>Identifies the <see cref="BadgeTemplate"/> dependency property.</summary>
        public static readonly DependencyProperty BadgeTemplateProperty 
            = DependencyProperty.Register(nameof(BadgeTemplate), 
                                          typeof(DataTemplate), 
                                          typeof(Badged), 
                                          new PropertyMetadata(null));

        /// <summary>Identifies the <see cref="BadgeTemplateSelector"/> dependency property.</summary>
        public static readonly DependencyProperty BadgeTemplateSelectorProperty 
            = DependencyProperty.Register(nameof(BadgeTemplateSelector), 
                                          typeof(DataTemplateSelector), 
                                          typeof(Badged),
                                          new PropertyMetadata(null));


        public Storyboard BadgeChangedStoryboard
        {
            get => (Storyboard)this.GetValue(BadgeChangedStoryboardProperty);
            set => this.SetValue(BadgeChangedStoryboardProperty, value);
        }

        static Badged()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(Badged), new FrameworkPropertyMetadata(typeof(Badged)));
        }

        public override void OnApplyTemplate()
        {
            this.BadgeChanged -= this.OnBadgeChanged;

            base.OnApplyTemplate();

            this.BadgeChanged += this.OnBadgeChanged;
        }

        private void OnBadgeChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            var sb = this.BadgeChangedStoryboard;
            if (this._badgeContainer != null && sb != null)
            {
                try
                {
                    this._badgeContainer.BeginStoryboard(sb);
                }
                catch (Exception exception)
                {
                    throw new MahAppsException("Uups, it seems like there is something wrong with the given Storyboard.", exception);
                }
            }
        }



        /// <summary>
        /// Gets or Sets the <see cref="DataTemplate"/> for the Badge
        /// </summary>
        public DataTemplate BadgeTemplate
        {
            get { return (DataTemplate)GetValue(BadgeTemplateProperty); }
            set { SetValue(BadgeTemplateProperty, value); }
        }

        /// <summary>
        /// Gets or Sets the <see cref="DataTemplateSelector"/> for the Badge
        /// </summary>
        public DataTemplateSelector BadgeTemplateSelector
        {
            get { return (DataTemplateSelector)GetValue(BadgeTemplateSelectorProperty); }
            set { SetValue(BadgeTemplateSelectorProperty, value); }
        }

        



    }
}<commit_msg>Moved the Properties to ControlzEx<commit_after>﻿using System;
using System.Windows;
using System.Windows.Media.Animation;
using ControlzEx;

namespace MahApps.Metro.Controls
{
    [TemplatePart(Name = BadgeContainerPartName, Type = typeof(UIElement))]
    public class Badged : BadgedEx
    {
        /// <summary>Identifies the <see cref="BadgeChangedStoryboard"/> dependency property.</summary>
        public static readonly DependencyProperty BadgeChangedStoryboardProperty
            = DependencyProperty.Register(nameof(BadgeChangedStoryboard),
                                          typeof(Storyboard),
                                          typeof(Badged),
                                          new PropertyMetadata(default(Storyboard)));

        public Storyboard BadgeChangedStoryboard
        {
            get => (Storyboard)this.GetValue(BadgeChangedStoryboardProperty);
            set => this.SetValue(BadgeChangedStoryboardProperty, value);
        }

        static Badged()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(Badged), new FrameworkPropertyMetadata(typeof(Badged)));
        }

        public override void OnApplyTemplate()
        {
            this.BadgeChanged -= this.OnBadgeChanged;

            base.OnApplyTemplate();

            this.BadgeChanged += this.OnBadgeChanged;
        }

        private void OnBadgeChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            var sb = this.BadgeChangedStoryboard;
            if (this._badgeContainer != null && sb != null)
            {
                try
                {
                    this._badgeContainer.BeginStoryboard(sb);
                }
                catch (Exception exception)
                {
                    throw new MahAppsException("Uups, it seems like there is something wrong with the given Storyboard.", exception);
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.0797008936713478, 'fraction_numerical': 0.0, 'mean_word_length': 1.783756345177665, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7133236', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1188, 'n_words': 258}