private static string ReadFileContent(PackageFile file, out long size) { const int MaxLengthToOpen = 10 * 1024; // limit to 10K const int BufferSize = 2 * 1024; char[] buffer = new char[BufferSize]; // read 2K at a time StringBuilder sb = new StringBuilder(); Stream stream = file.GetStream(); size = stream.Length; using (StreamReader reader = new StreamReader(stream)) { while (sb.Length < MaxLengthToOpen) { int bytesRead = reader.Read(buffer, 0, BufferSize); if (bytesRead == 0) { break; } else { sb.Append(new string(buffer, 0, bytesRead)); } } // if not reaching the end of the stream yet, append the text "Truncating..." if (reader.Peek() > -1) { // continue reading the rest of the current line to avoid dangling line sb.AppendLine(reader.ReadLine()); if (reader.Peek() > -1) { sb.AppendLine().AppendLine("*** The rest of the content is truncated. ***"); } } } return sb.ToString(); }
public static void OpenFileInShellWith(PackageFile file) { // copy to temporary file // create package in the temprary file first in case the operation fails which would // override existing file with a 0-byte file. string tempFileName = Path.Combine(GetTempFilePath(), file.Name); using (Stream tempFileStream = File.Create(tempFileName)) { file.GetStream().CopyTo(tempFileStream); } if (File.Exists(tempFileName)) { var info = new ProcessStartInfo("rundll32.exe") { ErrorDialog = true, UseShellExecute = false, Arguments = "shell32.dll,OpenAs_RunDLL " + tempFileName }; Process.Start(info); } }
public static void OpenFileInShell(PackageFile file, IUIServices uiServices) { if (IsExecutableScript(file.Name)) { bool confirm = uiServices.Confirm( String.Format(CultureInfo.CurrentCulture, Resources.OpenExecutableScriptWarning_Title, file.Name), Resources.OpenExecutableScriptWarning, isWarning: true); if (!confirm) { return; } } // copy to temporary file // create package in the temprary file first in case the operation fails which would // override existing file with a 0-byte file. string tempFileName = Path.Combine(GetTempFilePath(), file.Name); using (Stream tempFileStream = File.Create(tempFileName)) { file.GetStream().CopyTo(tempFileStream); } if (File.Exists(tempFileName)) { Process.Start("explorer.exe", tempFileName); } }
private void ShowFile(PackageFile file) { bool isBinary = IsBinaryFile(file.Name); long size; string content; if (isBinary) { content = Resources.UnsupportedFormatMessage; using (Stream stream = file.GetStream()) { size = stream.Length; } } else { content = ReadFileContent(file, out size); } var fileInfo = new FileContentInfo( file, file.Path, content, !isBinary, size, DetermineLanguage(file.Name)); ViewModel.ShowFile(fileInfo); }
private static string ReadFileContent(PackageFile file, out bool truncated) { var buffer = new char[1024 * 32]; truncated = false; using (var stream = file.GetStream()) using (var reader = new StreamReader(stream)) { // Read 500 kb const int maxBytes = 500 * 1024; var sb = new StringBuilder(); int bytesRead; while ((bytesRead = reader.Read(buffer, 0, buffer.Length)) > 0) { sb.Append(buffer, 0, bytesRead); if (sb.Length >= maxBytes) { truncated = true; break; } } return(sb.ToString()); } }
internal void ReplaceFile(PackageFile oldFile, string newFilePath) { bool showingFile = PackageViewModel.IsShowingFileContent(oldFile); // temporarily remove the old file in order to add a new file Children.Remove(oldFile); PackageFile newFile = AddFile(newFilePath, isTempFile: false); if (newFile != null) { // new file added successfully, officially delete the old file by disposing it oldFile.Dispose(); if (showingFile) { PackageViewModel.ShowFileContent(newFile); } } else { // otherwise, if the adding failed, restore the old file Children.Add(oldFile); } }
public static void OpenFileInShellWith(PackageFile file) { DiagnosticsClient.TrackEvent("FileHelper_OpenFileInShellWith"); // copy to temporary file // create package in the temprary file first in case the operation fails which would // override existing file with a 0-byte file. var tempFileName = Path.Combine(GetTempFilePath(), file.Name); using (Stream tempFileStream = File.Create(tempFileName)) using (var packageStream = file.GetStream()) { packageStream.CopyTo(tempFileStream); } if (File.Exists(tempFileName)) { var info = new ProcessStartInfo("rundll32.exe") { ErrorDialog = true, UseShellExecute = false, Arguments = "shell32.dll,OpenAs_RunDLL " + tempFileName }; try { Process.Start(info); } catch // Possible Win32 exception, nothing we can do { } } }
public FileContentInfo(PackageFile file, string name, object content, bool isTextFile, long size) { File = file; Name = name; Content = content; IsTextFile = isTextFile; Size = size; }
public PackageFile AddFile(string filePath, bool isTempFile) { if (!File.Exists(filePath)) { throw new ArgumentException("File does not exist.", "filePath"); } string newFileName = System.IO.Path.GetFileName(filePath); if (ContainsFolder(newFileName)) { PackageViewModel.UIServices.Show(Resources.FileNameConflictWithExistingDirectory, MessageLevel.Error); return(null); } bool showingRemovedFile = false; if (ContainsFile(newFileName)) { bool confirmed = PackageViewModel.UIServices.Confirm( Resources.ConfirmToReplaceExsitingFile_Title, String.Format(CultureInfo.CurrentCulture, Resources.ConfirmToReplaceExsitingFile, newFileName), isWarning: true); if (confirmed) { var part = this[newFileName] as PackageFile; showingRemovedFile = PackageViewModel.IsShowingFileContent(part); // remove the existing file before adding the new one RemoveChildByName(newFileName); } else { return(null); } } string newTargetPath = this.Path + "\\" + newFileName; var physicalFile = new PhysicalPackageFile { SourcePath = filePath, TargetPath = newTargetPath }; var newFile = new PackageFile(physicalFile, newFileName, this); Children.Add(newFile); newFile.IsSelected = true; IsExpanded = true; PackageViewModel.NotifyChanges(); if (showingRemovedFile) { PackageViewModel.ShowFileContent(newFile); } return(newFile); }
public PackageFile AddFile(string filePath) { if (!File.Exists(filePath)) { throw new ArgumentException("File does not exist.", "filePath"); } string newFileName = System.IO.Path.GetFileName(filePath); if (ContainsFolder(newFileName)) { PackageViewModel.UIServices.Show(Resources.FileNameConflictWithExistingDirectory, Types.MessageLevel.Error); return(null); } bool showingRemovedFile = false; if (ContainsFile(newFileName)) { bool confirmed = PackageViewModel.UIServices.Confirm(Resources.ConfirmToReplaceExsitingFile, true); if (confirmed) { // check if we are currently showing the content of the file to be removed. // if we are, we'll need to show the new content after replacing the file. if (PackageViewModel.ShowContentViewer) { PackagePart part = this[newFileName]; if (PackageViewModel.CurrentFileInfo.File == part) { showingRemovedFile = true; } } // remove the existing file before adding the new one RemoveChildByName(newFileName); } else { return(null); } } var physicalFile = new PhysicalFile(filePath); var newFile = new PackageFile(physicalFile, newFileName, this); Children.Add(newFile); newFile.IsSelected = true; this.IsExpanded = true; PackageViewModel.NotifyChanges(); if (showingRemovedFile) { ICommand command = PackageViewModel.ViewContentCommand; command.Execute(newFile); } return(newFile); }
private IEnumerable <IPackageContentViewer> FindContentViewer(PackageFile file) { string extension = Path.GetExtension(file.Name); return(from p in ViewModel.ContentViewerMetadata where p.Metadata.SupportedExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase) orderby p.Metadata.Priority select p.Value); }
internal void ReplaceFile(PackageFile oldFile) { var result = PackageViewModel.UIServices.OpenFileDialog("Select New File", "All files (*.*)|*.*", out var selectedFileName); if (result) { ReplaceFile(oldFile, selectedFileName); } }
private IEnumerable <IPackageContentViewer> FindContentViewer(PackageFile file) { var extension = Path.GetExtension(file.Name); return(from p in ViewModel.ContentViewerMetadata where AppCompat.IsWindows10S ? p.Metadata.SupportsWindows10S : true // Filter out incompatible addins on 10s where p.Metadata.SupportedExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase) orderby p.Metadata.Priority select p.Value); }
private void OpenContentFileExecute(object parameter) { parameter = parameter ?? SelectedItem; PackageFile file = parameter as PackageFile; if (file != null) { FileHelper.OpenFileInShell(file, UIServices); } }
internal void ReplaceFile(PackageFile oldFile) { string?selectedFileName = null; var result = PackageViewModel?.UIServices.OpenFileDialog("Select New File", "All files (*.*)|*.*", out selectedFileName) ?? false; if (result) { ReplaceFile(oldFile, selectedFileName !); } }
private void SaveContentExecute(PackageFile file) { string selectedFileName; string title = "Save " + file.Name; string filter = "All files (*.*)|*.*"; if (UIServices.OpenSaveFileDialog(title, file.Name, filter, out selectedFileName)) { using (FileStream fileStream = File.OpenWrite(selectedFileName)) { file.GetStream().CopyTo(fileStream); } } }
private static string ReadFileContent(PackageFile file, out long size) { using (var stream = file.GetStream()) using (var ms = new MemoryStream()) using (var reader = new StreamReader(ms)) { stream.CopyTo(ms); size = ms.Length; ms.Position = 0; return(reader.ReadToEnd()); } }
private void SaveContentExecute(PackageFile file) { var title = "Save " + file.Name; const string filter = "All files (*.*)|*.*"; if (UIServices.OpenSaveFileDialog(title, file.Name, /* initial directory */ null, filter, /* overwritePrompt */ true, out var selectedFileName, out var filterIndex)) { using (var fileStream = File.OpenWrite(selectedFileName)) { file.GetStream().CopyTo(fileStream); } } }
public void AddFile(PackageFile file, bool makeCopy = false) { if (file == null) { throw new ArgumentNullException("file"); } if (Contains(file)) { return; } PackagePart newFile; if (makeCopy) { string fileCopyPath; using (Stream originalFileStream = file.GetStream()) { fileCopyPath = FileHelper.CreateTempFile(file.Name, originalFileStream); } string newTargetPath = this.Path + "\\" + file.Name; var physicalFile = new PhysicalPackageFile { SourcePath = fileCopyPath, TargetPath = newTargetPath }; newFile = new PackageFile(physicalFile, file.Name, this); } else { // detach from current parent if (file.Parent != null) { file.Parent.Detach(file); } newFile = file; } Attach(newFile); newFile.IsSelected = true; IsExpanded = true; PackageViewModel.NotifyChanges(); }
private void AddBuildFileCommandExecute(string extension) { string fileName = PackageMetadata.Id + extension; string sourcePath = FileHelper.CreateTempFile(fileName, Constants.ContentForBuildFile); var selectedFolder = SelectedItem as PackageFolder; if (selectedFolder != null) { PackageFile file = selectedFolder.AddFile(sourcePath, isTempFile: true); // file can be null if it collides with other files in the same directory if (file != null) { EditFileCommandExecute(file); } } }
public static void OpenFileInShell(PackageFile file, IUIServices uiServices) { if (file is null) { throw new ArgumentNullException(nameof(file)); } if (uiServices is null) { throw new ArgumentNullException(nameof(uiServices)); } if (IsExecutableScript(file.Name)) { var confirm = uiServices.Confirm( string.Format(CultureInfo.CurrentCulture, Resources.OpenExecutableScriptWarning_Title, file.Name), Resources.OpenExecutableScriptWarning, isWarning: true); if (!confirm) { return; } } // copy to temporary file // create package in the temprary file first in case the operation fails which would // override existing file with a 0-byte file. var tempFileName = Path.Combine(GetTempFilePath(), file.Name); using (Stream tempFileStream = File.Create(tempFileName)) using (var packageStream = file.GetStream()) { packageStream.CopyTo(tempFileStream); } if (File.Exists(tempFileName)) { try { Process.Start("explorer.exe", tempFileName); } catch // Possible Win32 exception, nothing we can do { } } }
private void AddScriptCommandExecute(string scriptName) { string content = scriptName.Equals("init.ps1", StringComparison.OrdinalIgnoreCase) ? Constants.ContentForInit : Constants.ContentForInstall; string sourcePath = FileHelper.CreateTempFile(scriptName, content); var selectedFolder = SelectedItem as PackageFolder; if (selectedFolder != null) { PackageFile file = selectedFolder.AddFile(sourcePath, isTempFile: true); // file can be null if it collides with other files in the same directory if (file != null) { EditFileCommandExecute(file); } } }
private void AddNewFileToFolder(PackageFolder folder) { string newName; bool result = UIServices.OpenRenameDialog( "NewFile.txt", "Provide name for the new file.", out newName); if (result) { string sourcePath = FileHelper.CreateTempFile(newName); PackageFile file = folder.AddFile(sourcePath, isTempFile: true); // file can be null if it collides with other files in the same directory if (file != null) { EditFileCommandExecute(file); } } }
private void SaveContentExecute(PackageFile file) { try { var title = "Save " + file.Name; const string filter = "All files (*.*)|*.*"; if (UIServices.OpenSaveFileDialog(title, file.Name, /* initial directory */ null, filter, /* overwritePrompt */ true, out var selectedFileName, out var filterIndex)) { using (var fileStream = File.Open(selectedFileName, FileMode.Create, FileAccess.Write, FileShare.Read)) using (var packageStream = file.GetStream()) { packageStream.CopyTo(fileStream); } } } catch (Exception e) { UIServices.Show(e.Message, MessageLevel.Error); } }
private static bool IsMicrosoftFile(PackageFile file) { IReadOnlyList <AuthenticodeSignature> sigs; SignatureCheckResult isValidSig; using (var str = file.GetStream()) using (var tempFile = new TemporaryFile(str, Path.GetExtension(file.Name))) { var extractor = new FileInspector(tempFile.FileName); sigs = extractor.GetSignatures().ToList(); isValidSig = extractor.Validate(); if (isValidSig == SignatureCheckResult.Valid && sigs.Count > 0) { return(sigs[0].SigningCertificate.Subject.EndsWith(", O=Microsoft Corporation, L=Redmond, S=Washington, C=US", StringComparison.OrdinalIgnoreCase)); } } return(false); }
private static string ReadFileContent(PackageFile file, out long size) { const int MaxLengthToOpen = 10 * 1024; // limit to 10K const int BufferSize = 2 * 1024; char[] buffer = new char[BufferSize]; // read 2K at a time StringBuilder sb = new StringBuilder(); Stream stream = file.GetStream(); size = stream.Length; using (StreamReader reader = new StreamReader(stream)) { while (sb.Length < MaxLengthToOpen) { int bytesRead = reader.Read(buffer, 0, BufferSize); if (bytesRead == 0) { break; } else { sb.Append(new string(buffer, 0, bytesRead)); } } // if not reaching the end of the stream yet, append the text "Truncating..." if (reader.Peek() > -1) { // continue reading the rest of the current line to avoid dangling line sb.AppendLine(reader.ReadLine()); if (reader.Peek() > -1) { sb.AppendLine().AppendLine("*** The rest of the content is truncated. ***"); } } } return(sb.ToString()); }
public void AddFile(PackageFile file, bool makeCopy = false) { if (file == null) { throw new ArgumentNullException(nameof(file)); } if (Contains(file)) { return; } PackagePart newFile; if (makeCopy) { string fileCopyPath; using (var originalFileStream = file.GetStream()) { fileCopyPath = FileHelper.CreateTempFile(file.Name, originalFileStream); } var newTargetPath = Path + "\\" + file.Name; var physicalFile = new DiskPackageFile(newTargetPath, fileCopyPath); newFile = new PackageFile(physicalFile, file.Name, this); } else { ((PackageFolder?)file.Parent)?.Detach(file); newFile = file; } Attach(newFile); newFile.IsSelected = true; IsExpanded = true; PackageViewModel?.NotifyChanges(); }
internal bool IsShowingFileContent(PackageFile file) { return(ShowContentViewer && CurrentFileInfo.File == file); }
private void SaveContentExecute(PackageFile file) { string selectedFileName; string title = "Save " + file.Name; const string filter = "All files (*.*)|*.*"; int filterIndex; if (UIServices.OpenSaveFileDialog(title, file.Name, /* initial directory */ null, filter, /* overwritePrompt */ true, out selectedFileName, out filterIndex)) { using (FileStream fileStream = File.OpenWrite(selectedFileName)) { file.GetStream().CopyTo(fileStream); } } }
private void ShowFile(PackageFile file) { object?content = null; var isBinary = false; // find all plugins which can handle this file's extension var contentViewers = FindContentViewer(file); if (contentViewers != null) { isBinary = true; try { // iterate over all plugins, looking for the first one that return non-null content foreach (var viewer in contentViewers) { // Get peer files var peerFiles = file.Parent !.GetFiles() .Select(pf => new PackageFile(pf, Path.GetFileName(pf.Path), file.Parent !)) .ToList(); content = viewer.GetView(file, peerFiles); if (content != null) { // found a plugin that can read this file, stop break; } } } catch (Exception ex) when(!(ex is FileNotFoundException)) { DiagnosticsClient.Notify(ex); // don't let plugin crash the app content = Resources.PluginFailToReadContent + Environment.NewLine + ex.ToString(); } if (content is string) { isBinary = false; } } // if plugins fail to read this file, fall back to the default viewer var truncated = false; if (content == null) { isBinary = FileHelper.IsBinaryFile(file.Name); if (isBinary) { content = Resources.UnsupportedFormatMessage; } else { content = ReadFileContent(file, out truncated); } } long size = -1; IReadOnlyList <AuthenticodeSignature> sigs; SignatureCheckResult isValidSig; using (var str = file.GetStream()) using (var tempFile = new TemporaryFile(str, Path.GetExtension(file.Name))) { var extractor = new FileInspector(tempFile.FileName); sigs = extractor.GetSignatures().ToList(); isValidSig = extractor.Validate(); size = tempFile.Length; } var fileInfo = new FileContentInfo( file, file.Path, content, !isBinary, size, truncated, sigs, isValidSig); ViewModel.ShowFile(fileInfo); }
internal bool IsShowingFileContent(PackageFile file) { return ShowContentViewer && CurrentFileInfo.File == file; }
private IEnumerable<IPackageContentViewer> FindContentViewer(PackageFile file) { string extension = Path.GetExtension(file.Name); return from p in ViewModel.ContentViewerMetadata where p.Metadata.SupportedExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase) orderby p.Metadata.Priority select p.Value; }
private bool SaveContentCanExecute(PackageFile file) { return(!IsInEditFileMode); }
private void ShowFile(PackageFile file) { long size = -1; object content = null; bool isBinary = false; // find all plugins which can handle this file's extension IEnumerable<IPackageContentViewer> contentViewers = FindContentViewer(file); if (contentViewers != null) { isBinary = true; try { // iterate over all plugins, looking for the first one that return non-null content foreach (IPackageContentViewer viewer in contentViewers) { using (Stream stream = file.GetStream()) { if (size == -1) { size = stream.Length; } content = viewer.GetView(Path.GetExtension(file.Name), stream); if (content != null) { // found a plugin that can read this file, stop break; } } } } catch (Exception ex) { // don't let plugin crash the app content = Resources.PluginFailToReadContent + Environment.NewLine + ex.ToString(); } if (content is string) { isBinary = false; } } // if plugins fail to read this file, fall back to the default viewer if (content == null) { isBinary = FileHelper.IsBinaryFile(file.Name); if (isBinary) { // don't calculate the size again if we already have it if (size == -1) { using (Stream stream = file.GetStream()) { size = stream.Length; } } content = Resources.UnsupportedFormatMessage; } else { content = ReadFileContent(file, out size); } } var fileInfo = new FileContentInfo( file, file.Path, content, !isBinary, size); ViewModel.ShowFile(fileInfo); }
internal void ShowFileContent(PackageFile file) { ViewContentCommand.Execute(file); }
internal void ReplaceFile(PackageFile oldFile) { string selectedFileName; bool result = PackageViewModel.UIServices.OpenFileDialog("Select New File", "All files (*.*)|*.*", out selectedFileName); if (result) { ReplaceFile(oldFile, selectedFileName); } }
public void AddFile(PackageFile file, bool makeCopy = false) { if (file == null) { throw new ArgumentNullException("file"); } if (Contains(file)) { return; } PackagePart newFile; if (makeCopy) { string fileCopyPath; using (Stream originalFileStream = file.GetStream()) { fileCopyPath = FileHelper.CreateTempFile(file.Name, originalFileStream); } string newTargetPath = this.Path + "\\" + file.Name; var physicalFile = new PhysicalPackageFile(isTempFile: true, originalPath: fileCopyPath, targetPath: newTargetPath); newFile = new PackageFile(physicalFile, file.Name, this); } else { // detach from current parent if (file.Parent != null) { file.Parent.Detach(file); } newFile = file; } Attach(newFile); newFile.IsSelected = true; IsExpanded = true; PackageViewModel.NotifyChanges(); }
public PackageFile AddFile(string filePath, bool isTempFile) { if (!File.Exists(filePath)) { throw new ArgumentException("File does not exist.", "filePath"); } string newFileName = System.IO.Path.GetFileName(filePath); if (ContainsFolder(newFileName)) { PackageViewModel.UIServices.Show(Resources.FileNameConflictWithExistingDirectory, MessageLevel.Error); return null; } bool showingRemovedFile = false; if (ContainsFile(newFileName)) { bool confirmed = PackageViewModel.UIServices.Confirm( Resources.ConfirmToReplaceExsitingFile_Title, String.Format(CultureInfo.CurrentCulture, Resources.ConfirmToReplaceExsitingFile, newFileName), isWarning: true); if (confirmed) { var part = this[newFileName] as PackageFile; showingRemovedFile = PackageViewModel.IsShowingFileContent(part); // remove the existing file before adding the new one RemoveChildByName(newFileName); } else { return null; } } string newTargetPath = this.Path + "\\" + newFileName; var physicalFile = new PhysicalPackageFile(isTempFile, filePath, newTargetPath); var newFile = new PackageFile(physicalFile, newFileName, this); Children.Add(newFile); newFile.IsSelected = true; IsExpanded = true; PackageViewModel.NotifyChanges(); if (showingRemovedFile) { PackageViewModel.ShowFileContent(newFile); } return newFile; }
private void ShowFile(PackageFile file) { object content = null; var isBinary = false; // find all plugins which can handle this file's extension var contentViewers = FindContentViewer(file); if (contentViewers != null) { isBinary = true; try { // iterate over all plugins, looking for the first one that return non-null content foreach (var viewer in contentViewers) { using (var stream = file.GetStream()) { content = viewer.GetView(Path.GetExtension(file.Name), stream); if (content != null) { // found a plugin that can read this file, stop break; } } } } catch (Exception ex) { // don't let plugin crash the app content = Resources.PluginFailToReadContent + Environment.NewLine + ex.ToString(); } if (content is string) { isBinary = false; } } // if plugins fail to read this file, fall back to the default viewer long size = -1; if (content == null) { isBinary = FileHelper.IsBinaryFile(file.Name); if (isBinary) { content = Resources.UnsupportedFormatMessage; } else { content = ReadFileContent(file, out size); } } if (size == -1) { // This is inefficient but cn be cleaned up later using (var str = file.GetStream()) using (var ms = new MemoryStream()) { str.CopyTo(ms); size = ms.Length; } } var fileInfo = new FileContentInfo( file, file.Path, content, !isBinary, size); ViewModel.ShowFile(fileInfo); }
private bool SaveContentCanExecute(PackageFile file) { return !IsInEditFileMode; }
public PackageFile AddFile(string filePath) { if (!File.Exists(filePath)) { throw new ArgumentException("File does not exist.", "filePath"); } string newFileName = System.IO.Path.GetFileName(filePath); if (ContainsFolder(newFileName)) { PackageViewModel.UIServices.Show(Resources.FileNameConflictWithExistingDirectory, Types.MessageLevel.Error); return null; } bool showingRemovedFile = false; if (ContainsFile(newFileName)) { bool confirmed = PackageViewModel.UIServices.Confirm(Resources.ConfirmToReplaceExsitingFile, true); if (confirmed) { // check if we are currently showing the content of the file to be removed. // if we are, we'll need to show the new content after replacing the file. if (PackageViewModel.ShowContentViewer) { PackagePart part = this[newFileName]; if (PackageViewModel.CurrentFileInfo.File == part) { showingRemovedFile = true; } } // remove the existing file before adding the new one RemoveChildByName(newFileName); } else { return null; } } var physicalFile = new PhysicalFile(filePath); var newFile = new PackageFile(physicalFile, newFileName, this); Children.Add(newFile); newFile.IsSelected = true; this.IsExpanded = true; PackageViewModel.NotifyChanges(); if (showingRemovedFile) { ICommand command = PackageViewModel.ViewContentCommand; command.Execute(newFile); } return newFile; }