Beispiel #1
0
        private bool mediaStateSortModeCollectionViewFilter(object item)
        {
            MediaFileSortItem sortItem = (MediaFileSortItem)item;

            switch (MediaFilter)
            {
            case MediaFilterMode.None:
                return(MediaFileSortFunctions.isAllSortMode(sortItem.SortMode));

            case MediaFilterMode.Video:
                return(MediaFileSortFunctions.isVideoSortMode(sortItem.SortMode));

            case MediaFilterMode.Images:
                return(MediaFileSortFunctions.isImageSortMode(sortItem.SortMode));

            case MediaFilterMode.Audio:
                return(MediaFileSortFunctions.isAudioSortMode(sortItem.SortMode));

            default:
                break;
            }

            return(false);
        }
Beispiel #2
0
        public MediaFileStateCollectionView(MediaFileState mediaState = null) :
            base(mediaState)
        {
            Filter         = filterFunc;
            InfoIconsCache = InfoIconsCacheStatic;

            MediaFilter = MediaFilterMode.None;

            SortFunc = MediaFileSortFunctions.getSortFunction(MediaFileSortMode.Name);
            SortMode = MediaFileSortMode.Name;

            FilterModes = new ListCollectionView(Enum.GetValues(typeof(MediaFilterMode)));

            SortItemCollection <MediaFileSortItem, MediaFileSortMode> mediaFileSortItemCollection = new SortItemCollection <MediaFileSortItem, MediaFileSortMode>();

            mediaFileSortItemCollection.ItemSortDirectionChanged += mediaFileSortItemCollection_ItemSortDirectionChanged;

            foreach (MediaFileSortMode mode in Enum.GetValues(typeof(MediaFileSortMode)))
            {
                mediaFileSortItemCollection.Add(new MediaFileSortItem(mode));
            }

            SortModes = new ListCollectionView(mediaFileSortItemCollection);

            SortModes.CurrentChanged += (s, e) =>
            {
                MediaFileSortItem sortItem = (MediaFileSortItem)SortModes.CurrentItem;

                SortMode      = sortItem.SortMode;
                SortDirection = sortItem.SortDirection;

                SortFunc = MediaFileSortFunctions.getSortFunction(SortMode);

                refresh();
            };

            SortModes.Filter = mediaStateSortModeCollectionViewFilter;

            FilterModes.CurrentChanged += (s, e) =>
            {
                MediaFilter = (MediaFilterMode)FilterModes.CurrentItem;

                SortModes.Refresh();

                bool isRefreshed = false;

                switch (MediaFilter)
                {
                case MediaFilterMode.None:
                    if (!MediaFileSortFunctions.isAllSortMode(SortMode))
                    {
                        SortModes.MoveCurrentToFirst();
                        isRefreshed = true;
                    }
                    break;

                case MediaFilterMode.Video:
                    if (!MediaFileSortFunctions.isVideoSortMode(SortMode))
                    {
                        SortModes.MoveCurrentToFirst();
                        isRefreshed = true;
                    }
                    break;

                case MediaFilterMode.Images:
                    if (!MediaFileSortFunctions.isImageSortMode(SortMode))
                    {
                        SortModes.MoveCurrentToFirst();
                        isRefreshed = true;
                    }
                    break;

                case MediaFilterMode.Audio:
                    if (!MediaFileSortFunctions.isAudioSortMode(SortMode))
                    {
                        SortModes.MoveCurrentToFirst();
                        isRefreshed = true;
                    }
                    break;

                default:
                    break;
                }

                if (!isRefreshed)
                {
                    refresh();
                }
            };

            FilterModes.MoveCurrentTo(MediaFilterMode.None);
        }