Ejemplo n.º 1
0
        private void ClickNewVerse(object o)
        {
            EditVerseWindow verseDialog = new EditVerseWindow();

            verseDialog.ShowDialog();
            if (verseDialog.DialogResult == true)
            {
                var      context = (VerseViewModel)verseDialog.DataContext;
                VerseDTO verse   = new VerseDTO()
                {
                    BeliefId   = SelectedBelief.Id,
                    Book       = context.BookList.IndexOf(context.SelectedBook),
                    Chapter    = context.SelectedChapter,
                    VerseStart = context.SelectedVerseStart,
                    VerseEnd   = context.SelectedVerseEnd
                };
                long newId = BibleBeliefsRepository.CreateVerse(verse);
                Verses = BibleBeliefsRepository.GetVerses(SelectedBelief.Id);
                var v = Verses.Single(s => s.Id == newId);
                if (v != null)
                {
                    SelectedVerse = v;
                }
            }
        }
Ejemplo n.º 2
0
        private int CalculateWordsPerMinute()
        {
            if (TotalSeconds == 0)
            {
                return(-1);
            }

            return(Verses.Sum(p => p.Field <int>("WordCount")) * 60 / TotalSeconds);
        }
Ejemplo n.º 3
0
 public Chapter(XElement chapterTag, Book book, int chapterNumber, Chapter previous) : base(chapterNumber, previous)
 {
     foreach (var verseTag in chapterTag.Descendants("VERS"))
     {
         Book = book;
         var prevVerse = Verses.Count > 0 ? Verses[Verses.Count - 1] : previous?.Verses[previous.Verses.Count - 1];
         Verses.Add(new Verse(verseTag.Value, this, Verses.Count + 1, prevVerse));
     }
 }
Ejemplo n.º 4
0
        protected override bool LoadData()
        {
            var text     = Scripture.kjvdat;
            var language = "english";
            var version  = _SelectedVersion;

            Books = Parser.Parse(version, language, text);
            Verses.AddRange(Books);
            //GenericObjectManager.WriteGenericList<Book>(books, @"books-of-the-bible.xml");
            return(true);
        }
Ejemplo n.º 5
0
        private void FinishedVerse(DataRow verse)
        {
            if (verse.Field <int>("VerseId") < User.Field <int>("NextVerseId"))
            {
                return;
            }

            if (Verses.All(p => p.Field <int>("VerseId") != verse.Field <int>("VerseId")))
            {
                Verses.Add(verse);
            }
        }
Ejemplo n.º 6
0
        public static long CreateVerse(VerseDTO verse)
        {
            Verses verses = new Verses();

            verses.BeliefId   = verse.BeliefId;
            verses.Book       = verse.Book;
            verses.Chapter    = verse.Chapter;
            verses.VerseStart = verse.VerseStart;
            verses.VerseEnd   = verse.VerseEnd;
            verses.Verse      = verse.ToString();
            context.Add <Verses>(verses);
            context.SaveChanges();
            return(verses.Id);
        }
Ejemplo n.º 7
0
        public VerseCollection(string songText, int languageCount)
        {
            MaxVerseLinesCount = 0;
            var             rgx        = new Regex(@"[-]{3}\s*(.*?)[$]{2}\s*(.*?)(\r\n)?(?=---|$)", RegexOptions.Singleline); //Filtert Verse aus
            MatchCollection versesText = rgx.Matches(songText);

            foreach (Match verseText in versesText)
            {
                Verses.Add(new LineCollection(verseText.Groups[2].Value, verseText.Groups[1].Value, languageCount));
                if (versesText.Count > MaxVerseLinesCount)
                {
                    MaxVerseLinesCount = versesText.Count;
                }
            }
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ModifiedTimestamp != null ? ModifiedTimestamp.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CreatedIn != null ? CreatedIn.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ModifiedIn != null ? ModifiedIn.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CcliIdentifier != null ? CcliIdentifier.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Copyright != null ? Copyright.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ReleaseYear != null ? ReleaseYear.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Comments != null ? Comments.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Verses != null ? Verses.GetHashCode() : 0);
         return(hashCode);
     }
 }
Ejemplo n.º 9
0
        private void Search(List <string> list)
        {
            IEnumerable <string> ids = Indexer.Query(list);

            SearchResults = Verses.Where(v => ids.Contains(v.Id)).ToList();
        }
Ejemplo n.º 10
0
        private void Stop(bool manualStop)
        {
            StopTimer();

            if (!HasStarted)
            {
                return;
            }

            SetupInitialState();

            HandleNotReadingAnymore();

            if (manualStop)
            {
                if (MessageBox.Show(@"Você leu o versículo atual até o fim?", @"Pergunta", MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Verses.Add(CurrentVerse);
                }
            }

            if (LastVerseRead == null)
            {
                return;
            }

            var wordsPerMinute = CalculateWordsPerMinute();
            var totalVerses    = Verses.Count;
            var totalWords     = Verses.AsEnumerable().Sum(p => p.Field <int>("WordCount"));

            try
            {
                using (var scope = TransactionScopeUtility.GetTransactionScope())
                {
                    var nextVerse = GetNextBibleVerse(LastVerseRead);

                    if (nextVerse != null)
                    {
                        new User().UpdateNextVerseId(User.Field <int>("UserId"), nextVerse.Field <int>("VerseId"));
                    }

                    new Reading().InsertReading(StartedAt,
                                                FinishedAt,
                                                FirstVerseRead.Field <int>("VerseId"),
                                                LastVerseRead.Field <int>("VerseId"),
                                                TotalSeconds,
                                                wordsPerMinute,
                                                totalVerses,
                                                totalWords,
                                                User.Field <int>("UserId"));

                    scope.Complete();
                }
            }
            catch (Exception)
            {
                // Gravar o XML para carregar para o banco depois
            }

            LoadStartInformation();
        }