Esempio n. 1
0
        public static void NewSong(Song song)
        {
            var stream = File.OpenWrite(song.Key);
            var sw = new StreamWriter(stream);
            sw.Write(song.SongText);

            sw.Close();
        }
Esempio n. 2
0
        public MainViewModel()
        {
            ScreenSettings = new ScreenSettings();

            this.MouseEnterCommand = new DelegateCommand(this.MouseEnter);
            this.MouseLeaveCommand = new DelegateCommand(this.MouseLeave);

            CurrentSong = new Song("Romans 15:7" + Environment.NewLine + "=" + Environment.NewLine + "Therefore welcome one another" + Environment.NewLine + "as Christ has welcomed you," + Environment.NewLine + "for the glory of God.", "");
        }
Esempio n. 3
0
        public static Song LoadSong(string key)
        {
            var stream = File.OpenRead(key);
            var sr = new StreamReader(stream);

            var wholeSong = sr.ReadToEnd();
            var song = new Song(wholeSong, key);
            sr.Close();

            return song;
        }
Esempio n. 4
0
        public static void SaveSong(Song song)
        {
            bool needsLoaded = false;
            if (!File.Exists(song.Key))
                needsLoaded = true;

            var stream = File.OpenWrite(song.Key);
            var sw = new StreamWriter(stream);
            sw.Write(song.SongText);
            sw.Close();

            if (needsLoaded)
                Initialize();
        }
Esempio n. 5
0
 protected override void OnActivate()
 {
     try
     {
         BookManager.Initialize();
     }
     catch (Exception)
     {
         CurrentSong = new Song
             {
                 Title = "We have a problem",
                 CurrentVerse = "There was an error loading the books directory. Make sure it exists."
             };
     }
 }
        public static FlowDocument SongDocument(Song song)
        {
            FlowDocument doc = new FlowDocument();

            Paragraph title = new Paragraph(new Run(song.Title));
            title.FontSize = 25;

            doc.Blocks.Add(title);

            if (string.IsNullOrEmpty(song.Subtitle) == false)
            {
                Paragraph subtitle = new Paragraph(new Run(song.Subtitle));
                doc.Blocks.Add(subtitle);
            }

            Song doubledSong = new Song(song.SongText, song.Key);

            foreach(Verse verse in doubledSong.Verses)
            {
                for(int lineIndex = 0; lineIndex < verse.AllLines.Count; lineIndex++)
                {
                    if (lineIndex + 1 < verse.AllLines.Count)
                    {
                        Line currentLine = verse.AllLines[lineIndex];
                        Line nextLine = verse.AllLines[lineIndex + 1];

                        if (currentLine.IsNotText)
                        {
                            currentLine.Text = currentLine.Text.PadRight(Convert.ToInt32(Math.Ceiling(nextLine.Text.Length * 1.4)));
                        }

                        if (currentLine.IsNotText == nextLine.IsNotText)
                        {
                            currentLine.Text += " " + nextLine.Text;
                            verse.AllLines.Remove(nextLine);
                        }
                        else if (lineIndex + 2 < verse.AllLines.Count)
                        {
                            Line lineAfterNext = verse.AllLines[lineIndex + 2];

                            if(currentLine.IsNotText == lineAfterNext.IsNotText)
                            {
                                currentLine.Text += " " + lineAfterNext.Text;
                                verse.AllLines.Remove(lineAfterNext);
                            }
                        }
                    }
                }
            }

            foreach(Verse verse in doubledSong.Verses)
            {
                foreach(Line line in verse.AllLines)
                {
                    Paragraph currentLine = new Paragraph(new Run(line.Text));

                    if(line.IsNotText)
                    {
                        currentLine.FontSize = 12;
                        currentLine.FontStyle = FontStyles.Italic;
                        currentLine.Foreground = Brushes.Blue;
                        currentLine.FontFamily = new FontFamily("Consolas");
                        currentLine.LineHeight = 5;
                    }
                    else
                    {
                        currentLine.FontFamily = new FontFamily("Segoe UI");
                        currentLine.FontSize = 22;
                        currentLine.LineHeight = 5;
                    }

                    doc.Blocks.Add(currentLine);
                }

                Paragraph space = new Paragraph(new Run(""));
                doc.Blocks.Add(space);
            }

            return doc;
        }
Esempio n. 7
0
 protected override void OnActivate()
 {
     try
     {
         if(BookManager.Books == null)
             BookManager.Initialize();
     }
     catch (Exception)
     {
         CurrentSong = new Song("We have a problem", "NoKey");
     }
 }
Esempio n. 8
0
        public void SetSong(SearchSong song)
        {
            if(song == null)
            {
                int x;
                if (IsSearching && SearchString.Length <= 3 && SearchString.All(Char.IsDigit) && int.TryParse(SearchString, out x) && x > 0)
                {
                    string fmt = "000";
                    string songNumber = x.ToString(fmt);
                    string bookKey;
                    string bookTitle;
                    if (CurrentBook != null)
                    {
                        bookKey = CurrentBook.Key;
                        bookTitle = CurrentBook.Title;
                    }
                    else
                    {
                        bookKey = BookManager.Books[0].Key;
                        bookTitle = BookManager.Books[0].Title;
                    }

                    CurrentSong = new Song("No Song At This Index" + Environment.NewLine + "=" + Environment.NewLine + "You can press the edit key to create a new song", bookKey + "/" + bookTitle + songNumber + ".TXT");
                }
                return;
            }

            CurrentSong = BookManager.LoadSong(song.Key);
            CurrentSong.BookNumber = song.BookNumber;

            SearchResults = null;
            SelectedSearchSong = null;
            SearchString = null;
        }