コード例 #1
0
ファイル: MyPrintDialog.cs プロジェクト: WillOmae/MySermons
 public MyPrintDialog(ParentForm parent, RichTextBoxEx rtbSource)
 {
     if (GetPrintText(rtbSource))
     {
         CommonConstructor(parent, Visible);
     }
 }
コード例 #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
ファイル: Cleaner.cs プロジェクト: WillOmae/MySermons
 private static void InvokeRemoveText(string toRemove, RichTextBoxEx rtb)
 {
     if (toRemove.Contains(@"\b") && !toRemove.Contains(@"\b0"))
     {
         rtb.Rtf = rtb.Rtf.Replace(toRemove, @"\b");
     }
     else if (toRemove.Contains(@"\b0") && !toRemove.Contains(@"\b"))
     {
         rtb.Rtf = rtb.Rtf.Replace(toRemove, @"\b0");
     }
     else
     {
         rtb.Rtf = rtb.Rtf.Replace(toRemove, string.Empty);
     }
 }
コード例 #4
0
ファイル: Cleaner.cs プロジェクト: WillOmae/MySermons
            public static void RemoveVerseHiddenText(string existingRtf, RichTextBoxEx rtb)
            {
                d_DeleteText myDelegate;

                var textMatches = Regex.Matches(existingRtf, @"\\v(.*?)\\v0");

                if (textMatches.Count > 0)
                {
                    foreach (Match match in textMatches)
                    {
                        myDelegate = new d_DeleteText(InvokeRemoveText);
                        rtb.Invoke(myDelegate, match.Value, rtb);
                    }
                }
            }
