[Visual Studio] UI 요소 숨기기

Visual Studio는 매우 훌륭한 IDE입니다만, 사소한 부분에서 부족한 점이 있습니다. 창 상단의 툴바를 고정할 수 없다거나, 특정 UI 요소를 숨길 수 없다거나 하는 것 말이죠.

이 글에서는 은근히 거슬리는 로그인 버튼과 피드백 버튼을 제거하는 방법을 알려드리겠습니다.

Visual Commander 설치

먼저 Visual Commander 확장 패키지 설치가 필요합니다.

Visual Studio를 연 뒤, '확장 - 확장 관리' 메뉴를 눌러 확장 관리자를 엽니다.

검색창에 Visual Commander를 검색한 후, 해당 확장 패키지를 설치합니다. Visual Studio를 완전히 종료해야 확장 패키지가 실제로 설치되므로, Visual Studio를 종료한 후, 다시 시작합니다.

이제 Visual Studio를 다시 열면 '확장' 메뉴 아래 VCmd 메뉴가 새로 생긴 것을 확인할 수 있습니다.

Extension 다운로드 및 불러오기

다음 두 파일을 다운로드합니다.

 1
 2 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 3   />
 4  
 5    
 6      1
 7      Hide Feedback in VS 2022
 8      public class HideFeedback : VisualCommanderExt.IExtension {
 9  private System.Windows.Threading.DispatcherTimer timer;
10  private string target = "FeedbackButton";
11  
12  public void SetSite(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) {
13    timer = new System.Windows.Threading.DispatcherTimer();
14    timer.Interval = System.TimeSpan.FromMilliseconds(1000);
15    timer.Tick += OnTimer;
16    if (!HideElement()) timer.Start();
17  }
18  
19  public void Close() { timer.Stop(); }
20  
21  private void OnTimer(System.Object o, System.EventArgs a) {
22    try { if (HideElement()) timer.Stop(); }
23    catch (System.Exception e) {}
24  }
25  
26  private bool HideElement() {
27    System.Windows.FrameworkElement e = FindElement(System.Windows.Application.Current.MainWindow, target);
28    if (e != null) {
29      e.Visibility = System.Windows.Visibility.Collapsed;
30      return true;
31    }
32    return false;
33  }
34  
35  private System.Windows.FrameworkElement FindElement(System.Windows.Media.Visual v, string name) {
36    if (v == null) return null;
37    for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(v); ++i) {
38      System.Windows.Media.Visual child = System.Windows.Media.VisualTreeHelper.GetChild(v, i) as System.Windows.Media.Visual;
39      if (child != null) {
40        System.Windows.FrameworkElement e = child as System.Windows.FrameworkElement;
41        if (e != null && e.Name == name) return e;
42      }
43      System.Windows.FrameworkElement result = FindElement(child, name);
44      if (result != null) return result;
45    }
46    return null;
47  }
48}
49
50       />
51      Extension
52      CS
53      v4.0
54      true
55      false
56    
57  
58   />
59
 1
 2 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 3   />
 4  
 5    
 6      2
 7      Hide Sign in VS 2022
 8      public class HideSignIn : VisualCommanderExt.IExtension {
 9  private System.Windows.Threading.DispatcherTimer timer;
10  private string target = "PART_TitleBarRightFrameControlContainer";
11  
12  public void SetSite(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) {
13    timer = new System.Windows.Threading.DispatcherTimer();
14    timer.Interval = System.TimeSpan.FromMilliseconds(1000);
15    timer.Tick += OnTimer;
16    if (!HideElement()) timer.Start();
17  }
18
19  public void Close() { timer.Stop(); }
20
21  private void OnTimer(System.Object o, System.EventArgs a) {
22    try { if (HideElement()) timer.Stop(); }
23    catch (System.Exception e) {}
24  }
25
26  private bool HideElement() {
27    System.Windows.FrameworkElement e = FindElement(System.Windows.Application.Current.MainWindow, target);
28    if (e != null) {
29      e.Visibility = System.Windows.Visibility.Collapsed;
30      return true;
31    }
32    return false;
33  }
34
35  private System.Windows.FrameworkElement FindElement(System.Windows.Media.Visual v, string name) {
36    if (v == null) return null;
37    for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(v); ++i) {
38      System.Windows.Media.Visual child = System.Windows.Media.VisualTreeHelper.GetChild(v, i) as System.Windows.Media.Visual;
39      if (child != null) {
40        System.Windows.FrameworkElement e = child as System.Windows.FrameworkElement;
41        if (e != null && e.Name == name) return e;
42      }
43      System.Windows.FrameworkElement result = FindElement(child, name);
44      if (result != null) return result;
45    }
46    return null;
47  }
48}
49
50       />
51      Extension
52      CS
53      v4.0
54      true
55      false
56    
57  
58   />
59

'확장 - VCmd - Import'를 눌러 두 vcmd 파일을 불러옵니다. 각각 하나의 Extension을 등록합니다.

이제 Visual Studio를 재시작하면 로그인 버튼과 피드백 버튼이 사라진 걸 확인할 수 있습니다.

comments powered by Disqus