/// <summary>
 /// Shows the form as a dialog and the specified playlist.
 /// </summary>
 /// <param name="owner">The owner window.</param>
 /// <param name="playlist">The playlist.</param>
 /// <returns>The dialog result.</returns>
 public DialogResult ShowDialog(IWin32Window owner, Playlist playlist)
 {
     // Set the playlist.
     this.controlPlaylist.Playlist = playlist;
     // Set the title.
     this.Text = "Playlist {0} Properties".FormatWith(playlist.Id);
     // Open the dialog.
     return base.ShowDialog(owner);
 }
        /// <summary>
        /// Adds a new playlist to the list.
        /// </summary>
        /// <param name="playlist">The playlist.</param>
        public void Add(Playlist playlist)
        {
            ListViewItem item = new ListViewItem(
                new string[] {
                    playlist.Id,
                    playlist.Title,
                    playlist.Author != null ? playlist.Author.UserId : string.Empty
                },
                0);
            item.Tag = playlist;

            this.listView.Items.Add(item);
        }
        // Protected methods.
        /// <summary>
        /// An event handler called when a new playlist has been set.
        /// </summary>
        /// <param name="oldPlaylist">The old playlist.</param>
        /// <param name="newPlaylist">The new playlist.</param>
        protected virtual void OnPlaylistSet(Playlist oldPlaylist, Playlist newPlaylist)
        {
            // If the playlist has not changed, do nothing
            if (oldPlaylist == newPlaylist) return;

            if (null == newPlaylist)
            {
                this.labelTitle.Text = "No playlist selected";
                this.tabControl.Visible = false;
            }
            else
            {
                this.labelTitle.Text = newPlaylist.Title;
                this.textBoxId.Text = newPlaylist.Id;
                this.textBoxPublished.Text = newPlaylist.Published != null ? newPlaylist.Published.ToString() : string.Empty;
                this.textBoxUpdated.Text = newPlaylist.Updated.ToString();
                this.textBoxAuthor.Text = newPlaylist.Author != null ? newPlaylist.Author.UserId : string.Empty;
                this.textBoxSummary.Text = newPlaylist.Summary != null ? newPlaylist.Summary : string.Empty;
                this.textBoxCount.Text = newPlaylist.CountHint.ToString();
                this.tabControl.Visible = true;
            }

            this.tabControl.SelectedTab = this.tabPageGeneral;
            if (this.Focused)
            {
                this.textBoxId.Select();
                this.textBoxId.SelectionStart = 0;
                this.textBoxId.SelectionLength = 0;
            }
        }