Example #1
0
        /// <summary>
        /// When displaying bible verses (on the live screen), the reference shown comes
        /// from the bible.BibleBooks[?].Long (or .Short) fields. This code sets those
        /// fields for all bibles in the library to the names found in the user selected
        /// Sword locales.d file.
        /// </summary>
        /// <param name="Bibles"></param>
        /// <param name="SwordPath"></param>
        /// <param name="locale"></param>
        public static void SetBibleLocale(BibleLib Bibles, string SwordPath, string locale)
        {
            string       localeDir = Path.Combine(SwordPath, "locales.d");
            string       longFile  = Path.Combine(localeDir, locale + ".conf");
            string       abbrFile  = Path.Combine(localeDir, locale + "_abbr.conf");
            IniStructure longNames = IniStructure.ReadIni(longFile);
            IniStructure abbrNames = IniStructure.ReadIni(abbrFile);

            if (longNames == null)
            {
                return;
            }
            foreach (string translation in Bibles.Translations())
            {
                BibleVersion bible = Bibles[translation];
                int          i     = 0;
                foreach (string book in BibleVersion.SwordBookNames)
                {
                    string localizedName = longNames.GetValue("Text", book);
                    bible.BibleBooks[i].Long = longNames.GetValue("Text", book);
                    if (abbrNames != null)
                    {
                        bible.BibleBooks[i].Short = abbrNames.GetValue("Text", book);
                    }
                    else
                    {
                        bible.BibleBooks[i].Short = longNames.GetValue("Text", book);
                    }
                    i++;
                }
            }
        }
Example #2
0
        public Repository(BibleVersion version)
        {
            var dbpath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MyBibles", "Bibles", string.Concat(version.ToString(), ".SQLite3"));

            Db = new SQLiteConnection(dbpath);
            Db.CreateTable <Book>();
            Db.CreateTable <Verse>();
            Db.CreateTable <Info>();
        }
Example #3
0
 private static void SeedBibleBooks(Context context, bool update, BibleVersion code, IBibleService service)
 {
     if (!context.BibleBooks.Any(x => x.Version == code))
     {
         AddBibleBooks(context, service);
     }
     else if (update)
     {
         UpdateBook(context, service);
     }
 }
Example #4
0
 public Translation GetTranslation(BibleVersion version)
 {
     ChangeRepo(version);
     return(new Translation
     {
         Code = version,
         Title = _repo.Db.Table <MyBibles.Models.Info>().Where(x => x.Name == "description").FirstOrDefault().Value,
         Description = _repo.Db.Table <MyBibles.Models.Info>().Where(x => x.Name == "detailed_info").FirstOrDefault().Value,
         HasStrongs = _repo.Db.Table <MyBibles.Models.Info>().Where(x => x.Name == "strong_numbers").FirstOrDefault().Value == "true" ? true : false,
     });
 }
Example #5
0
 public Seed(BibleVersion version)
 {
     _repo   = new Repository(version);
     _mapper = new Mapper(new MapperConfiguration(cfg =>
     {
         cfg.CreateMap <MyBibles.Models.Book, Book>()
         .ForMember(dest => dest.Colour, opt => opt.MapFrom(src => src.BookColor))
         .ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.LongName))
         .ForMember(dest => dest.BookNo, opt => opt.MapFrom(src => src.BookNumber))
         .ForMember(dest => dest.ShortTitle, opt => opt.MapFrom(src => src.ShortName));
         cfg.CreateMap <MyBibles.Models.Verse, Verse>()
         .ForMember(dest => dest.Chapter, opt => opt.Ignore());
     }));
 }
Example #6
0
        /// <summary>
        /// If this display is a remote server it will receive a description of the content,
        /// and will have to create a content object based on that. We don't want to send
        /// actual objects to remote servers.
        /// </summary>
        /// <param name="identity">A "description" of the content</param>
        public bool SetContent(ContentIdentity identity)
        {
            IContentOperations newContent = null;
            bool success = true;

            try {
                switch ((ContentType)identity.Type)
                {
                case ContentType.BibleVerseIdx:
                    newContent = new ABibleVerse(bibleLib[identity.BibleTransl], identity.VerseIdx, Display.config);
                    break;

                case ContentType.BibleVerseRef:
                    BibleVersion bible = bibleLib[identity.BibleTransl];
                    int          idx   = bible.GetVerseIndex(identity.VerseRef);
                    newContent = new ABibleVerse(bible, idx, Display.config);
                    break;

                case ContentType.PlainText:
                    newContent = new TextToolContents(identity.Text, Display.config);
                    break;

                case ContentType.Song:
                    string songFile = DreamTools.GetDirectory(DirType.Songs, identity.SongName);
                    newContent = (Song)Song.DeserializeFrom(songFile, identity.SongStrophe, Display.config);
                    break;
                }
            } catch { }                 // Covers a multitude of sins (non-existent translation, or song, or verse, etc...)

            if (newContent != null)
            {
                if (NextDisplay != null)
                {
                    success = NextDisplay.SetContent(newContent);
                }
                if (success)
                {
                    this.content = newContent;
                    success      = this.UpdateDisplay(false);
                }
            }
            else
            {
                success = false;
            }

            return(success);
        }
