예제 #1
0
        private void LoadVerses()
        {
            this.versesDictionaryLeft = null;

            this.versesDictionaryRight = null;

            string bibleKeyRemoved = Formatters.RemoveBibleId(this.selectedKey);

            this.versesDictionaryLeft = BiblesData.Database.GetVerses($"{this.BibleLeft.BibleId}||{bibleKeyRemoved}");

            this.versesDictionaryRight = BiblesData.Database.GetVerses($"{this.BibleRight.BibleId}||{bibleKeyRemoved}");

            this.ResetversSetup();

            #region LOAD LEFTSIDE

            for (int verse = 1; verse <= this.versesDictionaryLeft.Count; ++verse)
            {
                BibleVerseModel item = this.versesDictionaryLeft[verse];

                StackPanel panel = BibleLoader.GetVerseNumberPanel(this.BibleLeft.BibleId, item, 0);

                this.uxVerseGrid.Children.Add(panel);

                HighlightRitchTextBox textBox = BibleLoader.GetVerseAsTextBox(this.BibleLeft.BibleId, item, 1);

                textBox.GotFocus += this.VerseLeft_GotFocus;

                this.uxVerseGrid.Children.Add(textBox);

                this.loadedTextBoxDictionaryLeft.Add(verse, textBox);

                this.loadedVerseStackDictionaryLeft.Add(verse, panel);
            }

            #endregion

            #region LOAD RIGHT

            for (int verse = 1; verse <= this.versesDictionaryRight.Count; ++verse)
            {
                BibleVerseModel item = this.versesDictionaryRight[verse];

                StackPanel panel = BibleLoader.GetVerseNumberPanel(this.BibleRight.BibleId, item, 2);

                this.uxVerseGrid.Children.Add(panel);

                HighlightRitchTextBox textBox = BibleLoader.GetVerseAsTextBox(this.BibleLeft.BibleId, item, 3);

                textBox.GotFocus += this.VerseRight_GotFocus;

                this.uxVerseGrid.Children.Add(textBox);

                this.loadedTextBoxDictionaryRight.Add(verse, textBox);

                this.loadedVerseStackDictionaryRight.Add(verse, panel);
            }

            #endregion
        }
        private void LoadVerses()
        {
            this.versesDictionary = null;

            this.versesDictionary = Formatters.IsBiblesKey(this.selectedKey) ?
                                    BiblesData.Database.GetVerses(this.selectedKey)
                :
                                    BiblesData.Database.GetVerses($"{this.Bible.BibleId}||{this.selectedKey}");

            this.ResetversSetup();

            for (int verse = 1; verse <= this.versesDictionary.Count; ++verse)
            {
                BibleVerseModel item = this.versesDictionary[verse];

                StackPanel panel = BibleLoader.GetVerseNumberPanel(this.Bible.BibleId, item, 0);

                this.uxVerseGrid.Children.Add(panel);

                HighlightRitchTextBox textBox = BibleLoader.GetVerseAsTextBox(this.Bible.BibleId, item, 1);

                textBox.GotFocus += this.Verse_GotFocus;

                this.uxVerseGrid.Children.Add(textBox);

                this.loadedTextBoxDictionary.Add(verse, textBox);

                this.loadedVerseStackDictionary.Add(verse, panel);
            }
        }
