<commit_before>﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FrameRateCounter.cs" company="Catel development team">
//   Copyright (c) 2008 - 2013 Catel development team. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Catel.Windows.Controls
{
    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media;
    using System.Windows.Threading;

    /// <summary>
    /// A counter to show the frame rate inside an application.
    /// </summary>
    public class FrameRateCounter : TextBlock
    {
        #region Fields
        private int _frameRateCounter;
        private readonly DispatcherTimer _frameRateTimer = new DispatcherTimer();
        #endregion

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="FrameRateCounter"/> class.
        /// </summary>
        public FrameRateCounter()
        {
            Loaded += OnControlLoaded;
            Unloaded += OnControlUnloaded;

            _frameRateTimer.Interval = new TimeSpan(0, 0, 0, 1);
            _frameRateTimer.Tick += (sender, e) => OnFrameRateCounterElapsed();
        }
        #endregion

        #region Methods
        private void OnControlLoaded(object sender, RoutedEventArgs e)
        {
            _frameRateTimer.Start();

            CompositionTarget.Rendering += OnRendering;
        }

        private void OnControlUnloaded(object sender, RoutedEventArgs e)
        {
            CompositionTarget.Rendering -= OnRendering;

            _frameRateTimer.Stop();
        }

        private void OnRendering(object sender, EventArgs e)
        {
            _frameRateCounter++;
        }

        private void OnFrameRateCounterElapsed()
        {
             Text = _frameRateCounter.ToString();
            _frameRateCounter = 0;
        }
        #endregion
    }
}<commit_msg>Added Prefix property to FrameRateCounter control<commit_after>﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FrameRateCounter.cs" company="Catel development team">
//   Copyright (c) 2008 - 2013 Catel development team. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Catel.Windows.Controls
{
    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media;
    using System.Windows.Threading;

    /// <summary>
    /// A counter to show the frame rate inside an application.
    /// </summary>
    public class FrameRateCounter : TextBlock
    {
        #region Fields
        private int _frameRateCounter;
        private readonly DispatcherTimer _frameRateTimer = new DispatcherTimer();
        #endregion

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="FrameRateCounter"/> class.
        /// </summary>
        public FrameRateCounter()
        {
            Loaded += OnControlLoaded;
            Unloaded += OnControlUnloaded;

            _frameRateTimer.Interval = new TimeSpan(0, 0, 0, 1);
            _frameRateTimer.Tick += (sender, e) => OnFrameRateCounterElapsed();
        }
        #endregion

        #region Properties
        /// <summary>
        /// Gets or sets the prefix.
        /// </summary>
        /// <value>The prefix.</value>
        public string Prefix
        {
            get { return (string)GetValue(PrefixProperty); }
            set { SetValue(PrefixProperty, value); }
        }

        /// <summary>
        /// The prefix dependency property definition.
        /// </summary>
        public static readonly DependencyProperty PrefixProperty = DependencyProperty.Register("Prefix", typeof(string), typeof(FrameRateCounter), new PropertyMetadata("Frame rate: "));
        #endregion

        #region Methods
        private void OnControlLoaded(object sender, RoutedEventArgs e)
        {
            _frameRateTimer.Start();

            CompositionTarget.Rendering += OnRendering;
        }

        private void OnControlUnloaded(object sender, RoutedEventArgs e)
        {
            CompositionTarget.Rendering -= OnRendering;

            _frameRateTimer.Stop();
        }

        private void OnRendering(object sender, EventArgs e)
        {
            _frameRateCounter++;
        }

        private void OnFrameRateCounterElapsed()
        {
            string text = string.Empty;
            if (!string.IsNullOrWhiteSpace(Prefix))
            {
                text += Prefix;
            }

            text += _frameRateCounter.ToString();

            Text = text;

            _frameRateCounter = 0;
        }
        #endregion
    }
}
{'fraction_non_alphanumeric': 0.17931309904153356, 'fraction_numerical': 0.005191693290734824, 'mean_word_length': 1.5095190380761523, 'pattern_counts': {'":': 0, '<': 23, '<?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': '4560742', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1127, 'n_words': 297}