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); }
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); }
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); }
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"); } } }
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); }
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); }
private void ShowInfo() { int size = ImageSizeChecker.GetSizeInKilobyte(PictureAsBytes); MessageBox.ShowInfo(ImageMessages.MessageMaxSizeManualResize(size), "Bildgrösse"); }