コード例 #1
0
        /// <summary>
        /// Sorts the specified root folders based on the media item being oragnised into them
        /// </summary>
        /// <param name="mediaItem">Media item being oragnised into the specified root folders</param>
        /// <param name="rootFolders">Root folders the media item is being organised into</param>
        /// <returns>Specified root folders sorted based on the media item being oragnised into them</returns>
        public static OrganisingRootFolder[] SortForMediaItem(MediaItem mediaItem, OrganisingRootFolder[] rootFolders)
        {
            List <MatchedOrganisingRootFolder> sorted = new List <MatchedOrganisingRootFolder>();

            foreach (OrganisingRootFolder rootFolder in rootFolders)
            {
                if (rootFolder.MediaItemType == mediaItem.Type)
                {
                    Int32 matches = 0;

                    foreach (IntelligentString tag in rootFolder.Tags)
                    {
                        if (mediaItem.ContainsSearchText(tag.Value))
                        {
                            matches++;
                        }
                    }

                    sorted.Add(new MatchedOrganisingRootFolder(rootFolder, matches));
                }
            }

            sorted.Sort();

            return((from sortedRootFolder in sorted
                    select sortedRootFolder.RootFolder).ToArray());
        }
コード例 #2
0
        /// <summary>
        /// Determines whether or not the specified media item passes the filter
        /// </summary>
        /// <param name="mediaItem">Media item being filtered</param>
        /// <returns>True if the specified media item passes the filter, false if not</returns>
        public Boolean PassMediaItem(MediaItem mediaItem)
        {
            if (ShowHidden.HasValue)
            {
#if !DEBUG
                if (ShowHidden.Value)
                {
                    if ((!mediaItem.IsHidden) || (mediaItem.UserName.ToLower() != Environment.UserDomainName.ToLower() + "\\" + Environment.UserName.ToLower()))
                    {
                        return(false);
                    }
                }
                else
                {
#endif
                if (mediaItem.IsHidden != ShowHidden.Value)
                {
                    return(false);
                }
#if !DEBUG
            }
#endif
            }

            if (ShowPlayed.HasValue)
            {
                if (ShowPlayed.Value)
                {
                    if (mediaItem.PlayCount == 0)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (mediaItem.PlayCount > 0)
                    {
                        return(false);
                    }
                }
            }

            if (ShowPartsExist.HasValue)
            {
                if (mediaItem.Parts.PartsExist != ShowPartsExist)
                {
                    return(false);
                }
            }

            if (!mediaItem.ContainsSearchText(SearchText))
            {
                return(false);
            }

            return(true);
        }