<commit_before>﻿// Copyright (c) <NAME>. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Perspex;
using Perspex.Controls;
using Perspex.Input;
using Perspex.Media;
using Renderer.Perspex;
using System;
using static System.Math;

namespace Core2D.Perspex.Controls.PanAndZoom
{
    public class PanAndZoom : Border
    {
        private Control _element;
        private Point _pan;
        private Point _previous;
        private Matrix _matrix;

        public double ZoomSpeed { get; set; }

        public AutoFitMode AutoFitMode { get; set; }

        public Action<double, double, double> InvalidatedChild { get; set; }

        public PanAndZoom()
            : base()
        {
            _matrix = MatrixHelper.Identity;

            ZoomSpeed = 1.2;
            AutoFitMode = AutoFitMode.None;

            Focusable = true;
            Background = Brushes.Transparent;

            DetachedFromVisualTree += PanAndZoom_DetachedFromVisualTree;

            this.GetObservable(ChildProperty).Subscribe(value =>
            {
                if (value != null && value != _element && _element != null)
                {
                    Unload();
                }

                if (value != null && value != _element)
                {
                    Initialize(value);
                }
            });
        }

        private void PanAndZoom_DetachedFromVisualTree(object sender, VisualTreeAttachmentEventArgs e)
        {
            if (_element != null)
            {
                Unload();
            }
        }

        private void Initialize(Control element)
        {<commit_msg>Converted to PerspexProperty<commit_after>﻿// Copyright (c) <NAME>. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Perspex;
using Perspex.Controls;
using Perspex.Input;
using Perspex.Media;
using Renderer.Perspex;
using System;
using static System.Math;

namespace Core2D.Perspex.Controls.PanAndZoom
{
    public class PanAndZoom : Border
    {
        private Control _element;
        private Point _pan;
        private Point _previous;
        private Matrix _matrix;

        public Action<double, double, double> InvalidatedChild { get; set; }

        public static PerspexProperty<double> ZoomSpeedProperty =
            PerspexProperty.Register<PanAndZoom, double>("ZoomSpeed", 1.2);

        public double ZoomSpeed
        {
            get { return GetValue(ZoomSpeedProperty); }
            set { SetValue(ZoomSpeedProperty, value); }
        }

        public static PerspexProperty<AutoFitMode> AutoFitModeProperty =
            PerspexProperty.Register<PanAndZoom, AutoFitMode>("AutoFitMode", AutoFitMode.None);

        public AutoFitMode AutoFitMode
        {
            get { return GetValue(AutoFitModeProperty); }
            set { SetValue(AutoFitModeProperty, value); }
        }

        public PanAndZoom()
            : base()
        {
            _matrix = MatrixHelper.Identity;

            Focusable = true;
            Background = Brushes.Transparent;

            DetachedFromVisualTree += PanAndZoom_DetachedFromVisualTree;

            this.GetObservable(ChildProperty).Subscribe(value =>
            {
                if (value != null && value != _element && _element != null)
                {
                    Unload();
                }

                if (value != null && value != _element)
                {
                    Initialize(value);
                }
            });
        }

        private void PanAndZoom_DetachedFromVisualTree(object sender, VisualTreeAttachmentEventArgs e)
        {
            if (_element != null)
            {
                Unload();
            }
        }

        private void Initialize(Control element)
        {
{'fraction_non_alphanumeric': 0.08016443987667009, 'fraction_numerical': 0.001541623843782117, 'mean_word_length': 1.8210144927536231, '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': '2136709', 'n_tokens_mistral': 1018, 'n_tokens_neox': 945, 'n_words': 254}