Пример #1
0
        private bool FilterRow(object row)
        {
            if (string.IsNullOrEmpty(FullTextSearch))
            {
                return(true);
            }

            string filterString = FullTextSearch.ToLower();

            bool found = false;

            AlbumViewItem avi = row as AlbumViewItem;

            if (avi == null)
            {
                return(false);
            }

            if (CatalogView.CompareString(avi.Artist, filterString))
            {
                return(true);
            }
            if (CatalogView.CompareString(avi.Title, filterString))
            {
                return(true);
            }
            if (CatalogView.CompareString(avi.Genre, filterString))
            {
                return(true);
            }
            if (CatalogView.CompareString(avi.Year, filterString))
            {
                return(true);
            }
            if (CatalogView.CompareString(avi.ArchiveNumber, filterString))
            {
                return(true);
            }

            foreach (Track t in avi.Tracks)
            {
                if (CatalogView.CompareString(t.Artist, filterString))
                {
                    found = true;
                    break;
                }
                if (CatalogView.CompareString(t.Title, filterString))
                {
                    found = true;
                    break;
                }
            }

            return(found);
        }
Пример #2
0
 private void listBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (VisualTreeExtensions.FindParent <ListBoxItem>(e.OriginalSource as DependencyObject) != null)
     {
         AlbumViewItem selItem = listBox.SelectedItem as AlbumViewItem;
         if (selItem != null)
         {
             OpenCD(this, new EventArgs());
             UpdateAlbumViewItem(selItem);
         }
     }
 }
Пример #3
0
        private void UpdateAlbumViewItem(AlbumViewItem albumViewItem)
        {
            DataBaseView view = AlbumView.CreateView(DataBase, CdListFields.GetFields(), CdListSort, albumViewItem.ID);

            object[] values = view.Read();

            FillAlbumViewItem(albumViewItem, values);

            ListCollectionView lcv = this.listBox.ItemsSource as ListCollectionView;

            lcv.Refresh();
        }
        // I've isolated the layout specific code to this region. If you want to do something other than tiling, this is
        // where you'll make your changes

        /// <summary>
        /// Calculate the extent of the view based on the available size
        /// </summary>
        /// <param name="availableSize">available size</param>
        /// <param name="itemCount">number of data items</param>
        /// <returns></returns>
        private Size CalculateExtent(Size availableSize)
        {
            if (totalHeight > 0)
            {
                return(new Size(availableSize.Width, totalHeight));
            }
            // Die Gesamtgröße der Liste berechnen.
            ItemsControl itemsControl = ItemsControl.GetItemsOwner(this);

            // We need to access InternalChildren before the generator to work around a bug
            UIElementCollection     children  = this.InternalChildren;
            IItemContainerGenerator generator = this.ItemContainerGenerator;

            // Get the generator position of the first visible data item
            GeneratorPosition startPos = generator.GeneratorPositionFromIndex(0);

            using (generator.StartAt(startPos, GeneratorDirection.Forward, true))
            {
                for (int itemIndex = 0; itemIndex < itemsControl.Items.Count; ++itemIndex)
                {
                    itemsTopPosition.Add(totalHeight);

                    // Get or create the child
                    bool newlyRealized;
                    // UIElement child = generator.GenerateNext(out newlyRealized) as UIElement;

                    // generator.PrepareItemContainer(child);

                    // Measurements will depend on layout algorithm
                    //child.Measure(GetChildSize());
                    AlbumViewItem avi = itemsControl.Items[itemIndex] as AlbumViewItem;
                    if (avi != null)
                    {
                        double height = Math.Max((avi.Tracks.Count * 18) + 10, 110);        // Minimale Höhe eines Albums
                        height       = Math.Min(height, 367);                               // Maximale Höhe eines Albums
                        totalHeight += height;
                        itemsHeight.Add(height);
                    }
                    AlbumViewTitle title = itemsControl.Items[itemIndex] as AlbumViewTitle;
                    if (title != null)
                    {
                        double height = 18;
                        totalHeight += height;
                        itemsHeight.Add(height);
                    }
                }
            }

            generator.RemoveAll();

            // See how big we are
            return(new Size(this.ActualWidth, totalHeight));
        }
Пример #5
0
        private void ChoosePictureUserControl_ImageChanged(object sender, EventArgs e)
        {
            ChoosePictureUserControl choosePictureUserControl = sender as ChoosePictureUserControl;

            ListBoxItem item = VisualTreeExtensions.FindParent <ListBoxItem>(choosePictureUserControl as DependencyObject);

            if (item != null)
            {
                AlbumViewItem selItem = item.DataContext as AlbumViewItem;

                selItem.ImageFilename = choosePictureUserControl.ImageFilename;
            }
        }
