private DefectiveProfilesWindow(ActionResultDict actionResultDict)
            : this()
        {
            var errors = new List <ProfileError>();

            TranslationHelper.Instance.TranslatorInstance.Translate(this);

            if (actionResultDict.Count() > 1)
            {
                DefectiveProfilesText.Text = TranslationHelper.Instance.TranslatorInstance.GetTranslation(
                    "DefectiveProfilesWindow", "DefectiveProfiles", "Defective profiles:");
            }
            else
            {
                DefectiveProfilesText.Text = TranslationHelper.Instance.TranslatorInstance.GetTranslation(
                    "DefectiveProfilesWindow", "DefectiveProfile", "Defective profile:");
            }

            foreach (var profileNameActionResult in actionResultDict)
            {
                foreach (var error in profileNameActionResult.Value)
                {
                    var errorText = ErrorCodeInterpreter.GetErrorText(error, false);
                    errors.Add(new ProfileError(profileNameActionResult.Key, errorText));
                }
            }

            ProfileList.ItemsSource = errors;

            var view             = (CollectionView)CollectionViewSource.GetDefaultView(ProfileList.ItemsSource);
            var groupDescription = new PropertyGroupDescription("Profile");

            view.GroupDescriptions.Add(groupDescription);
        }
        public void CopyToClipBoard_CopyToClipboardisCalledWithCorrectText()
        {
            var actionResultDict     = new ActionResultDict();
            var excpetedError        = _errorCodeInterpreter.GetErrorText(ErrorCode.Attachment_NoPdf, false);
            var oneErrorActionResult = new ActionResult(ErrorCode.Attachment_NoPdf);

            actionResultDict.Add("RegionWithOneError", oneErrorActionResult);
            var twoErrorsActionResult = new ActionResult(ErrorCode.Attachment_NoPdf);

            twoErrorsActionResult.Add(ErrorCode.Attachment_NoPdf);
            actionResultDict.Add("RegionWithTwoErrors", twoErrorsActionResult);
            var interaction = new MessageInteraction("text", "title", MessageOptions.OK, MessageIcon.Info, actionResultDict, "second text");

            _viewModel.SetInteraction(interaction);

            var receivedText = "";

            _clipboardService.SetDataObject(Arg.Do <object>(o => receivedText = o as string));

            _viewModel.CopyToClipboard_CommandBinding(null, null);

            var expectedText = new StringBuilder()
                               .AppendLine("text")
                               .AppendLine("RegionWithOneError")
                               .AppendLine("- " + excpetedError)
                               .AppendLine("RegionWithTwoErrors")
                               .AppendLine("- " + excpetedError)
                               .AppendLine("- " + excpetedError)
                               .AppendLine("second text")
                               .ToString();

            Assert.AreEqual(receivedText, expectedText);
        }
        private bool QueryIgnoreDefectiveProfiles(ActionResultDict actionResultDict)
        {
            var profileProblemsInteraction = new ProfileProblemsInteraction(actionResultDict);

            _interactionInvoker.Invoke(profileProblemsInteraction);
            return(profileProblemsInteraction.IgnoreProblems);
        }
        public void SetInteractionWithActionResultDict_ErrorListVisibiltyIsVisible_ErrorListIsBuild_RaisesPropertyChanged()
        {
            var actionResultDict     = new ActionResultDict();
            var excpetedError        = _errorCodeInterpreter.GetErrorText(ErrorCode.Attachment_NoPdf, false);
            var oneErrorActionResult = new ActionResult(ErrorCode.Attachment_NoPdf);

            actionResultDict.Add("RegionWithOneError", oneErrorActionResult);
            var twoErrorsActionResult = new ActionResult(ErrorCode.Attachment_NoPdf);

            twoErrorsActionResult.Add(ErrorCode.Attachment_NoPdf);
            actionResultDict.Add("RegionWithTwoErrors", twoErrorsActionResult);
            var interaction = new MessageInteraction("", "", MessageOptions.OK, MessageIcon.Info, actionResultDict);

            var propertyChangedList = new List <string>();

            _viewModel.PropertyChanged += (sender, args) => propertyChangedList.Add(args.PropertyName);

            _viewModel.SetInteraction(interaction);

            Assert.AreEqual("RegionWithOneError", _viewModel.ErrorList[0].Region);
            Assert.AreEqual(excpetedError, _viewModel.ErrorList[0].Error);
            Assert.AreEqual("RegionWithTwoErrors", _viewModel.ErrorList[1].Region);
            Assert.AreEqual(excpetedError, _viewModel.ErrorList[1].Error);
            Assert.AreEqual("RegionWithTwoErrors", _viewModel.ErrorList[2].Region);
            Assert.AreEqual(excpetedError, _viewModel.ErrorList[2].Error);

            Assert.AreEqual(Visibility.Visible, _viewModel.ErrorListVisibility);
            Assert.Contains(nameof(_viewModel.ErrorListVisibility), propertyChangedList);
        }
