private void releaseDetailsView_EditReleaseClicked(object sender, System.EventArgs e)
        {
            string id = this.releaseDetailsView.Release.Id;

            this.operations.EditRelease(id);
            this.SetSelectedItem(SelectionInfo.Release(id));
        }
        private void DisplayReleases(Release[] releases)
        {
            this.UpdateCurrentBrowser();

            this.currentReleaseBrowser.LoadReleases(releases);

            this.isLoading = false;

            if (!this.currentReleaseBrowser.SetSelectedItem(this.releaseToSelect))
            {
                string[] albumArtists = this.currentReleaseBrowser.AlbumArtists;

                if (albumArtists == null)
                {
                    if (releases.Length != 0)
                    {
                        this.currentReleaseBrowser.SetSelectedItem(SelectionInfo.Release(releases[0].Id));
                    }
                }
                else if (albumArtists.Length == 1)
                {
                    this.currentReleaseBrowser.SetSelectedItem(SelectionInfo.Artist(albumArtists[0]));
                }
            }
        }
예제 #3
0
        private void ImportTracks()
        {
            ImportTracksWindow window = new ImportTracksWindow(this.collectionSessionFactory);

            if (window.ShowDialog(this) == true)
            {
                this.mainCollectionView.SetSelectedItem(SelectionInfo.Release(window.InsertedReleaseId));
            }
        }
 public void SetSelectedItem(SelectionInfo info)
 {
     if (this.isLoading)
     {
         this.releaseToSelect = info;
     }
     else
     {
         this.currentReleaseBrowser.SetSelectedItem(info);
     }
 }
        public MainCollectionView()
        {
            this.operations      = new MainCollectionViewOperations(this);
            this.releaseFilter   = new ReleaseFilter();
            this.releaseToSelect = new SelectionInfo(SelectionInfoType.None);

            InitializeComponent();

            this.collectionStatistics.Init(this);

            this.ResetFilter();

            this.delayedExecution = new DelayedExecution(() =>
            {
                this.Dispatcher.Invoke(new Action(() =>
                {
                    this.ReloadReleases();
                }));
            }, TimeSpan.FromMilliseconds(300));

            this.UpdateSelectedRelease();
            this.groupFilter.Visibility = Visibility.Collapsed;
        }
        public MainCollectionView()
        {
            this.operations = new MainCollectionViewOperations(this);
            this.releaseFilter = new ReleaseFilter();
            this.releaseToSelect = new SelectionInfo(SelectionInfoType.None);

            InitializeComponent();

            this.collectionStatistics.Init(this);

            this.ResetFilter();

            this.delayedExecution = new DelayedExecution(() =>
            {
                this.Dispatcher.Invoke(new Action(() =>
                {
                    this.ReloadReleases();
                }));
            }, TimeSpan.FromMilliseconds(300));

            this.UpdateSelectedRelease();
            this.groupFilter.Visibility = Visibility.Collapsed;
        }
예제 #7
0
        public bool SetSelectedItem(SelectionInfo info)
        {
            if (info.Type == SelectionInfoType.None)
            {
                this.ClearSelection();
                return(false);
            }
            else if (info.Type == SelectionInfoType.Release)
            {
                TreeReleaseItem releaseItem;
                if (this.releaseItemByReleaseId.TryGetValue(info.ReleaseId, out releaseItem))
                {
                    releaseItem.ArtistItem.IsExpanded = true;
                    releaseItem.IsSelected            = true;
                    return(true);
                }

                return(false);
            }
            else if (info.Type == SelectionInfoType.Artist)
            {
                foreach (TreeArtistItem artist in this.ArtistItems)
                {
                    if (artist.Title == info.ArtistName)
                    {
                        artist.IsExpanded = true;
                        artist.IsSelected = true;
                        return(true);
                    }
                }
                return(false);
            }
            else
            {
                throw new ArgumentException("Unexpected argument type.");
            }
        }
