예제 #1
0
        public bool Close(FormClosingMode closeMode)
        {
            //сохраняем все переводы, если мы в режиме правки
            if (BaseSettings.TranslationMode && DCManager != null && DCManager.HasChanges)
            {
                if (!DCManager.SaveTranslations())
                {
                    return(false);
                }
            }

            Close();
            return(true);
        }
예제 #2
0
        public virtual bool Close(FormClosingMode closeMode)
        {
            //if (LifeTimeState == LifeTimeState.Closing)
            //    return;

            if (closeMode != FormClosingMode.NoSave)
            {
                if (closeMode == FormClosingMode.SaveWithConfirmation)
                {
                    if (!BaseActionPanel.ConfirmCancel(BusinessObject, FindForm()))
                    {
                        return(false);
                    }
                    ClearLastExecutedAction();
                }
                else if (!Post())
                {
                    return(false);
                }
            }


            //сохраняем все переводы, если мы в режиме правки
            if (BaseSettings.TranslationMode && DCManager != null && DCManager.HasChanges)
            {
                if (!DCManager.SaveTranslations())
                {
                    return(false);
                }
                //ttForm.DCManager.Release();
            }
            SaveGridLayout();
            Release();

            var form = FindForm();

            if (form != null && form != BaseFormManager.MainForm)
            {
                form.Close();
                return(true);
            }

            if (ParentLayout != null)
            {
                ParentLayout.Dispose();
            }
            Dispose();
            return(true);
        }
예제 #3
0
 public static bool Close
     (IApplicationForm form, DialogResult result = DialogResult.Cancel, FormClosingMode closeMode = FormClosingMode.NoSave)
 {
     if (FormClosing)
     {
         return(true);
     }
     FormClosing = true;
     //IApplicationForm nextForm = GetPreviousForm(form);
     try
     {
         form = GetRootAppForm(form);
         var basePanel = form as IBasePanel;
         if (basePanel != null)
         {
             (basePanel).LifeTimeState = LifeTimeState.Closing;
         }
         if (!form.Close(closeMode))
         {
             return(false);
         }
         var  baseFormContainer = ((Control)form).FindForm();
         bool disposed          = false;
         if (baseFormContainer != null)
         {
             if (ModalFormCount > 0)
             {
                 baseFormContainer.DialogResult = result;
                 baseFormContainer.Close();
                 disposed = true;
             }
             else if (baseFormContainer != MainForm)
             {
                 baseFormContainer.Close();
                 disposed = true;
             }
         }
         UnRegister(form);
         var panel = form as IBasePanel;
         if (panel != null)
         {
             (panel).LifeTimeState = LifeTimeState.Closed;
         }
         if (!disposed)
         {
             ((Control)form).Dispose();
             form = null;
         }
     }
     finally
     {
         if (form != null)
         {
             var basePanel = form as IBasePanel;
             if (basePanel != null)
             {
                 (basePanel).LifeTimeState = (basePanel).LifeTimeState & (~LifeTimeState.Closing);
             }
         }
         //else
         //    Activate(nextForm);
         FormClosing = false;
     }
     return(true);
 }