Esempio n. 1
0
        /// <summary>
        /// Invoked when the user selects to rename a playlist item.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        public void RenamePlaylist_Clicked(object sender, RoutedEventArgs e)
        {
            EditableTextBlock etb = sender as EditableTextBlock;

            if (etb == null && sender is TreeViewItem)
            {
                etb = Tvi2Etb(sender as TreeViewItem);
            }
            if (etb == null)
            {
                etb = Tvi2Etb(NavigationTree.SelectedItem as TreeViewItem);
            }
            if (etb == null || !etb.IsEditable)
            {
                return;
            }
            var playlist = PlaylistManager.FindPlaylist(etb.Text);

            // do not rename playlists we don't own
            if (PlaylistManager.IsSomeoneElses(playlist))
            {
                return;
            }

            etb.IsInEditMode = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Invoked when the user right-clicks on a playlist
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        public void Playlist_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            TreeViewItem tvi = sender as TreeViewItem;

            if (tvi == null)
            {
                return;
            }
            if (!tvi.IsSelected)
            {
                rightClickedTvi = tvi;
                tvi.IsSelected  = true;
            }

            playlistMenuRename.Visibility = Visibility.Visible;

            var dp = tvi.Header as DockPanel;

            if (dp == null)
            {
                return;
            }
            var etb = dp.Children[1] as EditableTextBlock;

            if (etb == null)
            {
                return;
            }
            var pl = PlaylistManager.FindPlaylist(etb.Text);

            if (pl == null)
            {
                return;
            }

            // do not rename playlists we don't own
            if (PlaylistManager.IsSomeoneElses(pl))
            {
                playlistMenuRename.Visibility = Visibility.Collapsed;
            }
        }