Ejemplo n.º 1
0
        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            // closing all child forms
            PrepareCloseAll(false);
            bool cancel;

            winControl.CloseAllForms(out cancel);
            e.Cancel = cancel;

            if (!cancel)
            {
                // maintaining the state of the form
                if (WindowState == FormWindowState.Normal)
                {
                    settings.FormSt.Left      = Left;
                    settings.FormSt.Top       = Top;
                    settings.FormSt.Width     = Width;
                    settings.FormSt.Height    = Height;
                    settings.FormSt.Maximized = false;
                }
                else
                {
                    settings.FormSt.Left   = RestoreBounds.Left;
                    settings.FormSt.Top    = RestoreBounds.Top;
                    settings.FormSt.Width  = RestoreBounds.Width;
                    settings.FormSt.Height = RestoreBounds.Height;
                    if (WindowState == FormWindowState.Maximized)
                    {
                        settings.FormSt.Maximized = true;
                    }
                }

                settings.FormSt.ExplorerWidth = pnlLeft.Width;

                string errMsg;
                if (!settings.SaveFormState(out errMsg))
                {
                    ScadaUiUtils.ShowError(errMsg);
                }
            }
        }
Ejemplo n.º 2
0
        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            // закрытие всех дочерних форм
            PrepareCloseAll(false);
            bool cancel;

            winControl.CloseAllForms(out cancel);
            e.Cancel = cancel;

            if (!cancel)
            {
                // сохранение состояния формы
                if (WindowState == FormWindowState.Normal)
                {
                    settings.FormSt.Left      = Left;
                    settings.FormSt.Top       = Top;
                    settings.FormSt.Width     = Width;
                    settings.FormSt.Height    = Height;
                    settings.FormSt.Maximized = false;
                }
                else
                {
                    settings.FormSt.Left   = RestoreBounds.Left;
                    settings.FormSt.Top    = RestoreBounds.Top;
                    settings.FormSt.Width  = RestoreBounds.Width;
                    settings.FormSt.Height = RestoreBounds.Height;
                    if (WindowState == FormWindowState.Maximized)
                    {
                        settings.FormSt.Maximized = true;
                    }
                }
                settings.FormSt.ExplorerWidth = pnlLeft.Width;

                string errMsg;
                if (!settings.SaveFormState(out errMsg))
                {
                    ScadaUiUtils.ShowError(errMsg);
                }
            }
        }