예제 #3
0
        private void LinkVerse_Cliked(object sender, RoutedEventArgs e)
        {
            if (this.SelectedVerseKey.IsNullEmptyOrWhiteSpace() ||
                Formatters.GetVerseFromKey(this.SelectedVerseKey) <= 0 ||
                this.SelectedSide == ParalelleSideEnum.None)
            {
                MessageDisplay.Show("Please select a Verse.");

                return;
            }

            try
            {
                Type linkType = Type.GetType("Bibles.Link.LinkEditor,Bibles.Link");

                object[] args = new object[]
                {
                    this.selectedBibleId,
                    this.SelectedSide == ParalelleSideEnum.Left ?
                    this.versesDictionaryLeft[Formatters.GetVerseFromKey(this.SelectedVerseKey)]
                        :
                    this.versesDictionaryRight[Formatters.GetVerseFromKey(this.SelectedVerseKey)]
                };

                UserControlBase linkEditor = Activator.CreateInstance(linkType, args) as UserControlBase;

                string title = $"Link - {GlobalStaticData.Intance.GetKeyDescription(this.SelectedVerseKey)}";

                linkEditor.Height = this.Height;

                if (ControlDialog.ShowDialog(title, linkEditor, "AcceptLink", false).IsFalse())
                {
                    return;
                }

                int selectedVerse = Formatters.GetVerseFromKey(this.selectedKey);

                BibleLoader.RefreshVerseNumberPanel
                (
                    this.loadedVerseStackDictionaryLeft[selectedVerse],
                    this.BibleLeft.BibleId,
                    this.versesDictionaryLeft[selectedVerse]
                );

                BibleLoader.RefreshVerseNumberPanel
                (
                    this.loadedVerseStackDictionaryRight[selectedVerse],
                    this.BibleRight.BibleId,
                    this.versesDictionaryRight[selectedVerse]
                );
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
예제 #4
0
        private void Notes_Cliked(object sender, RoutedEventArgs e)
        {
            try
            {
                string bibleVerseKey = this.SelectedVerseKey;

                if (!Formatters.IsBiblesKey(bibleVerseKey))
                {
                    bibleVerseKey = $"{this.selectedBibleId}||{bibleVerseKey}";
                }

                VerseNotesModel noteModel = BiblesData.Database.GetVerseNotes(bibleVerseKey);

                if (noteModel == null)
                {
                    noteModel = new VerseNotesModel {
                        BibleVerseKey = bibleVerseKey, FootNote = new byte[] { }
                    };
                }

                string footNotes = noteModel.FootNote.UnzipFile().ParseToString();

                if (TextEditing.ShowDialog(GlobalStaticData.Intance.GetKeyDescription(this.SelectedVerseKey), footNotes).IsFalse())
                {
                    return;
                }

                noteModel.FootNote = TextEditing.Text.ZipFile();

                BiblesData.Database.InsertVerseNote(noteModel);

                int selectedVerse = Formatters.GetVerseFromKey(this.selectedKey);

                BibleLoader.RefreshVerseNumberPanel
                (
                    this.loadedVerseStackDictionaryLeft[selectedVerse],
                    this.BibleLeft.BibleId,
                    this.versesDictionaryLeft[selectedVerse]
                );

                BibleLoader.RefreshVerseNumberPanel
                (
                    this.loadedVerseStackDictionaryRight[selectedVerse],
                    this.BibleRight.BibleId,
                    this.versesDictionaryRight[selectedVerse]
                );
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
예제 #5
0
        internal static StackPanel GetVerseNumberPanel(int bibleId, BibleVerseModel verse, int column)
        {
            StackPanel result = new StackPanel
            {
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top
            };

            BibleLoader.RefreshVerseNumberPanel(result, bibleId, verse);

            Grid.SetRow(result, (Formatters.GetVerseFromKey(verse.BibleVerseKey) - 1));

            Grid.SetColumn(result, column);

            return(result);
        }
        private void RemoteLinkViewer_Closed(object sender, string verseKey)
        {
            try
            {
                int selectedVerse = Formatters.GetVerseFromKey(verseKey);

                BibleLoader.RefreshVerseNumberPanel
                (
                    this.loadedVerseStackDictionary[selectedVerse],
                    this.Bible.BibleId,
                    this.versesDictionary[selectedVerse]
                );
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
예제 #7
0
        public static void RefreshVerseNumberPanel(StackPanel versePanel, int bibleId, BibleVerseModel verse)
        {
            versePanel.Children.Clear();

            UIElement[] children = BibleLoader.GetVerseNumberElements(bibleId, verse);

            versePanel.Children.Add(children[0]);

            for (int x = 1; x < children.Length; ++x)
            {
                if (children[x] == null)
                {
                    continue;
                }

                versePanel.Children.Add(children[x]);
            }
        }
        private static UIElement[] GetVerseNumberElements(int bibleId, BibleVerseModel verse)
        {
            UIElement[] result = new UIElement[4];

            Label labelVerse = new Label {
                Content = Formatters.GetVerseFromKey(verse.BibleVerseKey), Foreground = Brushes.LightGray, Tag = verse
            };

            result[0] = labelVerse;

            result[1] = BibleLoader.GetVerseBookmarkImage(bibleId, verse.BibleVerseKey);

            result[2] = BibleLoader.GetStudyBookmarkImage(bibleId, verse.BibleVerseKey);

            result[3] = BibleLoader.GetLinkImage(verse.BibleVerseKey);

            return(result);
        }
        private void Bookmark_Cliked(object sender, RoutedEventArgs e)
        {
            try
            {
                int selectedVerse = Formatters.GetVerseFromKey(this.selectedKey);

                if (selectedVerse <= 0)
                {
                    throw new ApplicationException("Please select a Verse.");
                }

                Dictionary <int, UserControlBase> openStudies = new Dictionary <int, UserControlBase>();

                Dictionary <int, StudyHeader> studyHeaders = new Dictionary <int, StudyHeader>();

                #region CHECK FOR OPEN STUDIES

                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() != typeof(ControlWindow))
                    {
                        continue;
                    }

                    UserControlBase controlBase = window.GetPropertyValue("ControlContent").To <UserControlBase>();

                    if (controlBase.GetType() != typeof(EditStudy))
                    {
                        continue;
                    }

                    StudyHeader studyHeader = controlBase.GetPropertyValue("SubjectHeader").To <StudyHeader>();

                    if (studyHeader.StudyHeaderId <= 0)
                    {
                        string studyName = studyHeader.StudyName.IsNullEmptyOrWhiteSpace() ? "Unknown" : studyHeader.StudyName;

                        string message = $"Study {studyName} have not been saved yet. This study will not be available for bookmarks.";

                        MessageDisplay.Show(message);

                        continue;
                    }

                    openStudies.Add(studyHeader.StudyHeaderId, controlBase);

                    studyHeaders.Add(studyHeader.StudyHeaderId, studyHeader);
                }

                #endregion

                ModelsBookmark bookmark = new ModelsBookmark();

                ModelView.OnItemBrowse += this.BookmarkModel_Browse;

                if (Formatters.IsBiblesKey(this.selectedKey))
                {
                    bookmark.SetVerse(this.selectedKey);
                }
                else
                {
                    bookmark.SetVerse($"{this.Bible.BibleId}||{this.selectedKey}");
                }

                if (studyHeaders.Count > 0)
                {
                    #region STUDY BOOKMARKS

                    StudyBookmarksModel studyMark = bookmark.CopyToObject(new StudyBookmarksModel()).To <StudyBookmarksModel>();

                    List <DataItemModel> studyOptions = new List <DataItemModel>();

                    studyOptions.Add(new DataItemModel {
                        DisplayValue = $"<{this.Bible.BibleName}>", ItemKey = -1
                    });

                    foreach (KeyValuePair <int, StudyHeader> studyKey in studyHeaders)
                    {
                        studyOptions.Add(new DataItemModel {
                            DisplayValue = studyKey.Value.StudyName, ItemKey = studyKey.Key
                        });
                    }

                    studyMark.AvailableStudies = studyOptions.ToArray();

                    if (ModelView.ShowDialog("Bookmark", studyMark).IsFalse())
                    {
                        return;
                    }

                    if (studyMark.Study <= 0)
                    {
                        BookmarkModel dbModel = studyMark.CopyToObject(new BookmarkModel()).To <BookmarkModel>();

                        BiblesData.Database.InsertBookmarkModel(dbModel);
                    }
                    else
                    {
                        StudyBookmarkModel dbModel = studyMark.CopyToObject(new StudyBookmarkModel()).To <StudyBookmarkModel>();

                        dbModel.StudyName = studyMark.AvailableStudies.First(st => st.ItemKey.ToInt32() == studyMark.Study).DisplayValue;

                        dbModel.StudyVerseKey = $"{studyMark.Study}||{dbModel.VerseKey}";

                        BiblesData.Database.InsertStudyBookmarkModel(dbModel);

                        this.InvokeMethod(openStudies[studyMark.Study], "AddBookmark", new object[] { bookmark });
                    }

                    #endregion
                }
                else
                {
                    #region NORMAL BOOKMARKS

                    if (ModelView.ShowDialog("Bookmark", bookmark).IsFalse())
                    {
                        return;
                    }

                    BookmarkModel dbModel = bookmark.CopyToObject(new BookmarkModel()).To <BookmarkModel>();

                    BiblesData.Database.InsertBookmarkModel(dbModel);

                    #endregion
                }

                BibleLoader.RefreshVerseNumberPanel
                (
                    this.loadedVerseStackDictionary[selectedVerse],
                    this.Bible.BibleId,
                    this.versesDictionary[selectedVerse]
                );
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
            finally
            {
                ModelView.OnItemBrowse -= this.BookmarkModel_Browse;
            }
        }