aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains/MaterialDesignInXamlToolkit-master/MainDemo.Wpf/ProvingGroundStuff/MeasuringTextBox.cs
blob: f13df11b621d559b3e62d348204ce48070df5ed2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using MaterialDesignThemes.Wpf;

namespace MaterialDesignDemo.ProvingGroundStuff
{
    public class MeasuringTextBox : TextBox
    {
        static MeasuringTextBox()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(MeasuringTextBox), new FrameworkPropertyMetadata(typeof(TextBox)));
        }

        protected override Size ArrangeOverride(Size arrangeBounds)
        {
            var stopwatch = Stopwatch.StartNew();
            var result = base.ArrangeOverride(arrangeBounds);
            stopwatch.Stop();
            Debug.WriteLine($"Arrange: {stopwatch.ElapsedMilliseconds} - {stopwatch.ElapsedTicks} - ({GetHashCode()})");
            return result;
        }


        protected override Size MeasureOverride(Size constraint)
        {
            var stopwatch = Stopwatch.StartNew();
            var result = base.MeasureOverride(constraint);
            stopwatch.Stop();
            Debug.WriteLine($"Measure: {stopwatch.ElapsedMilliseconds} - {stopwatch.ElapsedTicks} - ({GetHashCode()})");
            return result;
        }
    }
}