Exemplo n.º 1
0
 protected void OnPlaylistSelected(PlaylistSelectedEventArgs e)
 {
     if (PlaylistSelected != null)
     {
         PlaylistSelected(this, e);
     }
 }
Exemplo n.º 2
0
        private void treeView_MouseUp(object sender, MouseEventArgs e)
        {
            var treeNode = treeView.SelectedNode = treeView.GetNodeAt(e.X, e.Y);

            if (treeNode == null)
            {
                return;
            }

            if (e.Button == MouseButtons.Right)
            {
                if (treeNode != null)
                {
                    if (treeNode == this.treeView.Nodes["NodePlaylist"])
                    {
                        this.cntMnStrpMain.Show(treeView, e.Location);
                    }
                    else
                    {
                        var playlist = savedPlaylists.Where(m => m.Name == treeNode.Text).FirstOrDefault();

                        if (playlist.GetType() == typeof(AutoPlaylist <Song>))
                        {
                            this.cntMnStrpAutomaticPlaylist.Show(treeView, e.Location);
                        }
                        else
                        {
                            this.cntMnStrpSimplePlaylist.Show(treeView, e.Location);
                        }
                    }
                }
            }
            else if (e.Button == MouseButtons.Left)
            {
                if (treeNode != this.treeView.Nodes["NodePlaylist"])
                {
                    IPlaylist <Song> playlist = savedPlaylists.Where(m => m.Name == treeNode.Text).FirstOrDefault();

                    if (playlist != null)
                    {
                        this.CurrentPlaylist = playlist;
                    }
                    else
                    {
                        playlist = this.CurrentPlaylist;
                    }

                    if (playlist == null)
                    {
                        return;
                    }

                    PlaylistSelectedEventArgs ple = new PlaylistSelectedEventArgs(playlist.Name);
                    this.OnPlaylistSelected(ple);

                    PlaylistMediaLoadedEventArgs pmbe = new PlaylistMediaLoadedEventArgs();

                    if (ple != null)
                    {
                        foreach (IMedia path in playlist.Media)
                        {
                            if (SharedData.AudioFormats.Union(SharedData.VideoFormats).Contains(System.IO.Path.GetExtension(path.Filename)))
                            {
                                var targetSong = SharedData.Database.Song.Where(song => song.Filename == path.Filename).FirstOrDefault();

                                pmbe.Media = targetSong != null ? targetSong : SharedData.Id3SongCreator.CreateFromFile(path.Filename);

                                this.OnPlaylistMediaLoaded(pmbe);
                            }
                        }
                    }
                }
                else
                {
                    EventArgs ea = new EventArgs();
                    this.OnPlaylistNodeSelected(ea);
                }
            }
        }