Exemplo n.º 1
0
            protected override void Read()
            {
                string splitterDistance = ControlPreferences.GetValue(Name, "SplitterDistance");

                if (splitterDistance != null)
                {
                    try
                    {
                        _splitContainer.SplitterDistance = int.Parse(splitterDistance, Culture);
                    }
                    catch
                    {
                    }
                }
            }
Exemplo n.º 2
0
            protected override void Read()
            {
                FormWindowState?formWindowState = null;

                string windowState = ControlPreferences.GetValue(Name, "State");

                if (windowState != null)
                {
                    formWindowState = (FormWindowState)Enum.Parse(typeof(FormWindowState), windowState);
                }

                bool sizable = _form.FormBorderStyle == FormBorderStyle.Sizable || _form.FormBorderStyle == FormBorderStyle.SizableToolWindow;

                string xs      = ControlPreferences.GetValue(Name, "X");
                string ys      = ControlPreferences.GetValue(Name, "Y");
                string widths  = ControlPreferences.GetValue(Name, "Width");
                string heights = ControlPreferences.GetValue(Name, "Height");

                if (xs != null && ys != null)
                {
                    int x = int.Parse(xs, Culture);
                    int y = int.Parse(ys, Culture);
                    int width;
                    int height;


                    if (x < -30000)
                    {
                        x = 50;
                    }
                    if (y < -30000)
                    {
                        y = 0;
                    }

                    if (sizable && widths != null && heights != null)
                    {
                        width  = int.Parse(widths, Culture);
                        height = int.Parse(heights, Culture);
                    }
                    else
                    {
                        width  = _form.Width;
                        height = _form.Height;
                    }

                    System.Drawing.Rectangle formBounds = new System.Drawing.Rectangle(x, y, width, height);

                    if (this.IsRectangleVisible(formBounds))
                    {
                        _form.DesktopBounds = formBounds;

                        if (_form.WindowState == FormWindowState.Normal)
                        {
                            User.SetWindowPos
                                (_form.Handle, IntPtr.Zero, x + SystemInformation.WorkingArea.X, y + SystemInformation.WorkingArea.Y, width, height
                                , SetWindowPosOptions.SWP_NOSIZE);
                        }
                    }
                }

                if (formWindowState != null)
                {
                    SetWindowState(_form, formWindowState.Value);
                }
                else
                {
                    SetWindowDefaultState(_form);
                }
            }