예제 #1
0
 private bool GetPrintText(int DocumentID)
 {
     try
     {
         rtbPrintContent = new RichTextBoxEx()
         {
             Rtf = SermonReader.DisplayStoredSermon(Sermon.GetSermonComponents(DocumentID)).RTFpublic
         };
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #2
0
 private void RecentsTreeNode_DoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         string[] arraySermonComponents = RecentlyOpenedDocs.OpenSermonFromID(int.Parse(e.Node.Name));
         if (arraySermonComponents == null)
         {
             return;
         }
         else
         {
             Form displayForm = SermonReader.DisplayStoredSermon(arraySermonComponents);
             parentForm.AddNewTabPage(displayForm);
         }
     }
 }
예제 #3
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);
            }
        }
예제 #4
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 {; }
            }
        }
예제 #5
0
        private void SaveTypedData()
        {
            try
            {
                DateTime datetime = dtPicker.Value;

                int series;
                try
                {
                    if (!int.TryParse(cmbxSeries.SelectedValue.ToString(), out series))
                    {
                        series = 0;
                    }
                }
                catch
                {
                    series = 0;
                }

                string venue;
                if (string.IsNullOrEmpty(txbVenue_Name.Text))
                {
                    venue = "NOT SET";
                }
                if (txbVenue_Name.Text == txbVenue_Name.Watermark)
                {
                    venue = "NOT SET";
                }
                else
                {
                    venue = txbVenue_Name.Text;
                }

                string town;
                if (string.IsNullOrEmpty(txbVenue_Town.Text))
                {
                    town = "NOT SET";
                }
                if (txbVenue_Town.Text == txbVenue_Town.Watermark)
                {
                    town = "NOT SET";
                }
                else
                {
                    town = txbVenue_Town.Text;
                }

                string activity;
                if (string.IsNullOrEmpty(txbVenue_Activity.Text))
                {
                    activity = "NOT SET";
                }
                if (txbVenue_Activity.Text == txbVenue_Activity.Watermark)
                {
                    activity = "NOT SET";
                }
                else
                {
                    activity = txbVenue_Activity.Text;
                }

                string speaker;
                if (string.IsNullOrEmpty(txbSpeakerName.Text))
                {
                    speaker = "NOT SET";
                }
                if (txbSpeakerName.Text == txbSpeakerName.Watermark)
                {
                    speaker = "NOT SET";
                }
                else
                {
                    speaker = txbSpeakerName.Text;
                }

                string keytext;
                if (string.IsNullOrEmpty(txbKeyText.Text))
                {
                    keytext = "NOT SET";
                }
                if (txbKeyText.Text == txbKeyText.Watermark)
                {
                    keytext = "NOT SET";
                }
                else
                {
                    keytext = txbKeyText.Text;
                }

                string hymn;
                if (string.IsNullOrEmpty(txbHymn.Text))
                {
                    hymn = "NOT SET";
                }
                if (txbHymn.Text == txbHymn.Watermark)
                {
                    hymn = "NOT SET";
                }
                else
                {
                    hymn = txbHymn.Text;
                }

                string title;
                if (string.IsNullOrEmpty(txbTitle.Text))
                {
                    title = "NOT SET";
                }
                if (txbTitle.Text == txbTitle.Watermark)
                {
                    title = "NOT SET";
                }
                else
                {
                    title = txbTitle.Text;
                }

                string theme;
                if (string.IsNullOrEmpty(txbTheme.Text))
                {
                    theme = "NOT SET";
                }
                if (txbTheme.Text == txbTheme.Watermark)
                {
                    theme = "NOT SET";
                }
                else
                {
                    theme = txbTheme.Text;
                }

                string content = rtbContent.Rtf;

                StatusBarMessages.SetStatusBarMessageAction("Saving " + title);

                if (isEdited == false)//new sermon
                {
                    Sermon sermon = new Sermon(0, series, datetime, venue, town, activity, speaker, keytext, hymn, title, theme, content);

                    string[] arraySubItems = Sermon.ComponentsToString(sermon);
                    if (Sermon.WriteSermon(arraySubItems) == 1)//sermon inserted successfully
                    {
                        AppEngine.Database.Sermon dummy = new AppEngine.Database.Sermon()
                        {
                            Activity    = sermon.Activity,
                            Content     = sermon.Content,
                            DateCreated = sermon.DateCreated,
                            Hymn        = sermon.Hymn,
                            KeyText     = sermon.KeyText,
                            Speaker     = sermon.Speaker,
                            Title       = sermon.Title,
                            Theme       = sermon.Theme,
                            Town        = sermon.Town,
                            Venue       = sermon.Venue
                        };
                        if (dummy.Exists(dummy))
                        {
                            sermon.Id = dummy.Id;
                            parentForm.tabControl.TabPages.Remove(parentForm.tabControl.SelectedTab);
                            parentForm.AddNewTabPage(SermonReader.DisplayStoredSermon(Sermon.ComponentsToString(sermon)));
                            treeViewEx.AddNewTreeNode(dummy.Title, dummy.Id.ToString());
                        }
                    }
                    else
                    {
                        MessageBox.Show("Document not added.\nPlease try again.");
                    }
                }
                else//edited sermon: use existing ID
                {
                    Sermon   sermon        = new Sermon(editedID, series, datetime, venue, town, activity, speaker, keytext, hymn, title, theme, content);
                    string[] arraySubItems = Sermon.ComponentsToString(sermon);
                    arraySubItems[iID] = editedID.ToString();
                    Sermon.OverwriteSermon(arraySubItems);
                    parentForm.tabControl.TabPages.Remove(parentForm.tabControl.SelectedTab);
                    parentForm.AddNewTabPage(SermonReader.DisplayStoredSermon(arraySubItems));
                }
                StatusBarMessages.SetStatusBarMessageAction("Saved " + title);
            }
            catch
            {
                StatusBarMessages.SetStatusBarMessageAction("Error saving " + txbTitle.Text);
            }
        }
예제 #6
0
 /* private void lvShowFoundItems_SelectedIndexChanged (<object>, <EventArgs>)
  * This function is called when the user clicks on a list view item
  *
  *
  */
 private void lvShowFoundItems_SelectedIndexChanged(object sender, EventArgs e)
 {
     parentForm.AddNewTabPage(SermonReader.DisplayStoredSermon(Sermon.GetSermonComponents(int.Parse(lvShowFoundItems.FocusedItem.Name))));
     Close();
 }
예제 #7
0
        public void DisplayTreeNodeItem(TreeNode treeNodeSelected)
        {
            Form sermonReader = SermonReader.DisplayStoredSermon(Sermon.GetSermonComponents(int.Parse(treeNodeSelected.Name)));

            parentForm.AddNewTabPage(sermonReader);
        }