Ejemplo n.º 1
0
        public ColoredTextBoxPanel()
        {
            InitializeComponent();


            this.rte.MouseWheel += new MouseEventHandler(this.MouseWheelHandler);

            renew    = true;
            oldLines = DreamTools.SplitString(rte.Text, separator);
            for (int i = 0; i < oldLines.Length; i++)
            {
                Typelist.Add(LyricsType.Verse);
            }
            this.Update();
        }
Ejemplo n.º 2
0
        public void setText(Song song)
        {
            if (verseSeparator == SongVerseSeparator.OneBlankLine)
            {
                separator = "\n\n";
            }
            if (verseSeparator == SongVerseSeparator.TwoBlankLines)
            {
                separator = "\n\n\n";
            }

            Typelist = new ArrayList();
            //song.SongLyrics.Sort();
            StringBuilder s = new StringBuilder();
            int           i = 0;

            foreach (LyricsItem item in song.SongLyrics)
            {
                if (item.Lyrics.Length > 0)
                {
                    if (s.Length > 0)
                    {
                        s.Append(separator);
                    }

                    s.Append(item.Lyrics);
                    Typelist.Add(item.Type);
                    i++;
                }
            }
            if (Typelist.Count == 0)
            {
                Typelist.Add(LyricsType.Verse);
            }
            Updating = true;

            rte.Text = song.SanitizeLyrics(s.ToString());
            oldLines = DreamTools.SplitString(rte.Text, separator);
            rte.Font = new Font("Microsoft Sans Serif", 9);
            Updating = false;
            renew    = true;
            Update();
            Resizer(false);
        }
Ejemplo n.º 3
0
        public void GetText(Song song)
        {
            string[] newLines    = DreamTools.SplitString(rte.Text, separator);
            int      verseCount  = 1;
            int      chorusCount = 1;
            int      otherCount  = 1;
            int      j           = 0;

            song.ClearLyrics();

            StringBuilder verse  = new StringBuilder();
            StringBuilder chorus = new StringBuilder();
            StringBuilder other  = new StringBuilder();

            foreach (string line in newLines)
            {
                switch ((LyricsType)Typelist[j])
                {
                case LyricsType.Verse:
                    verseCount = song.AddLyrics(LyricsType.Verse, line, verseCount, verseSeparator);
                    //if (verse.Length > 0) verse.Append(separator);
                    //verse.Append(line);
                    break;

                case LyricsType.Chorus:
                    //if (chorus.Length > 0) chorus.Append(separator);
                    //chorus.Append(line);
                    chorusCount = song.AddLyrics(LyricsType.Chorus, line, chorusCount, verseSeparator);
                    break;

                case LyricsType.Other:
                    //if (other.Length > 0) other.Append(separator);
                    //other.Append(line);
                    otherCount = song.AddLyrics(LyricsType.Other, line, otherCount, verseSeparator);
                    break;
                }
                j++;
            }

            //song.SetLyrics(LyricsType.Verse, verse.ToString(), verseSeparator);
            //song.SetLyrics(LyricsType.Chorus, chorus.ToString(), verseSeparator);
            //song.SetLyrics(LyricsType.Other, other.ToString(), verseSeparator);
        }
Ejemplo n.º 4
0
        private void WhatChanged()
        {
            string[] newLines = DreamTools.SplitString(rte.Text, separator);

            if (newLines.Length != oldLines.Length)
            {
                ArrayList NewTypelist = new ArrayList();

                for (int i = 0; i < newLines.Length; i++)
                {
                    NewTypelist.Add(LyricsType.Undefined);
                }
                int j = 0;
                foreach (string line in newLines)
                {
                    int k = 0;
                    foreach (string oldline in oldLines)
                    {
                        if (line == oldline)
                        {
                            NewTypelist[j] = Typelist[k];
                        }
                        k++;
                    }
                    j++;
                }

                for (int i = 0; i < NewTypelist.Count; i++)
                {
                    if ((LyricsType)NewTypelist[i] == LyricsType.Undefined)
                    {
                        // Maybe the Line was split, so the next line is undefined too
                        if (i + 1 < NewTypelist.Count)
                        {
                            if ((LyricsType)NewTypelist[i + 1] == LyricsType.Undefined)
                            {
                                if (i < Typelist.Count)
                                {
                                    NewTypelist[i]     = Typelist[i];
                                    NewTypelist[i + 1] = Typelist[i];
                                }
                            }
                        }


                        // if its still not undefined...
                        if ((LyricsType)NewTypelist[i] == LyricsType.Undefined)
                        {
                            //is it a new verse at the first line?
                            if (i == 0)
                            {
                                if (i < Typelist.Count)
                                {
                                    NewTypelist[i] = Typelist[i];
                                }
                            }
                            else
                            {
                                NewTypelist[i] = Typelist[i - 1];
                            }
                        }

                        // Last Option, if nothing worked
                        if ((LyricsType)NewTypelist[i] == LyricsType.Undefined)
                        {
                            NewTypelist[i] = LyricsType.Verse;
                        }
                    }
                }
                Typelist = NewTypelist;
                renew    = true;
            }
            oldLines = DreamTools.SplitString(rte.Text, separator);
        }