Пример #5
0
        public override void Execute(object obj)
        {
            var currentRegion = _regionHelper.CurrentRegionName;
            MessageInteraction interaction = null;

            if (currentRegion == MainRegionViewNames.SettingsView)
            {
                var currentSettings = _currentSettingsProvider.Settings;
                var result          = _appSettingsChecker.CheckDefaultViewers(currentSettings.ApplicationSettings);
                var resultDict      = new ActionResultDict();
                resultDict.Add(Translation.DefaultViewer, result);
                interaction = DetermineInteraction(resultDict, settingsChanged: false);
            }
            else if (currentRegion == MainRegionViewNames.ProfilesView)
            {
                var currentSettings = _currentSettingsProvider.Settings;
                var resultDict      = _profileChecker.CheckProfileList(currentSettings.ConversionProfiles, currentSettings.ApplicationSettings.Accounts);
                var settingsChanged = _settingsChanged.HaveChanged();
                interaction = DetermineInteraction(resultDict, settingsChanged);
            }

            if (interaction != null)
            {
                _interactionRequest.Raise(interaction, ResolveInteractionResult);
            }
            else
            {
                IsDone?.Invoke(this, new MacroCommandIsDoneEventArgs(ResponseStatus.Success));
            }
        }
Пример #6
0
 public MessageInteraction(string text, string title, MessageOptions buttons, MessageIcon icon,
                           string resultKey, ActionResult actionResult, string secondText = null)
     : this(text, title, buttons, icon)
 {
     ActionResultDict = new ActionResultDict {
         { resultKey, actionResult }
     };
     SecondText = secondText;
 }
        public ActionResultDict ProfileCheckDict(ConversionProfile profile, Accounts accounts)
        {
            var nameResultDict = new ActionResultDict();
            var result         = ProfileCheck(profile, accounts);

            nameResultDict.Add(profile.Name, result);

            return(nameResultDict);
        }
Пример #8
0
 public MessageInteraction(string text, string title, MessageOptions buttons, MessageIcon icon,
                           ActionResultDict actionResultDict = null, string secondText = null)
 {
     Text             = text;
     Title            = title;
     Buttons          = buttons;
     Icon             = icon;
     ActionResultDict = actionResultDict;
     SecondText       = secondText;
     ShowErrorRegions = true;
 }
Пример #9
0
        public ActionResultDict CheckProfileList(IList<ConversionProfile> profileList, Accounts accounts)
        {
            var nameResultDict = new ActionResultDict();

            foreach (var profile in profileList)
            {
                var result = ProfileCheck(profile, accounts, CheckLevel.Profile);
                if (!result)
                    nameResultDict.Add(profile.Name, result);
            }

            return nameResultDict;
        }
