private bool FilterRow(object row) { if (string.IsNullOrEmpty(FullTextSearch)) { return(true); } string filterString = FullTextSearch.ToLower(); bool found = false; MyMusicListItem trackItem = row as MyMusicListItem; foreach (object value in trackItem.Items) { if (value != null) { if (CatalogView.CompareString(value.ToString(), filterString)) { found = true; break; } } } return(found); }
private void ButtonMultiLineEdit_Click(object sender, RoutedEventArgs e) { DataGridRow row = VisualTreeExtensions.FindParent <DataGridRow>(e.OriginalSource as DependencyObject); DataGridCell cell = VisualTreeExtensions.FindParent <DataGridCell>(e.OriginalSource as DependencyObject); Field field = (Field)cell.Column.GetValue(Big3.Hitbase.Controls.DataGridExtensions.FieldProperty); MyMusicListItem myMusicListItem = row.DataContext as MyMusicListItem; WindowMultiline wm = new WindowMultiline(); wm.Owner = Window.GetWindow(this); object textValue = myMusicListItem.Comment; if (textValue != null) { wm.Text = textValue.ToString(); } wm.Title = DataBase.GetNameOfField(field); if (wm.ShowDialog() == true) { // Im Moment hier nur Read-Only /* cell.IsEditing = true; * track.SetValueToField(field, wm.Text); * cell.IsEditing = false;*/ } }
private void UpdateMyMusicList(MyMusicListItem myMusicListItem) { FieldCollection fc = new FieldCollection(); int internalFieldsCount = 0; foreach (Field field in internalFields) { if (this.trackListFields.SingleOrDefault(x => x.Field == field) == null) { fc.Add(field); internalFieldsCount++; } } fc.AddRange(this.trackListFields.GetFields()); int soundFileIndex = fc.IndexOf(Field.TrackSoundFile); DataBaseView view = TrackView.CreateView(DataBase, fc, trackListSort, myMusicListItem.ID); object[] values = view.Read(); FillRowValues(myMusicListItem, values, soundFileIndex, internalFieldsCount); ListCollectionView lcv = this.dataGrid.ItemsSource as ListCollectionView; lcv.Refresh(); }
private void RatingCell_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { DataGridRow row = VisualTreeExtensions.FindParent <DataGridRow>((DependencyObject)e.OriginalSource); DataGridCell cell = VisualTreeExtensions.FindParent <DataGridCell>((DependencyObject)e.OriginalSource); DataGridColumn column = cell.Column; RatingUserControl ratingUserControl = sender as RatingUserControl; MyMusicListItem musicItem = row.DataContext as MyMusicListItem; dataGrid.CommitEdit(DataGridEditingUnit.Row, true); if (this.dataGrid.SelectedItems.Count > 1) { WpfMessageBoxResult result = WPFMessageBox.Show(Window.GetWindow(this), StringTable.MultiTagEdit, StringTable.MultiTagEditWarning, "/Big3.Hitbase.SharedResources;component/Images/RenameLarge.png", WpfMessageBoxButtons.YesNo, "MultiTagEdit", false); if (result == WpfMessageBoxResult.Yes) { Field field = (Field)column.GetValue(DataGridExtensions.FieldProperty); int columnIndex = column.DisplayIndex - 1; musicItem.Items[columnIndex] = ratingUserControl.Rating; PerformMultiEdit(musicItem, field, columnIndex); } } else { Field field = (Field)column.GetValue(DataGridExtensions.FieldProperty); musicItem.Items[column.DisplayIndex - 1] = ratingUserControl.Rating; EditTrackField(column.DisplayIndex - 1, field, musicItem); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string soundFile = null; Track track = value as Track; if (track != null) { soundFile = track.Soundfile; } MyMusicListItem listItem = value as MyMusicListItem; if (listItem != null) { soundFile = listItem.Soundfile; } if (string.IsNullOrEmpty(soundFile)) { if (Settings.Current.CurrentColorStyle == ColorStyle.Black) { return(Brushes.White); } else { return(Brushes.Black); } } else { if (File.Exists(soundFile)) { if (Settings.Current.CurrentColorStyle == ColorStyle.Black) { return(Brushes.LightGreen); } else { return(Brushes.DarkGreen); } } else { if (Settings.Current.CurrentColorStyle == ColorStyle.Black) { SolidColorBrush solidColorBrush = new SolidColorBrush(Color.FromArgb(255, 255, 192, 192)); solidColorBrush.Freeze(); return(solidColorBrush); } else { return(Brushes.DarkRed); } } } }
private void AddToPlaylistPlayLast(object sender, System.Windows.RoutedEventArgs e) { DataGridRow dataGridRow = VisualTreeExtensions.FindParent <DataGridRow>((System.Windows.DependencyObject)sender); MyMusicListItem myMusicListItem = dataGridRow.DataContext as MyMusicListItem; if (myMusicListItem != null) { string soundFile = DataBase.GetSoundfileByTrackId(myMusicListItem.ID); AddTracksFromSearchResult(soundFile, AddTracksToPlaylistType.End); } }
private void MenuItemAddTracksToPlaylistPreListen_Click(object sender, RoutedEventArgs e) { if (dataGrid.SelectedItems.Count == 0) { return; } MyMusicListItem item = dataGrid.SelectedItems[0] as MyMusicListItem; Track track = DataBase.GetTrackById(item.ID); HitbaseCommands.PreListenTrack.Execute(track, this); }
private void AddToPlaylistPreListen(object sender, System.Windows.RoutedEventArgs e) { DataGridRow dataGridRow = VisualTreeExtensions.FindParent <DataGridRow>((System.Windows.DependencyObject)sender); MyMusicListItem myMusicListItem = dataGridRow.DataContext as MyMusicListItem; if (myMusicListItem != null) { Track track = DataBase.GetTrackById(myMusicListItem.ID); HitbaseCommands.PreListenTrack.Execute(track, this); } }
private void PerformMultiEdit(MyMusicListItem musicItem, Field field, int columnIndex) { WaitProgressUserControl waitProgressUserControl = new WaitProgressUserControl(); GlobalServices.ModalService.NavigateTo(waitProgressUserControl, StringTable.MultiTagEdit, delegate(bool returnValue) { }, false); waitProgressUserControl.progressBar.Maximum = dataGrid.SelectedItems.Count; List <MyMusicListItem> selectedItems = new List <MyMusicListItem>(); foreach (MyMusicListItem item in dataGrid.SelectedItems) { selectedItems.Add(item); } BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += delegate { for (int i = 0; i < selectedItems.Count; i++) { MyMusicListItem item = selectedItems[i]; item.Items[columnIndex] = musicItem.Items[columnIndex]; EditTrackField(columnIndex, field, item); if (waitProgressUserControl.Canceled) { break; } this.Dispatcher.Invoke((Action)(() => { waitProgressUserControl.progressBar.Value++; })); } }; bw.RunWorkerCompleted += delegate(object completedSender, RunWorkerCompletedEventArgs completedEventArgs) { if (completedEventArgs.Error != null) { UnhandledExceptionWindow unhandledExceptionWindow = new UnhandledExceptionWindow(completedEventArgs.Error); unhandledExceptionWindow.ShowDialog(); } GlobalServices.ModalService.CloseModal(); UpdateList(); }; bw.RunWorkerAsync(); }
int IComparer.Compare(object X, object Y) { int result = 0; int columnIndex = 0; foreach (DataGridSortColumn sortItem in columnSortDirections) { // Erst Spalte abziehen columnIndex = sortItem.Index - 1; MyMusicListItem albumItem1 = (MyMusicListItem)X; MyMusicListItem albumItem2 = (MyMusicListItem)Y; if (albumItem1.Items[columnIndex] is Int32) { int val1 = albumItem1.Items[columnIndex] is DBNull ? 0 : (int)albumItem1.Items[columnIndex]; int val2 = albumItem2.Items[columnIndex] is DBNull ? 0 : (int)albumItem2.Items[columnIndex]; result = Int32Compare(val1, val2, sortItem.SortDirection); } else if (IsDateField(Fields[columnIndex].Field)) { DateTime val1 = albumItem1.Items[columnIndex] is DBNull ? DateTime.MinValue : (DateTime)albumItem1.Items[columnIndex]; DateTime val2 = albumItem2.Items[columnIndex] is DBNull ? DateTime.MinValue : (DateTime)albumItem2.Items[columnIndex]; result = DateTimeCompare(val1, val2, sortItem.SortDirection); } else if (Fields[columnIndex].Field == Field.ArchiveNumber && Settings.Current.SortArchiveNumberNumeric) { int val1 = albumItem1.Items[columnIndex] is DBNull ? 0 : Misc.Atoi((string)albumItem1.Items[columnIndex]); int val2 = albumItem2.Items[columnIndex] is DBNull ? 0 : Misc.Atoi((string)albumItem2.Items[columnIndex]); result = Int32Compare(val1, val2, sortItem.SortDirection); } else { string str1 = albumItem1.Items[columnIndex].ToString(); string str2 = albumItem2.Items[columnIndex].ToString(); result = StringCompare(str1, str2, sortItem.SortDirection); } if (result != 0) { return(result); } } return(result); }
private void dataGrid_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) { DataGridRow row = VisualTreeExtensions.FindParent <DataGridRow>(e.OriginalSource as DependencyObject); if (row != null) { dataGrid.CancelEdit(DataGridEditingUnit.Row); MyMusicListItem listItem = ((MyMusicListItem)row.DataContext); Track track = DataBase.GetTrackById(listItem.ID); HitbaseCommands.OpenTrack.Execute(track, this); e.Handled = true; UpdateMyMusicList(listItem); } }
private void dataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) { if (!isManualEditCommit) { isManualEditCommit = true; try { MyMusicListItem musicItem = e.Row.DataContext as MyMusicListItem; DataGrid grid = (DataGrid)sender; grid.CommitEdit(DataGridEditingUnit.Row, true); if (this.dataGrid.SelectedItems.Count > 1) { WpfMessageBoxResult result = WPFMessageBox.Show(Window.GetWindow(this), StringTable.MultiTagEdit, StringTable.MultiTagEditWarning, "/Big3.Hitbase.SharedResources;component/Images/RenameLarge.png", WpfMessageBoxButtons.YesNo, "MultiTagEdit", false); if (result == WpfMessageBoxResult.Yes) { Field field = (Field)e.Column.GetValue(DataGridExtensions.FieldProperty); int columnIndex = e.Column.DisplayIndex - 1; PerformMultiEdit(musicItem, field, columnIndex); } } else { Field field = (Field)e.Column.GetValue(DataGridExtensions.FieldProperty); EditTrackField(e.Column.DisplayIndex - 1, field, musicItem); } } finally { isManualEditCommit = false; } } } }
void bwTrackList_DoWork(object sender, DoWorkEventArgs e) { SafeObservableCollection <MyMusicListItem> items = new SafeObservableCollection <MyMusicListItem>(); int count = 0; FieldCollection fc = new FieldCollection(); int internalFieldsCount = 0; foreach (Field field in internalFields) { if (this.trackListFields.SingleOrDefault(x => x.Field == field) == null) { fc.Add(field); internalFieldsCount++; } } fc.AddRange(this.trackListFields.GetFields()); int soundFileIndex = fc.IndexOf(Field.TrackSoundFile); Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree); using (DataBaseView view = TrackView.CreateView(this.DataBase, fc, this.trackListSort, 0, searchCondition)) { object[] values; while ((values = view.Read()) != null) { MyMusicListItem newItem = new MyMusicListItem(); FillRowValues(newItem, values, soundFileIndex, internalFieldsCount); items.AddItemFromThread(newItem); count++; } } e.Result = items; }
private void EditTrackField(int column, Field field, MyMusicListItem musicItem) { #if false int cdId = DataBase.GetCDIDByTrackID(musicItem.ID); CD cd = DataBase.GetCDById(cdId); int trackIndex = cd.FindTrackIndexByTrackID(musicItem.ID); object newValue = musicItem.Items[column]; if (FieldHelper.IsCDField(field)) { cd.SetValueToField(field, newValue); } else { cd.SetTrackValueToField(trackIndex, field, newValue); } //cd.Save(DataBase, cd.Tracks[trackIndex]); Big3.Hitbase.SoundEngine.SoundFileInformation.WriteMP3Tags(cd, musicItem.ID); Big3.Hitbase.SoundFilesManagement.SynchronizeCatalogWorker.Instance.ScanFile(cd.Tracks[trackIndex].Soundfile); #endif SoundFileInformation sfi = SoundFileInformation.GetSoundFileInformation(musicItem.Soundfile); object newValue = musicItem.Items[column]; if (newValue != null) { sfi.SetField(field, newValue.ToString()); } else { sfi.SetField(field, ""); } Big3.Hitbase.SoundEngine.SoundFileInformation.WriteMP3Tags(sfi, field); Big3.Hitbase.SoundFilesManagement.SynchronizeCatalogWorker.Instance.ScanFile(musicItem.Soundfile); }
private void FillRowValues(MyMusicListItem newItem, object[] values, int soundFileIndex, int internalFieldsCount) { FieldCollection fc = this.trackListFields.GetFields(); newItem.ID = (int)values[0]; newItem.Soundfile = values[soundFileIndex + 1] is DBNull ? "" : (string)values[soundFileIndex + 1]; newItem.Items = new object[values.Length - internalFieldsCount - 1]; for (int i = internalFieldsCount + 1; i < values.Length; i++) { if (fc[i - internalFieldsCount - 1] == Field.Comment) { newItem.Comment = values[i] is DBNull ? "" : (string)values[i]; } else { newItem.Items[i - internalFieldsCount - 1] = values[i]; } } }
public new void Drop(Controls.DragDrop.IDropInfo dropInfo) { List <WishlistItem> wishlistItems = new List <WishlistItem>(); if (dropInfo.Data is PlaylistItem) { PlaylistItem playlistItem = dropInfo.Data as PlaylistItem; WishlistItem item = new WishlistItem(); item.Artist = playlistItem.Info.Artist; item.Title = playlistItem.Info.Title; item.TrackID = playlistItem.ID; wishlistItems.Add(item); } if (dropInfo.Data is Track || dropInfo.Data is List <Track> ) { // Prüfen, ob ein Track einer CD gedropped wurde MainCDUserControl mainCDUserControl = VisualTreeExtensions.FindParent <MainCDUserControl>(dropInfo.DragInfo.VisualSource); if (mainCDUserControl != null) { } else { Track track = dropInfo.Data as Track; List <Track> trackList = dropInfo.Data as List <Track>; if (track != null) { WishlistItem item = GetWishlistItemByTrack(track); wishlistItems.Add(item); } if (trackList != null) { foreach (Track trackItem in trackList) { WishlistItem item = GetWishlistItemByTrack(track); wishlistItems.Add(item); } } } } if (dropInfo.Data is MyMusicListItem) { MyMusicListItem item = dropInfo.Data as MyMusicListItem; Track track = DataBase.GetTrackById(item.ID); AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter(); addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex; addTracksParams.InsertIndex = dropInfo.InsertIndex; addTracksParams.Filenames.Add(track.Soundfile); HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this); } if (dropInfo.Data is List <MyMusicListItem> ) { List <MyMusicListItem> items = dropInfo.Data as List <MyMusicListItem>; AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter(); addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex; addTracksParams.InsertIndex = dropInfo.InsertIndex; foreach (MyMusicListItem item in items) { addTracksParams.Filenames.Add(item.Soundfile); } HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this); } if (wishlistItems.Count > 0) { HitbaseCommands.AddToWishlist.Execute(wishlistItems, System.Windows.Application.Current.MainWindow); } }
public new void Drop(Controls.DragDrop.IDropInfo dropInfo) { if (dropInfo.Data is PlaylistItem) { Controls.DragDrop.DragDrop.DefaultDropHandler.Drop(dropInfo); } if (dropInfo.Data is Big3.Hitbase.CDUtilities.WishlistItem) { Big3.Hitbase.CDUtilities.WishlistItem wishlistItem = dropInfo.Data as Big3.Hitbase.CDUtilities.WishlistItem; AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter(); addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex; addTracksParams.InsertIndex = dropInfo.InsertIndex; addTracksParams.TrackIds.Add(wishlistItem.TrackID); HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this); } if (dropInfo.Data is AlbumViewItem) { AlbumViewItem item = dropInfo.Data as AlbumViewItem; CD cd = DataBase.GetCDById(item.ID); AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter(); addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex; addTracksParams.InsertIndex = dropInfo.InsertIndex; foreach (Track track in cd.Tracks) { addTracksParams.TrackIds.Add(track.ID); } HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this); } if (dropInfo.Data is AlbumItem) { AlbumItem item = dropInfo.Data as AlbumItem; CD cd = DataBase.GetCDById(item.ID); AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter(); addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex; addTracksParams.InsertIndex = dropInfo.InsertIndex; foreach (Track track in cd.Tracks) { addTracksParams.TrackIds.Add(track.ID); } HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this); } if (dropInfo.Data is Track || dropInfo.Data is List <Track> ) { // Prüfen, ob ein Track einer CD gedropped wurde MainCDUserControl mainCDUserControl = VisualTreeExtensions.FindParent <MainCDUserControl>(dropInfo.DragInfo.VisualSource); if (mainCDUserControl != null) { Track track = dropInfo.Data as Track; List <Track> trackList = dropInfo.Data as List <Track>; AddCDTracksToPlaylistParameter addTracksParams = new AddCDTracksToPlaylistParameter(); addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex; addTracksParams.InsertIndex = dropInfo.InsertIndex; if (track != null) { addTracksParams.Tracks.Add(track); } if (trackList != null) { addTracksParams.Tracks.AddRange(trackList); } HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this); } else { Track track = dropInfo.Data as Track; List <Track> trackList = dropInfo.Data as List <Track>; AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter(); addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex; addTracksParams.InsertIndex = dropInfo.InsertIndex; if (track != null) { addTracksParams.TrackIds.Add(track.ID); } if (trackList != null) { foreach (Track trackItem in trackList) { addTracksParams.TrackIds.Add(trackItem.ID); } } HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this); } } if (dropInfo.Data is MyMusicListItem) { MyMusicListItem item = dropInfo.Data as MyMusicListItem; AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter(); addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex; addTracksParams.InsertIndex = dropInfo.InsertIndex; addTracksParams.TrackIds.Add(item.ID); HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this); } if (dropInfo.Data is List <MyMusicListItem> ) { List <MyMusicListItem> items = dropInfo.Data as List <MyMusicListItem>; AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter(); addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex; addTracksParams.InsertIndex = dropInfo.InsertIndex; foreach (MyMusicListItem item in items) { addTracksParams.TrackIds.Add(item.ID); } HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this); } if (dropInfo.Data is DataObject) { DataObject dataObject = dropInfo.Data as DataObject; if (dataObject.GetDataPresent(DataFormats.FileDrop)) { AddTracksToPlaylistParameter addTracksParams = new AddTracksToPlaylistParameter(); addTracksParams.AddTracksType = AddTracksToPlaylistType.InsertAtIndex; addTracksParams.InsertIndex = dropInfo.InsertIndex; foreach (string item in dataObject.GetFileDropList()) { addTracksParams.Filenames.Add(item); } HitbaseCommands.AddTracksToPlaylist.Execute(addTracksParams, this); } } }