예제 #1
0
            protected override void Read()
            {
                string splitterDistance = ControlPreferences.GetValue(Name, "SplitterDistance");

                if (splitterDistance != null)
                {
                    try
                    {
                        _splitContainer.SplitterDistance = int.Parse(splitterDistance, Culture);
                    }
                    catch
                    {
                    }
                }
            }
예제 #2
0
            protected override void Write()
            {
                if (_form.WindowState != FormWindowState.Minimized)
                {
                    ControlPreferences.SetValue(Name, "State", _form.WindowState.ToString());
                }

                if (_form.WindowState == FormWindowState.Normal)
                {
                    int x = _form.DesktopBounds.X;
                    int y = _form.DesktopBounds.Y;

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

                    ControlPreferences.SetValue(Name, "X", x.ToString(Culture));
                    ControlPreferences.SetValue(Name, "Y", y.ToString(Culture));

                    if (_form.FormBorderStyle == FormBorderStyle.Sizable || _form.FormBorderStyle == FormBorderStyle.SizableToolWindow)
                    {
                        ControlPreferences.SetValue(Name, "Width", _form.DesktopBounds.Width.ToString(Culture));
                        ControlPreferences.SetValue(Name, "Height", _form.DesktopBounds.Height.ToString(Culture));
                    }
                }
                else
                {
                    ControlPreferences.SetValue(Name, "X", _form.RestoreBounds.X.ToString(Culture));
                    ControlPreferences.SetValue(Name, "Y", _form.RestoreBounds.Y.ToString(Culture));

                    if (_form.FormBorderStyle == FormBorderStyle.Sizable || _form.FormBorderStyle == FormBorderStyle.SizableToolWindow)
                    {
                        ControlPreferences.SetValue(Name, "Width", _form.RestoreBounds.Width.ToString(Culture));
                        ControlPreferences.SetValue(Name, "Height", _form.RestoreBounds.Height.ToString(Culture));
                    }
                }
            }
예제 #3
0
 protected override void Write()
 {
     ControlPreferences.SetValue(Name, "SplitterDistance", _splitContainer.SplitterDistance.ToString(Culture));
 }
예제 #4
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);
                }
            }