Skip to content

Commit

Permalink
add button to open repository
Browse files Browse the repository at this point in the history
  • Loading branch information
yysun committed May 15, 2013
1 parent f565dda commit 202d0a2
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 10 deletions.
1 change: 1 addition & 0 deletions GitUI/GitViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class HistoryViewCommands
public static readonly RoutedUICommand GraphLoaded = new RoutedUICommand("GraphLoaded", "GraphLoaded", typeof(MainWindow));
public static readonly RoutedUICommand PendingChanges = new RoutedUICommand("PendingChanges", "PendingChanges", typeof(MainWindow));
public static readonly RoutedUICommand ShowMessage = new RoutedUICommand("ShowMessage", "ShowMessage", typeof(MainWindow));
public static readonly RoutedUICommand OpenRepository = new RoutedUICommand("OpenRepository", "OpenRepository", typeof(MainWindow));
}

public class GitViewModel
Expand Down
1 change: 1 addition & 0 deletions GitUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<CommandBinding Command="cmd:HistoryViewCommands.GraphLoaded" Executed="GraphLoaded_Executed" />
<CommandBinding Command="cmd:HistoryViewCommands.PendingChanges" Executed="PendingChanges_Executed" />
<CommandBinding Command="cmd:HistoryViewCommands.ShowMessage" Executed="ShowMessage_Executed" />
<CommandBinding Command="cmd:HistoryViewCommands.OpenRepository" Executed="OpenRepository_Executed" />
</Window.CommandBindings>

<Window.Resources>
Expand Down
35 changes: 25 additions & 10 deletions GitUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
this.Style = (Style)Resources["GradientStyle"];

GitBash.GitExePath = GitSccOptions.Current.GitBashPath;
GitBash.UseUTF8FileNames = !GitSccOptions.Current.NotUseUTF8FileNames;
GitBash.UseUTF8FileNames = !GitSccOptions.Current.NotUseUTF8FileNames;

if (!GitBash.Exists) GitBash.GitExePath = TryFindFile(new string[] {
@"C:\Program Files\Git\bin\sh.exe",
Expand All @@ -60,7 +60,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
////this.Dispatcher.BeginInvoke(a, DispatcherPriority.Render);
loading.Visibility = Visibility.Visible;
Action act = () =>
Action act = () =>
{
if (gitViewModel.Tracker.HasGitRepository)
{
Expand Down Expand Up @@ -215,7 +215,8 @@ private void ShowMessage_Executed(object sender, ExecutedRoutedEventArgs e)
DoubleAnimation doubleAnimation = new DoubleAnimation
{
Duration = new Duration(TimeSpan.FromMilliseconds(10000)),
From = 1.0, To = 0.0
From = 1.0,
To = 0.0
};
doubleAnimation.Completed += (o, _) => txtMessage.Visibility = Visibility.Collapsed;
txtMessage.BeginAnimation(UIElement.OpacityProperty, doubleAnimation);
Expand All @@ -224,7 +225,7 @@ private void ShowMessage_Executed(object sender, ExecutedRoutedEventArgs e)
#endregion

#region select and comapre commits

private void SelectCommit_Executed(object sender, ExecutedRoutedEventArgs e)
{
this.topToolBar.SelectCommit(e.Parameter as string, null);
Expand Down Expand Up @@ -273,14 +274,22 @@ private void PendingChanges_Executed(object sender, ExecutedRoutedEventArgs e)
loading.Visibility = Visibility.Collapsed;
};
this.pendingChanges.RenderTransform.BeginAnimation(TranslateTransform.XProperty, animation);

}
catch (Exception ex)
{
Log.WriteLine("MainWindow.PendingChanges_Executed {0}", ex.ToString());
}
}
#endregion
#endregion

private void OpenRepository(string path)
{
HistoryViewCommands.CloseCommitDetails.Execute(null, this);
HistoryViewCommands.CloseCommitDetails.Execute("PendingChanges", this);
this.gitViewModel.Open(path);
this.gitViewModel.Refresh(true);
}

private void Window_Drop(object sender, DragEventArgs e)
{
Expand All @@ -296,10 +305,7 @@ private void Window_Drop(object sender, DragEventArgs e)
MessageBox.Show("Do you want to open Git repository from " + gitWorkingFolder,
"Git repository found", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
HistoryViewCommands.CloseCommitDetails.Execute(null, this);
HistoryViewCommands.CloseCommitDetails.Execute("PendingChanges", this);
this.gitViewModel.Open(dropped);
this.gitViewModel.Refresh(true);
this.OpenRepository(dropped);
}
}
}
Expand All @@ -308,5 +314,14 @@ private void _OnSystemCommandCloseWindow(object sender, ExecutedRoutedEventArgs
{
SystemCommands.CloseWindow(this);
}

private void OpenRepository_Executed(object sender, ExecutedRoutedEventArgs e)
{
var dlg = new System.Windows.Forms.FolderBrowserDialog();
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.OpenRepository(dlg.SelectedPath);
}
}
}
}
1 change: 1 addition & 0 deletions GitUI/UI/MainToolBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
x:Name="btnPendingChanges" ToolTip="Pending Changes" Click="btnPendingChanges_Click"
Template="{DynamicResource PendingChangesButtonControlTemplate}" RenderTransformOrigin="11.042,1.083" />
<Button Content="Repositories" HorizontalAlignment="Right" Margin="0,5,107,41" Template="{DynamicResource OpenRepositoriesButtonControlTemplate}" ToolTip="Repositories" Visibility="Hidden"/>
<Button Command="cmd:HistoryViewCommands.OpenRepository" Content="Export" HorizontalAlignment="Right" Margin="0,16,107,0" Template="{DynamicResource OpenRepositoryButtonControlTemplate}" ToolTip="Open Repository ..." VerticalAlignment="Top" />
<!--<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>
28 changes: 28 additions & 0 deletions GitUI/UI/ResourceDictionary.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,32 @@
<TextBlock x:Name="textBlock" Margin="0,1,0,0" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" Foreground="#FF99B6D1" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16"><Span FontFamily="Wingdings 2" Language="en-us"><Run Text="Ó"/></Span></TextBlock>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="OpenRepositoryButtonControlTemplate" 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>
<VisualStateGroup x:Name="ValidationStates">
<VisualState x:Name="Valid"/>
<VisualState x:Name="InvalidFocused"/>
<VisualState x:Name="InvalidUnfocused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Ellipse x:Name="ellipse" Stroke="#FF99B6D1" StrokeThickness="2" Fill="White"/>
<TextBlock x:Name="textBlock" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" Foreground="#FF99B6D1" FontFamily="Webdings" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontSize="13.333" Margin="3.975,4.134,2.107,5.068"><Span FontFamily="Wingdings" Language="en-us"><Run Text="1"/></Span></TextBlock>
</Grid>
</ControlTemplate>
</ResourceDictionary>

0 comments on commit 202d0a2

Please sign in to comment.