|
1 | 1 | using System; |
2 | 2 | using System.Windows; |
| 3 | +using System.Windows.Input; |
3 | 4 | using System.Windows.Controls; |
4 | 5 | using System.Windows.Controls.Primitives; |
5 | 6 | using System.ComponentModel.Composition; |
|
9 | 10 | using GitHub.Services; |
10 | 11 | using GitHub.Models; |
11 | 12 | using GitHub.Logging; |
| 13 | +using GitHub.Extensions; |
12 | 14 | using Serilog; |
13 | 15 | using ReactiveUI; |
14 | 16 |
|
@@ -69,12 +71,17 @@ void RefreshCurrentSession() |
69 | 71 |
|
70 | 72 | PullRequestStatusViewModel CreatePullRequestStatusViewModel(IPullRequestModel pullRequest) |
71 | 73 | { |
72 | | - var pullRequestStatusViewModel = new PullRequestStatusViewModel(showCurrentPullRequestCommand); |
| 74 | + var trackingCommand = new UsageTrackingCommand(showCurrentPullRequestCommand, usageTracker); |
| 75 | + var pullRequestStatusViewModel = new PullRequestStatusViewModel(trackingCommand); |
73 | 76 | pullRequestStatusViewModel.Number = pullRequest.Number; |
74 | 77 | pullRequestStatusViewModel.Title = pullRequest.Title; |
75 | 78 | return pullRequestStatusViewModel; |
76 | 79 | } |
77 | 80 |
|
| 81 | + void IncrementNumberOfShowCurrentPullRequest() |
| 82 | + { |
| 83 | + } |
| 84 | + |
78 | 85 | void ShowStatus(PullRequestStatusViewModel pullRequestStatusViewModel = null) |
79 | 86 | { |
80 | 87 | var statusBar = FindSccStatusBar(Application.Current.MainWindow); |
@@ -113,5 +120,41 @@ StatusBar FindSccStatusBar(Window mainWindow) |
113 | 120 | var contentControl = mainWindow?.Template?.FindName(StatusBarPartName, mainWindow) as ContentControl; |
114 | 121 | return contentControl?.Content as StatusBar; |
115 | 122 | } |
| 123 | + |
| 124 | + class UsageTrackingCommand : ICommand |
| 125 | + { |
| 126 | + readonly ICommand command; |
| 127 | + readonly IUsageTracker usageTracker; |
| 128 | + |
| 129 | + internal UsageTrackingCommand(ICommand command, IUsageTracker usageTracker) |
| 130 | + { |
| 131 | + this.command = command; |
| 132 | + this.usageTracker = usageTracker; |
| 133 | + } |
| 134 | + |
| 135 | + public event EventHandler CanExecuteChanged |
| 136 | + { |
| 137 | + add |
| 138 | + { |
| 139 | + command.CanExecuteChanged += value; |
| 140 | + } |
| 141 | + |
| 142 | + remove |
| 143 | + { |
| 144 | + command.CanExecuteChanged -= value; |
| 145 | + } |
| 146 | + } |
| 147 | + |
| 148 | + public bool CanExecute(object parameter) |
| 149 | + { |
| 150 | + return command.CanExecute(parameter); |
| 151 | + } |
| 152 | + |
| 153 | + public void Execute(object parameter) |
| 154 | + { |
| 155 | + command.Execute(parameter); |
| 156 | + usageTracker.IncrementCounter(x => x.NumberOfShowCurrentPullRequest).Forget(); |
| 157 | + } |
| 158 | + } |
116 | 159 | } |
117 | 160 | } |
0 commit comments