Ejemplo n.º 1
0
 public void Reset()
 {
     CloneSettings();
     SelectedProfile = _settings.GetProfileByName(_selectedProfile.Name);
     SettingsChanged?.Invoke(this, EventArgs.Empty);
     RaisePropertyChanged(nameof(Settings));
 }
Ejemplo n.º 2
0
 public void Reset()
 {
     CloneSettings();
     SelectedProfile = _settings.GetProfileByName(_selectedProfile.Name);
     SettingsChanged?.Invoke(this, EventArgs.Empty);
     RaisePropertyChanged(nameof(Settings));
     RaisePropertyChanged(nameof(Accounts));
     RaisePropertyChanged(nameof(TitleReplacements));
     RaisePropertyChanged(nameof(PrinterMappings));
 }
Ejemplo n.º 3
0
        public void GetProfileByName_WithNonexistantProfile_ReturnsProfile()
        {
            var settings = new PdfCreatorSettings();
            var p1       = new ConversionProfile {
                Guid = "g1", Name = "p1"
            };
            var p2 = new ConversionProfile {
                Guid = "g2", Name = "p2"
            };

            settings.ConversionProfiles.Add(p1);
            settings.ConversionProfiles.Add(p2);

            Assert.IsNull(settings.GetProfileByName("p3"));
        }
Ejemplo n.º 4
0
        public void GetProfileByName_WithExistingProfile_ReturnsProfile()
        {
            var settings = new PdfCreatorSettings(Substitute.For <IStorage>());
            var p1       = new ConversionProfile {
                Guid = "g1", Name = "p1"
            };
            var p2 = new ConversionProfile {
                Guid = "g2", Name = "p2"
            };

            settings.ConversionProfiles.Add(p1);
            settings.ConversionProfiles.Add(p2);

            Assert.AreSame(p1, settings.GetProfileByName("p1"));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Determines the preselected profile for the printer that was used while creating the job
        /// </summary>
        /// <param name="jobInfo">The jobinfo used for the decision</param>
        /// <param name="settings">The settings used for the decision</param>
        /// <returns>The profile that is associated with the printer or the default profile</returns>
        private ConversionProfile PreselectedProfile(JobInfo jobInfo, PdfCreatorSettings settings)
        {
            ConversionProfile profile = null;

            foreach (var mapping in settings.ApplicationSettings.PrinterMappings)
            {
                if (mapping.PrinterName.Equals(jobInfo.SourceFiles[0].PrinterName, StringComparison.OrdinalIgnoreCase))
                {
                    profile = settings.GetProfileByGuid(mapping.ProfileGuid);

                    if (mapping.ProfileGuid == ProfileGuids.LAST_USED_PROFILE_GUID)
                    {
                        profile = settings.GetLastUsedProfile();
                    }

                    if (profile != null)
                    {
                        break;
                    }
                }
            }

            //consider LastUsedProfile
            //todo: Do not relate to empty string and use own GUID to request LastUsedProfile (see above)
            if (jobInfo.SourceFiles.Count > 0 && string.IsNullOrEmpty(jobInfo.SourceFiles[0].PrinterName))
            {
                var lastUsedProfile = settings.GetLastUsedProfile();
                if (lastUsedProfile != null)
                {
                    profile = lastUsedProfile;
                }
            }

            //Consider commandline paramaters
            if (_parametersManager.HasPredefinedParameters())
            {
                var parameters       = _parametersManager.GetAndResetParameters();
                var profileParameter = parameters.Profile;
                if (!string.IsNullOrEmpty(profileParameter))
                {
                    profile = settings.GetProfileByName(profileParameter);
                    if (profile == null)
                    {
                        profile = settings.GetProfileByGuid(profileParameter);
                    }
                }

                var outputFile = parameters.Outputfile;
                if (outputFile != null)
                {
                    jobInfo.OutputFileParameter = outputFile;
                }
            }

            if (profile != null)
            {
                return(profile);
            }

            // try default profile
            var defaultProfile = GetDefaultProfile(settings.ConversionProfiles);

            if (defaultProfile != null)
            {
                return(defaultProfile);
            }

            // last resort: first profile from the list
            return(settings.ConversionProfiles[0]);
        }