public void CopyFrom(IEPubConversionSettings temp)
 {
     if (temp == null)
     {
         throw new ArgumentNullException("temp");
     }
     if (temp == this)
     {
         return;
     }
     _transliterateFileName = temp.TransliterateFileName;
     _addFB2Info            = temp.Fb2Info;
     _addSeqToTitle         = temp.AddSeqToTitle;
     _sequenceFormat        = temp.SequenceFormat;
     _noSequenceFormat      = temp.NoSequenceFormat;
     _noSeriesFormat        = temp.NoSeriesFormat;
     _authorFormat          = temp.AuthorFormat;
     _fileAsFormat          = temp.FileAsFormat;
     _skipAboutPage         = temp.SkipAboutPage;
     _ignoreTitle           = temp.IgnoreTitle;
     _ignoreAuthors         = temp.IgnoreAuthors;
     _ignoreTranslators     = temp.IgnoreTranslators;
     _ignoreGenres          = temp.IgnoreGenres;
     _decorateFontNames     = temp.DecorateFontNames;
     _fonts.CopyFrom(temp.Fonts);
     _transliterationSettings.CopyFrom(temp.TransliterationSettings);
 }
Example #2
0
 public void CopyFrom(IEPubConversionSettings temp)
 {
     if (temp == null)
     {
         throw new ArgumentNullException("temp");
     }
     if (temp == this)
     {
         return;
     }
     _transliterateFileName = temp.TransliterateFileName;
     _addFB2Info = temp.Fb2Info;
     _addSeqToTitle = temp.AddSeqToTitle;
     _sequenceFormat = temp.SequenceFormat;
     _noSequenceFormat = temp.NoSequenceFormat;
     _noSeriesFormat = temp.NoSeriesFormat;
     _authorFormat = temp.AuthorFormat;
     _fileAsFormat = temp.FileAsFormat;
     _skipAboutPage = temp.SkipAboutPage;
     _ignoreTitle = temp.IgnoreTitle;
     _ignoreAuthors = temp.IgnoreAuthors;
     _ignoreTranslators = temp.IgnoreTranslators;
     _ignoreGenres = temp.IgnoreGenres;
     _decorateFontNames = temp.DecorateFontNames;
     _fonts.CopyFrom(temp.Fonts);
     _transliterationSettings.CopyFrom(temp.TransliterationSettings);
 }