Example #7
0
        public void Populate(BibleVersion bible, int target)
        {
            StringBuilder _rtfData = new StringBuilder();

            //DreamTools.ElapsedTime("Start Populate");

            if (target < 0 || target >= bible.VerseCount)
            {
                return;
            }

            int[] range = loadRange(target, bible.VerseCount - 1);

            verseIndex.Clear();
            firstVerse   = range[0];
            lastVerse    = range[1];
            currentVerse = target;

            int length = 0;

            for (int i = range[0]; i <= range[1]; i++)
            {
                verseIndex.Add(length);

                // Set the reference text to background color 2, foreground color 3,
                // bold, font 0, size 10pt
                _rtfData.Append(@"\highlight12\cf3\b\f0\fs20 ");
                // We need to keep track of how many non-control characters we're adding so we
                // can't just use: _rtfData.Append( bible.GetSimpleRef(i) + " " );
                // The text added here should be identical to the text searched for in BibleVersion.Find
                length += BibleRTF.AppendText(_rtfData, bible.GetSimpleRef(i, true) + " ");
                _rtfData.Append(@"\highlight0\cf2\b0\f1\fs20 ");
                length += BibleRTF.AppendText(_rtfData, " " + bible.GetSimpleVerseText(i) + "\n");

                // Note: Unicode characters get converted to their ASCII equivalents.
            }

            this.SelectAll();
            this.InsertRawRtf(_rtfData.ToString(), rtfFonts, rtfColors);

            this.SelectAll();
            this.SelectionIndent        = 5;
            this.SelectionHangingIndent = 75;
            this.SelectionRightIndent   = 5;

            this.ScrollTo(this.GetSelectionFromVerseIndex(target)[0]);
            //DreamTools.ElapsedTime("Finish Populate");
        }
Example #8
0
        private static IBibleService GetService(Context context, BibleVersion code)
        {
            IBibleService service = null;

            switch (code)
            {
            case BibleVersion.KJVAE:
                service = new KJVAEService(context.Bibles.FirstOrDefault(x => x.Code == Core.Models.Enums.BibleVersion.KJVAE), context.Books.ToList());
                break;

            case BibleVersion.NKJV:
                service = new NKJVService(context.Books.ToList(), context.Bibles.FirstOrDefault(x => x.Code == code));
                break;
            }

            return(service);
        }
Example #9
0
        /// <summary>
        /// Finds a verse matching the regex, and updates the RTF control to make the verse visible.
        /// </summary>
        /// <param name="bible"></param>
        /// <param name="dirFwd"></param>
        /// <param name="regex"></param>
        /// <returns>The result of calling BibleVersion.Find (negative number to indicate failure, or a 0-based verse index)</returns>
        public int Find(BibleVersion bible, bool dirFwd, string regex)
        {
            DreamTools.ElapsedTime("Start regex search");

            if (regex.Length == 0)
            {
                return(-1);
            }

            // We need to handle "FindNext" and "FindPrevious" type searches
            if (regex == lastRegex)
            {
                if (currentVerse == matchFound && dirFwd)
                {
                    currentVerse++;
                }
                else if (currentVerse == matchFound && !dirFwd)
                {
                    currentVerse--;
                }
            }

            int target = bible.Find(currentVerse, dirFwd, regex);

            DreamTools.ElapsedTime("End regex search");

            lastRegex = regex;
            if (target >= 0)
            {
                currentVerse = target;
                matchFound   = target;
                Populate(bible, target);
                this.HighlightVerseRegex(target, regex);
            }
            else if (matchFound >= 0)
            {
                // Re-populate to remove highlight
                Populate(bible, currentVerse);
                matchFound = -1;
            }
            return(target);
        }
