This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathPullRequestReviewCommentView.xaml.cs
More file actions
84 lines (72 loc) · 2.46 KB
/
Copy pathPullRequestReviewCommentView.xaml.cs
File metadata and controls
84 lines (72 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.ComponentModel.Composition;
using System.Windows.Input;
using GitHub.Exports;
using GitHub.Services;
using GitHub.UI;
using GitHub.ViewModels;
using GitHub.VisualStudio.UI.Helpers;
using ReactiveUI;
namespace GitHub.VisualStudio.Views
{
public class GenericPullRequestReviewCommentView : ViewBase<IPullRequestReviewCommentViewModel, GenericPullRequestReviewCommentView> { }
[ExportViewFor(typeof(IPullRequestReviewCommentViewModel))]
[PartCreationPolicy(CreationPolicy.NonShared)]
public partial class PullRequestReviewCommentView : GenericPullRequestReviewCommentView
{
public PullRequestReviewCommentView()
{
InitializeComponent();
this.Loaded += CommentView_Loaded;
bodyMarkdown.PreviewMouseWheel += ScrollViewerUtilities.FixMouseWheelScroll;
this.WhenActivated(d =>
{
d(ViewModel.OpenOnGitHub.Subscribe(_ => DoOpenOnGitHub()));
});
}
static IVisualStudioBrowser GetBrowser()
{
return Services.GitHubServiceProvider.GetService<IVisualStudioBrowser>();
}
void DoOpenOnGitHub()
{
GetBrowser().OpenUrl(ViewModel.WebUrl);
}
private void CommentView_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
if (buttonPanel.IsVisible)
{
BringIntoView();
body.Focus();
}
}
private void ReplyPlaceholder_GotFocus(object sender, System.Windows.RoutedEventArgs e)
{
var command = (ICommand)((ICommentViewModel)DataContext)?.BeginEdit;
if (command?.CanExecute(null) == true)
{
command.Execute(null);
}
}
private void buttonPanel_IsVisibleChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
{
if (buttonPanel.IsVisible)
{
BringIntoView();
}
}
void OpenHyperlink(object sender, ExecutedRoutedEventArgs e)
{
Uri uri;
if (Uri.TryCreate(e.Parameter?.ToString(), UriKind.Absolute, out uri))
{
GetBrowser().OpenUrl(uri);
}
}
private void body_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
var textBox = (PromptTextBox)sender;
textBox.SelectAll();
}
}
}