Exemple #1
0
        private void StartProject(bool activate)
        {
#if DEMO
            searchExpired = true;
#endif
            if (currentSong == null)
            {
                return;
            }

            // Check if the song is already running
            foreach (IProject p in Program.Presenter.projects)
            {
                if (p.GetProjectType() == ProjectType.Song)
                {
                    SongProject songp = (SongProject)p;
                    if (songp.currentSong.AutoNumber == currentSong.AutoNumber)
                    {
                        Program.Presenter.ActivateController(songp);
                        this.Deactivate();
                        return;
                    }
                }
            }

            SongProject sp = new SongProject(currentSong);
            Program.Presenter.AddProject(sp);
            if (activate)
            {
                sp.Activate();
            }
            this.Deactivate(); // Clear ui
        }
Exemple #2
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);
        }
Exemple #3
0
        private void UpdateSearchDisplayer(int autoNumber, int songNumber)
        {
            SongProject.LoadVerses(lSearchResultVerses, autoNumber, true);
            fullSongPreview.Init(lSearchResultVerses, songNumber, SearchHelper.BreakSearchTerms(txtFulltextSearch.Text));

            // Select the song behind the scenes
            dvSongs.RowFilter = "AutoNumber = " + autoNumber;
            if (dvSongs.Count > 0)
            {
                currentSong = (PresenterDataset.SongsRow)dvSongs[0].Row;
                UpdateUI();
            }
        }
        public void AttachProject(SongProject proj)
        {
            if (proj != this.proj)
            {
                DetachProject();

                this.proj          = proj;
                ehRefresh          = new EventHandler(proj_refresh);
                this.proj.Refresh += ehRefresh;

                RefreshData();
            }
        }
Exemple #5
0
        public void DetachProject()
        {
            if (this.proj != null)
            {
                if (ehRefresh != null)
                {
                    this.proj.Refresh -= ehRefresh;
                    ehRefresh          = null;
                }
            }
            this.proj = null;

            songPreviewControl1.DetachProject();
        }
Exemple #6
0
        public void AttachProject(IProject proj)
        {
            if (this.proj != proj)
            {
                DetachProject();

                this.proj = (SongProject)proj;
                if ((object)proj as ISlideShow == null)
                {
                    throw (new ApplicationException("The project must implement ISlideShow"));
                }
                ehRefresh          = new EventHandler(project_Refresh);
                this.proj.Refresh += ehRefresh;

                songPreviewControl1.AttachProject(this.proj);
            }
            this.RefreshUI();
        }
Exemple #7
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button == MouseButtons.Left && proj != null)
            {
                switch (proj.GetProjectType())
                {
                case ProjectType.Bible:
                    BibleProject bp = (BibleProject)proj;
                    bp.GoNextSlide();
                    break;

                case ProjectType.Song:
                    SongProject sp = (SongProject)proj;
                    sp.GoNextSlide();
                    break;
                }
            }
        }
        public void DetachProject()
        {
            if (proj != null && ehRefresh != null)
            {
                proj.Refresh -= ehRefresh;
            }
            this.proj = null;
            ehRefresh = null;

            // Reset variables
            if (slideText != null)
            {
                slideText.Clear();
            }
            slideText = null;
            slideRectMapping.Clear();
            highlightedItem = -1;
            scrollerPos     = 0;
            scrollerRatio   = 1;
            scrollerHeight  = 0;
        }
Exemple #9
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());
        }