Permalink
Browse files

Added support for branch creation.

  • Loading branch information...
1 parent 18c1488 commit 94ea3b550948cac552411ba92d1a010e75183a45 @kaisellgren committed May 26, 2012
View
@@ -152,7 +152,6 @@
<DependentUpon>About.xaml</DependentUpon>
</Compile>
<Compile Include="AppTabDataTemplateSelector.cs" />
- <Compile Include="Command.cs" />
<Compile Include="Configuration.cs" />
<Compile Include="Converters\ExtensionToImageConverter.cs" />
<Compile Include="Converters\StatusGridGroupToColorConverter.cs" />
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -9,6 +10,7 @@
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
+using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
@@ -23,6 +25,23 @@ public partial class PromptDialog : Window
public PromptDialog()
{
InitializeComponent();
+
+ Application.Current.MainWindow.Effect = new BlurEffect
+ {
+ Radius = 4
+ };
+
+ Closing += OnClosing;
+ }
+
+ /// <summary>
+ /// Fired upon window closing.
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ void OnClosing(object sender, CancelEventArgs e)
+ {
+ Application.Current.MainWindow.Effect = null;
}
public string ResponseText
@@ -1,5 +1,4 @@
<UserControl x:Class="GG.UserControls.TopToolbar"
- x:Name="TopToolbarUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -19,7 +18,7 @@
<Separator Width="30" Height="1" Style="{StaticResource VerticalSeparatorStyle}" />
- <Button Command="{Binding Path=CreateBranchCommand, ElementName=TopToolbarUserControl}">
+ <Button Command="{Binding CreateBranchCommand}">
<StackPanel>
<Image Source="../Resources/Icons/Branch-24.png" Stretch="None" />
<TextBlock>Branch</TextBlock>
@@ -21,34 +21,9 @@ namespace GG.UserControls
/// </summary>
public partial class TopToolbar : UserControl
{
- public DelegateCommand CreateBranchCommand { get; private set; }
-
public TopToolbar()
{
InitializeComponent();
-
- CreateBranchCommand = new DelegateCommand(CreateBranch);
- }
-
- /// <summary>
- /// Creates a branch.
- /// </summary>
- /// <param name="action"></param>
- private void CreateBranch(object action)
- {
- Console.WriteLine("foo");
-
- var dialog = new PromptDialog
- {
- Title = "Creating a new branch",
- Message = "Please give a name for your new branch:"
- };
-
- dialog.ShowDialog();
-
- var name = dialog.DialogResult;
-
- Console.WriteLine(name);
}
}
}
@@ -13,6 +13,7 @@
using GG.Models;
using System.Windows.Controls;
using System.Windows.Media.Effects;
+using GG.UserControls.Dialogs;
namespace GG
{
@@ -60,6 +61,8 @@ public RepositoryViewModel()
StatusItemsGrouped.SortDescriptions.Add(new SortDescription("GenericStatus", ListSortDirection.Descending));
// Initialize commands.
+ CreateBranchCommand = new DelegateCommand(CreateBranch);
+
OpenAboutCommand = new DelegateCommand(OpenAbout);
StageUnstageCommand = new DelegateCommand(StageUnstage);
DeleteFileCommand = new DelegateCommand(DeleteFile);
@@ -70,11 +73,36 @@ public RepositoryViewModel()
/// </summary>
#region Commands.
+ public DelegateCommand CreateBranchCommand { get; set; }
+
public DelegateCommand OpenAboutCommand { get; private set; }
public DelegateCommand StageUnstageCommand { get; private set; }
public DelegateCommand DeleteFileCommand { get; private set; }
/// <summary>
+ /// Creates a branch.
+ /// </summary>
+ /// <param name="action"></param>
+ public void CreateBranch(object action)
+ {
+ var dialog = new PromptDialog
+ {
+ Title = "Creating a new branch",
+ Message = "Please give a name for your new branch:"
+ };
+
+ dialog.ShowDialog();
+
+ using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath))
+ {
+ var sha = repo.Head.Tip.Sha.ToString();
+ repo.Branches.Create(dialog.ResponseText, repo.Head.Tip.Sha.ToString());
+ }
+
+ ConstructRepository();
+ }
+
+ /// <summary>
/// Stages or unstages the selected item.
/// </summary>
/// <param name="action"></param>

0 comments on commit 94ea3b5

Please sign in to comment.