예제 #8
0
        public bool SetSelectedItem(SelectionInfo info)
        {
            if (info.Type == SelectionInfoType.None)
            {
                this.ClearSelection();
                return false;
            }
            else if (info.Type == SelectionInfoType.Release)
            {
                TreeReleaseItem releaseItem;
                if (this.releaseItemByReleaseId.TryGetValue(info.ReleaseId, out releaseItem))
                {
                    releaseItem.ArtistItem.IsExpanded = true;
                    releaseItem.IsSelected = true;
                    return true;
                }

                return false;
            }
            else if (info.Type == SelectionInfoType.Artist)
            {
                foreach (TreeArtistItem artist in this.ArtistItems)
                {
                    if (artist.Title == info.ArtistName)
                    {
                        artist.IsExpanded = true;
                        artist.IsSelected = true;
                        return true;
                    }
                }
                return false;
            }
            else
            {
                throw new ArgumentException("Unexpected argument type.");
            }
        }
 private void releaseCoverFlow_ItemSelected(object sender, EventArgs e)
 {
     this.SetSelectedItem(SelectionInfo.Release(this.releaseCoverFlow.Releases[this.releaseCoverFlow.SelectedIndex].Id));
 }
        private bool UpdateSelectedRelease()
        {
            if (this.collectionManager == null)
            {
                this.tracklistView.Visibility        = Visibility.Collapsed;
                this.collectionStatistics.Visibility = Visibility.Collapsed;
                this.releaseDetailsView.Visibility   = Visibility.Collapsed;
                this.releaseDetailsView.Release      = null;
                this.releaseCoverFlow.Visibility     = Visibility.Collapsed;
                this.releaseCoverFlow.Releases       = null;

                return(true);
            }

            SelectionInfo selectedItem = this.currentReleaseBrowser.GetSelectedItem();

            if (selectedItem.Type == SelectionInfoType.None)
            {
                this.tracklistView.Releases = null;

                this.tracklistView.Visibility        = Visibility.Collapsed;
                this.collectionStatistics.Visibility = Visibility.Visible;
                this.releaseDetailsView.Visibility   = Visibility.Collapsed;
                this.releaseDetailsView.Release      = null;
                this.releaseCoverFlow.Visibility     = Visibility.Collapsed;
                this.releaseCoverFlow.Releases       = null;
            }
            else if (selectedItem.Type == SelectionInfoType.Release)
            {
                Release release = this.GetLocalRelease(selectedItem.ReleaseId);

                this.tracklistView.Releases = new Release[] { release };

                this.tracklistView.Visibility        = Visibility.Visible;
                this.collectionStatistics.Visibility = Visibility.Collapsed;
                this.releaseDetailsView.Visibility   = Visibility.Visible;
                this.releaseDetailsView.Release      = release;
                this.releaseCoverFlow.Visibility     = Visibility.Collapsed;
                this.releaseCoverFlow.Releases       = null;
            }
            else if (selectedItem.Type == SelectionInfoType.Artist)
            {
                var       releaseIds = this.currentReleaseBrowser.GetReleaseIdsByAlbumArtist(selectedItem.ArtistName);
                Release[] releases   = releaseIds.Select(r => this.GetLocalRelease(r)).Where(r => r != null).ToArray();
                this.tracklistView.Releases = releases;

                this.tracklistView.Visibility        = Visibility.Visible;
                this.collectionStatistics.Visibility = Visibility.Collapsed;
                if (releases.Length == 1)
                {
                    this.releaseDetailsView.Visibility = Visibility.Visible;
                    this.releaseDetailsView.Release    = releases[0];
                    this.releaseCoverFlow.Visibility   = Visibility.Collapsed;
                    this.releaseCoverFlow.Releases     = null;
                }
                else
                {
                    this.releaseDetailsView.Visibility  = Visibility.Collapsed;
                    this.releaseDetailsView.Release     = null;
                    this.releaseCoverFlow.Visibility    = Visibility.Visible;
                    this.releaseCoverFlow.Releases      = releases;
                    this.releaseCoverFlow.SelectedIndex = (releases.Length - 1) / 2;
                }
            }
            return(false);
        }
        private void ReloadReleases()
        {
            Task localBackgroundTask = this.backgroundTask;

            if (localBackgroundTask != null)
            {
                this.cancelSearch = true;
                localBackgroundTask.Wait();
                this.cancelSearch = false;
            }

            this.isLoading = true;
            if (this.currentReleaseBrowser != null)
            {
                this.releaseToSelect = this.currentReleaseBrowser.GetSelectedItem();
            }

            this.releaseTree.LoadReleases(null);
            this.releaseList.LoadReleases(null);

            this.releaseSelectorBusyIndicator.IsBusy = this.collectionManager != null;

            this.releaseTree.IsEnabled = this.collectionManager != null;
            this.releaseList.IsEnabled = this.collectionManager != null;

            this.textFilter.IsEnabled    = this.collectionManager != null;
            this.tracklistView.IsEnabled = this.collectionManager != null;

            this.UpdateFilterDetails();

            if (this.collectionManager != null)
            {
                this.UpdateCurrentBrowser();

                Release[] filteredReleases = null;

                this.backgroundTask = new Task(() =>
                {
                    if (this.releases == null)
                    {
                        this.releases = this.collectionManager.Releases.ToArray();
                    }
                    filteredReleases = this.releases.Where(r =>
                    {
                        if (this.cancelSearch)
                        {
                            return(false);
                        }
                        return(this.releaseFilter.Match(r));
                    }).ToArray();

                    if (!this.cancelSearch)
                    {
                        this.Dispatcher.BeginInvokeAction(() =>
                        {
                            this.collectionStatistics.Releases = this.releases;

                            if (filteredReleases != null)
                            {
                                DisplayReleases(filteredReleases);
                            }

                            this.releaseSelectorBusyIndicator.IsBusy = false;
                        });
                    }
                    this.backgroundTask = null;
                });

                this.backgroundTask.Start();
            }
        }
