<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 System;
using Core2D.Editor.Tools.Selection;
using Core2D.Shape;
using Core2D.Shapes;

namespace Core2D.Editor.Tools
{
    /// <summary>
    /// Ellipse tool.
    /// </summary>
    public class ToolEllipse : ToolBase
    {
        public enum State { TopLeft, BottomRight }
        public enum Mode { Rectangle, Circle }
        private readonly IServiceProvider _serviceProvider;
        private State _currentState = State.TopLeft;
        private Mode _currentMode = Mode.Circle;
        private XEllipse _ellipse;
        private ToolEllipseSelection _selection;
        private double _centerX;
        private double _centerY;

        /// <inheritdoc/>
        public override string Name => "Ellipse";

        /// <summary>
        /// Initialize new instance of <see cref="ToolEllipse"/> class.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        public ToolEllipse(IServiceProvider serviceProvider) : base()
        {
            _serviceProvider = serviceProvider;
        }

        private void ConstrainToCircle(double sx, double sy)
        {
            double rx = Math.Abs(_centerX - sx);
            double ry = Math.Abs(_centerY - sy);
            double r = Math.Max(rx, ry);
            _ellipse.TopLeft.X = _centerX - r;
            _ellipse.TopLeft.Y = _centerY - r;
            _ellipse.BottomRight.X = _centerX + r;
            _ellipse.BottomRight.Y = _centerY + r;
        }

        /// <inheritdoc/><commit_msg>Set default mode to rectangle<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 System;
using Core2D.Editor.Tools.Selection;
using Core2D.Shape;
using Core2D.Shapes;

namespace Core2D.Editor.Tools
{
    /// <summary>
    /// Ellipse tool.
    /// </summary>
    public class ToolEllipse : ToolBase
    {
        public enum State { TopLeft, BottomRight }
        public enum Mode { Rectangle, Circle }
        private readonly IServiceProvider _serviceProvider;
        private State _currentState = State.TopLeft;
        private Mode _currentMode = Mode.Rectangle;
        private XEllipse _ellipse;
        private ToolEllipseSelection _selection;
        private double _centerX;
        private double _centerY;

        /// <inheritdoc/>
        public override string Name => "Ellipse";

        /// <summary>
        /// Initialize new instance of <see cref="ToolEllipse"/> class.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        public ToolEllipse(IServiceProvider serviceProvider) : base()
        {
            _serviceProvider = serviceProvider;
        }

        private void ConstrainToCircle(double sx, double sy)
        {
            double rx = Math.Abs(_centerX - sx);
            double ry = Math.Abs(_centerY - sy);
            double r = Math.Max(rx, ry);
            _ellipse.TopLeft.X = _centerX - r;
            _ellipse.TopLeft.Y = _centerY - r;
            _ellipse.BottomRight.X = _centerX + r;
            _ellipse.BottomRight.Y = _centerY + r;
        }

        /// <inheritdoc/>
{'fraction_non_alphanumeric': 0.09799820734986556, 'fraction_numerical': 0.0023902001792650133, 'mean_word_length': 2.12022367194781, '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': '3615391', 'n_tokens_mistral': 949, 'n_tokens_neox': 924, 'n_words': 265}