Example #10
0
        private static void SeedHeadings(Context context, bool update, BibleVersion code, IBibleService service)
        {
            if (!context.Books.Any())
            {
                return;
            }

            service.BibleBooks = context.BibleBooks.Where(x => x.Version == code).ToList();

            if (service.Headings == null)
            {
                return;
            }

            if (!context.Headings.Any())
            {
                foreach (var item in service.Headings)
                {
                    context.Headings.Add(item);
                }
                context.SaveChanges();
            }
            else if (update)
            {
                foreach (var item in service.Headings)
                {
                    var dbobj = context.Headings.FirstOrDefault(x => x.LocalId == item.LocalId);
                    if (dbobj != null)
                    {
                        item.Id = dbobj.Id;
                        context.Entry(dbobj).CurrentValues.SetValues(item);
                    }
                    else
                    {
                        context.Headings.Add(item);
                    }
                }
                context.SaveChanges();
            }
        }
Example #11
0
        public BibleText(BibleVersion version, BookAbbreviationInfo book, VersicleInfo versicle)
        {
            _book     = book;
            _versicle = versicle;
            switch (version)
            {
            case BibleVersion.ASV:   _pathToExcelFile = @"C:\Users\anton\source\repos\myMLApp\myMLApp.Data\CSV\t_asv.csv"; break; // American Standard-ASV1901

            case BibleVersion.BBE:   _pathToExcelFile = @"C:\Users\anton\source\repos\myMLApp\myMLApp.Data\CSV\t_bbe.csv"; break; // Bible in Basic English

            case BibleVersion.DARBY: _pathToExcelFile = @"C:\Users\anton\source\repos\myMLApp\myMLApp.Data\CSV\t_dby.csv"; break; // Darby English Bible

            case BibleVersion.KJV:   _pathToExcelFile = @"C:\Users\anton\source\repos\myMLApp\myMLApp.Data\CSV\t_kjv.csv"; break; // King James Version

            case BibleVersion.WBT:   _pathToExcelFile = @"C:\Users\anton\source\repos\myMLApp\myMLApp.Data\CSV\t_wbt.csv"; break; // Webster's Bible

            case BibleVersion.WEB:   _pathToExcelFile = @"C:\Users\anton\source\repos\myMLApp\myMLApp.Data\CSV\t_web.csv"; break; // World English Bible

            case BibleVersion.YLT:   _pathToExcelFile = @"C:\Users\anton\source\repos\myMLApp\myMLApp.Data\CSV\t_ylt.csv"; break; // Young's Literal Translation

            default: _pathToExcelFile = @"C:\Users\anton\source\repos\myMLApp\myMLApp.Data\CSV\t_asv.csv"; break;                 // By defaul is the American standard version
            }
            _conxObject = new ConnectiontoExcel(_pathToExcelFile);
        }
Example #12
0
 public async Task <IEnumerable <Verse> > GetAsync(BibleVersion bible, BookList book, int chapter)
 {
     return(await _restService.Client.For <Verse>().Expand(c => c.BibleBook).Filter(x => x.BibleBook.Version == bible && x.BibleBook.BookCode == book && x.ChapterNum == chapter).OrderBy(s => s.ChapterNum).ThenBy(v => v.Position).FindEntriesAsync());
 }
Example #13
0
 public async Task <BibleBook> GetAsync(BibleVersion bible, BookList book, int chapter)
 {
     return(await _restService.Client.For <BibleBook>().Filter(x => x.Version == bible && x.BookCode == book).Expand(v => v.Verses).FindEntryAsync());
 }
Example #14
0
 public async Task <IEnumerable <BibleBook> > GetAsync(BibleVersion bible)
 {
     return(await _restService.Client.For <BibleBook>().Filter(x => x.Version == bible).FindEntriesAsync());
 }
Example #15
0
        public async Task <bool> DownloadAsync(BibleVersion bible, BookList book)
        {
            var result = await _restService.Client.For <BibleBook>().Filter(f => f.Version == bible && f.BookCode == book).Expand("*").FindEntryAsync();

            return(await _dataStore.UpdateAsync(result, true));
        }
Example #16
0
 public async Task <Bible> GetAsync(BibleVersion code)
 {
     return(await _restService.Client.For <Bible>().Filter(f => f.Code == code).Expand(x => x.BibleBooks).FindEntryAsync());
 }
Example #17
0
 private void ChangeRepo(BibleVersion version)
 {
     _repo = new Repository(version);
 }
Example #18
0
 public Translation GetTranslation(BibleVersion version)
 {
     _seed = new SeedBible(version);
     return(_seed.GetTranslation(version));
 }
Example #19
0
 public async Task <IEnumerable <Book> > GetBooksForVersionAsync(BibleVersion version)
 {
     return(await _restService.Client.For <Book>().Expand(e => e.BibleBooks).Filter(f => f.BibleBooks.Any(c => c.Version == version)).OrderBy(o => o.Code).FindEntriesAsync());
 }