예제 #1
0
 private void VmOnPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName != nameof(vm.CurrentIndex) || TracksDataGrid.Items.IsEmpty)
     {
         return;
     }
     TracksDataGrid.ScrollIntoView(TracksDataGrid.Items[vm.CurrentIndex]);
 }
        //    public class TrackRow: INotifyPropertyChanged {
        //      public PlaylistTrack PlaylistTrack { get;}
        //      public Track Track { get; }
        //      public string LocationLower { get; }
        //      public string AlbumLower { get; }
        //      public string ArtistsLower { get; }
        //      public string ComposersLower { get; }
        //      public string PublisherLower { get; }
        //      public string TitleLower { get; }
        //      public bool IsAdditionalTrack { get; }
        //      public Brush RowBackground { get; }
        //      public int PlaylistTrackNo {
        //        get {
        //          return playlistTrackNo;
        //        }
        //        set {
        //          if (playlistTrackNo!=value) {
        //            playlistTrackNo = value;
        //            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PlaylistTrackNo)));
        //          }
        //        }
        //      }
        //      int playlistTrackNo;
        //      public int PlaylistTrackNoOld { get; }


        //      /// <summary>
        //      /// Track is marked for removal from playlist
        //      /// </summary>
        //      public bool IsRemoval {
        //        get {
        //          return isRemoval;
        //        }
        //        set {
        //          if (isRemoval!=value) {
        //            isRemoval = value;
        //            //**--updatePlaylistCheckBox();
        //            HasIsRemovalChanged?.Invoke();
        //          }
        //        }
        //      }
        //      bool isRemoval;


        //      /// <summary>
        //      /// User selected this track for adding to playlist OR CheckBox is disabled and displays that the track is already in the playlist
        //      /// </summary>
        //      public bool IsAddPlaylist {
        //        get {
        //          return isAddPlaylist;
        //        }
        //        set {
        //          if (isAddPlaylist!=value) {
        //            isAddPlaylist = value;
        //            HasIsAddPlaylistChanged?.Invoke();
        //            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsAddPlaylist)));
        //          }
        //        }
        //      }
        //      bool isAddPlaylist;


        //      /// <summary>
        //      /// Playlist CheckBox is visible if a playlist name is entered and track is not marked for deletion
        //      /// </summary>
        //      public Visibility PlaylistCheckBoxVisibility {
        //        get {
        //          return playlistCheckBoxVisibility;
        //        }
        //        set {
        //          if (playlistCheckBoxVisibility!=value) {
        //            playlistCheckBoxVisibility = value;
        //            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PlaylistCheckBoxVisibility)));
        //          }
        //        }
        //      }
        //      Visibility playlistCheckBoxVisibility;


        //      /// <summary>
        //      /// Playlist CheckBox is disabled when the track is already in the playlist
        //      /// </summary>
        //      public bool PlaylistCheckBoxIsEnabled {
        //        get {
        //          return playlistCheckBoxIsEnabled;
        //        }
        //        set {
        //          if (playlistCheckBoxIsEnabled!=value) {
        //            playlistCheckBoxIsEnabled = value;
        //            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PlaylistCheckBoxIsEnabled)));
        //          }
        //        }
        //      }
        //      bool playlistCheckBoxIsEnabled;
        //      public event PropertyChangedEventHandler? PropertyChanged;


        //#pragma warning disable CA2211 // Non-constant fields should not be visible
        //      public static Action? HasIsRemovalChanged;
        //      public static Action? HasIsAddPlaylistChanged;
        //#pragma warning restore CA2211

        //      static readonly Brush highlightedBackgroundBrush = new SolidColorBrush(Color.FromRgb(0xDF, 0xF1, 0xFA));


        //      public TrackRow(PlaylistTrack playlistTrack, bool isAdditionalTrack = false) {
        //        PlaylistTrack = playlistTrack;
        //        Track = playlistTrack.Track;
        //        LocationLower = Track.Location.Name.ToLowerInvariant();
        //        ArtistsLower = Track.Artists?.ToLowerInvariant()??"";
        //        AlbumLower = Track.Album?.ToLowerInvariant()??"";
        //        ComposersLower = Track.Composers?.ToLowerInvariant()??"";
        //        PublisherLower = Track.Publisher?.ToLowerInvariant()??"";
        //        TitleLower = Track.Title?.ToLowerInvariant()??"";
        //        IsAdditionalTrack = isAdditionalTrack;
        //        RowBackground = isAdditionalTrack ? highlightedBackgroundBrush : Brushes.White;
        //        PlaylistTrackNoOld = PlaylistTrackNo = playlistTrack.TrackNo;
        //        isRemoval = false;
        //        isAddPlaylist = false;
        //      }
        //    }
        #endregion


        #region Events
        //      ------

        private void playlistWindow_Loaded(object sender, RoutedEventArgs e)
        {
            PlaylistNameTextBox.Focus();
            if (firstAddedTrackRow is not null)
            {
                TracksDataGrid.ScrollIntoView(firstAddedTrackRow);
            }

            AddToOtherPlaylistComboBox.SelectionChanged += addToOtherPlaylistComboBox_SelectionChanged;
            AddToOtherPlaylistComboBox.AddHandler(TextBoxBase.TextChangedEvent, new RoutedEventHandler(addToOtherPlaylistComboBox_TextChanged));
            AddToOtherPlaylistComboBox.LostFocus += addToOtherPlaylistComboBox_LostFocus;
            updatePlaylistCheckBoxes();
        }