Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add button for creating patch

  • Loading branch information...
commit 607a698fa901abd774c850e0741178abe2db4386 1 parent 05cb33a
Yiyi Sun authored
340 GitUI/GitViewModel.cs
View
@@ -10,147 +10,201 @@
namespace GitUI
{
- public static class HistoryViewCommands
- {
- public static readonly RoutedUICommand CloseCommitDetails = new RoutedUICommand("CloseCommitDetails", "CloseCommitDetails", typeof(MainWindow));
- public static readonly RoutedUICommand OpenCommitDetails = new RoutedUICommand("OpenCommitDetails", "OpenCommitDetails", typeof(MainWindow));
- public static readonly RoutedUICommand SelectCommit = new RoutedUICommand("SelectCommit", "SelectCommit", typeof(MainWindow));
- public static readonly RoutedUICommand CompareCommits = new RoutedUICommand("CompareCommits", "CompareCommits", typeof(MainWindow));
- public static readonly RoutedUICommand ExportGraph = new RoutedUICommand("ExportGraph", "ExportGraph", typeof(MainWindow));
- public static readonly RoutedUICommand RefreshGraph = new RoutedUICommand("RefreshGraph", "RefreshGraph", typeof(MainWindow));
- public static readonly RoutedUICommand ScrollToCommit = new RoutedUICommand("ScrollToCommit", "ScrollToCommit", typeof(MainWindow));
- public static readonly RoutedUICommand GraphLoaded = new RoutedUICommand("GraphLoaded", "GraphLoaded", typeof(MainWindow));
- }
-
- public class GitViewModel
- {
- #region singleton
- private static GitViewModel current;
- public static GitViewModel Current
- {
- get
- {
- if (current == null) current = new GitViewModel();
- return current;
- }
- }
- #endregion
-
- public event EventHandler GraphChanged = delegate { };
- private GitFileStatusTracker tracker;
- private string workingDirectory;
-
- public GitFileStatusTracker Tracker { get { return tracker; } }
- public string WorkingDirectory { get { return workingDirectory; } }
-
- DispatcherTimer timer;
-
- private GitViewModel()
- {
- var args = Environment.GetCommandLineArgs();
- workingDirectory = args.Length > 1 ? args[1] :
- Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
-
- tracker = new GitFileStatusTracker(workingDirectory);
- if (tracker.HasGitRepository) workingDirectory = tracker.GitWorkingDirectory;
- if (Directory.Exists(workingDirectory))
- {
- FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(workingDirectory);
-
- fileSystemWatcher.Created += (_, e) => Refresh();
- fileSystemWatcher.Changed += (_, e) => Refresh();
- fileSystemWatcher.Deleted += (_, e) => Refresh();
- fileSystemWatcher.Renamed += (_, e) => Refresh();
- fileSystemWatcher.EnableRaisingEvents = true;
- }
-
- timer = new DispatcherTimer();
- timer.Interval = TimeSpan.FromSeconds(1);
- timer.Tick +=new EventHandler(timer_Tick);
- }
-
- private bool NoRefresh;
-
- private void timer_Tick(Object sender, EventArgs args)
- {
- timer.Stop(); // one time deal
-
- if (!NoRefresh)
- {
- NoRefresh = true;
- tracker.Refresh();
- GraphChanged(this, null);
- NoRefresh = false;
- }
- }
-
- internal void Refresh()
- {
- timer.Start();
-
- //double delta = DateTime.Now.Subtract(lastTimeRefresh).TotalMilliseconds;
- //if (delta > 100)
- //{
- //System.Diagnostics.Debug.WriteLine("==== GitViewModel Refresh {0}", delta);
- //tracker.Refresh();
- //}
- //lastTimeRefresh = DateTime.Now;
- }
-
- internal void RefreshGraph()
- {
- GraphChanged(this, null);
- }
-
- private string GitRun(string cmd)
- {
- if (!GitBash.Exists) throw new Exception("git.exe is not found.");
- if (this.Tracker == null) throw new Exception("Git repository is not found.");
-
- var ret = GitBash.Run(cmd, this.Tracker.GitWorkingDirectory);
- Refresh();
-
- return ret;
- }
-
- internal string AddTag(string name, string id)
- {
- return GitRun(string.Format("tag \"{0}\" {1}", name, id));
- }
-
- internal string GetTagId(string name)
- {
- return GitRun("show-ref refs/tags/" + name);
- }
-
- internal string DeleteTag(string name)
- {
- return GitRun("tag -d " + name);
- }
-
- internal string AddBranch(string name, string id)
- {
- return GitRun(string.Format("branch \"{0}\" {1}", name, id));
- }
-
- internal string GetBranchId(string name)
- {
- return GitRun("show-ref refs/heads/" + name);
- }
-
- internal string DeleteBranch(string name)
- {
- return GitRun("branch -d " + name);
- }
-
- internal string CheckoutBranch(string name)
- {
- return GitRun("checkout " + name);
- }
-
- internal string Archive(string id, string fileName)
- {
- return GitRun(string.Format("archive {0} --format=zip --output \"{1}\"", id, fileName));
- }
- }
+ public static class HistoryViewCommands
+ {
+ public static readonly RoutedUICommand CloseCommitDetails = new RoutedUICommand("CloseCommitDetails", "CloseCommitDetails", typeof(MainWindow));
+ public static readonly RoutedUICommand OpenCommitDetails = new RoutedUICommand("OpenCommitDetails", "OpenCommitDetails", typeof(MainWindow));
+ public static readonly RoutedUICommand SelectCommit = new RoutedUICommand("SelectCommit", "SelectCommit", typeof(MainWindow));
+ public static readonly RoutedUICommand CompareCommits = new RoutedUICommand("CompareCommits", "CompareCommits", typeof(MainWindow));
+ public static readonly RoutedUICommand ExportGraph = new RoutedUICommand("ExportGraph", "ExportGraph", typeof(MainWindow));
+ public static readonly RoutedUICommand RefreshGraph = new RoutedUICommand("RefreshGraph", "RefreshGraph", typeof(MainWindow));
+ public static readonly RoutedUICommand ScrollToCommit = new RoutedUICommand("ScrollToCommit", "ScrollToCommit", typeof(MainWindow));
+ public static readonly RoutedUICommand GraphLoaded = new RoutedUICommand("GraphLoaded", "GraphLoaded", typeof(MainWindow));
+ }
+
+ public class GitViewModel
+ {
+ #region singleton
+ private static GitViewModel current;
+ public static GitViewModel Current
+ {
+ get
+ {
+ if (current == null) current = new GitViewModel();
+ return current;
+ }
+ }
+ #endregion
+
+ public event EventHandler GraphChanged = delegate { };
+ private GitFileStatusTracker tracker;
+ private string workingDirectory;
+
+ public GitFileStatusTracker Tracker { get { return tracker; } }
+ public string WorkingDirectory { get { return workingDirectory; } }
+
+ DispatcherTimer timer;
+ FileSystemWatcher fileSystemWatcher;
+
+ private GitViewModel()
+ {
+ var args = Environment.GetCommandLineArgs();
+ workingDirectory = args.Length > 1 ? args[1] :
+ Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+
+ tracker = new GitFileStatusTracker(workingDirectory);
+ if (tracker.HasGitRepository) workingDirectory = tracker.GitWorkingDirectory;
+ if (Directory.Exists(workingDirectory))
+ {
+ fileSystemWatcher = new FileSystemWatcher(workingDirectory);
+
+ //fileSystemWatcher.Created += (_, e) => Refresh();
+ //fileSystemWatcher.Changed += (_, e) => Refresh();
+ //fileSystemWatcher.Deleted += (_, e) => Refresh();
+ //fileSystemWatcher.Renamed += (_, e) => Refresh();
+
+ fileSystemWatcher.Changed +=new FileSystemEventHandler(fileSystemWatcher_Changed);
+ fileSystemWatcher.EnableRaisingEvents = true;
+
+ timer = new DispatcherTimer();
+ timer.Interval = TimeSpan.FromMilliseconds(100);
+ timer.Tick+=new EventHandler(timer_Tick);
+ timer.Start();
+ }
+ }
+
+ #region Refresh
+
+ internal DateTime lastTimeRefresh = DateTime.Now.AddDays(-1);
+ internal DateTime nextTimeRefresh = DateTime.Now.AddDays(-1);
+
+ private void fileSystemWatcher_Changed(object source, FileSystemEventArgs e)
+ {
+ if (!NoRefresh)
+ {
+ double delta = DateTime.Now.Subtract(lastTimeRefresh).TotalMilliseconds;
+ if (delta > 500)
+ {
+ NeedRefresh = true;
+ lastTimeRefresh = DateTime.Now;
+ nextTimeRefresh = DateTime.Now;
+ }
+ }
+ }
+
+ internal bool NoRefresh;
+ private bool NeedRefresh;
+
+ private void timer_Tick(Object sender, EventArgs args)
+ {
+ if (NeedRefresh && !NoRefresh)
+ {
+ double delta = DateTime.Now.Subtract(nextTimeRefresh).TotalMilliseconds;
+ if (delta > 200)
+ {
+ System.Diagnostics.Debug.WriteLine("$$$$ Refresh");
+ DisableAutoRefresh();
+ Refresh(true);
+ NoRefresh = false;
+ NeedRefresh = false;
+ nextTimeRefresh = DateTime.Now;
+ }
+ }
+ }
+
+ internal void Refresh(bool reload)
+ {
+ if (reload) tracker.Refresh();
+ GraphChanged(this, null);
+ }
+
+ internal void EnableAutoRefresh()
+ {
+ timer.Start();
+ NoRefresh = false;
+ NeedRefresh = false;
+ lastTimeRefresh = DateTime.Now;
+ }
+
+ internal void DisableAutoRefresh()
+ {
+ timer.Stop();
+ NoRefresh = true;
+ NeedRefresh = false;
+ lastTimeRefresh = DateTime.Now.AddSeconds(2);
+ }
+
+ #endregion
+
+ #region Git commands
+
+ private string GitRun(string cmd)
+ {
+ if (!GitBash.Exists) throw new Exception("git.exe is not found.");
+ if (this.Tracker == null) throw new Exception("Git repository is not found.");
+
+ var ret = GitBash.Run(cmd, this.Tracker.GitWorkingDirectory);
+ return ret;
+ }
+
+ private void GitRunCmd(string cmd)
+ {
+ if (!GitBash.Exists) throw new Exception("git.exe is not found.");
+ if (this.Tracker == null) throw new Exception("Git repository is not found.");
+
+ GitBash.RunCmd(cmd, this.Tracker.GitWorkingDirectory);
+ }
+
+ internal string AddTag(string name, string id)
+ {
+ return GitRun(string.Format("tag \"{0}\" {1}", name, id));
+ }
+
+ internal string GetTagId(string name)
+ {
+ return GitRun("show-ref refs/tags/" + name);
+ }
+
+ internal string DeleteTag(string name)
+ {
+ return GitRun("tag -d " + name);
+ }
+
+ internal string AddBranch(string name, string id)
+ {
+ return GitRun(string.Format("branch \"{0}\" {1}", name, id));
+ }
+
+ internal string GetBranchId(string name)
+ {
+ return GitRun("show-ref refs/heads/" + name);
+ }
+
+ internal string DeleteBranch(string name)
+ {
+ return GitRun("branch -d " + name);
+ }
+
+ internal string CheckoutBranch(string name)
+ {
+ return GitRun("checkout " + name);
+ }
+
+ internal string Archive(string id, string fileName)
+ {
+ return GitRun(string.Format("archive {0} --format=zip --output \"{1}\"", id, fileName));
+ }
+
+ internal void Patch(string id1, string fileName)
+ {
+ GitRunCmd(string.Format("format-patch {0} -1 --stdout > \"{1}\"", id1, fileName));
+ }
+
+ internal void Patch(string id1, string id2, string fileName)
+ {
+ GitRunCmd(string.Format("format-patch {0}..{1} -o \"{2}\"", id1, id2, fileName));
+ }
+
+ #endregion
+ }
}
2  GitUI/MainWindow.xaml
View
@@ -14,7 +14,7 @@
<CommandBinding Command="cmd:HistoryViewCommands.GraphLoaded" Executed="GraphLoaded_Executed" />
</Window.CommandBindings>
<Grid x:Name="rootGrid" MouseRightButtonUp="rootGrid_MouseRightButtonUp">
- <GitScc_UI:HistoryGraph HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="graph"/>
+ <GitScc_UI:HistoryGraph HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="graph" Margin="0,90,0,0" />
<my:MainToolBar x:Name="topToolBar" Height="90"
HorizontalAlignment="Stretch" VerticalAlignment="Top">
6 GitUI/MainWindow.xaml.cs
View
@@ -232,17 +232,21 @@ private void GraphLoaded_Executed(object sender, ExecutedRoutedEventArgs e)
//};
//this.loading.BeginAnimation(UIElement.OpacityProperty, animation);
+ gitViewModel.DisableAutoRefresh();
+
this.loading.Visibility = Visibility.Collapsed;
this.topToolBar.GitViewModel = gitViewModel;
this.Title = gitViewModel.Tracker.HasGitRepository ?
string.Format("{0} ({1})", gitViewModel.Tracker.GitWorkingDirectory, gitViewModel.Tracker.CurrentBranch) :
string.Format("{0} (No Repository)", gitViewModel.WorkingDirectory);
+
+ gitViewModel.EnableAutoRefresh();
}
private void RefreshGraph_Executed(object sender, ExecutedRoutedEventArgs e)
{
this.loading.Visibility = Visibility.Visible;
- gitViewModel.Refresh();
+ gitViewModel.Refresh(true);
this.graph.Show(gitViewModel.Tracker, true);
}
26 GitUI/UI/CommitDetails.xaml
View
@@ -62,6 +62,29 @@
<TextBlock x:Name="textBlock" Margin="0" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FF99B6D1" FontWeight="Bold"><Span FontSize="17.3333333333333" FontFamily="Wingdings 3" Language="en-us"><Run Text="F"/></Span></TextBlock>
</Grid>
</ControlTemplate>
+ <ControlTemplate x:Key="PatchButtonTemplate" TargetType="{x:Type Button}">
+ <Grid Width="24" Height="24">
+ <VisualStateManager.VisualStateGroups>
+ <VisualStateGroup x:Name="CommonStates">
+ <VisualState x:Name="Normal"/>
+ <VisualState x:Name="MouseOver">
+ <Storyboard>
+ <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="ellipse">
+ <EasingColorKeyFrame KeyTime="0" Value="#FF99B6D1"/>
+ </ColorAnimationUsingKeyFrames>
+ <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBlock">
+ <EasingColorKeyFrame KeyTime="0" Value="White"/>
+ </ColorAnimationUsingKeyFrames>
+ </Storyboard>
+ </VisualState>
+ <VisualState x:Name="Pressed"/>
+ <VisualState x:Name="Disabled"/>
+ </VisualStateGroup>
+ </VisualStateManager.VisualStateGroups>
+ <Ellipse x:Name="ellipse" Fill="#FFF4F4F5" Stroke="#FF99B6D1" StrokeThickness="2"/>
+ <TextBlock x:Name="textBlock" Margin="0" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#FF99B6D1" FontWeight="Bold"><Run FontWeight="Normal" FontSize="16" FontFamily="Webdings" Text="Í"/></TextBlock>
+ </Grid>
+ </ControlTemplate>
</UserControl.Resources>
@@ -77,7 +100,8 @@
<Label Content="Author" HorizontalAlignment="Right" Margin="0,0,6,0" Name="lblAuthor" VerticalAlignment="Bottom" FontSize="10"/>
<Button Content="back to graphic view" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,6,10,0" Padding="10,0"
Command="cmd:HistoryViewCommands.CloseCommitDetails" Template="{DynamicResource BackButtonControlTemplate}" ToolTip="Back to graphic view" />
- <Button HorizontalAlignment="Right" Margin="0,6,40,0" Name="btnSwitch" VerticalAlignment="Top" Click="btnSwitch_Click" Template="{DynamicResource btnSwitchControlTemplate}" RenderTransformOrigin="-1.5,0.542" ToolTip="Reverse the comparison order" Visibility="Collapsed" />
+ <Button HorizontalAlignment="Right" Margin="0,6,69,0" x:Name="btnSwitch" Click="btnSwitch_Click" Template="{DynamicResource btnSwitchControlTemplate}" RenderTransformOrigin="-1.5,0.542" ToolTip="Reverse the comparison order" VerticalAlignment="Top" />
+ <Button HorizontalAlignment="Right" Margin="0,6,39,0" x:Name="btnSave" VerticalAlignment="Top" Click="btnSave_Click" Template="{DynamicResource PatchButtonTemplate}" RenderTransformOrigin="-1.5,0.542" ToolTip="Save patch ..." />
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFF2F2F2" Offset="0" />
43 GitUI/UI/CommitDetails.xaml.cs
View
@@ -8,6 +8,7 @@
using GitScc.DataServices;
using NGit.Diff;
using System.Diagnostics;
+using GitUI;
namespace GitScc.UI
{
@@ -22,6 +23,7 @@ public partial class CommitDetails : UserControl
public CommitDetails()
{
InitializeComponent();
+ btnSwitch.Visibility = Visibility.Collapsed;
}
#region show file in editor
@@ -256,5 +258,46 @@ private void menuSaveFile_Click(object sender, RoutedEventArgs e)
}
}
}
+
+ private void btnSave_Click(object sender, RoutedEventArgs e)
+ {
+ var dlg = new Microsoft.Win32.SaveFileDialog();
+ dlg.DefaultExt = ".patch";
+ dlg.Filter = "Patch (.patch)|*.patch";
+ if (btnSwitch.Visibility == Visibility.Collapsed)
+ {
+ var id = this.commitId2.Substring(0, 7);
+ dlg.FileName = id + ".patch";
+ if (dlg.ShowDialog() == true)
+ {
+ try
+ {
+ GitViewModel.Current.Patch( this.commitId2, dlg.FileName);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+ }
+ else
+ {
+ var id1 = this.commitId1.Substring(0, 7);
+ var id2 = this.commitId2.Substring(0, 7);
+ dlg.FileName = id1 + "-" + id2 + ".patch";
+
+ if (dlg.ShowDialog() == true)
+ {
+ try
+ {
+ GitViewModel.Current.Patch(this.commitId1, this.commitId2, dlg.FileName);
+ }
+ catch(Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+ }
+ }
}
}
14 GitUI/UI/MainToolBar.xaml
View
@@ -24,12 +24,12 @@
<Label Content="Branches" Height="28" HorizontalAlignment="Left" Margin="6,2,0,0" x:Name="label1" VerticalAlignment="Top" FontSize="10" />
<Label Content="Tags" Height="28" HorizontalAlignment="Left" Margin="6,26,0,0" x:Name="label2" VerticalAlignment="Top" FontSize="10" />
<ListBox x:Name="branchList" Margin="60,3,200,67" ItemsPanel="{DynamicResource ItemsPanelTemplate1}" ItemTemplate="{DynamicResource DataTemplate1}"
- Background="#00000000" BorderBrush="{x:Null}" Height="20" ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"
- ScrollViewer.HorizontalScrollBarVisibility="hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" SelectionChanged="branchList_SelectionChanged" />
+ Background="#00000000" BorderBrush="{x:Null}" Height="26" ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"
+ ScrollViewer.HorizontalScrollBarVisibility="hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" MouseLeftButtonUp="branchList_MouseLeftButtonUp" VerticalAlignment="Top" />
<ListBox x:Name="tagList" Margin="60,27,200,43" ItemsPanel="{DynamicResource ItemsPanelTemplate1}" ItemTemplate="{DynamicResource DataTemplate1}"
- Background="#00000000" BorderBrush="{x:Null}" Height="20" ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"
- ScrollViewer.HorizontalScrollBarVisibility="hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" SelectionChanged="tagList_SelectionChanged" />
+ Background="#00000000" BorderBrush="{x:Null}" Height="26" ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"
+ ScrollViewer.HorizontalScrollBarVisibility="hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" MouseLeftButtonUp="tagList_MouseLeftButtonUp" VerticalAlignment="Top" />
<CheckBox Content="Show simplified graph" HorizontalAlignment="Right" Margin="0,8,43,0" Name="checkBox1" Template="{DynamicResource ShowSimpleGraphCheckBoxControlTemplate}"
VerticalAlignment="Top" ToolTip="Toggle View" Click="checkBox1_Click"/>
@@ -41,9 +41,9 @@
<TextBox VerticalAlignment="Bottom" Margin="60,0,200,12.04" x:Name="txtSearch" TextChanged="txtSearch_TextChanged" PreviewKeyDown="txtSearch_PreviewKeyDown" PreviewMouseDown="txtSearch_PreviewMouseDown" />
<ListBox Height="100" Margin="60,0,200,-88.96" VerticalAlignment="Bottom" x:Name="lstSearch" PreviewKeyDown="lstSearch_PreviewKeyDown" MouseDoubleClick="lstSearch_MouseDoubleClick" />
<Button Content="Button" HorizontalAlignment="Right" Margin="0,36,72,0" Template="{DynamicResource CompareButtonControlTemplate}" ToolTip="Compare ..." x:Name="btnCompare" Click="btnCompare_Click"/>
- <TextBlock HorizontalAlignment="Right" Margin="0,37,96,29" TextWrapping="NoWrap" Text="123456" Width="88.38" Foreground="#FFFF5656" x:Name="txtCommit1"/>
- <TextBlock HorizontalAlignment="Right" Height="24" Margin="0,0,96,7.211" TextWrapping="NoWrap" Text="123456" VerticalAlignment="Bottom" Width="88.38" Foreground="#FFFF5656" x:Name="txtCommit2"/>
- <Label Content="Selected Commits &#xd;&#xa;to compare" Height="48" HorizontalAlignment="Right" Margin="0,1,88.483,0" VerticalAlignment="Top" FontSize="10" Width="99.897" x:Name="lblSelectedCommits"/>
+ <TextBlock HorizontalAlignment="Right" Margin="0,43,96,23" TextWrapping="NoWrap" Text="123456" Width="88.38" Foreground="#FFFF5656" x:Name="txtCommit1" FontSize="10" />
+ <TextBlock HorizontalAlignment="Right" Height="24" Margin="0,0,96,7.211" TextWrapping="NoWrap" Text="123456" VerticalAlignment="Bottom" Width="88.38" Foreground="#FFFF5656" x:Name="txtCommit2" FontSize="10" />
+ <Label Content="Selected Commits &#xd;&#xa;to compare" Height="46" HorizontalAlignment="Right" Margin="0,1,88.483,0" VerticalAlignment="Top" FontSize="10" Width="99.897" x:Name="lblSelectedCommits"/>
<!--<Button Content="0" HorizontalAlignment="Right" Margin="0,8,100,0" x:Name="btnCommitCount" VerticalAlignment="Top" Template="{DynamicResource CommitCountControlTemplate}" RenderTransformOrigin="-1.125,0.438" Click="btnCommitCount_Click" ToolTip="Click to clear selection" />-->
</Grid>
</UserControl>
7 GitUI/UI/MainToolBar.xaml.cs
View
@@ -64,11 +64,11 @@ private void checkBox1_Click(object sender, RoutedEventArgs e)
bool isSimplied = tracker.RepositoryGraph.IsSimplified;
tracker.RepositoryGraph.IsSimplified = !isSimplied;
this.lableView.Content = !isSimplied ? "Simplified view: ON" : "Simplified view: OFF";
- gitViewModel.RefreshGraph();
+ gitViewModel.Refresh(false);
}
}
- private void branchList_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ private void branchList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
var name = branchList.SelectedValue as string;
var id = tracker.RepositoryGraph.Refs
@@ -82,7 +82,7 @@ private void branchList_SelectionChanged(object sender, SelectionChangedEventArg
}
}
- private void tagList_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ private void tagList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
var name = tagList.SelectedValue as string;
var id = tracker.RepositoryGraph.Refs
@@ -226,5 +226,6 @@ private void btnCompare_Click(object sender, RoutedEventArgs e)
}
#endregion
+
}
}
8 GitUI/UI/ResourceDictionary.xaml
View
@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
- <StackPanel IsItemsHost="True" Orientation="Horizontal"/>
+ <StackPanel IsItemsHost="True" Orientation="Horizontal" Height="20"/>
</ItemsPanelTemplate>
<DataTemplate x:Key="DataTemplate1">
@@ -19,7 +19,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
- <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true" Margin="0,0,4,0" CornerRadius="4">
+ <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true" Margin="0,0,4,0" CornerRadius="4" Height="20" VerticalAlignment="Top" HorizontalAlignment="Center">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFEDEDED" Offset="0"/>
@@ -38,6 +38,10 @@
</VisualState>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
+ <VisualStateGroup x:Name="FocusStates">
+ <VisualState x:Name="Unfocused"/>
+ <VisualState x:Name="Focused"/>
+ </VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
2  PendingChangesToolWindow.cs
View
@@ -94,6 +94,8 @@ internal void Refresh(GitFileStatusTracker tracker, bool force = false)
{
this.Caption += " - [AUTO REFRESH DISABLED]";
}
+
+ sccProviderService.lastTimeRefresh = DateTime.Now;
}
catch (Exception ex)
{
12 PendingChangesView.xaml.cs
View
@@ -72,7 +72,6 @@ private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs
return;
}
- //var dispatcher = Dispatcher.CurrentDispatcher;
Action act = () =>
{
service.NoRefresh = true;
@@ -178,9 +177,8 @@ internal void Refresh(GitFileStatusTracker tracker)
return;
}
- //var dispatcher = Dispatcher.CurrentDispatcher;
- //Action act = () =>
- //{
+ Action act = () =>
+ {
service.NoRefresh = true;
ShowStatusMessage("Getting changed files ...");
@@ -223,11 +221,9 @@ internal void Refresh(GitFileStatusTracker tracker)
service.NoRefresh = false;
service.lastTimeRefresh = DateTime.Now; //important!!
- //};
-
- //dispatcher.BeginInvoke(act, DispatcherPriority.ApplicationIdle);
+ };
- //lastTimeRefresh = DateTime.Now;
+ this.Dispatcher.BeginInvoke(act, DispatcherPriority.ApplicationIdle);
}
internal void ClearUI()
15 PkgCmd.vsct
View
@@ -325,23 +325,24 @@
<CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandGitBash" priority="0x0008">
<Parent guid="guidSccProviderCmdSet" id="igrpPendingChangesToolWindowToolbarGroup"/>
</CommandPlacement>
-
- <CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandGitExtension" priority="0x0009">
+
+ <CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandHistory" priority="0x0009">
<Parent guid="guidSccProviderCmdSet" id="igrpPendingChangesToolWindowToolbarGroup"/>
</CommandPlacement>
- <CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandGitTortoise" priority="0x0010">
+ <CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandGitExtension" priority="0x0010">
+ <Parent guid="guidSccProviderCmdSet" id="igrpPendingChangesToolWindowToolbarGroup"/>
+ </CommandPlacement>
+ <CommandPlacement guid="guidSccProviderCmdSet" id="icmdSccCommandGitTortoise" priority="0x0011">
<Parent guid="guidSccProviderCmdSet" id="igrpPendingChangesToolWindowToolbarGroup"/>
</CommandPlacement>
- <CommandPlacement guid="guidSccProviderCmdSet" id="icmdGitExtCommand1" priority="0x0002">
+ <CommandPlacement guid="guidSccProviderCmdSet" id="icmdGitExtCommand1" priority="0x0000">
<Parent guid="guidSccProviderCmdSet" id="igrpPendingChangesToolWindowGitExt"/>
</CommandPlacement>
- <CommandPlacement guid="guidSccProviderCmdSet" id="icmdGitTorCommand1" priority="0x0002">
+ <CommandPlacement guid="guidSccProviderCmdSet" id="icmdGitTorCommand1" priority="0x0000">
<Parent guid="guidSccProviderCmdSet" id="igrpPendingChangesToolWindowGitTor"/>
</CommandPlacement>
-
-
</CommandPlacements>
<Symbols>
8 Readme.htm
View
@@ -19,15 +19,17 @@
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=KBCLF3PZD6C98&amp;lc=US&amp;item_name=Git%20Source%20Control%20Provider&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted">
<img alt="Donate" style="border:0px; vertical-align:middle" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" title="Donate" /></a><br />
<h2>Change Logs</h2>
- <strong>V0.9.1 (RC4 - 340eca9) </strong>
+ <strong>V0.9.1 (RC4 - 4e26b86) </strong>
<ul>
- <li>Change History Window to be a stand alone program<ul>
- <li>add/delete tag, add/checkout branch</li>
+ <li>Change History Window to be a stand alone program - Dragon<ul>
+ <li>add/delete tag</li>
+ <li>add/delete/checkout branch</li>
<li>scroll to branch/tag</li>
<li>refresh button</li>
<li>search commits</li>
<li>select and compare too commits</li>
<li>Archive (export) commit</li>
+ <li>create patch</li>
</ul>
</li>
<li>Add Git Extensions menus to Pending Changed tool window </li>
30 SccProviderService.cs
View
@@ -651,7 +651,8 @@ private void CloseTracker()
Debug.WriteLine("==== Close Tracker");
trackers.Clear();
RemoveFolderMonitor();
- RefreshToolWindows();
+ NodesGlyphsDirty = true; // set refresh flag
+ //RefreshToolWindows();
}
private void RemoveFolderMonitor()
@@ -925,13 +926,19 @@ private GitFileStatus GetFileStatus(IVsHierarchy phierHierarchy, uint itemidNode
internal bool NodesGlyphsDirty = false;
internal bool NoRefresh = false;
internal DateTime lastTimeRefresh = DateTime.Now.AddDays(-1);
+ internal DateTime nextTimeRefresh = DateTime.Now;
internal void Refresh()
{
if (!NoRefresh)
{
- NodesGlyphsDirty = true;
- lastTimeRefresh = DateTime.Now;
+ double delta = DateTime.Now.Subtract(lastTimeRefresh).TotalMilliseconds;
+ if (delta > 500)
+ {
+ NodesGlyphsDirty = true;
+ lastTimeRefresh = DateTime.Now;
+ nextTimeRefresh = DateTime.Now;
+ }
}
}
@@ -939,11 +946,13 @@ public void UpdateNodesGlyphs()
{
if (NodesGlyphsDirty && !NoRefresh)
{
- double delta = DateTime.Now.Subtract(lastTimeRefresh).TotalMilliseconds;
- if (delta > 500)
+ double delta = DateTime.Now.Subtract(nextTimeRefresh).TotalMilliseconds;
+ if (delta > 200)
{
- Stopwatch stopwatch = new Stopwatch();
- stopwatch.Start();
+ Debug.WriteLine("==== UpdateNodesGlyphs: " + delta.ToString());
+
+ //Stopwatch stopwatch = new Stopwatch();
+ //stopwatch.Start();
NoRefresh = true;
OpenTracker();
@@ -952,10 +961,9 @@ public void UpdateNodesGlyphs()
NoRefresh = false;
NodesGlyphsDirty = false;
- stopwatch.Stop();
- Debug.WriteLine("==== UpdateNodesGlyphs: " + stopwatch.ElapsedMilliseconds);
-
- lastTimeRefresh = DateTime.Now; //important !!
+ nextTimeRefresh = DateTime.Now; //important !!
+ //stopwatch.Stop();
+ //Debug.WriteLine("==== UpdateNodesGlyphs: " + stopwatch.ElapsedMilliseconds);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.