Can I hide the smiley in Visual Studio 2015 final? - visual-studio

In Visual Studio 2015 RC, there was that Feedback smiley in the upper right of the main window.
Unfortunately, it is still there in the final release of Visual Studio 2015:
I've searched all through the options and settings and found no way to hide this smiley.
My question:
Any option or other (Registry etc.) hack to remove the smiley?
Update 2015-12-01:
Yesterday Update 1 for Visual Studio was released.
While I still find no option to hide the smiley, they at least provided a less distracting icon for it:

Edit:
Visual Studio 2015 Update 1 changes the feedback icon to an understated black and white one so no more smiley! It's not mentioned in the release notes.
Original answer:
As in OPs answer, this icon is specified in this registry key:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0_Config\MainWindowFrameControls{F66FBC48-9AE4-41DC-B1AF-0D64F0F54A07}
if you delete the key, Visual Studio recreates it, but if you invalidate the "Package" value of the registry key and restart Visual Studio then the smiley icon is gone:
However, when you install a Visual Studio update (eg SSDT, Resharper) the installer restores the package value, and the smiley is back. So I have created a registry file like this to run when the smiley reappears:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0_Config\MainWindowFrameControls\{F66FBC48-9AE4-41DC-B1AF-0D64F0F54A07}]
#="Feedback Button"
"Package"="{00000000-AA51-43B1-97EE-509A33B681F3}"
"DisplayName"="#1001"
"ViewFactory"="{060EAB95-139E-407D-BEDC-CC2B7A9B39D4}"
"ViewId"=dword:00000064
"Alignment"="TitleBarRight"
"Sort"=dword:00000064
"FullScreenAlignment"="MenuBarRight"
"FullScreenSort"=dword:00000064
This doesn't seem to affect startup time or stability, but there are no guarantees, registry changes are bad mmm, etc.

Thanks to Jehof's hint for Visual Studio 2013, I was able to resolve this:
Deleting the following Registry key actually helped.
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0_Config\MainWindowFrameControls\{F66FBC48-9AE4-41DC-B1AF-0D64F0F54A07}
(Please note the 14.0 instead of the 12.0 in the linked blog post)
After restarting Visual Studio, the Feedback button is now gone.
Update one day later
Suddenly the Feedback icon is here again. And the registry key is here again, too.
How on earth can this happen?
Seems the smiley resurrected from its grave. I'm really frightened now…

Following the advice in this thread, I modified also the registry key and it worked at first, but VS2015 keeps recreating the key to its original value after a while.
To remedy that, I added a VS2015 shortcut in Taskbar, and then Shift+Right Click to access 'Properties'. Replace the Target path of the shortcut pointing to devenv.exe with a own local c:\tools\vs.bat file.
Additionally, I changed Run to 'Minimized' in the shortcut properties. The vs.bat looks as follows:
#echo off
reg ADD HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0_Config\MainWindowFrameControls\{F66FBC48-9AE4-41DC-B1AF-0D64F0F54A07} /v Package /t REG_SZ /d {00000000-AA51-43B1-97EE-509A33B681F3} /f 2> nul
start /B devenv.exe
This ensures the key is overwritten every time I start VS2015 via Taskbar shourtcut. I found this to be reliably working for me.
If you ever start VS without this (e.g., on a VS restart), you may need to run the above twice.

I have removed value of Alignment key (just left it empty). The icon has gone until now but I didn't install no updates yet. Will keep posting.
UPDATE Restoring VS2015 not only restored this button but also changed the way it is configured: now my method doesn't work. Moreover, removing the registry key no longer helps. Wrote to MS through this helpful tool.

