Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed issues in commit panel.

  • Loading branch information...
commit ddce7d3ceba606f347d25c36a180232ac9774dd1 1 parent b60778e
@kaisellgren authored
View
27 UserControls/CommitPanel.xaml
@@ -4,14 +4,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:userControls="clr-namespace:GG.UserControls"
- xmlns:converters="clr-namespace:GG.Converters"
- mc:Ignorable="d"
+ mc:Ignorable="d"
+ Loaded="CommitPanelLoaded"
d:DesignHeight="480" d:DesignWidth="640">
- <UserControl.Resources>
- <converters:NullToVisibilityConverter x:Key="nullToVisibilityConverter" />
- </UserControl.Resources>
-
<DockPanel>
<userControls:Panel>
<userControls:Panel.Header>
@@ -29,16 +25,16 @@
<ComboBox ToolTip="Copy a previous commit message. The entire message will be copied."
ItemsSource="{Binding RecentCommitMessages}"
DisplayMemberPath="CroppedMessage"
- Loaded="ComboBoxLoaded"
+ Initialized="ComboBoxInitialized"
SelectionChanged="OnRecentCommitMessagesSelectionChanged"
Width="135" Margin="0,4,4,4">
</ComboBox>
- <WrapPanel Margin="8,9,0,0" Visibility="{Binding SelectedItem, ElementName=RecentCommitMessages, Converter={StaticResource nullToVisibilityConverter}}">
+ <WrapPanel Margin="8,9,0,0" Visibility="Visible">
<Image Source="../Resources/Icons/MessageWrite.png" Stretch="None" Margin="0,0,4,0" />
<TextBlock IsHitTestVisible="False" Text="Copy a message" Foreground="#333" />
</WrapPanel>
</Grid>
- <Button Margin="0,3,3,3" Command="{Binding CommitCommand}" CommandParameter="{Binding Text, ElementName=CommitMessageTextBox}">
+ <Button Initialized="ButtonInitialized" Margin="0,3,3,3">
<WrapPanel>
<Image Source="../Resources/Icons/RepositoryWrite.png" Width="16" Margin="0,0,4,0" />
<TextBlock>Commit</TextBlock>
@@ -49,22 +45,15 @@
<userControls:Panel.Body>
<DockPanel Margin="4" VerticalAlignment="Stretch">
- <TextBox Loaded="TextBoxLoaded"
+ <TextBox
ToolTip="Enter your commit message."
FontSize="12"
FontFamily="Courier New"
DockPanel.Dock="Top"
+ Initialized="TextBoxInitialized"
LostFocus="CommitMessageLostFocus"
GotFocus="CommitMessageGotFocus"
- Height="51">
-
- <TextBox.InputBindings>
- <KeyBinding Key="Enter"
- Modifiers="Control"
- Command="{Binding CommitCommand}"
- CommandParameter="{Binding Text, ElementName=CommitMessageTextBox}" />
- </TextBox.InputBindings>
- </TextBox>
+ Height="51" />
<userControls:DiffPanel DockPanel.Dock="Bottom" Margin="0,4,0,0" />
</DockPanel>
View
51 UserControls/CommitPanel.xaml.cs
@@ -1,6 +1,8 @@
using System;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Input;
using GG.Libraries;
using GG.Models;
@@ -16,11 +18,6 @@ public CommitPanel()
InitializeComponent();
}
- private void TextBoxLoaded(object sender, RoutedEventArgs e)
- {
- ((TextBox) sender).Name = "CommitMessageTextBox";
- }
-
private void OnRecentCommitMessagesSelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Retrieve elements.
@@ -40,11 +37,6 @@ private void OnRecentCommitMessagesSelectionChanged(object sender, SelectionChan
recentCommitMessages.SelectedIndex = -1;
}
- private void ComboBoxLoaded(object sender, RoutedEventArgs e)
- {
- ((ComboBox) sender).Name = "RecentCommitMessages";
- }
-
private void CommitMessageLostFocus(object sender, RoutedEventArgs e)
{
@@ -54,5 +46,44 @@ 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
}
}
View
5 UserControls/MainMenu.xaml.cs
@@ -1,5 +1,6 @@
-using System;
+using System.Windows;
using System.Windows.Controls;
+using GG.Libraries;
namespace GG.UserControls
{
@@ -13,4 +14,4 @@ public MainMenu()
InitializeComponent();
}
}
-}
+}
View
13 ViewModels/RepositoryViewModel.cs
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows;
-using System.Windows.Data;
using System.Windows.Threading;
using System.Windows.Controls;
using System.Windows.Media.Effects;
@@ -359,7 +357,7 @@ private void StageUnstage(object action)
/// <param name="action"></param>
private void CommitChanges(object action)
{
- var commitMessage = (string) action;
+ var commitMessage = ((TextBox) action).Text;
Task.Run(() =>
{
@@ -384,7 +382,12 @@ private void CommitChanges(object action)
/// <param name="action"></param>
private bool CommitChanges_CanExecute(object action)
{
- var commitMessage = (string) action;
+ var textBox = ((TextBox) action);
+
+ if (textBox == null)
+ return false;
+
+ var commitMessage = textBox.Text;
// Only allow commit if there's something to commit and there's a commit message.
if (commitMessage != null && StatusItemsStaged.Count > 0)
@@ -727,7 +730,7 @@ private void LoadRecentCommitMessages()
/// <param name="collection"> </param>
public void UpdateStatusItemDiff(IList collection)
{
- if (NotOpened == true)
+ if (NotOpened)
return;
var diff = "";
Please sign in to comment.
Something went wrong with that request. Please try again.