-
Notifications
You must be signed in to change notification settings - Fork 19
/
CommitPanel.xaml.cs
89 lines (71 loc) · 2.79 KB
/
CommitPanel.xaml.cs
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
85
86
87
88
89
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using GG.Libraries;
using GG.Models;
namespace GG.UserControls
{
/// <summary>
/// Interaction logic for CommitPanel.xaml
/// </summary>
public partial class CommitPanel : UserControl
{
public CommitPanel()
{
InitializeComponent();
}
private void OnRecentCommitMessagesSelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Retrieve elements.
var recentCommitMessages = UIHelper.FindChild<ComboBox>(this, "RecentCommitMessages");
var commitMessageBox = UIHelper.FindChild<TextBox>(this, "CommitMessageTextBox");
var selectedRecentCommitMessage = recentCommitMessages.SelectedItem as RecentCommitMessage;
if (selectedRecentCommitMessage == null)
return;
// Set the commit text box value.
commitMessageBox.Text = selectedRecentCommitMessage.FullMessage;
commitMessageBox.Focus();
// Reset the drop down menu.
recentCommitMessages.SelectedIndex = -1;
}
private void CommitMessageLostFocus(object sender, RoutedEventArgs e)
{
}
private void CommitMessageGotFocus(object sender, RoutedEventArgs e)
{
}
private void CommitPanelLoaded(object sender, RoutedEventArgs e)
{
// Find elements.
var commitButton = UIHelper.FindChild<Button>(this, "CommitButton");
var commitMessageBox = UIHelper.FindChild<TextBox>(this, "CommitMessageTextBox");
// Set up bindings for commit button.
commitButton.Command = ((RepositoryViewModel) DataContext).CommitCommand;
commitButton.CommandParameter = commitMessageBox;
// Set up bindings for commit text box.
commitMessageBox.InputBindings.Add(new KeyBinding
{
Key = Key.Enter,
Modifiers = ModifierKeys.Control,
Command = ((RepositoryViewModel) DataContext).CommitCommand,
CommandParameter = commitMessageBox
});
}
#region Names.
private void ComboBoxInitialized(object sender, EventArgs e)
{
((ComboBox) sender).Name = "RecentCommitMessages";
}
private void TextBoxInitialized(object sender, EventArgs e)
{
((TextBox) sender).Name = "CommitMessageTextBox";
}
private void ButtonInitialized(object sender, EventArgs e)
{
((Button) sender).Name = "CommitButton";
}
#endregion
}
}