示例#1
0
		private static void SetLocation(LObject objToBePositioned, float atp_W,
				float atp_H, float obj_X, float obj_Y, float obj_XW, float obj_YH,
				Position position) {
			switch (position) {
			case Position.CENTER:
				objToBePositioned.SetX((obj_XW / 2f) - atp_W / 2f);
				objToBePositioned.SetY((obj_YH / 2f) - atp_H / 2f);
				break;
			case Position.SAME:
				objToBePositioned.SetLocation(obj_X, obj_Y);
				break;
			case Position.LEFT:
				objToBePositioned.SetLocation(obj_X, obj_YH / 2f - atp_H / 2f);
				break;
			case Position.TOP_LEFT:
				objToBePositioned.SetLocation(obj_X, obj_YH - atp_H);
				break;
			case Position.TOP_LEFT_CENTER:
				objToBePositioned.SetLocation(obj_X - atp_W / 2f, obj_YH - atp_H
						/ 2f);
				break;
			case Position.TOP_RIGHT:
				objToBePositioned.SetLocation(obj_XW - atp_W, obj_YH - atp_H);
				break;
			case Position.TOP_RIGHT_CENTER:
				objToBePositioned.SetLocation(obj_XW - atp_W / 2f, obj_YH - atp_H
						/ 2f);
				break;
			case Position.TOP_CENTER:
				objToBePositioned.SetLocation(obj_XW / 2f - atp_W / 2f, obj_YH
						- atp_H);
				break;
			case Position.BOTTOM_LEFT:
				objToBePositioned.SetLocation(obj_X, obj_Y);
				break;
			case Position.BOTTOM_LEFT_CENTER:
				objToBePositioned.SetLocation(obj_X - atp_W / 2f, obj_Y - atp_H
						/ 2f);
				break;
			case Position.BOTTOM_RIGHT:
				objToBePositioned.SetLocation(obj_XW - atp_W, obj_Y);
				break;
			case Position.BOTTOM_RIGHT_CENTER:
				objToBePositioned.SetLocation(obj_XW - atp_W / 2f, obj_Y - atp_H
						/ 2f);
				break;
			case Position.BOTTOM_CENTER:
				objToBePositioned.SetLocation(obj_XW / 2f - atp_W / 2f, obj_Y);
				break;
			case Position.RIGHT_CENTER:
				objToBePositioned.SetLocation(obj_XW - atp_W, obj_YH / 2f - atp_H
						/ 2f);
				break;
			default:
				objToBePositioned.SetLocation(objToBePositioned.GetX(),
						objToBePositioned.GetY());
				break;
			}
		}
示例#2
0
        private static void SetLocation(LObject objToBePositioned, float atp_W,
                                        float atp_H, float obj_X, float obj_Y, float obj_XW, float obj_YH,
                                        Position position)
        {
            switch (position)
            {
            case Position.CENTER:
                objToBePositioned.SetX((obj_XW / 2f) - atp_W / 2f);
                objToBePositioned.SetY((obj_YH / 2f) - atp_H / 2f);
                break;

            case Position.SAME:
                objToBePositioned.SetLocation(obj_X, obj_Y);
                break;

            case Position.LEFT:
                objToBePositioned.SetLocation(obj_X, obj_YH / 2f - atp_H / 2f);
                break;

            case Position.TOP_LEFT:
                objToBePositioned.SetLocation(obj_X, obj_YH - atp_H);
                break;

            case Position.TOP_LEFT_CENTER:
                objToBePositioned.SetLocation(obj_X - atp_W / 2f, obj_YH - atp_H
                                              / 2f);
                break;

            case Position.TOP_RIGHT:
                objToBePositioned.SetLocation(obj_XW - atp_W, obj_YH - atp_H);
                break;

            case Position.TOP_RIGHT_CENTER:
                objToBePositioned.SetLocation(obj_XW - atp_W / 2f, obj_YH - atp_H
                                              / 2f);
                break;

            case Position.TOP_CENTER:
                objToBePositioned.SetLocation(obj_XW / 2f - atp_W / 2f, obj_YH
                                              - atp_H);
                break;

            case Position.BOTTOM_LEFT:
                objToBePositioned.SetLocation(obj_X, obj_Y);
                break;

            case Position.BOTTOM_LEFT_CENTER:
                objToBePositioned.SetLocation(obj_X - atp_W / 2f, obj_Y - atp_H
                                              / 2f);
                break;

            case Position.BOTTOM_RIGHT:
                objToBePositioned.SetLocation(obj_XW - atp_W, obj_Y);
                break;

            case Position.BOTTOM_RIGHT_CENTER:
                objToBePositioned.SetLocation(obj_XW - atp_W / 2f, obj_Y - atp_H
                                              / 2f);
                break;

            case Position.BOTTOM_CENTER:
                objToBePositioned.SetLocation(obj_XW / 2f - atp_W / 2f, obj_Y);
                break;

            case Position.RIGHT_CENTER:
                objToBePositioned.SetLocation(obj_XW - atp_W, obj_YH / 2f - atp_H
                                              / 2f);
                break;

            default:
                objToBePositioned.SetLocation(objToBePositioned.GetX(),
                                              objToBePositioned.GetY());
                break;
            }
        }