I got it raising the right command when a ITextView
is opened. This is important cause if a ITextView
it's not opened it seems to me the command just fails. The quicker way is to create an Editor Margin extension project (VS SDK must be installed). On the EditorMargin
class do this:
[Import]
private SVsServiceProvider _ServiceProvider;
private DTE2 _DTE2;
public EditorMargin1(IWpfTextView textView)
{
// [...]
_DTE2 = (DTE2)_ServiceProvider.GetService(typeof(DTE));
textView.GotAggregateFocus += new EventHandler(textView_GotAggregateFocus);
}
void textView_GotAggregateFocus(object sender, EventArgs e)
{
_DTE2.Commands.Raise(VSConstants.CMDSETID.StandardCommandSet2K_string,
(int)VSConstants.VSStd2KCmdID.TOGGLEVISSPACE, null, null);
// The following is probably the same
// _DET2.ExecuteCommand("Edit.ViewWhiteSpace");
}
Note: IWpfTextViewCreationListener
should be enough if you don't want to create a Margin. Learn about MEF extensions to use it.
Now, this setting was probably controlled in Tools -> Options page prior to VS2010 . Other options of that page can be controlled with DTE automation:
_DTE2.Properties["TextEditor", "General"].Item("DetectUTF8WithoutSignature").Value = true;
_DTE2.Properties["Environment", "Documents"].Item("CheckLineEndingsOnLoad").Value = true;
ShellSettingsManager
is only about writing to the registry, there's no settings refresh function (if it exists, it would be not efficient anyway cause it would have to reload the entire collection of settings). The previous ones were what I was looking for. Solving your problem was a bonus :)