コード例 #1
0
 private void EhLinkClicked(object sender, LinkClickedEventArgs e)
 {
     try
     {
         System.Diagnostics.Process.Start(e.LinkText);
     }
     catch
     {
         string friendlyText = e.LinkText;
         var    list1        = XMLBible.ParseStringToVerse(friendlyText);
         if (list1.Count > 0)
         {
             XMLBible.BCVSTRUCT start = new XMLBible.BCVSTRUCT();
             XMLBible.BCVSTRUCT end   = new XMLBible.BCVSTRUCT();
             var bcv = list1[0].bcv;
             if (XMLBible.ParseForBCVStructs(bcv, ref start, ref end) != "NOT_A_VERSE")
             {
                 string        szHeader            = e.LinkText;
                 List <string> listofTextToDisplay = new List <string>();
                 listofTextToDisplay = XMLBible.GetVerseText(ref start, ref end);
                 TextCardHolder PopUp = new TextCardHolder(listofTextToDisplay.ToArray(), szHeader);
             }
         }
     }
 }
コード例 #2
0
ファイル: Cleaner.cs プロジェクト: WillOmae/MySermons
            public static void ConvertOldFormat1(string existingRtf, RichTextBoxEx rtb)
            {
                var textMatches1 = Regex.Matches(existingRtf, @"\d?[a-zA-Z]{1,3}\.\d{1,3}\.\d{1,3}-\d?[a-zA-Z]{1,3}\.\d{1,3}\.\d{1,3}");
                var textMatches2 = Regex.Matches(existingRtf, @"\d?[a-zA-Z]{1,3}\.\d{1,3}\.\d{1,3}");

                int arraySize = textMatches1.Count + textMatches2.Count;

                Match[] matches = new Match[arraySize];

                textMatches1.CopyTo(matches, 0);
                textMatches2.CopyTo(matches, textMatches1.Count);

                if (matches.Length > 0)
                {
                    foreach (Match match in matches)
                    {
                        string             oldVerseText = match.Value.Trim();
                        XMLBible.BCVSTRUCT start, end;
                        start = new XMLBible.BCVSTRUCT();
                        end   = new XMLBible.BCVSTRUCT();
                        XMLBible.ParseForBCVStructs(oldVerseText, ref start, ref end);



                        if (!string.IsNullOrEmpty(start.Book) &&
                            XMLBible.ConfirmBookNameExists(start.Book) &&
                            int.Parse(start.Chapter) <= XMLBible.ChapterCount(start.Book) &&
                            int.Parse(start.Verse) <= XMLBible.VerseCount(start.Book, start.Chapter))
                        {
                            string newVerseText = string.Empty;
                            if (string.IsNullOrEmpty(end.Book))
                            {
                                newVerseText = XMLBible.GetBookName_abbr(start.Book) + " " + start.Chapter + ":" + start.Verse;
                            }
                            else
                            {
                                if (XMLBible.ConfirmBookNameExists(end.Book) &&
                                    int.Parse(end.Chapter) <= XMLBible.ChapterCount(end.Book) &&
                                    int.Parse(end.Verse) <= XMLBible.VerseCount(end.Book, end.Chapter))
                                {
                                    if (start.Verse == "1" && end.Verse == XMLBible.VerseCount(end.Book, end.Chapter).ToString())
                                    {
                                        newVerseText = XMLBible.GetBookName_short(start.Book) + " " + start.Chapter;
                                    }
                                    else
                                    {
                                        newVerseText = XMLBible.GetBookName_abbr(start.Book) + " " + start.Chapter + ":" + start.Verse + "-" + end.Verse;
                                    }
                                }
                            }
                            if (!string.IsNullOrEmpty(newVerseText))
                            {
                                d_ReplaceOldVerseText myDelegate = new d_ReplaceOldVerseText(InvokeReplaceOldVerseText);
                                rtb.Invoke(myDelegate, oldVerseText, newVerseText, rtb);
                            }
                        }
                    }
                }
            }
コード例 #3
0
        private void BackgroundWorkerRunProcess(BackgroundWorker bw)
        {
            MainThread.InitialChecks();
            XMLBible.LoadBibleIntoMemory();

            check_file_existence_results = MainThread.CheckFileExistence();

            new StaticLists();
        }
