コード例 #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            Allocation other = obj as Allocation;

            if (other == null)
            {
                return(false);
            }

            return(System.Math.Abs(d_x - other.X) < Epsilon &&
                   System.Math.Abs(d_y - other.Y) < Epsilon &&
                   System.Math.Abs(d_width - other.Width) < Epsilon &&
                   System.Math.Abs(d_height - other.Height) < Epsilon);
        }
コード例 #2
0
        public Allocation FromRegion()
        {
            Allocation rect = Copy();

            if (rect.Width < rect.X)
            {
                double tmp = rect.Width;

                rect.Width = rect.X;
                rect.X     = tmp;
            }

            if (rect.Height < rect.Y)
            {
                double tmp = rect.Height;

                rect.Height = rect.Y;
                rect.Y      = tmp;
            }

            return(new Allocation(rect.X, rect.Y, rect.Width - rect.X, rect.Height - rect.Y));
        }