In my Visual Studio extension I display related files.
I have code that can open a file in Visual Studio.
I want code that can preview a file
This is the code I use to open a file using the DTE2 object. But how can I preview the file?
public void ViewFile(FileInfo file)
{
if (null == file)
throw new ArgumentNullException(nameof(file));
var dte2 = (EnvDTE80.DTE2)DTE;
dte2.MainWindow.Activate();
var newWindow = dte2.ItemOperations.IsFileOpen(file.FullName)
? FindWindow(file.FullName)
: dte2.ItemOperations.OpenFile(file.FullName);
newWindow.Activate();
}
This is a previewed file, if you single click it in Solution Explorer:
This is an opened file, if you double click it in Solution Explorer, or make a change to a previewed file: