示例#1
0
        public static IEnumerable <IEnumerable <FileSystemEntryViewModel> > Create(
            ICodeSearchController host,
            TreeViewItemViewModel parentViewModel,
            FileSystemEntry fileSystemEntry,
            Action <FileSystemEntryViewModel> postCreate,
            bool flattenResults)
        {
            var fileEntry = fileSystemEntry as FileEntry;

            if (fileEntry != null)
            {
                return(new[] { CreateFileEntry(null, fileEntry, host, parentViewModel, fileSystemEntry, postCreate, flattenResults) });
            }
            else
            {
                if (flattenResults)
                {
                    var directoryEntry = fileSystemEntry as DirectoryEntry;
                    return(directoryEntry
                           .Entries
                           .Select(entry => CreateFileEntry(directoryEntry, (FileEntry)entry, host, parentViewModel, fileSystemEntry, postCreate, flattenResults))
                           .ToList());
                }
                else
                {
                    var result = new DirectoryEntryViewModel(host, parentViewModel, (DirectoryEntry)fileSystemEntry, postCreate);
                    postCreate(result);
                    return(new[] { new[] { result } });
                }
            }
        }
 public CodeSearchItemViewModelBase(
     ICodeSearchController controller,
     TreeViewItemViewModel parent,
     bool lazyLoadChildren)
   : base(controller.StandarImageSourceFactory, parent, lazyLoadChildren) {
   _controller = controller;
 }
 protected FileSystemEntryViewModel(
     ICodeSearchController controller,
     TreeViewItemViewModel parentViewModel,
     bool lazyLoadChildren)
     : base(controller, parentViewModel, lazyLoadChildren)
 {
 }
示例#4
0
 private static IEnumerable <FileSystemEntryViewModel> CreateFileEntry(
     DirectoryEntry directoryEntry,
     FileEntry fileEntry,
     ICodeSearchController host,
     TreeViewItemViewModel parentViewModel,
     FileSystemEntry fileSystemEntry,
     Action <FileSystemEntryViewModel> postCreate,
     bool flattenResults)
 {
     if (flattenResults)
     {
         var positionsData = fileEntry.Data as FilePositionsData;
         if (positionsData != null)
         {
             var flatFilePositions = positionsData
                                     .Positions
                                     .Select(x => new FlatFilePositionViewModel(host, parentViewModel, directoryEntry, fileEntry, x))
                                     .ToList();
             flatFilePositions.ForAll(postCreate);
             return(flatFilePositions);
         }
         else
         {
             var result = new FlatFilePositionViewModel(host, parentViewModel, directoryEntry, fileEntry, null);
             postCreate(result);
             return(new[] { result });
         }
     }
     else
     {
         var result = new FileEntryViewModel(host, parentViewModel, fileEntry);
         postCreate(result);
         return(new[] { result });
     }
 }
    public static IEnumerable<TreeViewItemViewModel> CreateViewModels(ICodeSearchController host, FileEntryViewModel parent, FileSystemEntryData data) {
      var positionsData = data as FilePositionsData;
      if (positionsData != null)
        return positionsData.Positions.Select(x => new FilePositionViewModel(host, parent, x));

      return Enumerable.Empty<TreeViewItemViewModel>();
    }
示例#6
0
 protected FileSystemEntryViewModel(
     ICodeSearchController controller,
     TreeViewItemViewModel parentViewModel,
     bool lazyLoadChildren)
     : base(controller, parentViewModel, lazyLoadChildren)
 {
 }
 public static FileSystemEntryViewModel Create(ICodeSearchController host, TreeViewItemViewModel parentViewModel, FileSystemEntry fileSystemEntry)
 {
     var fileEntry = fileSystemEntry as FileEntry;
       if (fileEntry != null)
     return new FileEntryViewModel(host, parentViewModel, fileEntry);
       else
     return new DirectoryEntryViewModel(host, parentViewModel, (DirectoryEntry)fileSystemEntry);
 }
 public CodeSearchItemViewModelBase(
     ICodeSearchController controller,
     TreeViewItemViewModel parent,
     bool lazyLoadChildren)
     : base(controller.StandarImageSourceFactory, parent, lazyLoadChildren)
 {
     _controller = controller;
 }
 public DirectoryEntryViewModel(
     ICodeSearchController controller,
     TreeViewItemViewModel parentViewModel,
     DirectoryEntry directoryEntry)
     : base(controller, parentViewModel, directoryEntry.Entries.Count > 0)
 {
     _directoryEntry = directoryEntry;
       _children = new Lazy<IList<TreeViewItemViewModel>>(CreateChildren);
 }
 public DirectoryEntryViewModel(
     ICodeSearchController controller,
     TreeViewItemViewModel parentViewModel,
     DirectoryEntry directoryEntry,
     Action <FileSystemEntryViewModel> postCreate)
     : base(controller, parentViewModel, directoryEntry.Entries.Count > 0)
 {
     _directoryEntry = directoryEntry;
     _postCreate     = postCreate;
     _children       = new Lazy <IList <TreeViewItemViewModel> >(CreateChildren);
 }
