public TestPlayerControlWindow()
        {
            InitializeComponent();

            TraceTextBox.Text =
                "Copyrights: " + Environment.NewLine +
                "Music promoted by https://www.free-stock-music.com" + Environment.NewLine +
                @"Track1: Stream Countdown(10s) by Alexander Nakarada | https://www.serpentsoundstudios.com
Attribution 4.0 International(CC BY 4.0)
https://creativecommons.org/licenses/by/4.0/" + Environment.NewLine + Environment.NewLine +

                @"Track2: Humorous And Comic Intro by Free Music | https://soundcloud.com/fm_freemusic
Creative Commons Attribution 3.0 Unported License
https://creativecommons.org/licenses/by/3.0/deed.en_US" + Environment.NewLine + Environment.NewLine +

                @"Track3: Music Logo For Storytelling by Free Music | https://soundcloud.com/fm_freemusic
Creative Commons Attribution 3.0 Unported License
https://creativecommons.org/licenses/by/3.0/deed.en_US" + Environment.NewLine + Environment.NewLine +

                @"Track4: Happy Media Music Opener by Free Music | https://soundcloud.com/fm_freemusic
Creative Commons Attribution 3.0 Unported License
https://creativecommons.org/licenses/by/3.0/deed.en_US" + Environment.NewLine + Environment.NewLine +

                "MediaPlayer test trace" + Environment.NewLine +
                "======================" + Environment.NewLine;
            _ = new DC(null);
            projectDirectory = new DirectoryInfo(Environment.CurrentDirectory).Parent !.Parent !.Parent !.Parent !;
            location         = new Location("locationPath", projectDirectory.FullName, isStoring: false);

            track1 = new Track(new FileInfo(projectDirectory.FullName + @"\track1.mp3"), location, isStoring: false);
            track2 = new Track(new FileInfo(projectDirectory.FullName + @"\track2.mp3"), location, isStoring: false);
            track3 = new Track(new FileInfo(projectDirectory.FullName + @"\track3.mp3"), location, isStoring: false);
            track4 = new Track(new FileInfo(projectDirectory.FullName + @"\track4.mp3"), location, isStoring: false);
            var errorFileName = projectDirectory.FullName + @"\trackError.mp3";

            File.Copy(track4.FullFileName, errorFileName, overwrite: true);
            trackError = new Track(new FileInfo(errorFileName), location, isStoring: false);
            trackError.Update(
                "TrackCausingError",
                trackError.Album,
                trackError.AlbumTrack,
                trackError.Artists,
                trackError.Composers,
                trackError.Publisher,
                trackError.Year,
                trackError.Genres,
                trackError.Weight,
                trackError.Volume,
                trackError.SkipStart,
                trackError.SkipEnd,
                trackError.TitleArtists);
            File.Delete(errorFileName);
            allTracks = new List <Track> {
                track1, track2, track3, track4
            };
            allTracksPlayinglist = new Playinglist(allTracks);

            Player.Current !.Traced += Player_Traced;
            TrackPlayer.Init(getPlayinglist);


            Play1Button.Click           += Play1Button_Click;
            Play2Button.Click           += Play2Button_Click;
            PlayAllButton.Click         += PlayAllButton_Click;
            PlayErrorButton.Click       += PlayErrorButton_Click;
            IsTracePositionButton.Click += IsTracePositionButton_Click;
        }
        public PlaylistWindow(
            Playlist?playlist = null,
            IEnumerable <PlaylistTrack>?additionalPlaylistTracks = null,
            Action?refreshOwner = null)
        {
            this.playlist     = playlist;
            this.refreshOwner = refreshOwner;

            InitializeComponent();

            Width  = SystemParameters.PrimaryScreenWidth * .8;
            Height = SystemParameters.PrimaryScreenHeight * .8;

            Loaded  += playlistWindow_Loaded;
            Closing += PlaylistWindow_Closing;
            Closed  += playlistWindow_Closed;

            //tracks
            tracks    = new();
            trackRows = new();
            var trackNo = 0;

            totalDuration = TimeSpan.Zero;
            locations     = new();
            albums        = new();
            artists       = new();
            genres        = new();
            years         = new();

            if (playlist is not null)
            {
                //there is usually a playlist, except when VS tries to display PlaylistWindow
                PlaylistNameTextBox.Text = playlist.Name;
                foreach (var playlistTrack in playlist.PlaylistTracks.GetStoredItems().OrderBy(plt => plt.TrackNo))
                {
                    tracks.Add(playlistTrack.Track);
                    var isAdditionalTrack = additionalPlaylistTracks?.Contains(playlistTrack) ?? false;
                    var trackRow          = new TrackRow(ref trackNo, playlistTrack, updateSelectedCountTextBox, isAdditionalTrack);
                    trackRows.Add(trackRow);
                    if (isAdditionalTrack && firstAddedTrackRow is null)
                    {
                        firstAddedTrackRow = trackRow;
                    }
                }
                DurationTextBox.Text = playlist.TracksDurationHhMm;
                DC.GetTracksStats(ref totalDuration, locations, albums, artists, genres, years, tracks);
            }

            PlaylistNameTextBox.TextChanged += playlistNameTextBox_TextChanged;
            TracksCountTextBox.Text          = tracks.Count.ToString();

            //filter
            FilterTextBox.TextChanged          += filterTextBox_TextChanged;
            ArtistComboBox.SelectionChanged    += filterComboBox_SelectionChanged;
            ArtistComboBox.ItemsSource          = artists;
            AlbumComboBox.SelectionChanged     += filterComboBox_SelectionChanged;
            AlbumComboBox.ItemsSource           = albums;
            AlbumComboBox.DisplayMemberPath     = "AlbumArtist";
            GenreComboBox.SelectionChanged     += filterComboBox_SelectionChanged;
            GenreComboBox.ItemsSource           = genres;
            YearComboBox.SelectionChanged      += yearComboBox_SelectionChanged;
            YearComboBox.ItemsSource            = years;
            LocationsComboBox.SelectionChanged += filterComboBox_SelectionChanged;
            LocationsComboBox.ItemsSource       = locations;
            RemoveCheckBox.Click      += checkBox_Click;
            PlaylistCheckBox.Click    += checkBox_Click;
            ClearButton.Click         += clearButton_Click;
            RemoveAllButton.Click     += removeAllButton_Click;
            PLAllButton.Click         += plAllButton_Click;
            UnselectAllButton.Click   += unselectAllButton_Click;
            ExecuteRemoveButton.Click += executeRemoveButton_Click;
            AddToOtherPlaylistComboBox.ItemsSource = DC.Data.PlaylistStrings.Where(pls => pls != PlaylistNameTextBox.Text);
            AddToOtherPlaylistButton.Click        += addToOtherPlaylistButton_Click;

            //datagrid
            tracksViewSource        = ((System.Windows.Data.CollectionViewSource) this.FindResource("TracksViewSource"));
            tracksViewSource.Source = trackRows;
            tracksViewSource.IsLiveSortingRequested = true;
            tracksViewSource.Filter += tracksViewSource_Filter;
            //strangely, it seems both following lines are needed to make sorting work properly
            TracksDataGrid.Columns[0].SortDirection = ListSortDirection.Ascending;
            tracksViewSource.View.SortDescriptions.Add(new SortDescription("PlaylistTrackNo", ListSortDirection.Ascending));
            TracksDataGrid.Sorting          += tracksDataGrid_Sorting;
            TracksDataGrid.SelectionChanged += tracksDataGrid_SelectionChanged;
            TracksDataGrid.LayoutUpdated    += TracksDataGrid_LayoutUpdated;
            BeginningButton.Click           += beginningButton_Click;
            UpPageButton.Click   += upPageButton_Click;
            UpRowButton.Click    += upRowButton_Click;
            DownRowButton.Click  += downRowButton_Click;
            DownPageButton.Click += downPageButton_Click;
            EndButton.Click      += endButton_Click;
            SaveButton.Click     += saveButton_Click;
            SaveButton.IsEnabled  = false;

            //Replaced: TracksDataGrid.MouseDoubleClick += tracksDataGrid_MouseDoubleClick;
            //Style rowStyle = new Style(typeof(DataGridRow));
            //rowStyle.Setters.Add(new EventSetter(DataGridRow.MouseDoubleClickEvent,
            //                         new MouseButtonEventHandler(tracksDataGrid_MouseDoubleClick)));
            //TracksDataGrid.RowStyle = rowStyle;
            TracksDataGrid.RowStyle.Setters.Add(new EventSetter(DataGridRow.MouseDoubleClickEvent,
                                                                new MouseButtonEventHandler(tracksDataGrid_MouseDoubleClick)));

            TrackPlayer.TrackChanged += trackPlayer_TrackChanged;
            TrackPlayer.Init(getPlayinglist);

            MainWindow.Register(this, "Playlist " + playlist?.Name);
        }