コード例 #4
0
        private void GetVerse(int boundStart, int boundEnd)
        {
            /* Here's the logic:
             * When the KeyUp event handler calls this method,
             * get the text between the bounds of the verse delimiter (~ in this case).
             * This text is then parsed to the XMLBible class parsing functions.
             * The result of the above step is then inserted as a custom link.
             */

            if ((boundEnd - boundStart) > 3)
            {
                string parseString = GetTextBetweenBounds(boundStart, boundEnd);
                List <XMLBible.BIBLETEXTINFO> list = XMLBible.ParseStringToVerse(parseString);

                if (list != null && list.Count != 0)
                {
                    int cursorPosition = -1;
                    DeleteRTBText(boundStart, boundEnd);
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (i == (list.Count - 1))//last item in the list
                        {
                            InsertVerse(list[i].FriendlyText, list[i].bcv, boundStart);
                            cursorPosition = boundStart + list[i].FriendlyText.Length;
                        }
                        else
                        {
                            InsertVerse(list[i].FriendlyText + "; ", list[i].bcv, boundStart);
                            cursorPosition = boundStart + list[i].FriendlyText.Length + 1;
                        }
                        boundStart = SelectionStart;
                    }
                    SelectionStart = cursorPosition;
                    return;
                }
            }
            Text           = Text.Insert(boundStart, "[");
            Text           = Text.Remove(boundStart + 1, 1);
            Text           = Text.Insert(boundEnd, "]");
            Text           = Text.Remove(boundEnd + 1, 1);
            SelectionStart = boundEnd + 1;
            return;
        }
コード例 #5
0
        /// <summary>
        /// When the form is shown, verse links are detected and updated in the text box.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormShown(object sender, EventArgs e)
        {
            textBox.Rtf = RTF;

            string rtf = textBox.Rtf;

            LoadingForm      loadingForm = new LoadingForm();
            BackgroundWorker bw          = new BackgroundWorker()
            {
                WorkerReportsProgress      = true,
                WorkerSupportsCancellation = true
            };

            bw.DoWork += delegate
            {
                Cleaner.VerseHiddenText.RemoveVerseHiddenText(rtf, textBox);
                Cleaner.BCVVerses.ConvertOldFormat1(rtf, textBox);
                d_GetText delegateGetTextBoxText = new d_GetText(InvokeGetText);
                string    text = (string)textBox.Invoke(delegateGetTextBoxText);

                var textMatches1 = Regex.Matches(text, @"\d?[ ]?[a-zA-Z]+[ ]?\d{1,3}[ ]?:[ ]?\d{1,3}[ ]?-[ ]?\d{1,3}");
                var textMatches2 = Regex.Matches(text, @"\d?[ ]?[a-zA-Z]+[ ]?\d{1,3}[ ]?:[ ]?\d{1,3}");
                var textMatches5 = Regex.Matches(text, @"\d?[ ]?[a-zA-Z]+[ ]?\d{1,3}");

                int     arraySize = textMatches1.Count + textMatches2.Count + textMatches5.Count;
                Match[] matches   = new Match[arraySize];
                textMatches1.CopyTo(matches, 0);
                textMatches2.CopyTo(matches, textMatches1.Count);
                textMatches5.CopyTo(matches, textMatches1.Count + textMatches2.Count);

                if (matches.Length > 0)
                {
                    foreach (Match match in matches)
                    {
                        string matchText       = match.Value.Trim();
                        var    booknameMatches = Regex.Match(matchText, @"^\d? ?[a-zA-Z]*");
                        if (booknameMatches.Success)
                        {
                            if (XMLBible.ConfirmBookNameExists(booknameMatches.Value))
                            {
                                d_InsertLink myDelegate = new d_InsertLink(InsertLink_TextMethod);
                                textBox.Invoke(myDelegate, matchText);
                            }
                        }
                    }
                }
            };
            bw.RunWorkerCompleted += delegate
            {
                BackToStart();
                loadingForm.Close();
            };
            loadingForm.FormClosing += delegate
            {
                if (bw != null && bw.IsBusy)
                {
                    bw.CancelAsync();
                }
            };

            bw.RunWorkerAsync();
            loadingForm.ShowDialog();
        }