Пример #6
0
        private void UpdateAlbumItem(AlbumViewItem albumItem)
        {
            CD cd = DataBase.GetCDById(albumItem.ID);

            albumItem.ArchiveNumber = cd.ArchiveNumber;
            albumItem.Artist        = cd.Artist;
            albumItem.Genre         = cd.Category;
            albumItem.ImageFilename = cd.CDCoverFrontFilename;
            albumItem.Title         = cd.Title;
            albumItem.Year          = cd.YearRecorded == 0 ? "" : cd.YearRecorded.ToString();
            albumItem.Tracks.Clear();
            foreach (Track track in cd.Tracks)
            {
                albumItem.Tracks.Add(track);
            }

            // ListCollectionView lcv = this.itemsControl.ItemsSource as ListCollectionView;
            // lcv.Refresh();
        }
Пример #7
0
        private bool FilterRow(object row)
        {
            if (string.IsNullOrEmpty(FullTextSearch))
            {
                return(true);
            }

            string filterString = FullTextSearch.ToLower();

            bool found = false;

            AlbumViewItem cdItem = row as AlbumViewItem;

            if (CatalogView.CompareString(cdItem.Artist, filterString))
            {
                found = true;
            }

            if (CatalogView.CompareString(cdItem.Title, filterString))
            {
                found = true;
            }

            if (CatalogView.CompareString(cdItem.Year, filterString))
            {
                found = true;
            }

            if (CatalogView.CompareString(cdItem.Genre, filterString))
            {
                found = true;
            }

            if (CatalogView.CompareString(cdItem.ArchiveNumber, filterString))
            {
                found = true;
            }

            return(found);
        }
Пример #8
0
        private void itemsControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListBoxItem listBoxItem = VisualTreeExtensions.FindParent <ListBoxItem>(e.OriginalSource as DependencyObject);

            if (listBoxItem != null && listBoxItem.DataContext is Track)
            {
                HitbaseCommands.OpenTrack.Execute(listBoxItem.DataContext, this);

                ListBoxItem   lbItem = VisualTreeExtensions.FindParent <ListBoxItem>(listBoxItem);
                AlbumViewItem item   = lbItem.DataContext as AlbumViewItem;
                UpdateAlbumItem(item);
            }
            else
            {
                if (listBoxItem != null && listBoxItem.DataContext is AlbumViewItem)
                {
                    OpenCD(this, new EventArgs());

                    AlbumViewItem item = listBoxItem.DataContext as AlbumViewItem;
                    UpdateAlbumItem(item);
                }
            }
        }
Пример #9
0
        private static AlbumViewItem FillAlbumViewItem(AlbumViewItem item, object[] values)
        {
            item.ID = (int)values[0];

            string artistDisplay = (string)values[1];
            string artist        = values[2] is DBNull ? "" : (string)values[2];
            string title         = values[3] as string;

            item.ID            = (int)values[0];
            item.Artist        = artistDisplay;
            item.Title         = title;
            item.ImageFilename = values[4] is DBNull ? "" : (string)values[4];
            item.Genre         = values[5] is DBNull ? "" : (string)values[5];
            item.ArchiveNumber = values[6] is DBNull ? "" : (string)values[6];
            int yearRecorded = values[7] is DBNull ? 0 : (int)values[7];

            if (yearRecorded > 0)
            {
                item.Year = yearRecorded.ToString();
            }

            return(item);
        }
Пример #10
0
        void bwCDList_DoWork(object sender, DoWorkEventArgs e)
        {
            int count = 0;

            SafeObservableCollection <AlbumViewItem> items = new SafeObservableCollection <AlbumViewItem>();

            Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree);

            using (DataBaseView view = AlbumView.CreateView(this.DataBase, this.CdListFields.GetFields(), this.CdListSort, 0, searchCondition))
            {
                object[] values;

                while ((values = view.Read()) != null)
                {
                    AlbumViewItem newItem = new AlbumViewItem();
                    FillAlbumViewItem(newItem, values);
                    items.AddItemFromThread(newItem);

                    count++;
                }
            }

            e.Result = items;
        }
