mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
optimize(Manager): add context menu for recent opened repositories
This commit is contained in:
parent
08dc039768
commit
28e3a1bb27
2 changed files with 48 additions and 19 deletions
|
@ -36,11 +36,16 @@
|
|||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Style="{StaticResource Style.ListView.Borderless}"
|
||||
ItemContainerStyle="{StaticResource Style.ListViewItem.Borderless}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
GotFocus="RecentsGotFocus"
|
||||
SelectionChanged="RecentsSelectionChanged"
|
||||
MouseDoubleClick="RecentsMouseDoubleClick">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource Style.ListViewItem.Borderless}">
|
||||
<EventSetter Event="ContextMenuOpening" Handler="RecentsContextMenuOpening"/>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type git:Repository}">
|
||||
<StackPanel Orientation="Horizontal" Height="24">
|
||||
|
@ -143,20 +148,11 @@
|
|||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Name & Path & OpenButton -->
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" x:Name="repoName" FontSize="20" FontWeight="Bold"/>
|
||||
<Label Grid.Column="1" x:Name="repoPath" FontSize="20" FontWeight="Light" Opacity="0.5" VerticalAlignment="Center"/>
|
||||
<Button Grid.Column="3" Click="OpenRepo" ToolTip="Open">
|
||||
<Path Width="20" Height="20" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder}"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
<!-- Name & Path -->
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||
<Label x:Name="repoName" FontSize="20" FontWeight="Bold"/>
|
||||
<Label x:Name="repoPath" FontSize="20" FontWeight="Light" Opacity="0.5" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Status of selected repository -->
|
||||
<Label Grid.Row="1" Content="STATUS" FontSize="16" Margin="0,16,0,4" FontWeight="Bold" Opacity=".8"/>
|
||||
|
|
|
@ -87,6 +87,42 @@ namespace SourceGit.UI {
|
|||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void RecentsContextMenuOpening(object sender, ContextMenuEventArgs e) {
|
||||
var repo = (sender as ListViewItem).DataContext as Git.Repository;
|
||||
if (repo == null) return;
|
||||
|
||||
var open = new MenuItem();
|
||||
open.Header = "Open";
|
||||
open.Click += (o, ev) => {
|
||||
CheckAndOpenRepo(repo.Path);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var explore = new MenuItem();
|
||||
explore.Header = "Open Container Folder";
|
||||
explore.Click += (o, ev) => {
|
||||
Process.Start(repo.Path);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var delete = new MenuItem();
|
||||
delete.Header = "Delete";
|
||||
delete.Click += (o, ev) => {
|
||||
App.Preference.RemoveRepository(repo.Path);
|
||||
UpdateRecentOpened();
|
||||
UpdateTree();
|
||||
HideBrief();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(open);
|
||||
menu.Items.Add(explore);
|
||||
menu.Items.Add(delete);
|
||||
menu.IsOpen = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region EVENT_TREEVIEW
|
||||
|
@ -299,6 +335,7 @@ namespace SourceGit.UI {
|
|||
delete.Header = "Delete";
|
||||
delete.Click += (o, ev) => {
|
||||
DeleteNode(node);
|
||||
HideBrief();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
|
@ -364,10 +401,6 @@ namespace SourceGit.UI {
|
|||
private void HideBrief() {
|
||||
briefMask.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void OpenRepo(object sender, RoutedEventArgs e) {
|
||||
CheckAndOpenRepo(repoPath.Content as string);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PRIVATES
|
||||
|
|
Loading…
Reference in a new issue