示例#1
0
        private static Point GetNewLocation(Form parent, Form child, ChildFormPosition position)
        {
            Point newLocation = Point.Empty;

            switch (position)
            {
            case ChildFormPosition.TopLeft:
                newLocation = new Point(parent.Location.X, parent.Location.Y - child.Size.Height);
                break;

            case ChildFormPosition.TopRight:
                newLocation = new Point(parent.Location.X + parent.Size.Width, parent.Location.Y);
                break;

            case ChildFormPosition.BottomLeft:
                newLocation = new Point(parent.Location.X, parent.Location.Y + parent.Height + 1);
                break;

            case ChildFormPosition.BottomCentre:
                newLocation = new Point(
                    parent.Location.X + ((parent.Size.Width - child.Size.Width) / 2),
                    parent.Location.Y + parent.Size.Height);
                break;

            case ChildFormPosition.BottomRight:
                newLocation = new Point(
                    parent.Location.X + parent.Width - child.Width,
                    parent.Location.Y + parent.Height + 1);
                break;

            case ChildFormPosition.MiddleLeft:
                newLocation = new Point(
                    parent.Location.X + 50,
                    ((parent.ClientSize.Height - child.ClientSize.Height) / 2) + parent.Location.Y);
                break;

            case ChildFormPosition.MiddleCentre:
                newLocation = new Point(
                    ((parent.ClientSize.Width - child.ClientSize.Width) / 2) + parent.Location.X,
                    ((parent.ClientSize.Height - child.ClientSize.Height) / 2) + parent.Location.Y);
                break;

            default:
                break;
            }

            return(newLocation);
        }
示例#2
0
 private static void PositionChildForm(Form parent, Form child, ChildFormPosition position)
 {
     child.Location = GetNewLocation(parent, child, position);
 }
示例#3
0
 private static Point GetNewLocation(Form child, ChildFormPosition position)
 {
     return(GetNewLocation(_mainForm, child, position));
 }
示例#4
0
 private static void PositionChildForm(Form child, ChildFormPosition position)
 {
     PositionChildForm(_mainForm, child, position);
 }
示例#5
0
 private static void PositionChildForm(Form parent, Form child, ChildFormPosition position)
 {
     child.Location = GetNewLocation(parent, child, position);
 }
示例#6
0
 private static void PositionChildForm(Form child, ChildFormPosition position)
 {
     PositionChildForm(_mainForm, child, position);
 }
示例#7
0
        private static Point GetNewLocation(Form parent, Form child, ChildFormPosition position)
        {
            Point newLocation = Point.Empty;

            switch (position)
            {
                case ChildFormPosition.TopLeft:
                    newLocation = new Point(parent.Location.X, parent.Location.Y - child.Size.Height);
                    break;
                case ChildFormPosition.TopRight:
                    newLocation = new Point(parent.Location.X + parent.Size.Width, parent.Location.Y);
                    break;
                case ChildFormPosition.BottomLeft:
                    newLocation = new Point(parent.Location.X, parent.Location.Y + parent.Height + 1);
                    break;
                case ChildFormPosition.BottomCentre:
                    newLocation = new Point(
                    parent.Location.X + ((parent.Size.Width - child.Size.Width) / 2),
                    parent.Location.Y + parent.Size.Height);
                    break;
                case ChildFormPosition.BottomRight:
                    newLocation = new Point(
                    parent.Location.X + parent.Width - child.Width,
                    parent.Location.Y + parent.Height + 1);
                    break;
                case ChildFormPosition.MiddleLeft:
                    newLocation = new Point(
                        parent.Location.X + 50,
                        ((parent.ClientSize.Height - child.ClientSize.Height) / 2) + parent.Location.Y);
                    break;
                case ChildFormPosition.MiddleCentre:
                    newLocation = new Point(
                        ((parent.ClientSize.Width - child.ClientSize.Width) / 2) + parent.Location.X,
                        ((parent.ClientSize.Height - child.ClientSize.Height) / 2) + parent.Location.Y);
                    break;
                default:
                    break;

            }

            return newLocation;
        }
示例#8
0
 private static Point GetNewLocation(Form child, ChildFormPosition position)
 {
     return GetNewLocation(_mainForm, child, position);
 }