コード例 #5
0
ファイル: MyPrintDialog.cs プロジェクト: WillOmae/MySermons
 private bool GetPrintText(int DocumentID)
 {
     try
     {
         rtbPrintContent = new RichTextBoxEx()
         {
             Rtf = SermonReader.DisplayStoredSermon(Sermon.GetSermonComponents(DocumentID)).RTFpublic
         };
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #6
0
        /// <summary>
        /// Specifies how a recorded sermon is to appear on a form.
        /// </summary>
        /// <param name="arraySermonComponents">An array of strings consisting of sermon components.</param>
        /// <returns>A form containing the sermon to be displayed.</returns>
        static public SermonReader DisplayStoredSermon(string[] arraySermonComponents)
        {
            AlterArraySermonComponents(ref arraySermonComponents);

            if (arraySermonComponents != null && arraySermonComponents.Length > 0)
            {
                RichTextBoxEx textBox = new RichTextBoxEx()
                {
                    Font = new Font("Times New Roman", 14)
                };
                textBox.Text += arraySermonComponents[Sermon.iTitle] + " by " + arraySermonComponents[Sermon.iSpeaker] + Environment.NewLine;
                textBox.Text += arraySermonComponents[Sermon.iDateCreated];

                string RTF     = textBox.Rtf;
                string RTFNew1 = arraySermonComponents[Sermon.iContent].Remove(0, arraySermonComponents[Sermon.iContent].IndexOf(";}") + 2);
                RTFNew1 = RTFNew1.Remove(RTFNew1.IndexOf(";}}") + 3);

                string RTFNew2 = arraySermonComponents[Sermon.iContent].Remove(0, arraySermonComponents[Sermon.iContent].IndexOf(";}}") + 3);

                string RTFOld1 = textBox.Rtf.Remove(textBox.Rtf.IndexOf("}}") + 1);

                string RTFOld2 = textBox.Rtf.Replace(RTFOld1, "");
                RTFOld2 = RTFOld2.Remove(0, 1);
                RTFOld2 = RTFOld2.Remove(RTFOld2.LastIndexOf("}"));

                RTF = RTFOld1 + RTFNew1 + RTFOld2 + RTFNew2;

                SermonReader sermonReader = new SermonReader(RTF, arraySermonComponents)
                {
                    Text      = arraySermonComponents[Sermon.iTitle],
                    Name      = arraySermonComponents[Sermon.iID],
                    RTFpublic = RTF
                };
                return(sermonReader);
            }
            else
            {
                return(null);
            }
        }
コード例 #7
0
        private void MenuItemPrintAll_Click(object sender, EventArgs e)
        {
            DialogResult userChoice = MessageBox.Show("If many files are to be printed, your PC will be taxed. Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (userChoice == DialogResult.Yes)
            {
                try
                {
                    RichTextBoxEx rtbSource = new RichTextBoxEx();
                    foreach (TreeNode tnParentNode in Nodes)
                    {
                        foreach (TreeNode tnChildNode in tnParentNode.Nodes)
                        {
                            try
                            {
                                string rtf = SermonReader.DisplayStoredSermon(Sermon.GetSermonComponents(int.Parse(tnChildNode.Name))).RTFpublic;
                                try
                                {
                                    if (rtbSource.Rtf.ToLower().Contains("rtf"))
                                    {
                                        rtf = AppendRTF(rtbSource.Rtf, rtf);
                                    }
                                }
                                catch { }

                                rtbSource.Rtf = rtf;

                                rtbSource.Text += PAGE_BREAK;
                            }
                            catch
                            {
                                MessageBox.Show("An error was encountered in opening [" + tnChildNode.Text + "].");
                            }
                        }
                    }
                    MyPrintDialog myPrintDialog = new MyPrintDialog(parentForm, rtbSource);
                }
                catch {; }
            }
        }
コード例 #8
0
ファイル: MyPrintDialog.cs プロジェクト: WillOmae/MySermons
 private bool GetPrintText()
 {
     if (parentForm.tabControl.SelectedTab != null)
     {
         foreach (Control control in parentForm.tabControl.SelectedTab.Controls)
         {
             if (control is Form)
             {
                 if ((szDocName = control.Text) == "")
                 {
                     szDocName = "Default Text";
                 }
                 if (control.Text.ToLower() == "start page")
                 {
                     MessageBox.Show("Can't print the start page");
                 }
                 else
                 {
                     foreach (Control subcontrol in control.Controls)
                     {
                         switch (subcontrol.GetType().Name)
                         {
                         case "TextBox":
                         case "RichTextBox":
                         case "RichTextBoxEx":
                             RichTextBoxEx tb = (RichTextBoxEx)subcontrol;
                             rtbPrintContent = tb;
                             return(true);
                         }
                     }
                 }
                 MessageBox.Show(szDocName);
             }
         }
     }
     return(false);
 }
コード例 #9
0
ファイル: Cleaner.cs プロジェクト: WillOmae/MySermons
 private static void InvokeReplaceOldVerseText(string oldText, string newText, RichTextBoxEx rtb)
 {
     rtb.Rtf = rtb.Rtf.Replace(oldText, newText);
 }
コード例 #10
0
        private void InitializeComponents()
        {
            #region ****************** ToolStrip ******************
            ts = new ToolStrip()
            {
                ImageList        = new ImageList(),
                Location         = new Point(Left, Top),
                Name             = "ts",
                ShowItemToolTips = true,
                Size             = new Size(ClientSize.Width, 26),
                TabIndex         = 0
            };
            ts.ItemClicked += new ToolStripItemClickedEventHandler(ToolStripItem_Click);
            #endregion

            #region ****************** RichTextBoxEx ******************
            rtb = new RichTextBoxEx()
            {
                BorderStyle = BorderStyle.Fixed3D,
                Location    = new Point(Left, ts.Bottom + 2),
                Name        = "rtb",
                Size        = new Size(ClientSize.Width, ClientSize.Height - ts.Bottom)
            };
            rtb.SelectionChanged += RtbEx_SelectionChanged;
            rtb.KeyDown          += Rtb_KeyDown;
            rtb.KeyPress         += Rtb_KeyPress;
            if (RichTextBoxEx.ffInstalledFonts != null)
            {
                ffInstalledFonts = RichTextBoxEx.ffInstalledFonts;
            }
            else
            {
                ffInstalledFonts = new System.Drawing.Text.InstalledFontCollection().Families;
            }
            #endregion

            #region ****************** ToolStripButton Copy ******************
            tsiCopy = new ToolStripButton()
            {
                Name         = "tsiCopy",
                Tag          = "copy",
                ToolTipText  = "Copy",
                ImageIndex   = 0,
                CheckOnClick = false
            };
            #endregion

            #region ****************** ToolStripButton Cut ******************
            tsiCut = new ToolStripButton()
            {
                Name         = "tsiCut",
                Tag          = "cut",
                ToolTipText  = "Cut",
                ImageIndex   = 1,
                CheckOnClick = false
            };
            #endregion

            #region ****************** ToolStripButton Paste ******************
            tsiPaste = new ToolStripButton()
            {
                Name         = "tsiPaste",
                Tag          = "paste",
                ToolTipText  = "Paste",
                ImageIndex   = 2,
                CheckOnClick = false
            };
            #endregion

            #region ****************** ToolStripSeparator ******************
            tsiSeparator1 = new ToolStripSeparator()
            {
                Name     = "tsiSeparator1",
                Tag      = "separator",
                AutoSize = true
            };
            #endregion

            #region ****************** ToolStripButton Bold ******************
            tsiBold = new ToolStripButton()
            {
                Name         = "tsiBold",
                Tag          = "bold",
                ToolTipText  = "Bold",
                ImageIndex   = 3,
                CheckOnClick = true
            };
            #endregion

            #region ****************** ToolStripButton Italic ******************
            tsiItalic = new ToolStripButton()
            {
                Name         = "tsiItalic",
                Tag          = "italic",
                ToolTipText  = "Italize",
                ImageIndex   = 4,
                CheckOnClick = true
            };
            #endregion

            #region ****************** ToolStripButton Underline ******************
            tsiUnderline = new ToolStripButton()
            {
                Name         = "tsiUnderline",
                Tag          = "underline",
                ToolTipText  = "Underline",
                ImageIndex   = 5,
                CheckOnClick = true
            };
            #endregion

            #region ****************** ToolStripSeparator ******************
            tsiSeparator2 = new ToolStripSeparator()
            {
                Name = "tsiSeparator2",
                Tag  = "separator"
            };
            #endregion

            #region ****************** ToolStripButton Align Left ******************
            tsiAlignLeft = new ToolStripButton()
            {
                Name         = "tsiAlignLeft",
                Tag          = "alignLeft",
                ToolTipText  = "Align left",
                CheckOnClick = true,
                ImageIndex   = 8
            };
            #endregion

            #region ****************** ToolStripButton Align Centre ******************
            tsiAlignCentre = new ToolStripButton()
            {
                Name         = "tsiAlignCentre",
                Tag          = "alignCentre",
                ToolTipText  = "Align centre",
                CheckOnClick = true,
                ImageIndex   = 9
            };
            #endregion

            #region ****************** ToolStripButton Align Right ******************
            tsiAlignRight = new ToolStripButton()
            {
                Name         = "tsiAlignRight",
                Tag          = "alignRight",
                ToolTipText  = "Align right",
                CheckOnClick = true,
                ImageIndex   = 10
            };
            #endregion

            #region ****************** ToolStripButton Align Justify ******************
            tsiAlignJustify = new ToolStripButton()
            {
                Name         = "tsiAlignJustify",
                Tag          = "alignJustify",
                ToolTipText  = "Justify",
                CheckOnClick = true,
                ImageIndex   = 11
            };
            #endregion

            #region ****************** ToolStripSeparator ******************
            tsiSeparator3 = new ToolStripSeparator()
            {
                Name = "tsiSeparator3",
                Tag  = "separator"
            };
            #endregion

            #region ****************** ToolStripComboBox FontFamilies ******************
            tscmbxFontFamily = new ToolStripComboBox("Times New Roman")
            {
                Name        = "tscmbxFontFamily",
                Text        = "Times New Roman",
                ToolTipText = "Set font"
            };
            tscmbxFontFamily.SelectedIndexChanged += new EventHandler(Font_Click);
            for (int i = 0; i < ffInstalledFonts.Length; i++)
            {
                tscmbxFontFamily.Items.Add(ffInstalledFonts[i].Name);
            }
            #endregion

            #region ****************** ToolStripCombobox FontSize ******************
            tscmbxFontSize = new ToolStripComboBox("12")
            {
                Name = "tscmbxFontSize",
                Text = "12"
            };
            tscmbxFontSize.TextChanged          += new EventHandler(Control_TextChanged);
            tscmbxFontSize.ToolTipText           = "Set font-size";
            tscmbxFontSize.Tag                   = tscmbxFontSize.Text;
            tscmbxFontSize.Size                  = new Size((int)(2 * tscmbxFontSize.Font.Size), tscmbxFontSize.Height);
            tscmbxFontSize.SelectedIndexChanged += new EventHandler(FontSize_Click);
            string[] textSizes = new string[] { "8", "9", "10", "11", "12", "14", "16", "18", "20", "22", "24", "26", "28", "36", "48", "72" };
            foreach (string s in textSizes)
            {
                tscmbxFontSize.Items.Add(new MenuItem().Text = s);
            }
            #endregion

            #region ****************** ToolStripButton Font Color ******************
            tsiFontColor = new ToolStripButton()
            {
                Name         = "tsiFontColor",
                Tag          = "fontColour",
                ToolTipText  = "Font colour",
                CheckOnClick = false,
                ImageIndex   = 6
            };
            #endregion

            #region ****************** ToolStripSeparator ******************
            tsiSeparator4 = new ToolStripSeparator()
            {
                Name = "tsiSeparator4",
                Tag  = "separator"
            };
            #endregion

            #region ****************** ToolStripButton Highlight Color ******************
            tsiHighlightColor = new ToolStripButton()
            {
                Name         = "tsiHighlightColor",
                Tag          = "highlightColor",
                ToolTipText  = "Highlight colour",
                CheckOnClick = false,
                ImageIndex   = 7
            };
            #endregion
            //Add ToolStripItems to the ToolStrip
            ts.Items.AddRange(new ToolStripItem[]
            {
                tsiCopy, tsiCut, tsiPaste, tsiSeparator1,
                tsiBold, tsiItalic, tsiUnderline, tsiSeparator2,
                tsiAlignLeft, tsiAlignCentre, tsiAlignRight, tsiAlignJustify, tsiSeparator3,
                tscmbxFontFamily, tscmbxFontSize, tsiFontColor, tsiSeparator4,
                tsiHighlightColor
            });

            //Add items to the ToolStrip.ImageList
            ts.ImageList.ImageSize        = new Size((int)(ts.ClientSize.Height * 0.90), (int)(ts.ClientSize.Height * 0.90));
            ts.ImageList.ColorDepth       = ColorDepth.Depth32Bit;
            ts.ImageList.TransparentColor = Color.Transparent;
            ts.ImageList.Images.AddRange(new Image[]
            {
                Properties.Resources.Copy,
                Properties.Resources.Cut,
                Properties.Resources.Paste,
                Properties.Resources.Bold,
                Properties.Resources.Italic,
                Properties.Resources.Underline,
                Properties.Resources.ColorFont,
                Properties.Resources.Highlight,
                Properties.Resources.Align_Left,
                Properties.Resources.Align_Center,
                Properties.Resources.Align_Right,
                Properties.Resources.Align_Justified
            });

            //Add controls to the UserControl
            try
            {
                Controls.AddRange(new Control[] { ts, rtb });
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }
        }
コード例 #11
0
ファイル: MyPrintDialog.cs プロジェクト: WillOmae/MySermons
 private bool GetPrintText(RichTextBoxEx rtbSource)
 {
     rtbPrintContent = rtbSource;
     return(true);
 }