Example #1
0
        public Rect(Point location, Size size)
        {
            if (location.IsNullOrEmpty() || size.IsNullOrEmpty())
            {
                this.IsEmpty = true;

                this.Location = Point.Empty;
                this.Size     = Size.Empty;

                this.Left   = Double.NaN;
                this.Top    = Double.NaN;
                this.Right  = Double.NaN;
                this.Bottom = Double.NaN;
                this.Width  = Double.NaN;
                this.Height = Double.NaN;
            }
            else
            {
                if (size.IsPartiallyEmpty)
                {
                    throw new Granular.Exception("Can't create Rect with a size with an empty dimension");
                }

                if (size.Width < 0 || size.Height < 0)
                {
                    throw new Granular.Exception("Can't create Rect with a negative size");
                }

                this.IsEmpty = false;

                this.Location = location;
                this.Size     = size;

                this.Left   = Location.X;
                this.Top    = Location.Y;
                this.Right  = Size.Width + Location.X;
                this.Bottom = Size.Height + Location.Y;
                this.Width  = Size.Width;
                this.Height = Size.Height;
            }
        }
Example #2
0
        public Rect(Point location, Size size)
        {
            if (location.IsNullOrEmpty() || size.IsNullOrEmpty())
            {
                this.IsEmpty = true;

                this.Location = Point.Empty;
                this.Size = Size.Empty;

                this.Left = Double.NaN;
                this.Top = Double.NaN;
                this.Right = Double.NaN;
                this.Bottom = Double.NaN;
                this.Width = Double.NaN;
                this.Height = Double.NaN;
            }
            else
            {
                if (size.IsPartiallyEmpty)
                {
                    throw new Granular.Exception("Can't create Rect with a size with an empty dimension");
                }

                if (size.Width < 0 || size.Height < 0)
                {
                    throw new Granular.Exception("Can't create Rect with a negative size");
                }

                this.IsEmpty = false;

                this.Location = location;
                this.Size = size;

                this.Left = Location.X;
                this.Top = Location.Y;
                this.Right = Size.Width + Location.X;
                this.Bottom = Size.Height + Location.Y;
                this.Width = Size.Width;
                this.Height = Size.Height;
            }
        }
Example #3
0
 public static Size DefaultIfNullOrEmpty(this Size size, Size defaultValue = null)
 {
     return(Size.IsNullOrEmpty(size) ? (defaultValue ?? Size.Zero) : size);
 }
Example #4
0
 public static bool IsNullOrEmpty(this Size size)
 {
     return(Size.IsNullOrEmpty(size));
 }