7
Hide Sign in (2019)
public class E : VisualCommanderExt.IExtension
{
public void SetSite(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
enabled = DTE.Version.Substring(0, 2) == "16";
if (enabled)
{
timer = new System.Windows.Threading.DispatcherTimer();
timer.Interval = System.TimeSpan.FromMilliseconds(1000);
timer.Tick += OnTimer;
if (!HideAll())
timer.Start();
}
}
public void Close()
{
if (enabled)
timer.Stop();
}
private void OnTimer(System.Object o, System.EventArgs a)
{
try
{
if (HideAll())
timer.Stop();
}
catch (System.Exception e)
{
}
}
private bool HideAll()
{
return HideElement("PART_TitleBarRightFrameControlContainer");
}
private bool HideElement(string name)
{
System.Windows.FrameworkElement e =
FindElement(System.Windows.Application.Current.MainWindow,
name);
if (e != null)
{
e.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 bool enabled;
private System.Windows.Threading.DispatcherTimer timer;
}
Extension
CS
v4.0
true
false