예제 #12
0
        public bool SetSelectedItem(SelectionInfo info)
        {
            if (info.Type == SelectionInfoType.None)
            {
                this.listView.SelectedItem = null;
                return true;
            }
            else if (info.Type == SelectionInfoType.Release)
            {
                ReleaseItem releaseItem;
                if (this.releaseItemByReleaseId.TryGetValue(info.ReleaseId, out releaseItem))
                {
                    this.listView.SelectedItem = releaseItem;

                    ReleaseItem[] items = (ReleaseItem[])this.listView.ItemsSource;
                    int index = items.IndexOf(releaseItem);
                    this.listView.ScrollIntoView(items[Math.Max(0, index - 3)]);
                    this.listView.ScrollIntoView(items[Math.Min(items.Length - 1, index + 3)]);
                    this.listView.ScrollIntoView(items[index]);

                    return true;
                }
                return false;
            }
            else if (info.Type == SelectionInfoType.Artist)
            {
                return false;
            }
            else
            {
                throw new NotSupportedException();
            }
        }
        private void ReloadReleases()
        {
            Task localBackgroundTask = this.backgroundTask;
            if (localBackgroundTask != null)
            {
                this.cancelSearch = true;
                localBackgroundTask.Wait();
                this.cancelSearch = false;
            }

            this.isLoading = true;
            if (this.currentReleaseBrowser != null)
            {
                this.releaseToSelect = this.currentReleaseBrowser.GetSelectedItem();
            }

            this.releaseTree.LoadReleases(null);
            this.releaseList.LoadReleases(null);

            this.releaseSelectorBusyIndicator.IsBusy = this.collectionManager != null;

            this.releaseTree.IsEnabled = this.collectionManager != null;
            this.releaseList.IsEnabled = this.collectionManager != null;

            this.textFilter.IsEnabled = this.collectionManager != null;
            this.tracklistView.IsEnabled = this.collectionManager != null;

            this.UpdateFilterDetails();

            if (this.collectionManager != null)
            {
                this.UpdateCurrentBrowser();

                Release[] filteredReleases = null;

                this.backgroundTask = new Task(() =>
                {
                    if (this.releases == null)
                    {
                        this.releases = this.collectionManager.Releases.ToArray();
                    }
                    filteredReleases = this.releases.Where(r =>
                    {
                        if (this.cancelSearch) return false;
                        return this.releaseFilter.Match(r);
                    }).ToArray();

                    if (!this.cancelSearch)
                    {
                        this.Dispatcher.BeginInvokeAction(() =>
                        {
                            this.collectionStatistics.Releases = this.releases;

                            if (filteredReleases != null)
                            {
                                DisplayReleases(filteredReleases);
                            }

                            this.releaseSelectorBusyIndicator.IsBusy = false;
                        });
                    }
                    this.backgroundTask = null;
                });

                this.backgroundTask.Start();
            }
        }
 public void SetSelectedItem(SelectionInfo info)
 {
     if (this.isLoading)
     {
         this.releaseToSelect = info;
     }
     else
     {
         this.currentReleaseBrowser.SetSelectedItem(info);
     }
 }