1313using GitHub . Extensions ;
1414using System . Windows . Input ;
1515using ReactiveUI ;
16+ using GitHub . VisualStudio . UI ;
17+ using GitHub . Settings ;
18+ using System . Windows . Threading ;
19+ using GitHub . Info ;
1620
1721namespace GitHub . VisualStudio . TeamExplorer . Home
1822{
@@ -21,22 +25,58 @@ namespace GitHub.VisualStudio.TeamExplorer.Home
2125 public class GitHubHomeSection : TeamExplorerSectionBase , IGitHubHomeSection
2226 {
2327 public const string GitHubHomeSectionId = "72008232-2104-4FA0-A189-61B0C6F91198" ;
24- IVisualStudioBrowser visualStudioBrowser ;
28+ const string TrainingUrl = "https://services.github.com/on-demand/windows/visual-studio" ;
29+
30+ readonly IVisualStudioBrowser visualStudioBrowser ;
31+ readonly ITeamExplorerServices teamExplorerServices ;
32+ readonly IPackageSettings settings ;
33+ readonly IUsageTracker usageTracker ;
2534
2635 [ ImportingConstructor ]
2736 public GitHubHomeSection ( IGitHubServiceProvider serviceProvider ,
28- ISimpleApiClientFactory apiFactory , ITeamExplorerServiceHolder holder ,
29- IVisualStudioBrowser visualStudioBrowser )
37+ ISimpleApiClientFactory apiFactory ,
38+ ITeamExplorerServiceHolder holder ,
39+ IVisualStudioBrowser visualStudioBrowser ,
40+ ITeamExplorerServices teamExplorerServices ,
41+ IPackageSettings settings ,
42+ IUsageTracker usageTracker )
3043 : base ( serviceProvider , apiFactory , holder )
3144 {
3245 Title = "GitHub" ;
3346 View = new GitHubHomeContent ( ) ;
3447 View . DataContext = this ;
3548 this . visualStudioBrowser = visualStudioBrowser ;
49+ this . teamExplorerServices = teamExplorerServices ;
50+ this . settings = settings ;
51+ this . usageTracker = usageTracker ;
3652
3753 var openOnGitHub = ReactiveCommand . Create ( ) ;
3854 openOnGitHub . Subscribe ( _ => DoOpenOnGitHub ( ) ) ;
3955 OpenOnGitHub = openOnGitHub ;
56+
57+ // We want to display a welcome message but only if Team Explorer isn't
58+ // already displaying the "Install 3rd Party Tools" message. To do this
59+ // we need to set a timer and check in the tick as at this point the message
60+ // won't be initialized.
61+ if ( ! settings . HideTeamExplorerWelcomeMessage )
62+ {
63+ var timer = new DispatcherTimer ( ) ;
64+ timer . Interval = new TimeSpan ( 10 ) ;
65+ timer . Tick += ( s , e ) =>
66+ {
67+ timer . Stop ( ) ;
68+ if ( ! IsGitToolsMessageVisible ( ) )
69+ {
70+ ShowWelcomeMessage ( ) ;
71+ }
72+ } ;
73+ timer . Start ( ) ;
74+ }
75+ }
76+
77+ bool IsGitToolsMessageVisible ( )
78+ {
79+ return teamExplorerServices . IsNotificationVisible ( new Guid ( Guids . TeamExplorerInstall3rdPartyGitTools ) ) ;
4080 }
4181
4282 protected async override void RepoChanged ( bool changed )
@@ -107,6 +147,36 @@ void DoOpenOnGitHub()
107147 visualStudioBrowser ? . OpenUrl ( ActiveRepo . CloneUrl . ToRepositoryUrl ( ) ) ;
108148 }
109149
150+ void ShowWelcomeMessage ( )
151+ {
152+ var welcomeMessageGuid = new Guid ( Guids . TeamExplorerWelcomeMessage ) ;
153+ teamExplorerServices . ShowMessage (
154+ Resources . TeamExplorerWelcomeMessage ,
155+ new RelayCommand ( o =>
156+ {
157+ var str = o . ToString ( ) ;
158+
159+ switch ( str )
160+ {
161+ case "show-training" :
162+ visualStudioBrowser . OpenUrl ( new Uri ( TrainingUrl ) ) ;
163+ usageTracker . IncrementWelcomeTrainingClicks ( ) . Forget ( ) ;
164+ break ;
165+ case "show-docs" :
166+ visualStudioBrowser . OpenUrl ( new Uri ( GitHubUrls . Documentation ) ) ;
167+ usageTracker . IncrementWelcomeDocsClicks ( ) . Forget ( ) ;
168+ break ;
169+ case "dont-show-again" :
170+ teamExplorerServices . HideNotification ( welcomeMessageGuid ) ;
171+ settings . HideTeamExplorerWelcomeMessage = true ;
172+ settings . Save ( ) ;
173+ break ;
174+ }
175+ } ) ,
176+ false ,
177+ welcomeMessageGuid ) ;
178+ }
179+
110180 protected GitHubHomeContent View
111181 {
112182 get { return SectionContent as GitHubHomeContent ; }
0 commit comments