Beispiel #1
0
        public static void ChangeClientSize_Center(Form form, Size new_client_size, bool is_hide_window_when_update)
        {
            if (form == null || new_client_size.Width <= 0 || new_client_size.Height <= 0)
            {
                throw new ArgumentException("引수エラ\x30FC");
            }
            if (form.ClientSize == new_client_size)
            {
                return;
            }
            Point positionCenter     = Useful.GetPositionCenter(form);
            Size  size               = form.Size - form.ClientSize + new_client_size;
            Point positionFromCenter = Useful.GetPositionFromCenter(positionCenter, size);

            if (is_hide_window_when_update)
            {
                bool visible = form.Visible;
                form.Visible = false;
                form.SetBounds(positionFromCenter.X, positionFromCenter.Y, size.Width, size.Height);
                form.Visible = visible;
            }
            else
            {
                form.SetBounds(positionFromCenter.X, positionFromCenter.Y, size.Width, size.Height);
            }
        }
Beispiel #2
0
 public static Point GetPositionFromCenter(Form form, Point center_pos)
 {
     if (form == null)
     {
         return(Point.Empty);
     }
     else
     {
         return(Useful.GetPositionFromCenter(center_pos, form.Size));
     }
 }