Beispiel #1
0
        public static List <SongSearchResult> Search(List <string> searchTerms)
        {
            if (searchTerms.Count < 1)
            {
                throw (new ApplicationException("No search terms"));
            }

            // Double check sql
            string p = ",./<>?[]\\{}|!@#$%^&*()-=_+:;'\"";

            foreach (string str in searchTerms)
            {
                if (str.IndexOfAny(p.ToCharArray()) != -1)
                {
                    throw (new ApplicationException("Malformed sql passed to Search"));
                }
            }

            // Build the query
            string query = "SELECT \"SongVerses\".\"AutoNumber\", \"Songs\".\"Number\", \"SongVerses\".\"Verse\", \"SongVerses\".\"OrderNum\", \"SongVerses\".\"IsChorus\" " +
                           "FROM \"SongVerses\" INNER JOIN \"Songs\" ON \"SongVerses\".\"AutoNumber\" = \"Songs\".\"AutoNumber\" WHERE ";

            foreach (string s in searchTerms)
            {
                query += "(\"Verse\" LIKE '%" + s + "%') AND ";
            }
            query  = query.Remove(query.Length - 4);
            query += "ORDER BY \"Number\"";

            // Query the database
            List <SongSearchResult> lResult = new List <SongSearchResult>();

            using (FBirdTask t = new FBirdTask())
            {
                t.CommandText = query;
                t.ExecuteReader();
                int cutoff = 100;
                while (t.DR.Read() && cutoff > 0)
                {
                    cutoff--;
                    SongSearchResult ssr = new SongSearchResult();
                    ssr.autoNumber   = t.GetInt32(0);
                    ssr.songNumber   = t.GetInt32(1);
                    ssr.verseData    = t.GetString(2);
                    ssr.isAtStart    = t.GetInt32(3) == 0;
                    ssr.isChorus     = t.GetBoolean(4);
                    ssr.verseData    = SongProject.RemoveVerseFormatting(ssr.verseData);
                    ssr.searchResult = ssr.verseData;
                    lResult.Add(ssr);
                }
            }

            return(lResult);
        }
Beispiel #2
0
        public GfxContext GetCurrentGfxContext()
        {
            // Check bounds
            if (currentSlideNum > songSlides.Count - 1)
            {
                currentSlideNum = songSlides.Count - 1;
            }

            SongSlideData data    = songSlides[currentSlideNum];
            string        verse   = data.text;
            const int     PADDING = 30;

            // No formatting support
            if (stripFormatting)
            {
                verse = SongProject.RemoveVerseFormatting(verse);
            }

            // Double space support
            if (!stripFormatting)
            {
                string lineSpacing = songFont.DoubleSpace ? "\r\n\r\n" : "\r\n";
                verse = verse.Replace("\r\n", "\n").Replace("\n", lineSpacing);
            }

            #region Standard format (build context)
            Size nativeSize = DisplayEngine.NativeResolution.Size;
            graphicsContext.destSize = nativeSize;
            graphicsContext.textRegions.Clear();

            // Add the verse box
            GfxTextRegion rVerse = new GfxTextRegion();
            rVerse.bounds  = new Rectangle(PADDING, PADDING, nativeSize.Width - PADDING * 2, nativeSize.Height - 80);
            rVerse.font    = songFont;
            rVerse.message = verse;
            graphicsContext.textRegions.Add(rVerse);

            // Last slide ***
            if (data.isLast)
            {
                GfxTextRegion rEnd = new GfxTextRegion();
                rEnd.bounds = new Rectangle(PADDING, nativeSize.Height - 80, nativeSize.Width - PADDING * 2, 40);
                rEnd.font   = (PresenterFont)songFont.Clone();
                rEnd.font.HorizontalAlignment = HorizontalAlignment.Center;
                rEnd.message = "* * *";
                graphicsContext.textRegions.Add(rEnd);
            }

            // Copyright
            if (copyright != "")
            {
                GfxTextRegion rEnd = new GfxTextRegion();
                rEnd.bounds                   = new Rectangle(PADDING, nativeSize.Height - 40, nativeSize.Width - PADDING * 2, 40 - 7);
                rEnd.font                     = new PresenterFont();
                rEnd.font.fontName            = "Verdana";
                rEnd.font.Italic              = true;
                rEnd.font.SizeInPoints        = 12;
                rEnd.font.HorizontalAlignment = HorizontalAlignment.Center;
                rEnd.font.VerticalAlignment   = VerticalAlignment.Bottom;
                rEnd.font.Color               = songFont.Color;
                rEnd.font.Shadow              = false;
                rEnd.font.Outline             = false;
                rEnd.message                  = copyright;
                graphicsContext.textRegions.Add(rEnd);
            }
            #endregion

            return(graphicsContext.Clone());
        }