コード例 #1
0
        /// <summary>
        /// normalize instance value from negative to positive rectangle
        /// </summary>
        /// <returns></returns>
        public LayoutRect Normalize()
        {
            var l = Math.Min(L.Lx, R.Lx);
            var t = Math.Min(T.Ly, B.Ly);
            var r = Math.Max(L.Lx, R.Lx);
            var b = Math.Max(T.Ly, B.Ly);

            LT = new LayoutPos
            {
                X = new LayoutX {
                    Lx = l
                },
                Y = new LayoutY {
                    Ly = t
                },
            };
            RB = new LayoutPos
            {
                X = new LayoutX {
                    Lx = r
                },
                Y = new LayoutY {
                    Ly = b
                },
            };
            return(this);
        }
コード例 #2
0
        /// <summary>
        /// make a new instance from Left-Top and size
        /// </summary>
        /// <param name="lt"></param>
        /// <param name="size"></param>
        /// <returns></returns>

        public static LayoutRect From(LayoutPos lt, LayoutSize size)
        {
            return(new LayoutRect
            {
                LT = new LayoutPos
                {
                    X = new LayoutX {
                        Lx = lt.X.Lx
                    },
                    Y = new LayoutY {
                        Ly = lt.Y.Ly
                    },
                },
                RB = new LayoutPos
                {
                    X = new LayoutX {
                        Lx = lt.X.Lx + size.Width.Lx
                    },
                    Y = new LayoutY {
                        Ly = lt.Y.Ly + size.Height.Ly
                    },
                },
            });
        }
コード例 #3
0
        /// <summary>
        /// make a new instance from left, center y, width and height
        /// </summary>
        /// <param name="leftcenter"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <returns></returns>

        public static LayoutRect FromLWH(LayoutPos leftcenter, double width, double height)
        {
            return(new LayoutRect
            {
                LT = new LayoutPos
                {
                    X = new LayoutX {
                        Lx = leftcenter.X.Lx
                    },
                    Y = new LayoutY {
                        Ly = leftcenter.Y.Ly - height / 2
                    },
                },
                RB = new LayoutPos
                {
                    X = new LayoutX {
                        Lx = leftcenter.X.Lx + width
                    },
                    Y = new LayoutY {
                        Ly = leftcenter.Y.Ly + height / 2
                    },
                },
            });
        }
コード例 #4
0
 /// <summary>
 /// make a new instance from center x, bottom y, width and height
 /// </summary>
 /// <param name="centerbottom"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <returns></returns>
 public static LayoutRect FromCbWH(LayoutPos centerbottom, double width, double height)
 {
     return(new LayoutRect
     {
         LT = new LayoutPos
         {
             X = new LayoutX {
                 Lx = centerbottom.X.Lx - width / 2
             },
             Y = new LayoutY {
                 Ly = centerbottom.Y.Ly - height
             },
         },
         RB = new LayoutPos
         {
             X = new LayoutX {
                 Lx = centerbottom.X.Lx + width / 2
             },
             Y = new LayoutY {
                 Ly = centerbottom.Y.Ly
             },
         },
     });
 }
コード例 #5
0
        /// <summary>
        /// make a new instance from Left-Top, width and height
        /// </summary>
        /// <param name="lt"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <returns></returns>

        public static LayoutRect FromLTWH(LayoutPos lt, double width, double height)
        {
            return(new LayoutRect
            {
                LT = new LayoutPos
                {
                    X = new LayoutX {
                        Lx = lt.X.Lx
                    },
                    Y = new LayoutY {
                        Ly = lt.Y.Ly
                    },
                },
                RB = new LayoutPos
                {
                    X = new LayoutX {
                        Lx = lt.X.Lx + width
                    },
                    Y = new LayoutY {
                        Ly = lt.Y.Ly + height
                    },
                },
            });
        }
コード例 #6
0
        /// <summary>
        /// make a new instance from LT and RB
        /// </summary>
        /// <param name="lt">Left-Top</param>
        /// <param name="rb">Right-Bottom</param>
        /// <returns></returns>

        public static LayoutRect FromLTRB(LayoutPos lt, LayoutPos rb)
        {
            return(new LayoutRect
            {
                LT = new LayoutPos
                {
                    X = new LayoutX {
                        Lx = lt.X.Lx
                    },
                    Y = new LayoutY {
                        Ly = lt.Y.Ly
                    },
                },
                RB = new LayoutPos
                {
                    X = new LayoutX {
                        Lx = rb.X.Lx
                    },
                    Y = new LayoutY {
                        Ly = rb.Y.Ly
                    },
                },
            });
        }
コード例 #7
0
        /// <summary>
        /// make a new instance from center and size
        /// </summary>
        /// <param name="center"></param>
        /// <param name="size"></param>
        /// <returns></returns>

        public static LayoutRect FromCS(LayoutPos center, LayoutSize size)
        {
            return(FromCWH(center, size.Width.Lx, size.Height.Ly));
        }
コード例 #8
0
 /// <summary>
 /// check position is in this space
 /// </summary>
 /// <param name="pos"></param>
 /// <returns></returns>
 public bool IsIn(LayoutPos pos)
 {
     return(LT.X <= pos.X && RB.X >= pos.X && LT.Y <= pos.Y && RB.Y >= pos.Y);
 }
コード例 #9
0
        /// <summary>
        /// offset vertical position
        /// </summary>
        /// <param name="v1"></param>
        /// <param name="v2"></param>
        /// <returns></returns>

        public static LayoutRect operator -(LayoutRect v1, LayoutY v2)
        {
            return(new LayoutRect {
                LT = LayoutPos.From(v1.LT.X, v1.LT.Y - v2), RB = LayoutPos.From(v1.R, v1.RB.Y - v2),
            });
        }
コード例 #10
0
        /// <summary>
        /// offset horizontal position
        /// </summary>
        /// <param name="v1"></param>
        /// <param name="v2"></param>
        /// <returns></returns>

        public static LayoutRect operator +(LayoutRect v1, LayoutX v2)
        {
            return(new LayoutRect {
                LT = LayoutPos.From(v1.LT.X + v2, v1.LT.Y), RB = LayoutPos.From(v1.R + v2, v1.RB.Y),
            });
        }
コード例 #11
0
 /// <summary>
 /// deflate instance
 /// </summary>
 /// <param name="all"></param>
 /// <returns></returns>
 public void Deflate(LayoutSize size)
 {
     LT += size / 2;
     RB -= size / 2;
 }
コード例 #12
0
 /// <summary>
 /// infrate instance
 /// </summary>
 /// <param name="all"></param>
 /// <returns></returns>
 public void Inflate(LayoutSize size)
 {
     LT -= size / 2.0;
     RB += size / 2.0;
 }