The Visual Commander extension allows creation of extensions which can hook into events. One provided example is hiding the feedback icon.
// References: System.Xaml
public class E : VisualCommanderExt.IExtension
{
public void SetSite(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
timer = new System.Windows.Threading.DispatcherTimer();
timer.Interval = System.TimeSpan.FromMilliseconds(1000);
timer.Tick += OnTimer;
timer.Start();
}
public void Close()
{
timer.Stop();
}
private void OnTimer(System.Object o, System.EventArgs a)
{
try
{
if (HideSignIn() && HideFeedback())
;
}
catch (System.Exception e)
{
}
}
private bool HideSignIn()
{
System.Windows.FrameworkElement e =
FindElement(System.Windows.Application.Current.MainWindow,
"PART_MenuBarFrameControlContainer");
if (e != null)
{
e.Visibility = System.Windows.Visibility.Collapsed;
return true;
}
return false;
}
private bool HideFeedback()
{
System.Windows.FrameworkElement e =
FindElement(System.Windows.Application.Current.MainWindow,
"PART_TitleBarFrameControlContainer");
if (e != null)
{
System.Windows.DependencyObject o1 =
System.Windows.Media.VisualTreeHelper.GetChild(e, 0);
System.Windows.DependencyObject o2 =
System.Windows.Media.VisualTreeHelper.GetChild(o1, 0);
System.Windows.DependencyObject o3 =
System.Windows.Media.VisualTreeHelper.GetChild(o2, 0);
if (System.Windows.Media.VisualTreeHelper.GetChildrenCount(o3) == 3)
{
System.Windows.DependencyObject o4 =
System.Windows.Media.VisualTreeHelper.GetChild(o3, 1);
(o4 as System.Windows.FrameworkElement).Visibility =
System.Windows.Visibility.Collapsed;
return true;
}
}
return false;
}
private System.Windows.FrameworkElement FindElement(System.Windows.Media.Visual v, string name)
{
if (v == null)
return null;
for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(v); ++i)
{
System.Windows.Media.Visual child =
System.Windows.Media.VisualTreeHelper.GetChild(v, i) as
System.Windows.Media.Visual;
if (child != null)
{
System.Windows.FrameworkElement e =
child as System.Windows.FrameworkElement;
if (e != null && e.Name == name)
return e;
}
System.Windows.FrameworkElement result = FindElement(child, name);
if (result != null)
return result;
}
return null;
}
private System.Windows.Threading.DispatcherTimer timer;
}
Although, comparing this example with the hide publish button example it seems the OnTimer function should stop the timer once the icons have been hidden.
private void OnTimer(System.Object o, System.EventArgs a)
{
try
{
if (HideSignIn() && HideFeedback())
timer.Stop();
}
catch (System.Exception e)
{
}
}

This line of PowerShell removes the icon until an update is installed:
Set-ItemProperty -Path "HKCU:\Software\Microsoft\VisualStudio\14.0_Config\MainWindowFrameControls\{F66FBC48-9AE4-41DC-B1AF-0D64F0F54A07}" Package "{00000000-AA51-43B1-97EE-509A33B681F3}"

Related

Visual Studio Resources: Default Location for Add Existing File

In the Visual Studio Resources area, is there a way to set the default location in the file select dialog, when selecting "Add Existing File..."?
The default location, when clicking on that menu is:
C:\Program Files (x86)\Microsoft\Visual Studio\2017\Enterprise\Common7\IDE
True, it is a small thing, as selecting my Downloads folder or something else is easy, but I keep having to go somewhere else, usually my Downloads folder, and it would definitely save time to have the default location go somewhere else.
I know that the Open File common dialog, which Visual Studio uses, has the option in the initial structure to specify the initial (default) directory, so the only question is, if it is possible for the default directory to point somewhere else.
I am using Visual Studio 2017.
You can use my Visual Commander extension to monitor for the Resources.AddExistingFile command and set your preferred directory before its execution. See the following C# extension example:
public class E : VisualCommanderExt.IExtension
{
public void SetSite(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
events = DTE.Events;
commandEvents = events.get_CommandEvents(null, 0);
commands = DTE.Commands as EnvDTE80.Commands2;
commandEvents.BeforeExecute += OnBeforeExecute;
}
public void Close()
{
commandEvents.BeforeExecute -= OnBeforeExecute;
}
private void OnBeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)
{
string name = GetCommandName(Guid, ID);
if (name == "Resources.AddExistingFile")
System.IO.Directory.SetCurrentDirectory(#"c:\downloads");
}
private string GetCommandName(string Guid, int ID)
{
if (Guid == null)
return "null";
try
{
return commands.Item(Guid, ID).Name;
}
catch (System.Exception)
{
}
return "";
}
private EnvDTE.Events events;
private EnvDTE.CommandEvents commandEvents;
private EnvDTE80.Commands2 commands;
}

Is it possible to execute some code when visual studio enters break mode?

