Esempio n. 1
0
 private void deleteButton_Click(object sender, EventArgs e)
 {
     if (libraryListBox.CheckedItems.Count > 0)
     {
         string prompt = "Are you sure you want to delete ";
         if (libraryListBox.CheckedItems.Count == 1)
         {
             prompt += libraryListBox.CheckedItems[0].ToString();
         }
         else
         {
             prompt += libraryListBox.CheckedItems.Count + " items";
         }
         prompt += "?";
         if (MessageBox.Show(prompt, "Confirm delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             for (int x = 0; x < libraryListBox.CheckedItems.Count; x++)
             {
                 Library.removeFromLibrary((string)libraryListBox.CheckedItems[x]);
                 File.Delete(EditableSlideSet.getNewPath((string)libraryListBox.CheckedItems[x]));
             }
             updateLibraryList();
         }
     }
 }
Esempio n. 2
0
 private void openbutton_Click(object sender, EventArgs e)
 {
     if (open.ShowDialog() == DialogResult.OK)
     {
         openFile = open.selectedSet;
         openFile.loadFile();
         populate();
         saveToolStripMenuItem.Enabled = false;
     }
 }
Esempio n. 3
0
        private void importButton_Click(object sender, EventArgs e)
        {
            ImportForm imp = new ImportForm();

            if (imp.ShowDialog() == DialogResult.OK)
            {
                openFile = Importer.ImportedSlideSet;
                populate();
                checkSaveButton();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Import a SlideSet into the program's folder using an existing .sld file.
 /// </summary>
 /// <param name="path">The full path to the .sld file to import.</param>
 /// <returns>Returns an ErrorCode specifying what went wrong during the import.</returns>
 public static ImporterErrorCode importSLD(string path)
 {
     try
     {
         iss = new EditableSlideSet(path);
         iss.loadFile();
         iss.resetPath();
     }
     catch (Exception e)
     {
         //Program.ReportError(e);
         return(ImporterErrorCode.GenericError);
     }
     return(ImporterErrorCode.CompletedSucessfully);
 }
Esempio n. 5
0
 private void newButton_Click(object sender, EventArgs e)
 {
     enableCommonControls();
     chorusindex                   = -1;
     openFile                      = new EditableSlideSet();
     titleBox.Text                 = "";
     bylineBox.Text                = "";
     copyrightBox.Text             = "";
     slideContents.Text            = "";
     availableSlides.SelectedIndex = -1;
     slideOrder.SelectedIndex      = -1;
     slidePool.Clear();
     slideList.Clear();
     refreshLists();
     checkSaveButton();
 }
Esempio n. 6
0
 private void exportButton_Click(object sender, EventArgs e)
 {
     if (libraryListBox.CheckedIndices.Count != 0)
     {
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             string[] files = new string[libraryListBox.CheckedItems.Count];
             for (int x = 0; x < libraryListBox.CheckedItems.Count; x++)
             {
                 files[x] = EditableSlideSet.getNewPath((string)libraryListBox.CheckedItems[x]);
             }
             Library.ExportLibrary(saveFileDialog.FileName, files);
             updateLibraryList();
         }
     }
     else
     {
         MessageBox.Show("You must select at least one song to export.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Import a SlideSet using the data stored at the RUF Hymnbook website.
 /// </summary>
 /// <param name="url">Either the name of a song to search for or a URL directly to a song page.</param>
 /// <returns>Returns an ErrorCode specifying what went wrong during the import.</returns>
 public static ImporterErrorCode importRHO(string url)
 {
     //http://www.developer.com/net/csharp/article.php/2230091 Try this?
     try
     {
         WebClient client = new WebClient();
         iss = new EditableSlideSet();
         if (!url.Contains(".html"))
         {
             string search = client.DownloadString("http://www.igracemusic.com/hymnbook/hymns.html");
             url    = url.ToLower();
             search = search.ToLower();
             int sindex = search.IndexOf(url);
             if (sindex == -1)
             {
                 return(ImporterErrorCode.SearchTermNotFound);
             }
             string urlfind = "<a href=\"";
             int    uindex  = 0;
             while (true)
             {
                 int utemp = search.IndexOf(urlfind, uindex + 1);
                 if (utemp > sindex)
                 {
                     break;
                 }
                 uindex = utemp;
                 if (uindex == -1)
                 {
                     return(ImporterErrorCode.SearchConstantIncorrect);
                 }
             }
             uindex += urlfind.Length;
             int ulength = (search.IndexOf("\"", uindex) - uindex);
             url = "http://www.igracemusic.com/hymnbook/" + search.Substring(uindex, ulength);
         }
         string titlefind    = " class=\"header1\">";
         string versefind    = " class=\"body\">";
         string endversefind = "<a href=\"#top\">";
         string page         = client.DownloadString(url);
         int    index        = page.IndexOf(titlefind);
         int    length       = (page.IndexOf("</p>", index) - index - titlefind.Length);
         iss.Name = page.Substring((index + titlefind.Length), length);
         iss.Name = stripHTML(iss.Name);
         int    chop   = (page.IndexOf(endversefind, index) - index);
         string verses = page.Substring(index, chop);
         chop = 0;
         int n = 0;
         while (true)
         {
             chop = verses.IndexOf(versefind, chop + 1);
             if (chop == -1)
             {
                 break;
             }
             n++;
         }
         iss.setupTexts(n - 1, 0);
         index = 0;
         for (int x = 0; x < (n - 1); x++)
         {
             index  = verses.IndexOf(versefind, index + 1);
             length = (verses.IndexOf("</p>", index) - index - versefind.Length);
             string verse = verses.Substring((index + versefind.Length), length);
             verse = verse.Replace("&#146;", "'");
             verse = verse.Replace("&quot;", "\"");
             verse = verse.Replace("<br>\n", System.Environment.NewLine);
             verse = verse.Replace("              ", "");
             verse = stripHTML(verse);
             iss.addText(x, verse, 0);
         }
     }
     catch (Exception e)
     {
         //Program.ReportError(e);
         return(ImporterErrorCode.GenericError);
     }
     return(ImporterErrorCode.CompletedSucessfully);
 }
Esempio n. 8
0
 /// <summary>
 /// This function does not work. Do not use.
 /// </summary>
 /// <param name="path">This function does not work. Do not use.</param>
 /// <returns>Thus function does not work. Do not use.</returns>
 public static ImporterErrorCode importPPT(string path)
 {
     try
     {
         iss = new EditableSlideSet();
         StreamReader reader = new StreamReader(path);
         bool         flag1  = false;
         bool         flag2  = false;
         bool         flag3  = false;
         int          count  = 0;
         string       text   = "";
         while (!reader.EndOfStream)
         {
             int ch = reader.Read();
             if (flag1 && flag2)
             {
                 if (count == 0 && ch == 2)
                 {
                     flag1 = false;
                 }
                 if (count < 4)
                 {
                     count++;
                 }
                 else
                 {
                     if (ch == 0)
                     {
                         if (flag3)
                         {
                             flag1     = false;
                             iss.Name += "i";
                         }
                         else
                         {
                             flag3 = true;
                         }
                     }
                     else
                     {
                         text += (char)ch;
                     }
                 }
             }
             else
             {
                 text  = "";
                 count = 0;
                 if (flag1 && ch == 15)
                 {
                     flag2 = true;
                 }
                 else
                 {
                     flag1 = false;
                     flag2 = false;
                     if (ch == 160 || ch == 168)
                     {
                         flag1 = true;
                     }
                 }
             }
         }
         reader.Close();
     }
     catch (Exception e)
     {
         //Program.ReportError(e);
         return(ImporterErrorCode.GenericError);
     }
     return(ImporterErrorCode.CompletedSucessfully);
 }
Esempio n. 9
0
        /// <summary>
        /// Import a SlideSet using data stored at the Cyber Hymnal website.
        /// </summary>
        /// <param name="url">Either the name of a song to search for or a URL directly to a song page.</param>
        /// <returns>Returns an ErrorCode specifying what went wrong during the import.</returns>
        public static ImporterErrorCode importCH(string url)
        {
            try
            {
                WebClient client = new WebClient();
                iss = new EditableSlideSet();
                if (!url.Contains(".htm"))
                {
                    url = url.ToLower();
                    string search = client.DownloadString("http://www.cyberhymnal.org/ttl/ttl-" + url.ToCharArray()[0] + ".htm");
                    search = search.Replace("&#8217;", "'");
                    search = search.ToLower();
                    int sindex = search.IndexOf(url);
                    if (sindex == -1)
                    {
                        return(ImporterErrorCode.SearchTermNotFound);
                    }
                    string urlfind = "<a href=\"..";
                    int    uindex  = 0;
                    while (true)
                    {
                        int utemp = search.IndexOf(urlfind, uindex + 1);
                        if (utemp > sindex)
                        {
                            break;
                        }
                        uindex = utemp;
                        if (uindex == -1)
                        {
                            return(ImporterErrorCode.SearchConstantIncorrect);
                        }
                    }
                    uindex += urlfind.Length;
                    int ulength = (search.IndexOf("\"", uindex) - uindex);
                    url = "http://www.cyberhymnal.org" + search.Substring(uindex, ulength);
                }
                string titlefind        = "<title>";
                string versefind        = "<p>";
                string chorusfind       = "<p class=\"chorus\">";
                string versesectionfind = "<div class=\"lyrics\">";
                string page             = client.DownloadString(url);
                int    index            = page.IndexOf(titlefind);
                int    length           = (page.IndexOf("</title>", index) - index - titlefind.Length);
                iss.Name = page.Substring((index + titlefind.Length), length);

                index = page.IndexOf(versesectionfind);
                int    chop   = (page.IndexOf("</div>", index) - index);
                string verses = page.Substring(index, chop);
                chop = 0;
                int n = 0;
                while (true)
                {
                    chop = verses.IndexOf(versefind, chop + 1);
                    if (chop == -1)
                    {
                        break;
                    }
                    n++;
                }
                bool haschorus = false;
                if (verses.Contains(chorusfind))
                {
                    n++;
                    haschorus = true;
                }
                iss.setupTexts(n, 0);
                index = 0;
                for (int x = 0; x < (n - (haschorus ? 1 : 0)); x++)
                {
                    index  = verses.IndexOf(versefind, index + 1);
                    length = (verses.IndexOf("</p>", index) - index - versefind.Length);
                    string verse = verses.Substring((index + versefind.Length), length);
                    verse = verse.Replace("<br />", "");
                    verse = verse.Replace("&#8217;", "'");
                    verse = verse.Replace("&#8212;", ";");
                    verse = verse.Replace("&#8220;", "\"");
                    verse = verse.Replace("&#8221;", ",");
                    verse = stripHTML(verse);
                    iss.addText(x, verse, 0);
                }
                if (haschorus)
                {
                    index  = 0;
                    index  = verses.IndexOf(chorusfind, index + 1);
                    index  = verses.IndexOf(chorusfind, index + 1);
                    length = (verses.IndexOf("</p>", index) - index - chorusfind.Length);
                    string chorus = verses.Substring((index + chorusfind.Length), length);
                    chorus = chorus.Replace("<br />", "");
                    chorus = chorus.Replace("&#8217;", "'");
                    chorus = chorus.Replace("&#8212;", ";");
                    chorus = chorus.Replace("&#8220;", "\"");
                    chorus = chorus.Replace("&#8221;", ",");
                    chorus = stripHTML(chorus);
                    iss.addText(n - 1, chorus, 0);
                    iss.Chorus = n - 1;
                }
            }
            catch (Exception e)
            {
                //Program.ReportError(e);
                return(ImporterErrorCode.GenericError);
            }
            return(ImporterErrorCode.CompletedSucessfully);
        }