public bool LoadForm(Form xform, string aSection, bool forcaleitura)
{
string section = xform.Name + aSection;
if (!this.ValueExists(section, "top") && !this.ValueExists(section, "WindowState"))
{
if (xform.StartPosition == FormStartPosition.Manual && xform.MdiParent == null)
{
CenterForm(xform);
}
return false;
}
else
{
if (this.ValueExists(section, "WindowState"))
{
switch (this.ReadValue(section, "WindowState", 0))
{
case 2:
xform.WindowState = FormWindowState.Maximized;
break;
default:
xform.WindowState = FormWindowState.Normal;
break;
}
}
if (xform.WindowState == FormWindowState.Normal || forcaleitura)
{
int left = this.ReadValue(section, "left",xform.Location.X);//Left);
int top = this.ReadValue(section, "top", xform.Location.Y);//Top);
int width = xform.Size.Width,
height = xform.Size.Height;
switch (xform.FormBorderStyle)
{
case FormBorderStyle.Sizable:
case FormBorderStyle.SizableToolWindow:
case FormBorderStyle.None:
width = this.ReadValue(section, "width", xform.Size.Width);
height = this.ReadValue(section, "height", xform.Size.Height);
break;
}
if (xform.MdiParent==null)
{
if ((height + top) > SystemInformation.VirtualScreen.Height)
top = 0;
if ((width + left) > SystemInformation.VirtualScreen.Width)
left = 0;
}
xform.StartPosition = FormStartPosition.Manual;
xform.Location = new Point(left, top);
xform.Size = new Size(width, height);
}
return true;
}
}