Пример #1
0
 void plbl_ClickPrev(object sender, EventArgs e)
 {
     if (PreviousSongClicked != null)
     {
         _selectAfterLoad = SelectAfterLoad.Last;
         SongSwitchEventArgs p = new SongSwitchEventArgs((Song)((Button)sender).Tag);
         PreviousSongClicked(this, p);
     }
 }
Пример #2
0
 void plbl_ClickNext(object sender, EventArgs e)
 {
     if (NextSongClicked != null)
     {
         _selectAfterLoad = SelectAfterLoad.First;
         SongSwitchEventArgs p = new SongSwitchEventArgs((Song)((Button)sender).Tag);
         NextSongClicked(this, p);
     }
 }
Пример #3
0
        public void SetSong(Song sng, Song previousSong, Song nextSong)
        {
            PerformLayout();
            SuspendLayout();

            List <SongPart> parts = SongViewMode == SongViewMode.Sequence ? sng.PartSequence : sng.Parts;

            //
            // Cleanup
            //

            // Reset indices
            _currentSlideTextIdx = -1;
            _refrainIndex        = -1;
            _prechorusIndex      = -1;
            _bridgeIndex         = -1;
            _verse1Index         = -1;
            _verse2Index         = -1;
            _verse3Index         = -1;
            _verse4Index         = -1;

            // Clear existing controls
            RemoveControls(Controls);

            // Set scroll value
            VerticalScroll.Value = 0;

            // Clear lists
            _slideTexts.Clear();

            //
            // Draw new stuff
            //

            bool showFirstLastBackgrounds = ShowFirstAndLastBackground || (parts.Count > 0 && (previousSong != null || nextSong != null));

            int ypos = TopMargin;

            Size labelSize = new Size(0, 0);

            labelSize = AvailableSongCaption != null?AvailableSongCaption.Cast <string>().Aggregate(labelSize, (current, caption) => MeasureSize(caption, current)) : parts.Aggregate(labelSize, (current, part) => MeasureSize(part.Caption, current));

            _slidePanelOffset = labelSize.Width + 20;

            if (previousSong != null)
            {
                Size measured     = TextRenderer.MeasureText(previousSong.Title, _prevNextSongFont);
                int  buttonHeight = measured.Height + 6 + (2 * SongSwitchPanelPadding);

                // Add panel for previous song
                Panel pnl = new Panel
                {
                    Height = buttonHeight
                };
                pnl.Paint   += songSwitchPnl_Paint;
                pnl.Location = new Point(LeftMargin, TopMargin);

                // Add song title to panel
                _prevSongButton = new Button
                {
                    Location  = new Point(0, 0),
                    Height    = buttonHeight,
                    Text      = @" " + previousSong.Title,
                    Font      = _slideTextFont,
                    TextAlign = ContentAlignment.MiddleLeft,
                    Tag       = previousSong,
                    FlatStyle = FlatStyle.Flat,
                    Padding   = new Padding(SongSwitchPanelPadding),
                    Cursor    = Cursors.Hand
                };
                _prevSongButton.FlatAppearance.BorderColor = Color.White;
                _prevSongButton.FlatAppearance.BorderSize  = 0;
                if (PreviousSongIcon != null)
                {
                    _prevSongButton.Image             = PreviousSongIcon;
                    _prevSongButton.ImageAlign        = ContentAlignment.MiddleLeft;
                    _prevSongButton.TextImageRelation = TextImageRelation.ImageBeforeText;
                }
                _prevSongButton.Paint += plbl_Paint;
                _prevSongButton.Click += plbl_ClickPrev;

                pnl.Controls.Add(_prevSongButton);

                Controls.Add(pnl);

                ypos += pnl.Height;

                ypos += AddSpacer(ypos);
            }

            if (showFirstLastBackgrounds)
            {
                List <PartPanelElement> fe = new List <PartPanelElement>
                {
                    new PartPanelElement
                    {
                        Background = parts[0].Slides[0].Background
                    }
                };
                ypos += AddPartCopmponent(ypos, fe, ThumbnailSize.Height, labelSize, -1, null);
            }

            for (int i = 0; i < parts.Count; i++)
            {
                List <PartPanelElement> elements = parts[i].Slides.Select(e => new PartPanelElement
                {
                    Text       = e.GetOneLineText(),
                    Background = e.Background
                }).ToList();
                int partIdx = i;
                if (SongViewMode == SongViewMode.Sequence)
                {
                    for (int j = 0; j < sng.Parts.Count; j++)
                    {
                        if (parts[i].Equals(sng.Parts[j]))
                        {
                            partIdx = j;
                            break;
                        }
                    }
                }
                ypos += AddPartCopmponent(ypos, elements, ThumbnailSize.Height, labelSize, partIdx, parts[i].Caption);
            }

            if (showFirstLastBackgrounds)
            {
                List <PartPanelElement> fe2 = new List <PartPanelElement>
                {
                    new PartPanelElement
                    {
                        Background = parts[parts.Count - 1].Slides[parts[parts.Count - 1].Slides.Count - 1].Background
                    }
                };
                ypos += AddPartCopmponent(ypos, fe2, ThumbnailSize.Height, labelSize, -1, null);
            }

            if (nextSong != null)
            {
                Size measured = TextRenderer.MeasureText(nextSong.Title, _prevNextSongFont);

                int buttonHeight = measured.Height + 6 + (2 * SongSwitchPanelPadding);

                // Add panel for next song
                Panel pnl = new Panel
                {
                    Location = new Point(LeftMargin, ypos),
                    Height   = buttonHeight
                };
                pnl.Paint += songSwitchPnl_Paint;

                // Add song title to panel
                _nextSongButton = new Button
                {
                    Location  = new Point(0, 0),
                    Height    = buttonHeight,
                    Text      = @" " + nextSong.Title,
                    Font      = _slideTextFont,
                    TextAlign = ContentAlignment.MiddleLeft,
                    Tag       = nextSong,
                    FlatStyle = FlatStyle.Flat,
                    Padding   = new Padding(SongSwitchPanelPadding),
                    Cursor    = Cursors.Hand
                };
                _nextSongButton.FlatAppearance.BorderColor = Color.White;
                _nextSongButton.FlatAppearance.BorderSize  = 0;
                _nextSongButton.Paint += plbl_Paint;
                _nextSongButton.Click += plbl_ClickNext;
                if (NextSongIcon != null)
                {
                    _nextSongButton.Image             = NextSongIcon;
                    _nextSongButton.ImageAlign        = ContentAlignment.MiddleLeft;
                    _nextSongButton.TextImageRelation = TextImageRelation.ImageBeforeText;
                }

                pnl.Controls.Add(_nextSongButton);

                Controls.Add(pnl);

                ypos += pnl.Height;
            }

            Panel lpnl = new Panel
            {
                Location  = new Point(LeftMargin, ypos + BottomMargin - 1),
                BackColor = Color.White,
                Height    = 1
            };

            Controls.Add(lpnl);

            _currentSong = sng;

            ResumeLayout();

            if (_selectAfterLoad == SelectAfterLoad.First && _slideTexts.Count > 0)
            {
                _selectAfterLoad = SelectAfterLoad.None;
                _slideTexts[0].Focus();
                textLbl_Click(_slideTexts[0], new EventArgs());
            }
            else if (_selectAfterLoad == SelectAfterLoad.Last && _slideTexts.Count > 0)
            {
                _selectAfterLoad = SelectAfterLoad.None;
                _slideTexts[_slideTexts.Count - 1].Focus();
                textLbl_Click(_slideTexts[_slideTexts.Count - 1], new EventArgs());
            }
        }