Пример #11
0
        void bwAlbumView_DoWork(object sender, DoWorkEventArgs e)
        {
            FieldCollection fc = new FieldCollection();

            fc.AddRange(new Field[] { Field.CDID, Field.Title, Field.ArchiveNumber, Field.CDCoverFront, Field.YearRecorded,
                                      Field.TrackNumber, Field.TrackTitle, Field.TrackLength, Field.TrackRating, Field.TrackSoundFile,
                                      Field.ArtistCDName, Field.ArtistCDSaveAs, Field.ArtistTrackName, Field.Category, Field.ComposerTrackName });

            int count = 0;

            SortFieldCollection sfc = new SortFieldCollection();

            sfc.Add(Field.ArtistCDSaveAs);
            sfc.Add(Field.Title);
            sfc.Add(Field.CDID);
            // Die Verzeichnisansicht immer sortiert nach Dateiname
            if (this.ShowItemType == ShowItemType.Directory)
            {
                sfc.Add(Field.TrackSoundFile);
            }
            else
            {
                sfc.Add(Field.TrackNumber);
            }

            SafeObservableCollection <AlbumViewItemBase> items = new SafeObservableCollection <AlbumViewItemBase>();

            AlbumViewItem newItem         = null;
            string        lastArtist      = "";
            string        lastArtistTitle = "";
            string        lastTitle       = "";
            int           lastcdid        = 0;

            Big3.Hitbase.DataBaseEngine.Condition searchCondition = Big3.Hitbase.DataBaseEngine.Condition.Combine(Condition, ConditionFromTree);

            using (DataBaseView view = TrackView.CreateView(DataBase, fc, sfc, 0, searchCondition))
            {
                // Überall auf die Indizes 1 addieren, da die erste Spalte die TrackID ist.
                int colArtistName     = fc.IndexOf(Field.ArtistCDName) + 1;
                int colArtistSaveAs   = fc.IndexOf(Field.ArtistCDSaveAs) + 1;
                int colTitle          = fc.IndexOf(Field.Title) + 1;
                int colCDID           = fc.IndexOf(Field.CDID) + 1;
                int colFrontCover     = fc.IndexOf(Field.CDCoverFront) + 1;
                int colCategory       = fc.IndexOf(Field.Category) + 1;
                int colArchiveNumber  = fc.IndexOf(Field.ArchiveNumber) + 1;
                int colYearRecorded   = fc.IndexOf(Field.YearRecorded) + 1;
                int colTrackNumber    = fc.IndexOf(Field.TrackNumber) + 1;
                int colTrackTitle     = fc.IndexOf(Field.TrackTitle) + 1;
                int colTrackLength    = fc.IndexOf(Field.TrackLength) + 1;
                int colTrackRating    = fc.IndexOf(Field.TrackRating) + 1;
                int colTrackArtist    = fc.IndexOf(Field.ArtistTrackName) + 1;
                int colTrackComposer  = fc.IndexOf(Field.ComposerTrackName) + 1;
                int colTrackSoundFile = fc.IndexOf(Field.TrackSoundFile) + 1;
                int colTrackID        = 0;

                object[] values;

                while ((values = view.Read()) != null)
                {
                    string artistDisplay = values[colArtistName] is DBNull ? "" : (string)values[colArtistName];
                    string artist        = values[colArtistSaveAs] is DBNull ? "" : (string)values[colArtistSaveAs];
                    string title         = values[colTitle] is DBNull ? "" : (string)values[colTitle];
                    int    cdid          = (int)values[colCDID];

                    if (cdid != lastcdid)
                    {
                        if (newItem != null)
                        {
                            if (newItem.Artist != lastArtistTitle)
                            {
                                AlbumViewTitle albumTitle = new AlbumViewTitle();
                                albumTitle.Title = newItem.Artist;
                                items.Add(albumTitle);

                                lastArtistTitle = newItem.Artist;
                            }

                            items.Add(newItem);
                        }

                        newItem               = new AlbumViewItem();
                        newItem.ID            = cdid;
                        newItem.Artist        = artistDisplay;
                        newItem.Title         = title;
                        newItem.ImageFilename = values[colFrontCover] is DBNull ? "" : (string)values[colFrontCover];
                        newItem.Genre         = values[colCategory] is DBNull ? "" : (string)values[colCategory];
                        newItem.ArchiveNumber = values[colArchiveNumber] is DBNull ? "" : (string)values[colArchiveNumber];
                        int yearRecorded = values[colYearRecorded] is DBNull ? 0 : (int)values[colYearRecorded];
                        if (yearRecorded > 0)
                        {
                            newItem.Year = yearRecorded.ToString();
                        }

                        newItem.Tracks = new SafeObservableCollection <Track>();
                        lastArtist     = artist;
                        lastTitle      = title;
                    }

                    if (newItem != null)
                    {
                        Track track = new Track();
                        track.TrackNumber = (int)values[colTrackNumber];
                        track.Title       = values[colTrackTitle] is DBNull ? "" : (string)values[colTrackTitle];
                        track.Length      = (int)values[colTrackLength];
                        track.Rating      = values[colTrackRating] is DBNull ? 0 : (int)values[colTrackRating];
                        track.Artist      = values[colTrackArtist] is DBNull ? "" : (string)values[colTrackArtist];
                        track.Composer    = values[colTrackComposer] is DBNull ? "" : (string)values[colTrackComposer];
                        track.Soundfile   = values[colTrackSoundFile] is DBNull ? "" : (string)values[colTrackSoundFile];
                        track.CDID        = cdid;
                        track.ID          = (int)values[colTrackID];

                        newItem.Tracks.Add(track);
                    }

                    //toolStripStatusProgressBar.Value = (int)(100.0 / TrackView.Rows.Count * count);

                    count++;

                    lastcdid = cdid;
                }
            }


            if (newItem != null)
            {
                if (newItem.Artist != lastArtistTitle)
                {
                    AlbumViewTitle albumTitle = new AlbumViewTitle();
                    albumTitle.Title = newItem.Artist;
                    items.Add(albumTitle);
                }

                items.Add(newItem);
            }

            e.Result = items;
        }
        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);
                }
            }
        }