private void mediaState_SelectionChanged(object sender, EventArgs e)
        {
            List <MediaItem> items = new List <MediaItem>();

            MediaStateCollectionView.EnterReadLock();
            try
            {
                items = MediaStateCollectionView.getSelectedItems_RLock();

                if (items.Count == 0)
                {
                    CurrentPage = null;
                }
                else
                {
                    CurrentPage = MediaStateCollectionView.IndexOf(new SelectableMediaItem(items[0])) + 1;
                }
            }
            finally
            {
                MediaStateCollectionView.ExitReadLock();

                EventAggregator.GetEvent <MediaSelectionEvent>().Publish(new MediaSelectionPayload(MediaStateCollectionView.Guid, items));
            }
        }
Exemplo n.º 2
0
        void buildTagList()
        {
            List <TagItem> tagItems = new List <TagItem>();

            MediaCollectionView.EnterReadLock();
            try
            {
                foreach (SelectableMediaItem media in MediaCollectionView)
                {
                    if (media.Item.ItemState == MediaItemState.LOADED)
                    {
                        addTags(media, tagItems);
                    }
                }
            }
            finally
            {
                MediaCollectionView.ExitReadLock();
            }

            App.Current.Dispatcher.BeginInvoke(new Action(() => {
                tagsList.Clear();
                tagsList.AddRange(tagItems);

                ICollectionView view = CollectionViewSource.GetDefaultView(dataGrid.ItemsSource);
                view.Refresh();
            }));

/*
 *          App.Current.Dispatcher.BeginInvoke(new Action(() =>
 *          {
 *              SortDescription? sortDescription = null;
 *
 *              ICollectionView view = CollectionViewSource.GetDefaultView(dataGrid.ItemsSource);
 *              if (view != null && view.SortDescriptions.Count > 0)
 *              {
 *                  sortDescription = view.SortDescriptions[0];
 *              }
 *
 *              dataGrid.ItemsSource = tagsList.tagItems;
 *
 *              view = CollectionViewSource.GetDefaultView(dataGrid.ItemsSource);
 *              if (sortDescription == null)
 *              {
 *                  sortDescription = new SortDescription("Count", ListSortDirection.Descending);
 *              }
 *
 *              view.SortDescriptions.Add(sortDescription.Value);
 *              int index = dataGridColumnIndex(sortDescription.Value.PropertyName);
 *
 *              dataGrid.ColumnFromDisplayIndex(index).SortDirection = sortDescription.Value.Direction;
 *
 *              view.Refresh();
 *
 *          }));*/
        }
        private void mediaState_NrItemsInStateChanged(object sender, EventArgs e)
        {
            MediaStateCollectionView.EnterReadLock();
            try
            {
                NrPages = MediaStateCollectionView.Count();

                MediaItem selectedItem;

                int index = MediaStateCollectionView.getSelectedItem_RLock(out selectedItem);

                if (index != -1 && (index + 1) != CurrentPage)
                {
                    CurrentPage = index + 1;
                }
            }
            finally
            {
                MediaStateCollectionView.ExitReadLock();
            }
        }