Пример #10
0
        public void SetInteractionWitValidActionResultDict_ErrorListVisibiltyIsCollapsed_RaisesPropertyChanged()
        {
            var validActionResultDict = new ActionResultDict();
            var interaction           = new MessageInteraction("", "", MessageOptions.OK, MessageIcon.Info, validActionResultDict);
            var propertyChangedList   = new List <string>();

            _viewModel.PropertyChanged += (sender, args) => propertyChangedList.Add(args.PropertyName);

            _viewModel.SetInteraction(interaction);

            Assert.AreEqual(Visibility.Collapsed, _viewModel.ErrorListVisibility);
            Assert.Contains(nameof(_viewModel.ErrorListVisibility), propertyChangedList);
        }
        public void Execute_WithErrors_UserChoosesToCancel_CallsIsDoneWithCancel()
        {
            var command       = BuildCommand();
            var commandTester = new WaitableCommandTester <CheckProfileCommand>(command);
            var actionResult  = new ActionResultDict();

            actionResult.Add("a", new ActionResult(ErrorCode.Processing_GenericError));
            _profileChecker.ProfileCheckDict(null, null).ReturnsForAnyArgs(actionResult);
            _interactionRequest.RegisterInteractionHandler <ProfileProblemsInteraction>(i => i.IgnoreProblems = false);

            command.Execute(null);

            Assert.IsTrue(commandTester.IsDoneWasRaised);
            Assert.AreEqual(ResponseStatus.Cancel, commandTester.LastResponseStatus);
        }
Пример #12
0
        public ActionResultDict ProfileCheckDict(IList <ConversionProfile> profileList, Accounts accounts)
        {
            var nameResultDict = new ActionResultDict();

            foreach (var profile in profileList)
            {
                var result = ProfileCheck(profile, accounts);
                if (!result)
                {
                    nameResultDict.Add(profile.Name, result);
                }
            }

            return(nameResultDict);
        }
        public SettingsCheckResult CheckSettings()
        {
            var result = new ActionResult();

            foreach (var defaultViewer in _defaultViewerSettings.Settings)
            {
                result.AddRange(_defaultViewerCheck.Check(defaultViewer));
            }

            var resultDict = new ActionResultDict
            {
                { _translation.DefaultViewer, result }
            };

            return(new SettingsCheckResult(resultDict, false));
        }
        public void SaveCommand_WithDefects_WithoutIgnore_DoesNotFinishInteraction()
        {
            var viewModel = CreateProfileSettingsViewModel(_settings);
            var dict      = new ActionResultDict();

            dict.Add("some error", new ActionResult(ErrorCode.Conversion_UnknownError));

            _profileChecker.ProfileCheckDict(viewModel.Interaction.Settings.ConversionProfiles, Arg.Any <Accounts>()).Returns(dict);

            _interactionInvoker.HandleProfileProblemsInteraction += delegate(ProfileProblemsInteraction interaction) { interaction.IgnoreProblems = false; };

            viewModel.SaveButtonCommand.Execute(null);

            Assert.IsFalse(viewModel.Interaction.ApplySettings);
            Assert.IsFalse(_interactionHelper.InteractionIsFinished);
            Assert.AreEqual(1, _interactionInvoker.InvokedInteractions.Count, "Unexpected interactions were invoked");
        }
        public DesignTimeMessageViewModel(bool withErrors) : base(new DesignTimeTranslationUpdater(), new DesignTimeSoundPlayer(), new ErrorCodeInterpreter(new TranslationFactory()), null)
        {
            var messageInteraction = new MessageInteraction("The Message is Love", "The Title", MessageOptions.OK, MessageIcon.PDFForge);

            if (withErrors)
            {
                var actionResultDict = new ActionResultDict();
                var actionResult     = new ActionResult(ErrorCode.Conversion_UnknownError)
                {
                    ErrorCode.Conversion_UnknownError
                };
                actionResultDict.Add("ProfileName ", actionResult);
                actionResultDict.Add("Some other Profile", actionResult);
                messageInteraction = new MessageInteraction("You have defective or incomplete settings.", "The Title", MessageOptions.YesNoCancel, MessageIcon.Warning,
                                                            actionResultDict, "Are you sure you want to proceed?");
            }

            SetInteraction(messageInteraction);
        }
