<commit_before>﻿using System;
using System.Drawing;

namespace GraphicalEditor.Shapes
{
    public abstract class ShapeObject
    {
        public virtual Size Size
        {
            get { return this.Bounds.Size; }
            set
            {
                if (this.Bounds.Size == value) return;
                Rectangle rect = this.Bounds;
                rect.Size = value;
                this.Bounds = rect;
            }
        }

        private Size minimumSize;
        public virtual Size MinimumSize
        {
            get { return minimumSize; }
            set
            {
                if (value.Width < 0 || value.Height < 0)
                    throw new ArgumentOutOfRangeException("MinimumSize Width or Height must be at least zero.");
                minimumSize = value;
            }
        }

        public virtual Point Location
        {
            get
            {
                return this.Bounds.Location; ;
            }
            set
            {
                if (this.Bounds.Location == value) return;
                Rectangle rect = this.Bounds;
                rect.Location = value;
                this.Bounds = rect;
            }
        }

        private bool isSelected;
        public virtual bool IsSelected
        {
            get
            {
                return isSelected;
            }
            set
            {
                isSelected = value;
            }
        }

        private GrabHandles grabHandles;
        public virtual GrabHandles GrabHandles
        {
            get
            {
                if (grabHandles == null) grabHandles = new GrabHandles(this);
                return grabHandles;
            }
        }

        private Rectangle bounds;
        public virtual Rectangle Bounds
        {
            get { return bounds; }
            set
            {
                bounds = value;
                this.GrabHandles.SetBounds(value);
            }
        }

        private int id;
        public virtual int ID
        {
            get
            {
                return id;
            }

            set
            {
                if (value == id)
                    return;

                id = value;
            }
        }

        private Color color;
        public virtual Color Color
        {
            get
            {
                return color;
            }
            protected set
            {
                if (color == value)
                    return;

                color = value;
            }
        }

        public bool WasClicked(Point p)
        {
            return p.X >= Location.X && p.X < Location.X + Size.Width
                && p.Y >= Location.Y && p.Y < Location.Y + Size.Height;
        }

        public DrawHandler.HitStatus GetHitStatus(Point p)
        {
            return GrabHandles.GetHitTest(p);
        }

        public abstract void Draw(Graphics g);
    }
}
<commit_msg>Prevented application to throw an ArgumentOutOfRange exception when the minimum size is set to a lower value than 0. It will clamp now instead.<commit_after>﻿using GraphicalEditor.Util;
using System;
using System.Drawing;

namespace GraphicalEditor.Shapes
{
    public abstract class ShapeObject
    {
        public virtual Size Size
        {
            get { return Bounds.Size; }
            set
            {
                if (Bounds.Size == value) return;
                Rectangle rect = Bounds;

                value.Width.Clamp(MinimumSize.Width, int.MaxValue);
                value.Height.Clamp(MinimumSize.Height, int.MaxValue);

                rect.Size = value;

                Bounds = rect;
            }
        }

        private Size minimumSize;
        public virtual Size MinimumSize
        {
            get { return minimumSize; }
            set
            {
                value.Width.Clamp(0, int.MaxValue);
                value.Height.Clamp(0, int.MaxValue);

                minimumSize = value;
            }
        }

        public virtual Point Location
        {
            get
            {
                return Bounds.Location; ;
            }
            set
            {
                if (Bounds.Location == value) return;
                Rectangle rect = Bounds;
                rect.Location = value;
                Bounds = rect;
            }
        }

        private bool isSelected;
        public virtual bool IsSelected
        {
            get
            {
                return isSelected;
            }
            set
            {
                isSelected = value;
            }
        }

        private GrabHandles grabHandles;
        public virtual GrabHandles GrabHandles
        {
            get
            {
                if (grabHandles == null) grabHandles = new GrabHandles(this);
                return grabHandles;
            }
        }

        private Rectangle bounds;
        public virtual Rectangle Bounds
        {
            get { return bounds; }
            set
            {
                bounds = value;
                GrabHandles.SetBounds(value);
            }
        }

        private int id;
        public virtual int ID
        {
            get
            {
                return id;
            }

            set
            {
                if (value == id)
                    return;

                id = value;
            }
        }

        private Color color;
        public virtual Color Color
        {
            get
            {
                return color;
            }
            protected set
            {
                if (color == value)
                    return;

                color = value;
            }
        }

        public bool WasClicked(Point p)
        {
            return p.X >= Location.X && p.X < Location.X + Size.Width
                && p.Y >= Location.Y && p.Y < Location.Y + Size.Height;
        }

        public DrawHandler.HitStatus GetHitStatus(Point p)
        {
            return GrabHandles.GetHitTest(p);
        }

        public abstract void Draw(Graphics g);
    }
}

{'fraction_non_alphanumeric': 0.06609007832898173, 'fraction_numerical': 0.0008159268929503916, 'mean_word_length': 0.9371049304677623, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '4853090', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1412, 'n_words': 379}