Example #1
0
        private bool DoSave()
        {
            bool doSave = true;

            if (IsDirty)
            {
                if (!Focused)
                {
                    Focus();
                }

                DialogResult dr = MessageBox.ShowYesNo(BaseFormMessages.SaveDataQuestion, BaseFormMessages.Save);

                switch (dr)
                {
                case DialogResult.Yes:
                    doSave = Save();
                    break;

                case DialogResult.No:
                    break;

                case DialogResult.Cancel:
                    doSave = false;
                    break;

                default:
                    doSave = false;
                    break;
                }
            }
            return(doSave);
        }
Example #2
0
        public DialogResult ShowDialog()
        {
            DialogResult dialogResult = ImageOpenDialogStarter.Execute(ofdImage);

            if (dialogResult == DialogResult.OK)
            {
                if (ImageValidator.GetInstance().IsValidImage(ofdImage.FileName))
                {
                    PictureAsBytes = ImageLoader.GetByteFromFile(ofdImage.FileName);

                    if (ImageSizeChecker.MaxSizeExceeded(PictureAsBytes))
                    {
                        ShowInfo();
                        dialogResult = StartImageViewer(dialogResult);
                    }
                }
                else
                {
                    MessageBox.ShowInfo(Windows.Core.Localization.ImageMessages.UnkownImageFileFormatMsg,
                                        Windows.Core.Localization.ImageMessages.UnkownImageFileFormat);
                    dialogResult = DialogResult.Cancel;
                }
            }
            return(dialogResult);
        }
Example #3
0
        protected bool AskAndSave(bool saved)
        {
            if (_saveEnabled)
            {
                var result = DialogResult.None;
                if (IsDirty)
                {
                    result = MessageBox.ShowYesNo(BaseFormMessages.SaveDataQuestion, BaseFormMessages.Save);
                }

                if (result == DialogResult.Yes)
                {
                    saved = Save();
                }
                else if (result == DialogResult.Cancel)
                {
                    saved = false;
                }
            }
            else
            {
                saved = true;
            }

            return(saved);
        }
Example #4
0
        private bool PreSaveChecksOk(object businessObject, BindingSource bindingSource)
        {
            if (!Enabled)
            {
                if (!TestMode)
                {
                    MessageBox.ShowInfo(SaveManagerMessages.SaveManagerDisabled,
                                        SaveManagerMessages.SaveManagerDisabledCaption);
                }
                return(false);
            }

            var stateAuthorization = businessObject as IObjectStateAuthorization;

            if (stateAuthorization != null)
            {
                if (!stateAuthorization.Authorization.AllowEdit())
                {
                    if (!TestMode)
                    {
                        MessageBox.ShowInfo(SaveManagerMessages.AllowEditFalse);
                    }
                    return(false);
                }
            }

            var trackStatus = businessObject as ITrackStatus;

            if (trackStatus != null)
            {
                ObjectBindingManager.EndEditBinding(bindingSource);
                if (!trackStatus.IsDirty)
                {
                    return(false);
                }

                if (!trackStatus.IsValid)
                {
                    if (!TestMode && ShowDataNotSavedErrorMessage)
                    {
                        MessageBox.ShowInfo(_dataNotSavedErrorMessage, SaveManagerMessages.DataNotSavedCaption);
                    }
                    return(false);
                }
            }

            if (!BusinessRules.HasPermission(AuthorizationActions.EditObject, businessObject))
            {
                MessageBox.ShowInfo(SaveManagerMessages.NotAuthorized);
                return(false);
            }

            return(true);
        }
 public void AfterSplash()
 {
     try
     {
         _startupLogic.RunPluginApplication();
     }
     catch (Exception e)
     {
         MessageBox.ShowError("Error in PluginApplication", e, "PluginApplication");
         throw;
     }
 }
 public void BeforeSplash()
 {
     try
     {
         _startupLogic.SetApplicationInfo();
     }
     catch (Exception e)
     {
         MessageBox.ShowError("Error in PluginApplication", e, "PluginApplication");
         throw;
     }
 }