Пример #16
0
        private MessageInteraction DetermineInteraction(ActionResultDict actionResultDict, bool settingsChanged)
        {
            if (!actionResultDict)
            {
                var text         = Translation.InvalidSettings;
                var title        = Translation.PDFCreatorSettings;
                var userQuestion = settingsChanged ? Translation.SaveAnyway : Translation.ProceedAnyway;
                var buttons      = settingsChanged ? MessageOptions.YesNoCancel : MessageOptions.YesCancel;
                return(new MessageInteraction(text, title, buttons, MessageIcon.Warning, actionResultDict, userQuestion));
            }
            if (settingsChanged && QueryOnProfileSettingsChanged)
            {
                var text  = Translation.UnsavedChanges;
                var title = Translation.PDFCreatorSettings;
                return(new MessageInteraction(text, title, MessageOptions.YesNoCancel, MessageIcon.Question));
            }

            return(null);
        }
        public void Setup()
        {
            _interactionRequest = new UnitTestInteractionRequest();

            _settings = new PdfCreatorSettings(null);
            _currentSettingsProvider = Substitute.For <ICurrentSettingsProvider>();
            _currentSettingsProvider.Settings.Returns(_settings);
            _currentSettingsProvider.Profiles.Returns(_settings.ConversionProfiles);
            _currentSettingsProvider.SelectedProfile.Returns(_settings.ConversionProfiles.FirstOrDefault());

            var translationUpdater = new DesignTimeTranslationUpdater();

            _regionHelper = Substitute.For <IRegionHelper>();

            _profileChecker = Substitute.For <IProfileChecker>();
            _profileChecker.CheckProfileList(_settings.ConversionProfiles, _settings.ApplicationSettings.Accounts)
            .Returns(new ActionResultDict());

            _appSettingsChecker = Substitute.For <IAppSettingsChecker>();
            _appSettingsChecker.CheckDefaultViewers(Arg.Any <ApplicationSettings>())
            .Returns(new ActionResult());

            _settingsChanged = Substitute.For <ISettingsChanged>();

            _command = new EvaluateSettingsAndNotifyUserCommand(_interactionRequest, _currentSettingsProvider,
                                                                translationUpdater, _regionHelper, _profileChecker,
                                                                _appSettingsChecker, _settingsChanged);

            _commandTester = new WaitableCommandTester <EvaluateSettingsAndNotifyUserCommand>(_command);

            _translation = new EvaluateSettingsAndNotifyUserTranslation();

            _actionResultWithError = new ActionResult((ErrorCode)123456789);
            _errorsInProfile       = new ActionResultDict();
            _errorsInProfile.Add("Some Profile", _actionResultWithError);
        }
 public ProfileProblemsInteraction(ActionResultDict profileProblems)
 {
     ProfileProblems = profileProblems;
 }
        public static bool ShowDialogTopMost(ActionResultDict actionResultDict)
        {
            var window = new DefectiveProfilesWindow(actionResultDict);

            return(TopMostHelper.ShowDialogTopMost(window, true) == true);
        }
Пример #20
0
 public SettingsCheckResult(ActionResultDict result, bool settingsHaveChanged)
 {
     Result = result;
     SettingsHaveChanged = settingsHaveChanged;
 }
Пример #21
0
 private bool QueryIgnoreDefectiveProfiles(ActionResultDict actionResultDict)
 {
     return(DefectiveProfilesWindow.ShowDialogTopMost(actionResultDict));
 }
Пример #22
0
 public SettingsCheckResult()
 {
     Result = new ActionResultDict();
     SettingsHaveChanged = false;
 }