调用标准"文件更改的Visual Studio&QUOT之外;对话 [英] Invoking standard "File changed outside Visual Studio" dialog
问题描述
我已经succesfuly创造了我的VSPackage的自定义的单一视图编辑器。其中的很多事情我不得不面对被反应情况,当编辑文件的Visual Studio之外被改变 - 在Visual Studio中显示对话框的标准编辑器中包含的选择是,是所有(重装内容)等,所以,如果更多的文件发生了变化,只显示一个对话框。
I have succesfuly created custom single view editor in my VSPackage. One of many things I had to cope with was reacting to situation when edited file was changed outside Visual Studio - "standard" editors in Visual Studio display dialog with options like "yes", "yes to all" (reload content) etc., so if more files had changed, only one dialog is displayed.
不过,我唯一能在我的VSPackage的做的,到目前为止是显示自定义对话框时,文件发生了变化。它不是pretty的 - 。当编辑我的编辑文件改变连同其他一些,将有向用户显示两个完全不同的对话框
However, the only thing I can do in my VSPackage so far is display custom dialog when the file had changed. It is not pretty - when file edited in my editor changed along with some others, there will be two completely different dialogs displayed to the user.
所以,问题是 - ?有什么办法如何调用标准的Visual Studio文件更改外VS对话框中为我的文件
So the question is - is there any way how to invoke "standard" Visual Studio "file changed outside VS" dialog for my file?
推荐答案
听起来你正在使用的<一个href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsfilechangeex.aspx"相对=nofollow> IVSFileChangeEx 接口。
Sounds like you are using the IVSFileChangeEx interface.
这博客帖子几乎可以是你要找的。通常这是用来检查是否一个文件可以被编辑或重新装载,并会提供一个文件对话框提示(退房或重装)。
This blog post might be almost what you're looking for. Normally this is used for checking to see if a file can be edited, or reloaded and will provide a file dialog prompt to (check-out or reload).
本使用<一个href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsqueryeditquerysave2%28v=vs.100%29.aspx"相对=nofollow> IVsQueryEditQuerySave2 接口。你可能想调用 DeclareReloadableFile
,从而将国家,如果它在磁盘上更改文件将被重新加载。
This uses the IVsQueryEditQuerySave2 interface. You probably want to call DeclareReloadableFile
, which will "States that a file will be reloaded if it changes on disk."
private bool CanEditFile()
{
// --- Check the status of the recursion guard
if (_GettingCheckoutStatus) return false;
try
{
_GettingCheckoutStatus = true;
IVsQueryEditQuerySave2 queryEditQuerySave =
(IVsQueryEditQuerySave2)GetService(typeof(SVsQueryEditQuerySave));
// ---Now call the QueryEdit method to find the edit status of this file
string[] documents = { _FileName };
uint result;
uint outFlags;
int hr = queryEditQuerySave.QueryEditFiles(
0, // Flags
1, // Number of elements in the array
documents, // Files to edit
null, // Input flags
null, // Input array of VSQEQS_FILE_ATTRIBUTE_DATA
out result, // result of the checkout
out outFlags // Additional flags
);
if (ErrorHandler.Succeeded(hr) && (result ==
(uint)tagVSQueryEditResult.QER_EditOK))
{
return true;
}
}
finally
{
_GettingCheckoutStatus = false;
}
return false;
}
这篇关于调用标准&QUOT;文件更改的Visual Studio&QUOT之外;对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!