Example #7
0
        private bool Save(Func <bool> preSaveCheck, Action saveAction)
        {
            bool saved = false;

            if (preSaveCheck.Invoke())
            {
                try
                {
                    using (new StatusBusy(SaveManagerMessages.SavingData, ShowWaitForm))
                    {
                        saveAction.Invoke();
                        saved = true;
                    }
                }
                catch (ValidationException)
                {
                    if (ShowDataNotSavedErrorMessage)
                    {
                        MessageBox.ShowInfo(_dataNotSavedErrorMessage, SaveManagerMessages.DataNotSavedCaption);
                    }
                }
                catch (ConcurrencyException)
                {
                    MessageBox.ShowInfo(SaveManagerMessages.AnotherUserHasChangedData,
                                        SaveManagerMessages.AnotherUserHasChangedDataCaption);
                }
                catch (InvalidStateException)
                {
                    MessageBox.ShowInfo(SaveManagerMessages.SaveNotAllowedInvalidState);
                }
                catch (NotAllowedException)
                {
                    MessageBox.ShowInfo(SaveManagerMessages.OperationNowAllowed,
                                        SaveManagerMessages.OperationNowAllowedCaption);
                }
                catch (SecurityException)
                {
                    MessageBox.ShowInfo(SaveManagerMessages.NotAuthorized);
                }
                catch (Exception ex)
                {
                    MessageBox.ShowError(SaveManagerMessages.SaveException, ex.Message,
                                         SaveManagerMessages.SaveException);
                    throw;
                }
            }

            return(saved);
        }
        protected bool CheckAndConfirmDelete()
        {
            if (NeedsDeleteCheck())
            {
                var result = BusinessObject.CanDelete();
                if (!result.Allowed)
                {
                    var reason = result.CreateMessage(CommandRes.CantDelete);
                    MessageBox.ShowWarning(reason);
                    return(false);
                }
            }

            return(Confirmation());
        }
Example #9
0
 public override void Execute()
 {
     using (new StatusBusy("Hilfe wird geladen ...", false))
     {
         var helpProvider = Provider.Get();
         if (helpProvider != null)
         {
             helpProvider.ShowHelp(_help);
         }
         else
         {
             MessageBox.ShowInfo("Kein Hilfesystem (HelpProvider) konfiguriert.", "Hilfe");
         }
     }
 }
Example #10
0
        internal DialogResult GetDialogResult(SaveFileDialog saveFileDialog)
        {
            var dialogResult = DialogResult.No;

            try
            {
                dialogResult = saveFileDialog.ShowDialog();
            }
            catch (InvalidOperationException)
            {
                MessageBox.ShowInfo(string.Format(HelperRes.FileNameInvalid, saveFileDialog.FileName),
                                    HelperRes.FileExport);
            }
            return(dialogResult);
        }
 public void BeforeRun()
 {
     try
     {
         //Startform vorbereiten
         _mainForm = new FrmStartForm();
         _startupLogic.InitWindowManager(_mainForm);
         //_startupLogic.SetMainForm(_mainForm, ((FrmStartForm)_mainForm).bsiStatus);
         _startupLogic.CloseSplash();
     }
     catch (Exception e)
     {
         MessageBox.ShowError("Error in PluginApplication", e, "PluginApplication");
         throw;
     }
 }
Example #12
0
        private SaveFileDialog OpenSaveFileDialog()
        {
            var saveFileDialog = InitSaveDialog(ExportType, SaveFileName);

            var dialogResult = GetDialogResult(saveFileDialog);

            if (dialogResult != DialogResult.OK)
            {
                return(null);
            }

            if (!FileHelper.IsAccessible(saveFileDialog.FileName))
            {
                MessageBox.ShowInfo(string.Format(HelperRes.FileAlreadyOpen, saveFileDialog.FileName),
                                    HelperRes.FileExport);
                return(null);
            }
            return(saveFileDialog);
        }
Example #13
0
        public override void Execute()
        {
            IList <FrmBase> dirtyForms = WindowManager.FindDirtyWindows();

            if (dirtyForms != null && dirtyForms.Count == 0)
            {
                WindowManager.CloseAllForms();
                ApplicationExit = true;
            }
            else
            {
                string formInfo = string.Empty;

                foreach (FrmBase form in dirtyForms)
                {
                    formInfo += form.Text + Environment.NewLine;
                }

                DialogResult = MessageBox.ShowYesNo("Möchten Sie wirklich die Anwendung beenden?" +
                                                    Environment.NewLine +
                                                    "Sie haben noch folgende Fenster nicht gespeichert." +
                                                    Environment.NewLine +
                                                    Environment.NewLine +
                                                    formInfo,
                                                    "Anwendung beenden");

                if (DialogResult == DialogResult.Yes)
                {
                    WindowManager.CloseAllForms();
                    ApplicationExit = true;
                }
                else
                {
                    ApplicationExit = false;
                }
            }
        }
Example #14
0
        private void ShowInfo()
        {
            int size = ImageSizeChecker.GetSizeInKilobyte(PictureAsBytes);

            MessageBox.ShowInfo(ImageMessages.MessageMaxSizeManualResize(size), "Bildgrösse");
        }
        protected virtual bool Confirmation()
        {
            var dr = MessageBox.ShowYesNo(CommandRes.DeleteConfirmation, CommandRes.DeleteEntry);

            return(dr == DialogResult.Yes);
        }
Example #16
0
 private void ShowNoPermissionMessage()
 {
     MessageBox.ShowWarning(CommandExecutorRes.NoPermissionMsg, CommandExecutorRes.NoPermissionCaption);
 }