public HelpWindow(Window ownerWindow) { InitializeComponent(); MainWindow.Register(this, "Help"); Width = ownerWindow.Width * 0.4; Height = ownerWindow.Height * 0.8; Left = ownerWindow.Left + ownerWindow.Width * 0.5; Top = ownerWindow.Top + ownerWindow.Height * 0.1; Closed += HelpWindow_Closed; }
public ImportWindow() { InitializeComponent(); Width = SystemParameters.PrimaryScreenWidth * .8; Height = SystemParameters.PrimaryScreenHeight * .8; Loaded += importWindow_Loaded; ChangeDirectoryButton.Click += changeDirectoryButton_Click; //filter FilterTextBox.TextChanged += filterTextBox_TextChanged; ArtistComboBox.SelectionChanged += filterComboBox_SelectionChanged; AlbumComboBox.SelectionChanged += filterComboBox_SelectionChanged; ComposerComboBox.SelectionChanged += filterComboBox_SelectionChanged; PublisherComboBox.SelectionChanged += filterComboBox_SelectionChanged; YearComboBox.SelectionChanged += yearComboBox_SelectionChanged; GenreComboBox.SelectionChanged += filterComboBox_SelectionChanged; ImportCheckBox.Click += filterCheckBox_Click; PlaylistCheckBox.Click += filterCheckBox_Click; ExistCheckBox.Click += filterCheckBox_Click; DuplicateCheckBox.Click += filterCheckBox_Click; ClearButton.Click += clearButton_Click; ImportAllButton.Click += importAllButton_Click; PLAllButton.Click += plAllButton_Click; UnselectAllButton.Click += unselectAllButton_Click; RenameTrackButton.Click += renameTrackButton_Click; //datagrid tracksViewSource = ((System.Windows.Data.CollectionViewSource) this.FindResource("TracksViewSource")); tracksViewSource.Filter += tracksViewSource_Filter; //Replaced: TracksDataGrid.MouseDoubleClick += tracksDataGrid_MouseDoubleClick; TracksDataGrid.RowStyle.Setters.Add(new EventSetter(DataGridRow.MouseDoubleClickEvent, new MouseButtonEventHandler(tracksDataGrid_MouseDoubleClick))); TracksDataGrid.KeyDown += tracksDataGrid_KeyDown; var contextMenu = new ContextMenu(); var renameMenuItem = new MenuItem { Header = "Rename" }; renameMenuItem.Click += renameMenuItem_Click; contextMenu.Items.Add(renameMenuItem); TracksDataGrid.ContextMenu = contextMenu; ImportButton.Click += importButton_Click; ImportButton.IsEnabled = false; TrackPlayer.TrackChanged += trackPlayer_TrackChanged; Closed += memberWindow_Closed; MainWindow.Register(this, "Import"); }
public SetupWindow(Setup setup, Action?refreshOwner = null) { this.setup = setup; this.refreshOwner = refreshOwner; InitializeComponent(); IntroFlowDocument.Blocks.Add(new Paragraph( new Run($"MusicPlayer always stores the storage locations in {setup.SetupFilePath}."))); CsvFilePathTextBox.Initialise(setup.CsvFilePath, isRequired: true); BackupFilePathTextBox.Initialise(setup.BackupFilePath); CsvTestFilePathTextBox.Initialise(setup.CsvTestFilePath); updateSaveButtonIsEnabled(); Loaded += SetupWindow_Loaded; BrowseDataDirButton.Click += BrowseDataDirButton_Click; BrowseBackupDirButton.Click += BrowseBackupDirButton_Click; BrowseTestDirButton.Click += BrowseTestDirButton_Click; SaveButton.Click += saveButton_Click; Closing += SetupWindow_Closing; Closed += SetupWindow_Closed; MainWindow.Register(this, "Setup"); }
public TrackRenameWindow(Track?track = null, Action <Track>?refreshOwner = null) { this.track = track; this.refreshOwner = refreshOwner; InitializeComponent(); Loaded += trackRenameWindow_Loaded; GoogleButton.Click += googleButton_Click; SaveButton.Click += saveButton_Click; Closed += trackRenameWindow_Closed; if (track is null || lastPath != new FileInfo(track.FullFileName).DirectoryName) { lastPath = null; lastAlbum = null; lastGenres = null; lastYear = null; } if (track is not null) { FileNameTextBox.Text = track.FileName; TitleTextBox.Text = track.Title; TitleTextBoxNew.Initialise(track.Title); AlbumTextBox.Text = track.Album; if (track.Album is not null) { AlbumTextBoxNew.Initialise(track.Album); } else if (lastAlbum is not null) { AlbumTextBoxNew.Initialise(lastAlbum); } else { AlbumTextBoxNew.Initialise(null); } AlbumTrackTextBox.Text = track.AlbumTrack.ToString(); AlbumTrackTextBoxNew.Initialise(track.AlbumTrack); ArtistsTextBox.Text = track.Artists; ArtistsTextBoxNew.Initialise(track.Artists); ComposersTextBox.Text = track.Composers; ComposersTextBoxNew.Initialise(track.Composers); GenresTextBox.Text = track.Genres; GenreEditComboBox.ItemsSource = DC.Data.Genres; int?genreIndex = 0; var isFound = false; foreach (var genre in DC.Data.Genres) { if (genre == track.Genres) { isFound = true; break; } genreIndex++; } string?text; if (isFound) { text = null; } else { genreIndex = null; text = track.Genres; } if (text is not null || genreIndex is not null) { GenreEditComboBox.Initialise(text, genreIndex); } else if (lastGenres is not null) { GenreEditComboBox.Initialise(lastGenres, null); } else { GenreEditComboBox.Initialise(null, null); } //GenreEditComboBox.Text = track.Genres; PublisherTextBox.Text = track.Publisher; PublisherTextBoxNew.Initialise(track.Publisher); YearTextBox.Text = track.Year.ToString(); if (track.Year is not null) { YearTextBoxNew.Initialise(track.Year); //} else if (lastYear is not null) { //too confusing // YearTextBoxNew.Initialise(lastYear); } else { YearTextBoxNew.Initialise(null); } MainWindow.Register(this, $"Rename {track.FileName}"); updateSaveButtonIsEnabled(); }
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); }