public TreeViewItemWithIconViewModel(FilesTreeViewItem model, int stashId, FileIconsService fileIconService, VisualStudioGitService gitService) { _internalModel = model; _fileIconService = fileIconService; _gitService = gitService; Source = IsFile ? _fileIconService.GetFileIcon("." + FileExtension) : _fileIconService.GetFolderIcon(IsExpanded); var childNodes = model.Items.Select(m => new TreeViewItemWithIconViewModel(m, stashId, fileIconService, gitService)).ToList(); Items = new ObservableCollection <TreeViewItemWithIconViewModel>(childNodes); CompareWithPreviousVersionCommand = new DelegateCommand(o => { var treeItem = o as TreeViewItemWithIconViewModel; var filePath = treeItem?.FullPath; var fileName = treeItem?.Text; var isNew = treeItem?.IsNew ?? false; var isStaged = treeItem?.IsStaged ?? false; _gitService.RunDiff(stashId, filePath, fileName, isNew, isStaged); }); }
private static FilesTreeViewItem ToTreeViewItem(this TreeNode node, bool isFile) { var attributes = node.Tag as FileAttributes; var treeViewItem = new FilesTreeViewItem { Text = node.Text, FullPath = node.GetTreeViewNodeFullPath(), IsFile = isFile, IsNew = attributes?.IsNew, IsStaged = attributes?.IsStaged, Items = node.Nodes?.OfType <TreeNode>()?.Select(n => ToTreeViewItem(n, n.Nodes.Count == 0))?.ToList() ?? new List <FilesTreeViewItem>() }; return(treeViewItem); }