I have a large proces that I need to debug and the proces could stop at anytime. I have configured Visual Studio 2017, to stop at any thrown exception, as in, even if it is handled, because I want to see what caused the exception. What I need is some sort of alarm when this happens, so that I can leave the program to run and then alert me if anything comes up. The only thing I have found is an alarm sound when a break point is hit, but it might not be a break point and I need more than a sound, I need to be able to execute some code, so that I can make my Phone go nuts or whatever. Is there any way I can trigger code when the debugger enters break mode?
Thanks in advance.
It is, using a VS package. You'll need to add this attribute on top of the class in order for code to run on package startup:
[ProvideAutoLoad(Microsoft.VisualStudio.Shell.Interop.UIContextGuids80.SolutionExists)] ///Able to run code on solution startup
Add these class values variables:
private DTE2 applicationObject;
private BuildEvents buildEvents;
private DebuggerEvents debugEvents;
then the following code can run:
protected override void Initialize()
{
base.Initialize();
applicationObject = (DTE2)GetService(typeof(DTE));
buildEvents = applicationObject.Events.BuildEvents;
debugEvents = applicationObject.Events.DebuggerEvents;
SetupEventHandlers();
}
And finally the code we have "all" being waiting for:
private void SetupEventHandlers()
{
//buildEvents.OnBuildDone += (scope, action) =>
//{
//};
debugEvents.OnEnterBreakMode += delegate (dbgEventReason reason, ref dbgExecutionAction action)
{
};
//var componentModel =
// GetGlobalService(typeof(SComponentModel)) as IComponentModel;
//if (componentModel == null)
//{
// Debug.WriteLine("componentModel is null");
// return;
//}
//var operationState = componentModel.GetService<IOperationState>();
//operationState.StateChanged += OperationStateOnStateChanged;
}

In a Visual Studio Add-In, how to disable menu items during a build?

When you write a VS addin that proffers menu items to VS, it calls your QueryStatus implementation to check whether your menu items should be visible, enabled, etc.
My menu items are not appropriate to run during certain situations, e.g. when a build is happening. How do I detect whether there's a build running?
You're looking for the VsShellUtilities.IsSolutionBuilding method. An example of using it can be found the Managed Package Framework for Visual Studio 2010 (MPFProj10) in the ProjectNode class:
protected internal virtual bool IsCurrentStateASuppressCommandsMode()
{
if (VsShellUtilities.IsSolutionBuilding(this.Site))
{
return true;
}
DBGMODE dbgMode = VsShellUtilities.GetDebugMode(this.Site) & ~DBGMODE.DBGMODE_EncMask;
if (dbgMode == DBGMODE.DBGMODE_Run || dbgMode == DBGMODE.DBGMODE_Break)
{
return true;
}
return false;
}

Add button to the Visual Studio unloaded project context menu (Can't find the CommandBar its name)

NuGet package restore does not play well with the PostSharp package, this is of great annoyance to me and manually editing the csproj files is quickly becoming old.
I want to make a small Visual Studio AddIn that fixes the project for me by adding an extra button to the unloaded project context menu.
The problem I am facing sounds simple but haunts me: I somehow can't locate the CommandBar for the unloaded project context menu.
Thus, summarizing the question: What is the CommandBar name for the unloaded project context menu.
Many thanks!
Apparantly: "Stub Project". Found in the list at: CommandBar names
To sum up the OnConnection method to register this:
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
if (connectMode == ext_ConnectMode.ext_cm_UISetup)
{
object[] contextGUIDS = new object[] { };
Commands2 commands = (Commands2)_applicationObject.Commands;
string toolsMenuName = "Tools";
//Place the command on the tools menu.
//Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];
//Find the Tools command bar on the MenuBar command bar:
CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
CommandBars cmdBars = (CommandBars)(_applicationObject.CommandBars);
CommandBar vsBarProject = cmdBars["Stub Project"];
CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;
//This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in,
// just make sure you also update the QueryStatus/Exec method to include the new command names.
try
{
//Add a command to the Commands collection:
Command command = commands.AddNamedCommand2(_addInInstance, "FixNuGetPostSharp", "Fix NuGet PostSharp", "Executes the command for VsextensionTest", true, 0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
//Add a control for the command to the tools menu:
if ((command != null) && (toolsPopup != null))
{
command.AddControl(vsBarProject);
}
}
catch (System.ArgumentException)
{
//If we are here, then the exception is probably because a command with that name
// already exists. If so there is no need to recreate the command and we can
// safely ignore the exception.
}
}
}

Visual studio 2010: limiting the number of editor tabs

Visual studio doesn't appear to limit the number of opened editor tabs.
I'm using ReSharper and at a certain number of opened editor tabs things get really slow. So I have to keep track of opened tabs and periodically close old ones.
It would be cool if I could set a limit so that it would close old tabs when the limit is reached.
Is there a setting in VS / ReSharper or any VS addons that can help to achieve this?
I'm trying to solve this with a primitive addin at the moment. Seems to be working fine. Still testing it.
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_applicationObject.Events.WindowEvents.WindowCreated +=
window =>
{
if (window.Document != null)
{
documentWindows.AddFirst(window);
if(documentWindows.Count > 7)
{
Window lastWindow = documentWindows.Last.Value;
documentWindows.Remove(lastWindow);
lastWindow.Close(vsSaveChanges.vsSaveChangesYes);
}
}
};
_applicationObject.Events.WindowEvents.WindowClosing +=
window =>
{
if(window.Document != null)
{
documentWindows.Remove(window);
}
};
}

Resources