예제 #1
0
 public bool Test()
 {
     try
     {
         ConverterSettingsFile settingsFile = new ConverterSettingsFile();
         string filePath;
         var    settings = new ConverterSettings();
         DefaultSettingsLocatorHelper.EnsureDefaultSettingsFilePresent(out filePath, settings);
         settingsFile.Load(filePath);
         settingsFile.Settings.StandardVersion           = _version;
         settingsFile.Settings.FB2ImportSettings.FixMode = FixOptions.UseFb2Fix;
         IFb2EPubConverterEngine converter = ConvertProcessor.CreateConverterEngine(settingsFile.Settings);
         var path = new StringBuilder();
         path.AppendFormat(@"{0}\TestFiles\Test_001.fb2", Directory.GetCurrentDirectory());
         converter.LoadAndCheckFB2Files(path.ToString());
         string outPath = Path.GetTempPath();
         converter.Save(outPath);
     }
     catch (Exception ex)
     {
         _lastException = ex;
         return(false);
     }
     return(true);
 }
예제 #2
0
        /// <summary>
        /// Load settings from one of the default settings locations or file specified
        /// </summary>
        public void LoadSettings()
        {
            var file = new ConverterSettingsFile();

            if (string.IsNullOrEmpty(_processorSettings.SettingsFileToUse) || !File.Exists(ProcessorSettings.SettingsFileToUse))
            {
                if (!string.IsNullOrEmpty(_processorSettings.SettingsFileToUse))
                {
                    Logger.Log.ErrorFormat("LoadSettings - the specified settings file \"{0}\" not found, going to use standard settings file", _processorSettings.SettingsFileToUse);
                }
                string filePath;
                DefaultSettingsLocatorHelper.EnsureDefaultSettingsFilePresent(out filePath, file.Settings);
                _processorSettings.SettingsFileToUse = filePath;
            }
            try
            {
                Logger.Log.InfoFormat("Loading settings from {0}", _processorSettings.SettingsFileToUse);
                file.Load(ProcessorSettings.SettingsFileToUse);
            }
            catch (Exception ex)
            {
                Logger.Log.ErrorFormat("LoadSettings - unable to load file {0} , exception: {1}", _processorSettings.SettingsFileToUse, ex);
            }
            try
            {
                _processorSettings.Settings.CopyFrom(file.Settings);
            }
            catch (Exception ex)
            {
                Logger.Log.ErrorFormat("LoadSettings - unable to copy settings , exception: {0}", ex);
            }
        }
예제 #3
0
        public AboutBox()
        {
            InitializeComponent();
            Text = String.Format("About {0}", AssemblyTitle);
            linkLabelAbout.Links.Add(0, linkLabelAbout.Text.Length, @"http://www.fb2epub.net");
            Assembly asm     = Assembly.GetAssembly(GetType());
            string   version = "???";

            if (asm != null)
            {
                version = asm.GetName().Version.ToString();
            }
            textBoxNameAndVersion.Text = string.Format("FB2ePub GUI converter v{0}", version);
            textBoxLogPath.Text        = string.Format(Resources.Log_Folder, GlobalContext.Properties["LogName"]);
            string settingsLocation;

            DefaultSettingsLocatorHelper.SettingsLocation detected;
            DefaultSettingsLocatorHelper.LocateDefaultSettings(out settingsLocation, out detected);
            textBoxSettingsPath.Text = detected != DefaultSettingsLocatorHelper.SettingsLocation.NotDetected ? string.Format(Resources.Default_Settings_File, settingsLocation, detected) : Resources.AboutBox_AboutBox_Default_settings_file_not_found;
            textBoxResourcePath.Text = string.Format(Resources.Using_Resources_From, (ResourceLocator.Instance.GetResourcesPath()));
        }