/// <summary>
        /// Creates a new <see cref="DocumentMetadata"/>, setting
        /// <see cref="DocumentMetadata.ActivatedAt"/> at the specified time
        /// </summary>
        /// <param name="info">
        /// Information about the document's full name and containing project
        /// </param>
        /// <param name="activatedAt">
        /// Value to set <see cref="DocumentMetadata.ActivatedAt"/> as
        /// </param>
        /// <returns>A new <see cref="DocumentMetadata"/> instance</returns>
        public DocumentMetadata Create(DocumentMetadataInfo info, DateTime activatedAt)
        {
            var correctedCasing = _pathCasingRestorer.RestoreCasing(info.FullName);

            var displayName = _filePathService.ReducePath(
                correctedCasing,
                _userPreferences.PathSegmentCount);

            var projectBrush = _projectBrushService.GetBrush(
                info.ProjectFullName,
                _userPreferences);

            var extension = Path.GetExtension(info.FullName);
            var icon      = _documentIconService.GetIcon(extension);

            var displayNameHighlight = _displayNameHighlightEvaluator
                                       .GetHighlight(
                displayName,
                _userPreferences.HighlightFileName);

            var displayNamePostHighlight = _displayNameHighlightEvaluator
                                           .GetPostHighlight(
                displayName,
                _userPreferences.HighlightFileName);

            var displayNamePreHighlight = _displayNameHighlightEvaluator
                                          .GetPreHighlight(
                displayName,
                _userPreferences.HighlightFileName);

            var metadata = new DocumentMetadata(info, correctedCasing, icon)
            {
                ActivatedAt              = activatedAt,
                DisplayNameHighlight     = displayNameHighlight,
                DisplayNamePostHighlight = displayNamePostHighlight,
                DisplayNamePreHighlight  = displayNamePreHighlight,
                ProjectBrush             = projectBrush
            };

            return(metadata);
        }
Esempio n. 2
0
        public void UpdateCollection(
            ICollectionView view,
            IUserPreferences userPreferences)
        {
            var collection = (IList <DocumentMetadata>)view.SourceCollection;

            foreach (var metadata in collection)
            {
                var displayName = _filePathService.ReducePath(
                    metadata.CorrectedFullName,
                    userPreferences.PathSegmentCount);

                var preHighlight = _displayNameHighlightEvaluator
                                   .GetPreHighlight(
                    displayName,
                    userPreferences.HighlightFileName);

                var highlight = _displayNameHighlightEvaluator
                                .GetHighlight(
                    displayName,
                    userPreferences.HighlightFileName);

                var postHighlight = _displayNameHighlightEvaluator
                                    .GetPostHighlight(
                    displayName,
                    userPreferences.HighlightFileName);

                metadata.DisplayNamePreHighlight  = preHighlight;
                metadata.DisplayNameHighlight     = highlight;
                metadata.DisplayNamePostHighlight = postHighlight;
            }

            // Collection may need to be sorted: changing the number of path
            // segments could make the displayed item order no longer agree with
            // the selected sorting option, e.g. if an alphabetical sort is
            // applied.

            view.Refresh();
        }