示例#11
0
        public static IEnumerable <TreeViewItemViewModel> CreateViewModels(ICodeSearchController host, FileEntryViewModel parent, FileSystemEntryData data)
        {
            var positionsData = data as FilePositionsData;

            if (positionsData != null)
            {
                return(positionsData.Positions.Select(x => new FilePositionViewModel(host, parent, x)));
            }

            return(Enumerable.Empty <TreeViewItemViewModel>());
        }
示例#12
0
 public FlatFilePositionViewModel(
     ICodeSearchController controller,
     TreeViewItemViewModel parentViewModel,
     DirectoryEntry directoryEntry,
     FileEntry fileEntry,
     FilePositionSpan matchPosition)
     : base(controller, parentViewModel, fileEntry.Data != null)
 {
     _directoryEntry = directoryEntry;
     _fileEntry      = fileEntry;
     _matchPosition  = matchPosition;
 }
        public CodeSearchItemViewModelBase(
            ICodeSearchController controller,
            TreeViewItemViewModel parent,
            bool lazyLoadChildren)
            : base(controller.StandarImageSourceFactory, parent, lazyLoadChildren)
        {
            _controller = controller;
            var con = controller as CodeSearchController;

            if (con != null && con.ViewModel.ExpandAll)
            {
                LazySelect = (TreeViewItemViewModel x) => { ExpandAll(x); }
            }
            ;
        }
 public static FileSystemEntryViewModel Create(
   ICodeSearchController host,
   TreeViewItemViewModel parentViewModel,
   FileSystemEntry fileSystemEntry, Action<FileSystemEntryViewModel> postCreate) {
   var fileEntry = fileSystemEntry as FileEntry;
   if (fileEntry != null) {
     var result = new FileEntryViewModel(host, parentViewModel, fileEntry);
     postCreate(result);
     return result;
   }
   else {
     var result = new DirectoryEntryViewModel(host, parentViewModel, (DirectoryEntry) fileSystemEntry, postCreate);
     postCreate(result);
     return result;
   }
 }
示例#15
0
        public static FileSystemEntryViewModel Create(
            ICodeSearchController host,
            TreeViewItemViewModel parentViewModel,
            FileSystemEntry fileSystemEntry, Action <FileSystemEntryViewModel> postCreate)
        {
            var fileEntry = fileSystemEntry as FileEntry;

            if (fileEntry != null)
            {
                var result = new FileEntryViewModel(host, parentViewModel, fileEntry);
                postCreate(result);
                return(result);
            }
            else
            {
                var result = new DirectoryEntryViewModel(host, parentViewModel, (DirectoryEntry)fileSystemEntry, postCreate);
                postCreate(result);
                return(result);
            }
        }
示例#16
0
        public static void LoadFileExtracts(ICodeSearchController host, string path, IEnumerable <FlatFilePositionViewModel> filePositions)
        {
            var positions = filePositions.ToList();

            if (!positions.Any())
            {
                return;
            }

            var request = new GetFileExtractsRequest
            {
                FileName         = path,
                MaxExtractLength = host.GlobalSettings.MaxTextExtractLength,
                Positions        = positions
                                   .Select(x => new FilePositionSpan
                {
                    Position = x.Position,
                    Length   = x.Length
                })
                                   .ToList()
            };

            var uiRequest = new DispatchThreadServerRequest
            {
                Request = request,
                Id      = "FlatFilePositionViewModel-" + path,
                Delay   = TimeSpan.FromSeconds(0.0),
                OnDispatchThreadSuccess = (typedResponse) => {
                    var response = (GetFileExtractsResponse)typedResponse;
                    positions
                    .Zip(response.FileExtracts, (x, y) => new {
                        FilePositionViewModel = x,
                        FileExtract           = y
                    })
                    .Where(x => x.FileExtract != null)
                    .ForAll(x => x.FilePositionViewModel.SetTextExtract(x.FileExtract));
                }
            };

            host.DispatchThreadServerRequestExecutor.Post(uiRequest);
        }
示例#17
0
 public FilePositionViewModel(ICodeSearchController controller, FileEntryViewModel parentFile, FilePositionSpan matchPosition)
   : base(controller, parentFile, false) {
   _parentFile = parentFile;
   _matchPosition = matchPosition;
 }
 public FileEntryViewModel(ICodeSearchController controller, TreeViewItemViewModel parentViewModel, FileEntry fileEntry)
     : base(controller, parentViewModel, fileEntry.Data != null)
 {
     _fileEntry = fileEntry;
     _children  = new Lazy <IList <TreeViewItemViewModel> >(CreateChildren);
 }
示例#19
0
 public FileEntryViewModel(ICodeSearchController controller, TreeViewItemViewModel parentViewModel, FileEntry fileEntry)
     : base(controller, parentViewModel, fileEntry.Data != null)
 {
     _fileEntry = fileEntry;
       _children = new Lazy<IList<TreeViewItemViewModel>>(CreateChildren);
 }
 public FilePositionViewModel(ICodeSearchController controller, FileEntryViewModel parentFile, FilePositionSpan matchPosition)
     : base(controller, parentFile, false)
 {
     _parentFile    = parentFile;
     _matchPosition = matchPosition;
 }