Permalink
Browse files

add commit selection

  • Loading branch information...
1 parent 40a5bfd commit 1509ecfb1b7bd2aa2377319d3945460f3c461a05 @yysun committed Sep 11, 2011
Showing with 74 additions and 20 deletions.
  1. +11 −9 HistoryView.xaml
  2. +41 −11 HistoryView.xaml.cs
  3. +15 −0 ResourceDictionary.xaml
  4. +1 −0 UI/CommitBox.xaml.cs
  5. +6 −0 UI/CommitDetails.xaml.cs
View
20 HistoryView.xaml
@@ -16,6 +16,7 @@
<UserControl.CommandBindings>
<CommandBinding Command="cmd:HistoryViewCommands.CloseCommitDetails" Executed="CloseCommitDetails_Executed" />
<CommandBinding Command="cmd:HistoryViewCommands.OpenCommitDetails" Executed="OpenCommitDetails_Executed" />
+ <CommandBinding Command="cmd:HistoryViewCommands.SelectCommit" Executed="SelectCommit_Executed" />
</UserControl.CommandBindings>
<Grid x:Name="Main" Margin="4">
@@ -28,18 +29,18 @@
<my:HistoryGraph Grid.Row="1" x:Name="HistoryGraph" />
<Grid>
- <Label Content="Branches:" Height="28" HorizontalAlignment="Left" Margin="6,2,0,0" Name="label1" VerticalAlignment="Top" />
- <Label Content="Tags:" Height="28" HorizontalAlignment="Left" Margin="6,26,0,0" Name="label2" VerticalAlignment="Top" />
- <ListBox x:Name="branchList" Margin="70,4,160,36" ItemsPanel="{DynamicResource ItemsPanelTemplate1}" ItemTemplate="{DynamicResource DataTemplate1}"
+ <Label Content="Branches" Height="28" HorizontalAlignment="Left" Margin="6,2,0,0" Name="label1" VerticalAlignment="Top" FontSize="10" />
+ <Label Content="Tags" Height="28" HorizontalAlignment="Left" Margin="6,26,0,0" Name="label2" VerticalAlignment="Top" FontSize="10" />
+ <ListBox x:Name="branchList" Margin="60,4,160,36" ItemsPanel="{DynamicResource ItemsPanelTemplate1}" ItemTemplate="{DynamicResource DataTemplate1}"
Background="#00000000" BorderBrush="{x:Null}" Height="20" ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"
ScrollViewer.HorizontalScrollBarVisibility="hidden" PreviewMouseDown="branchList_PreviewMouseDown" />
- <ListBox x:Name="tagList" Margin="70,26,160,14" ItemsPanel="{DynamicResource ItemsPanelTemplate1}" ItemTemplate="{DynamicResource DataTemplate1}"
+ <ListBox x:Name="tagList" Margin="60,26,160,14" ItemsPanel="{DynamicResource ItemsPanelTemplate1}" ItemTemplate="{DynamicResource DataTemplate1}"
Background="#00000000" BorderBrush="{x:Null}" Height="20" ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"
- ScrollViewer.HorizontalScrollBarVisibility="hidden"/>
+ ScrollViewer.HorizontalScrollBarVisibility="hidden" PreviewMouseDown="branchList_PreviewMouseDown" />
<CheckBox Content="Show simplified graph" HorizontalAlignment="Right" Margin="0,8,14,0" Name="checkBox1" Click="checkBox1_Click" Template="{DynamicResource ShowSimpleGraphCheckBoxControlTemplate}" VerticalAlignment="Top" ToolTip="Toggle View" />
<Label Content="Simplified view: off" HorizontalAlignment="Right" Margin="0,0,12,4" Name="lableView" VerticalAlignment="Bottom" FontSize="9.333" />
- <Grid.Background>
+ <Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFF2F2F2" Offset="0" />
<GradientStop Color="#FFDBDBDB" Offset="1" />
@@ -48,10 +49,11 @@
</Grid.Background>
</Grid>
<Button Content="Button" HorizontalAlignment="Right" Margin="0,8,43,28" Template="{DynamicResource SaveButtonControlTemplate}" Click="button1_Click" ToolTip="Export graph ..." />
- <Button Content="Button" HorizontalAlignment="Right" Margin="0,8,72,28" Template="{DynamicResource CompareButtonControlTemplate}" ToolTip="Compare ..." RenderTransformOrigin="1.25,0.5" IsEnabled="False" />
- </Grid>
+ <Button Content="Button" HorizontalAlignment="Right" Margin="0,8,72,28" Template="{DynamicResource CompareButtonControlTemplate}" ToolTip="Select two commits to compare ..." Name="btnCompare" Click="btnCompare_Click" />
+ <Button Content="0" HorizontalAlignment="Right" Margin="0,8,100,0" Name="btnCommitCount" VerticalAlignment="Top" Template="{DynamicResource CommitCountControlTemplate}" RenderTransformOrigin="-1.125,0.438" />
+ </Grid>
- <my:CommitDetails x:Name="details" RenderTransformOrigin="0,0" Visibility="Collapsed" Background="White">
+ <my:CommitDetails x:Name="details" Visibility="Collapsed" Background="White">
<my:CommitDetails.RenderTransform>
<TranslateTransform/>
</my:CommitDetails.RenderTransform>
View
52 HistoryView.xaml.cs
@@ -1,21 +1,12 @@
using System;
-using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
-using System.Text;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using System.Windows.Threading;
-using NGit.Revwalk;
-using NGit.Revplot;
-using GitScc.DataServices;
using System.Windows.Media.Animation;
+using GitScc.DataServices;
namespace GitScc
{
@@ -26,11 +17,13 @@ public partial class HistoryView : UserControl
{
HistoryToolWindow toolWindow;
private GitFileStatusTracker tracker;
+ private ObservableCollection<string> selectedCommits;
public HistoryView(HistoryToolWindow toolWindow)
{
InitializeComponent();
this.toolWindow = toolWindow;
+ this.selectedCommits = new ObservableCollection<string>();
}
public void InsertNewEditor(object editor)
@@ -43,6 +36,8 @@ public void InsertNewEditor(object editor)
internal void Refresh(GitFileStatusTracker tracker)
{
this.HistoryGraph.Show(tracker);
+ SetSelectedCommitCount();
+
this.tracker = tracker;
if (tracker == null) return;
@@ -80,6 +75,8 @@ private void checkBox1_Click(object sender, RoutedEventArgs e)
{
this.HistoryGraph.SetSimplified(checkBox1.IsChecked==true);
this.lableView.Content = checkBox1.IsChecked == true ? "Simplified view: ON" : "Simplified view: OFF";
+ this.selectedCommits.Clear();
+ SetSelectedCommitCount();
}
private void branchList_PreviewMouseDown(object sender, MouseButtonEventArgs e)
@@ -119,11 +116,44 @@ private void OpenCommitDetails_Executed(object sender, ExecutedRoutedEventArgs e
{
ShowCommitDetails(e.Parameter as string);
}
+
+ private void SelectCommit_Executed(object sender, ExecutedRoutedEventArgs e)
+ {
+ var commit = e.Parameter as string;
+ if (this.selectedCommits.Contains(commit))
+ selectedCommits.Remove(commit);
+ else
+ this.selectedCommits.Add(commit);
+
+ SetSelectedCommitCount();
+ }
+
+ private void btnCompare_Click(object sender, RoutedEventArgs e)
+ {
+ this.details.RenderTransform.SetValue(TranslateTransform.XProperty, this.ActualWidth);
+ this.details.Visibility = Visibility.Visible;
+ var animationDuration = TimeSpan.FromSeconds(.5);
+ var animation = new DoubleAnimation(0, new Duration(animationDuration));
+ animation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
+ this.details.RenderTransform.BeginAnimation(TranslateTransform.XProperty, animation);
+
+ this.details.Show(this.tracker, this.selectedCommits[0], this.selectedCommits[1]);
+ }
+
+ private void SetSelectedCommitCount()
+ {
+ this.btnCompare.IsEnabled = this.selectedCommits.Count() == 2;
+ this.btnCommitCount.Visibility = this.selectedCommits.Count() > 0 ?
+ Visibility.Visible : Visibility.Collapsed;
+ this.btnCommitCount.Content = this.selectedCommits.Count().ToString();
+ }
}
public static class HistoryViewCommands
{
public static readonly RoutedUICommand CloseCommitDetails = new RoutedUICommand("CloseCommitDetails", "CloseCommitDetails", typeof(HistoryView));
public static readonly RoutedUICommand OpenCommitDetails = new RoutedUICommand("OpenCommitDetails", "OpenCommitDetails", typeof(HistoryView));
+ public static readonly RoutedUICommand SelectCommit = new RoutedUICommand("SelectCommit", "SelectCommit", typeof(HistoryView));
+
}
}
View
15 ResourceDictionary.xaml
@@ -147,4 +147,19 @@
<TextBlock x:Name="textBlock" Margin="0" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FF99B6D6" FontSize="14.667"><Span FontFamily="Webdings" Language="en-us"><Run Text="~"/></Span></TextBlock>
</Grid>
</ControlTemplate>
+ <ControlTemplate x:Key="CommitCountControlTemplate" TargetType="{x:Type Button}">
+ <Grid Width="16" Height="16">
+ <Ellipse Fill="White" Stroke="#FF99B6D1" StrokeThickness="2"/>
+ <TextBlock TextWrapping="Wrap" Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FF576B7C" FontSize="8" FontWeight="Bold" Margin="0,0,0,1"/>
+ </Grid>
+ </ControlTemplate>
+ <Style x:Key="ButtonFocusVisual">
+ <Setter Property="Control.Template">
+ <Setter.Value>
+ <ControlTemplate>
+ <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
</ResourceDictionary>
View
1 UI/CommitBox.xaml.cs
@@ -34,6 +34,7 @@ private void root_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
this.Selected = !this.Selected;
VisualStateManager.GoToElementState(this.root, this.Selected ? "SelectedSate" : "NotSelectedState", true);
+ HistoryViewCommands.SelectCommit.Execute(this.txtId.Text, null);
}
private void txtComment_MouseEnter(object sender, MouseEventArgs e)
View
6 UI/CommitDetails.xaml.cs
@@ -32,5 +32,11 @@ internal void Show(GitFileStatusTracker tracker, string p)
this.tracker = tracker;
this.label1.Content = p;
}
+
+ internal void Show(GitFileStatusTracker tracker, string p, string p_2)
+ {
+ this.tracker = tracker;
+ this.label1.Content = string.Format("{0} vs {1}", p, p_2);
+ }
}
}

0 comments on commit 1509ecf

Please sign in to comment.