Beispiel #1
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 static ConversionProfile PreselectedProfile(IJobInfo jobInfo, clawPDFSettings settings)
        {
            foreach (var mapping in settings.ApplicationSettings.PrinterMappings)
            {
                if (mapping.PrinterName.Equals(jobInfo.SourceFiles[0].PrinterName, StringComparison.OrdinalIgnoreCase))
                {
                    var p = settings.GetProfileByGuid(mapping.ProfileGuid);
                    if (p != null)
                    {
                        return(p);
                    }
                    break;
                }
            }

            var lastUsedProfile = settings.GetLastUsedProfile();

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

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

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

            // last resort: first profile from the list
            return(settings.ConversionProfiles[0]);
        }
Beispiel #2
0
        /// <summary>
        ///     Load the settings. If no valid settings exist for this user, default settings will be created.
        ///     加载设置。如果此用户不存在有效设置,则将创建默认设置。
        /// </summary>
        private static void LoadSettings()
        {
            var settingsMover = new SettingsMover();

            if (settingsMover.MoveRequired())
            {
                settingsMover.MoveSettings();
            }

            _settings = CreateEmptySettings();

            if (UserSettingsExist())
            {
                _settings.LoadData(_settings.GetStorage(), "", UpgradeSettings);
            }

            if (!CheckValidSettings(_settings))
            {
                if (DefaultUserSettingsExist())
                {
                    _settings.LoadData(new RegistryStorage(RegistryHive.Users, @".DEFAULT\" + SETTINGS_REG_PATH), "",
                                       UpgradeSettings);
                }
                else
                {
                    _settings = CreateDefaultSettings();
                }
            }

            CheckAndAddMissingDefaultProfile(_settings);

            CheckPrinterMappings();

            CheckTitleReplacement();

            if (_settings.ApplicationSettings.Language == "")
            {
                var language = TranslationHelper.Instance.LanguageLoader.FindBestLanguage(CultureInfo.CurrentCulture);

                if (language != null)
                {
                    _settings.ApplicationSettings.Language = Path.GetFileNameWithoutExtension(language.FileName);
                }
            }

            var applicationLanguage = Settings.ApplicationSettings.Language;

            TranslationHelper.Instance.InitTranslator(applicationLanguage);
            LoggingHelper.ChangeLogLevel(_settings.ApplicationSettings.LoggingLevel);
            TranslationHelper.Instance.TranslateProfileList(Settings.ConversionProfiles);

            if (_logger.IsTraceEnabled)
            {
                _logger.Trace("Profiles:");
                foreach (var conversionProfile in _settings.ConversionProfiles)
                {
                    _logger.Trace(conversionProfile.Name);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Create a workflow based on the job and settings objects provided. This will create an AutoSave workflow if the
        ///     job's printer has an AutoSave profile associated or the default profile uses AutoSave.
        ///     Otherwise, an interactive workflow will be created.
        ///     基于提供的作业和设置对象创建工作流。如果作业的打印机关联了自动保存配置文件或默认配置文件使用自动保存,
        ///     则此操作将创建自动保存工作流。否则,将创建交互式工作流。
        /// </summary>
        /// <param name="jobInfo">The jobinfo used for the decision</param>
        /// <param name="settings">The settings used for the decision</param>
        /// <returns>A ConversionWorkflow either for AutoSave or interactive use</returns>
        public static ConversionWorkflow CreateWorkflow(IJobInfo jobInfo, clawPDFSettings settings)
        {
            Logger.Trace("Creating Workflow");

            var preselectedProfile = PreselectedProfile(jobInfo, settings).Copy();

            Logger.Debug("Profile: {0} (GUID {1})", preselectedProfile.Name, preselectedProfile.Guid);

            var jobTranslations = new JobTranslations();

            jobTranslations.EmailSignature = MailSignatureHelper.ComposeMailSignature();

            var job = JobFactory.CreateJob(jobInfo, preselectedProfile, JobInfoQueue.Instance, jobTranslations);

            job.AutoCleanUp = true;


            if (preselectedProfile.AutoSave.Enabled)
            {
                Logger.Trace("Creating AutoSaveWorkflow");
                return(new AutoSaveWorkflow(job, settings));
            }

            Logger.Trace("Creating InteractiveWorkflow");
            return(new InteractiveWorkflow(job, settings));
        }
 public ProfileSettingsViewModel(clawPDFSettings settings,
                                 TranslationHelper translationHelper)
     : this()
 {
     Settings = settings;
     _unchangedOriginalSettings = _settings.Copy();
 }
Beispiel #5
0
        /// <summary>
        ///     Create a new Workflow object with the given job info
        /// </summary>
        /// <param name="job">Job to use for the conversion</param>
        /// <param name="settings">Settings to use during the conversion workflow</param>
        public AutoSaveWorkflow(IJob job, clawPDFSettings settings)
        {
            WorkflowStep = WorkflowStep.Init;

            JobInfo  = job.JobInfo;
            Job      = job;
            Settings = settings;
        }
 private void UpdateSettingsAction(clawPDFSettings settings)
 {
     GeneralTabUserControl.ViewModel.ApplicationSettings   = settings.ApplicationSettings;
     GeneralTabUserControl.ViewModel.ApplicationProperties = settings.ApplicationProperties;
     TitleTabUserControl.ViewModel.ApplyTitleReplacements(settings.ApplicationSettings.TitleReplacement);
     PrinterTabUserControl.ViewModel.ConversionProfiles  = settings.ConversionProfiles;
     PrinterTabUserControl.ViewModel.ApplicationSettings = settings.ApplicationSettings;
 }
Beispiel #7
0
        public ComWorkflow(IJob job, clawPDFSettings settings)
        {
            JobInfo  = job.JobInfo;
            Job      = job;
            Settings = settings;

            SetJobSettings();
        }
Beispiel #8
0
        /// <summary>
        ///     Create a new Workflow object with the given job info
        /// </summary>
        /// <param name="job">Job to use for the conversion</param>
        /// <param name="settings">Settigns to use during the conversion workflow</param>
        public InteractiveWorkflow(IJob job, clawPDFSettings settings)
        {
            WorkflowStep = WorkflowStep.Init;

            job.OnActionAdded          += job_OnActionAdded;
            job.OnRetypeOutputFilename += RetypeOutputFilename;

            JobInfo  = job.JobInfo;
            Job      = job;
            Settings = settings;
        }
Beispiel #9
0
        /// <summary>
        ///     Functions checks, if a default profile exists and adds one.
        /// </summary>
        private static void CheckAndAddMissingDefaultProfile(clawPDFSettings settings)
        {
            var defaultProfile = settings.GetProfileByGuid(ProfileGuids.DEFAULT_PROFILE_GUID);

            if (defaultProfile == null)
            {
                defaultProfile      = new ConversionProfile();
                defaultProfile.Name = "<Default Profile>";
                defaultProfile.Guid = ProfileGuids.DEFAULT_PROFILE_GUID;
                settings.ConversionProfiles.Add(defaultProfile);
            }

            SetDefaultProperties(defaultProfile, false);
        }
        public ProfileSettingsWindow(clawPDFSettings settings)
        {
            InitializeComponent();
            ViewModel = CreateViewModel(settings);

            ViewModel.ConversionProfilesView.CurrentChanged += OnConversionProfilesViewOnCurrentChanged;
            ViewModel.CurrentProfilePropertyChanged();

            AddActions();

            UpdateTabControls(ViewModel.CurrentProfile);

            if (ViewModel.CurrentProfile != null)
            {
                DocumentTabUserControl.UpdateFontLabel(ViewModel.CurrentProfile.Stamping);
            }
        }
Beispiel #11
0
        private void SettingsButton_OnClick(object sender, RoutedEventArgs e)
        {
            var vm = (PrintJobViewModel)DataContext;

            TopMostHelper.UndoTopMostWindow(this);
            _settings.ApplicationSettings.LastUsedProfileGuid = vm.SelectedProfile.Guid;

            var window = new ProfileSettingsWindow(_settings);

            if (window.ShowDialog() == true)
            {
                _settings = window.Settings;

                vm.Profiles            = _settings.ConversionProfiles;
                vm.ApplicationSettings = _settings.ApplicationSettings;
                vm.SelectProfileByGuid(_settings.ApplicationSettings.LastUsedProfileGuid);
            }
        }
Beispiel #12
0
 /// <summary>
 ///     Check if the settings provided are valid, i.e. contain at least one profile.
 /// </summary>
 /// <param name="settings">The settings to inspect</param>
 /// <returns>true, if they appear valid.</returns>
 public static bool CheckValidSettings(clawPDFSettings settings)
 {
     return(settings.ConversionProfiles.Count > 0);
 }
Beispiel #13
0
 /// <summary>
 ///     Applies a new set of settings to make it globally available
 /// </summary>
 /// <param name="settings">The new setting class</param>
 public static void ApplySettings(clawPDFSettings settings)
 {
     _settings = settings;
 }
 public ProfileSettingsViewModel(clawPDFSettings settings)
     : this(settings, TranslationHelper.Instance)
 {
 }