Example #3
0
 public bool IsIgnoreInfoSource(IgnoreInfoSourceOptions ignoreInfoSourceOptions)
 {
     if (ignoreInfoSourceOptions == IgnoreInfoSourceOptions.IgnoreMainTitle)
     {
         return(true);
     }
     if (ignoreInfoSourceOptions == IgnoreInfoSourceOptions.IgnoreMainAndSource)
     {
         return(true);
     }
     if (ignoreInfoSourceOptions == IgnoreInfoSourceOptions.IgnoreMainAndPublish)
     {
         return(true);
     }
     return(false);
 }
 public bool IsIgnoreInfoSource(IgnoreInfoSourceOptions ignoreInfoSourceOptions)
 {
     if (ignoreInfoSourceOptions == IgnoreInfoSourceOptions.IgnoreMainTitle)
     {
         return true;
     }
     if (ignoreInfoSourceOptions == IgnoreInfoSourceOptions.IgnoreMainAndSource)
     {
         return true;
     }
     if (ignoreInfoSourceOptions == IgnoreInfoSourceOptions.IgnoreMainAndPublish)
     {
         return true;
     }
     return false;
 }
        public void SetupDefaults()
        {
            _transliterateFileName = false;
            _addFB2Info = true;
            _addSeqToTitle = true;
            _sequenceFormat = @"%bt% %sa.l%-%sn%";
            _noSequenceFormat = @"%bt% (%sf.l%)";
            _noSeriesFormat = @"%bt%";
            _authorFormat = @"%f.c% %m.c% %l.c% %n.c:b%";
            _fileAsFormat = @"%l.c% %f.c%";
            _skipAboutPage = false;
            _ignoreTitle = IgnoreInfoSourceOptions.IgnoreNothing;
            _ignoreAuthors = IgnoreInfoSourceOptions.IgnoreNothing;
            _ignoreTranslators = IgnoreInfoSourceOptions.IgnoreNothing;
            _ignoreGenres = IgnoreInfoSourceOptions.IgnoreNothing;
            _decorateFontNames = true;
            _transliterationSettings.CopyFrom(new TransliterationSettingsImp {Mode = TranslitModeEnum.None});

            _fonts.FontFamilies.Clear();
            _fonts.CssElements.Clear();

            CSSFontFamily family = new CSSFontFamily() { Name = @"LiberationSerif" };

            CSSFont font1 = new CSSFont
            {
                FontStyle = FontStylesEnum.Normal,
                FontVariant = FontVaiantEnum.Normal,
                FontWidth = FontBoldnessEnum.B400,
                FontStretch = FontStretch.Normal
            };
            font1.Sources.Add(new FontSource() { Type = SourceTypes.Embedded, Format = FontFormat.Unknown, Location = @"%ResourceFolder%\Fonts/LiberationSerif-Regular.ttf" });
            family.Fonts.Add(font1);

            CSSFont font2 = new CSSFont
            {
                FontStyle = FontStylesEnum.Italic,
                FontVariant = FontVaiantEnum.Normal,
                FontWidth = FontBoldnessEnum.B400,
                FontStretch = FontStretch.Normal
            };
            font2.Sources.Add(new FontSource() { Type = SourceTypes.Embedded, Format = FontFormat.Unknown, Location = @"%ResourceFolder%\Fonts/LiberationSerif-Italic.ttf" });
            family.Fonts.Add(font2);

            CSSFont font3 = new CSSFont
            {
                FontStyle = FontStylesEnum.Normal,
                FontVariant = FontVaiantEnum.Normal,
                FontWidth = FontBoldnessEnum.B700,
                FontStretch = FontStretch.Normal
            };
            font3.Sources.Add(new FontSource() { Type = SourceTypes.Embedded, Format = FontFormat.Unknown, Location = @"%ResourceFolder%\Fonts/LiberationSerif-Bold.ttf" });
            family.Fonts.Add(font3);

            CSSFont font4 = new CSSFont
            {
                FontStyle = FontStylesEnum.Italic,
                FontVariant = FontVaiantEnum.Normal,
                FontWidth = FontBoldnessEnum.B700,
                FontStretch = FontStretch.Normal
            };
            font4.Sources.Add(new FontSource() { Type = SourceTypes.Embedded, Format = FontFormat.Unknown, Location = @"%ResourceFolder%\Fonts/LiberationSerif-BoldItalic.ttf" });
            family.Fonts.Add(font4);

            _fonts.FontFamilies.Add(family);

            CSSStylableElement css1 = new CSSStylableElement() { Name = "body" };
            css1.AssignedFontFamilies.Add(family.Name);
            _fonts.CssElements.Add(css1);

            CSSStylableElement css2 = new CSSStylableElement() { Name = "code" };
            css2.AssignedFontFamilies.Add(family.Name);
            _fonts.CssElements.Add(css2);

            CSSStylableElement css3 = new CSSStylableElement() { Name = "epub" };
            css3.AssignedFontFamilies.Add(family.Name);
            _fonts.CssElements.Add(css3);
        }
 public void ReadXml(XmlReader reader)
 {
     while (!reader.EOF)
     {
         if (reader.IsStartElement())
         {
             switch (reader.Name)
             {
                 case TransliterateFileElementName:
                     _transliterateFileName = reader.ReadElementContentAsBoolean();
                     continue;
                 case AddFB2InfoElementName:
                     _addFB2Info = reader.ReadElementContentAsBoolean();
                     continue;
                 case AddSequenceNameToTitleElementName:
                     _addSeqToTitle = reader.ReadElementContentAsBoolean();
                     continue;
                 case FormatWithSequenceNameElementName:
                     _sequenceFormat = reader.ReadElementContentAsString();
                     continue;
                 case FormatWithOutSequenceNameElementName:
                     _noSequenceFormat = reader.ReadElementContentAsString();
                     continue;
                 case FormatWithOutSeriesNameElementName:
                     _noSeriesFormat = reader.ReadElementContentAsString();
                     continue;
                 case AuthorNameFormatElementName:
                     _authorFormat = reader.ReadElementContentAsString();
                     continue;
                 case FileAsFormatElementName:
                     _fileAsFormat = reader.ReadElementContentAsString();
                     continue;
                 case SkipAboutPageGenerationElementName:
                     _skipAboutPage = reader.ReadElementContentAsBoolean();
                     continue;
                 case IgnoreTitleOptionElementName:
                     IgnoreInfoSourceOptions ignoreTitle;
                     string elementContent = reader.ReadElementContentAsString();
                     if (!Enum.TryParse(elementContent, true, out ignoreTitle))
                     {
                         throw new InvalidDataException(string.Format("Invalid ignore Title value read: {0}",elementContent));
                     }
                     _ignoreTitle = ignoreTitle;
                     continue;
                 case IgnoreAuthorsOptionElementName:
                     IgnoreInfoSourceOptions ignoreAuthors;
                     elementContent = reader.ReadElementContentAsString();
                     if (!Enum.TryParse(elementContent, true, out ignoreAuthors))
                     {
                         throw new InvalidDataException(string.Format("Invalit ignore Authors value read: {0}", elementContent));
                     }
                     _ignoreAuthors = ignoreAuthors;
                     continue;
                 case IgnoreTranstatorsOptionElementName:
                     IgnoreInfoSourceOptions ignoreTranslators;
                     elementContent = reader.ReadElementContentAsString();
                     if (!Enum.TryParse(elementContent, true, out ignoreTranslators))
                     {
                         throw new InvalidDataException(string.Format("Invalit ignore Translators value read: {0}", elementContent));
                     }
                     _ignoreTranslators = ignoreTranslators;
                     continue;
                 case IgnoreGenresOptionElementName:
                     IgnoreInfoSourceOptions ignoreGenres;
                     elementContent = reader.ReadElementContentAsString();
                     if (!Enum.TryParse(elementContent, true, out ignoreGenres))
                     {
                         throw new InvalidDataException(string.Format("Invalit ignore Genres value read: {0}", elementContent));
                     }
                     _ignoreGenres = ignoreGenres;
                     continue;
                 case DecorateFontNamesElementName:
                     _decorateFontNames = reader.ReadElementContentAsBoolean();
                     continue;
                 case EPubFontSettings.FontsElementName:
                     _fonts.ReadXml(reader.ReadSubtree());
                     break;
                 case TransliterationSettingsImp.TransliterationSettingsElementName:
                     _transliterationSettings.ReadXml(reader.ReadSubtree());
                     break;
             }
         }
         reader.Read();
     }
 }
        public void SetupDefaults()
        {
            _transliterateFileName = false;
            _addFB2Info            = true;
            _addSeqToTitle         = true;
            _sequenceFormat        = @"%bt% %sa.l%-%sn%";
            _noSequenceFormat      = @"%bt% (%sf.l%)";
            _noSeriesFormat        = @"%bt%";
            _authorFormat          = @"%f.c% %m.c% %l.c% %n.c:b%";
            _fileAsFormat          = @"%l.c% %f.c%";
            _skipAboutPage         = false;
            _ignoreTitle           = IgnoreInfoSourceOptions.IgnoreNothing;
            _ignoreAuthors         = IgnoreInfoSourceOptions.IgnoreNothing;
            _ignoreTranslators     = IgnoreInfoSourceOptions.IgnoreNothing;
            _ignoreGenres          = IgnoreInfoSourceOptions.IgnoreNothing;
            _decorateFontNames     = true;
            _transliterationSettings.CopyFrom(new TransliterationSettingsImp {
                Mode = TranslitModeEnum.None
            });


            _fonts.FontFamilies.Clear();
            _fonts.CssElements.Clear();

            CSSFontFamily family = new CSSFontFamily()
            {
                Name = @"LiberationSerif"
            };

            CSSFont font1 = new CSSFont
            {
                FontStyle   = FontStylesEnum.Normal,
                FontVariant = FontVaiantEnum.Normal,
                FontWidth   = FontBoldnessEnum.B400,
                FontStretch = FontStretch.Normal
            };

            font1.Sources.Add(new FontSource()
            {
                Type = SourceTypes.Embedded, Format = FontFormat.Unknown, Location = @"%ResourceFolder%\Fonts/LiberationSerif-Regular.ttf"
            });
            family.Fonts.Add(font1);

            CSSFont font2 = new CSSFont
            {
                FontStyle   = FontStylesEnum.Italic,
                FontVariant = FontVaiantEnum.Normal,
                FontWidth   = FontBoldnessEnum.B400,
                FontStretch = FontStretch.Normal
            };

            font2.Sources.Add(new FontSource()
            {
                Type = SourceTypes.Embedded, Format = FontFormat.Unknown, Location = @"%ResourceFolder%\Fonts/LiberationSerif-Italic.ttf"
            });
            family.Fonts.Add(font2);

            CSSFont font3 = new CSSFont
            {
                FontStyle   = FontStylesEnum.Normal,
                FontVariant = FontVaiantEnum.Normal,
                FontWidth   = FontBoldnessEnum.B700,
                FontStretch = FontStretch.Normal
            };

            font3.Sources.Add(new FontSource()
            {
                Type = SourceTypes.Embedded, Format = FontFormat.Unknown, Location = @"%ResourceFolder%\Fonts/LiberationSerif-Bold.ttf"
            });
            family.Fonts.Add(font3);

            CSSFont font4 = new CSSFont
            {
                FontStyle   = FontStylesEnum.Italic,
                FontVariant = FontVaiantEnum.Normal,
                FontWidth   = FontBoldnessEnum.B700,
                FontStretch = FontStretch.Normal
            };

            font4.Sources.Add(new FontSource()
            {
                Type = SourceTypes.Embedded, Format = FontFormat.Unknown, Location = @"%ResourceFolder%\Fonts/LiberationSerif-BoldItalic.ttf"
            });
            family.Fonts.Add(font4);

            _fonts.FontFamilies.Add(family);



            CSSStylableElement css1 = new CSSStylableElement()
            {
                Name = "body"
            };

            css1.AssignedFontFamilies.Add(family.Name);
            _fonts.CssElements.Add(css1);

            CSSStylableElement css2 = new CSSStylableElement()
            {
                Name = "code"
            };

            css2.AssignedFontFamilies.Add(family.Name);
            _fonts.CssElements.Add(css2);

            CSSStylableElement css3 = new CSSStylableElement()
            {
                Name = "epub"
            };

            css3.AssignedFontFamilies.Add(family.Name);
            _fonts.CssElements.Add(css3);
        }
        public void ReadXml(XmlReader reader)
        {
            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case TransliterateFileElementName:
                        _transliterateFileName = reader.ReadElementContentAsBoolean();
                        continue;

                    case AddFB2InfoElementName:
                        _addFB2Info = reader.ReadElementContentAsBoolean();
                        continue;

                    case AddSequenceNameToTitleElementName:
                        _addSeqToTitle = reader.ReadElementContentAsBoolean();
                        continue;

                    case FormatWithSequenceNameElementName:
                        _sequenceFormat = reader.ReadElementContentAsString();
                        continue;

                    case FormatWithOutSequenceNameElementName:
                        _noSequenceFormat = reader.ReadElementContentAsString();
                        continue;

                    case FormatWithOutSeriesNameElementName:
                        _noSeriesFormat = reader.ReadElementContentAsString();
                        continue;

                    case AuthorNameFormatElementName:
                        _authorFormat = reader.ReadElementContentAsString();
                        continue;

                    case FileAsFormatElementName:
                        _fileAsFormat = reader.ReadElementContentAsString();
                        continue;

                    case SkipAboutPageGenerationElementName:
                        _skipAboutPage = reader.ReadElementContentAsBoolean();
                        continue;

                    case IgnoreTitleOptionElementName:
                        IgnoreInfoSourceOptions ignoreTitle;
                        string elementContent = reader.ReadElementContentAsString();
                        if (!Enum.TryParse(elementContent, true, out ignoreTitle))
                        {
                            throw new InvalidDataException(string.Format("Invalid ignore Title value read: {0}", elementContent));
                        }
                        _ignoreTitle = ignoreTitle;
                        continue;

                    case IgnoreAuthorsOptionElementName:
                        IgnoreInfoSourceOptions ignoreAuthors;
                        elementContent = reader.ReadElementContentAsString();
                        if (!Enum.TryParse(elementContent, true, out ignoreAuthors))
                        {
                            throw new InvalidDataException(string.Format("Invalit ignore Authors value read: {0}", elementContent));
                        }
                        _ignoreAuthors = ignoreAuthors;
                        continue;

                    case IgnoreTranstatorsOptionElementName:
                        IgnoreInfoSourceOptions ignoreTranslators;
                        elementContent = reader.ReadElementContentAsString();
                        if (!Enum.TryParse(elementContent, true, out ignoreTranslators))
                        {
                            throw new InvalidDataException(string.Format("Invalit ignore Translators value read: {0}", elementContent));
                        }
                        _ignoreTranslators = ignoreTranslators;
                        continue;

                    case IgnoreGenresOptionElementName:
                        IgnoreInfoSourceOptions ignoreGenres;
                        elementContent = reader.ReadElementContentAsString();
                        if (!Enum.TryParse(elementContent, true, out ignoreGenres))
                        {
                            throw new InvalidDataException(string.Format("Invalit ignore Genres value read: {0}", elementContent));
                        }
                        _ignoreGenres = ignoreGenres;
                        continue;

                    case DecorateFontNamesElementName:
                        _decorateFontNames = reader.ReadElementContentAsBoolean();
                        continue;

                    case EPubFontSettings.FontsElementName:
                        _fonts.ReadXml(reader.ReadSubtree());
                        break;

                    case TransliterationSettingsImp.TransliterationSettingsElementName:
                        _transliterationSettings.ReadXml(reader.ReadSubtree());
                        break;
                    }
                }
                reader.Read();
            }
        }
 public bool IsIgnoreInfoSource(DataTypes type,IgnoreInfoSourceOptions ignoreInfoSourceOptions)
 {
     return _inclusionControls[type].IsIgnoreInfoSource(ignoreInfoSourceOptions);
 }
 public bool IsIgnoreInfoSource(DataTypes type, IgnoreInfoSourceOptions ignoreInfoSourceOptions)
 {
     return(_inclusionControls[type].IsIgnoreInfoSource(ignoreInfoSourceOptions));
 }