Esempio n. 1
0
        private static void LinkImage_Selected(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Image item = (Image)sender;

                string verseKey = item.Tag.ParseToString();

                Type linkViewerType = Type.GetType("Bibles.Link.LinkViewer,Bibles.Link");

                UserControlBase linkViewer = Activator.CreateInstance(linkViewerType, new object[] { verseKey }) as UserControlBase;

                if (ControlDialog.ShowDialog("Link Viewer", linkViewer, "SaveComments", autoSize: false).IsFalse())
                {
                    return;
                }

                string[] deletedLinks = linkViewer.GetPropertyValue("GetDeletedLinks").To <string[]>();

                foreach (string key in deletedLinks)
                {
                    BibleLoader.LinkViewerClosed?.Invoke(linkViewer, key);
                }
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
Esempio n. 2
0
        private void EditStudy_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (this.SelectedStudyHeader == null)
            {
                MessageDisplay.Show("Please select a Study.");

                return;
            }

            try
            {
                #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)
                    {
                        continue;
                    }

                    window.Focus();

                    this.CloseIfNotMainWindow(true);

                    return;
                }

                #endregion


                EditStudy edit = new EditStudy(this.SelectedStudyHeader);

                ControlDialog.Show(this.SelectedStudyHeader.StudyName, edit, "SaveStudy", autoSize: false);

                this.CloseIfNotMainWindow(true);
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
Esempio n. 3
0
        private static void StudyBookmark_Selected(object sender, RoutedEventArgs e)
        {
            try
            {
                MenuItem item = (MenuItem)sender;

                string studyKey = item.Tag.ParseToString();

                string[] keySplit = studyKey.Split(new string[] { "||" }, StringSplitOptions.None);

                int studyHeaderId = keySplit[0].ToInt32();

                #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)
                    {
                        continue;
                    }

                    window.Focus();

                    return;
                }

                #endregion

                StudyHeaderModel model = BiblesData.Database.GetStudyHeader(studyHeaderId.ToInt32());

                EditStudy edit = new EditStudy(model);

                ControlDialog.Show(model.StudyName, edit, "SaveStudy", autoSize: false);
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
        public bool TryEditStudy()
        {
            if (this.SelectedStudyHeader == null)
            {
                MessageDisplay.Show("Please select a Study.");

                return(false);
            }

            #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 ||
                    studyHeader.StudyHeaderId != this.SelectedStudyHeader.StudyHeaderId)
                {
                    continue;
                }

                window.Focus();

                return(true);
            }

            #endregion

            EditStudy edit = new EditStudy(this.SelectedStudyHeader);

            ControlDialog.Show(this.SelectedStudyHeader.StudyName, edit, "SaveStudy", autoSize: false, owner: Application.Current.MainWindow);

            return(true);
        }
        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;
            }
        }