示例#1
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);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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");
         }
     }
 }
示例#5
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);
        }
示例#6
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);
        }
示例#7
0
        private void ShowInfo()
        {
            int size = ImageSizeChecker.GetSizeInKilobyte(PictureAsBytes);

            MessageBox.ShowInfo(ImageMessages.MessageMaxSizeManualResize(size), "Bildgrösse");
        }