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"
|
Background="Transparent"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
Style="{StaticResource Style.ListView.Borderless}"
|
Style="{StaticResource Style.ListView.Borderless}"
|
||||||
ItemContainerStyle="{StaticResource Style.ListViewItem.Borderless}"
|
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||||
GotFocus="RecentsGotFocus"
|
GotFocus="RecentsGotFocus"
|
||||||
SelectionChanged="RecentsSelectionChanged"
|
SelectionChanged="RecentsSelectionChanged"
|
||||||
MouseDoubleClick="RecentsMouseDoubleClick">
|
MouseDoubleClick="RecentsMouseDoubleClick">
|
||||||
|
<ListView.ItemContainerStyle>
|
||||||
|
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource Style.ListViewItem.Borderless}">
|
||||||
|
<EventSetter Event="ContextMenuOpening" Handler="RecentsContextMenuOpening"/>
|
||||||
|
</Style>
|
||||||
|
</ListView.ItemContainerStyle>
|
||||||
|
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate DataType="{x:Type git:Repository}">
|
<DataTemplate DataType="{x:Type git:Repository}">
|
||||||
<StackPanel Orientation="Horizontal" Height="24">
|
<StackPanel Orientation="Horizontal" Height="24">
|
||||||
|
@ -143,20 +148,11 @@
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Name & Path & OpenButton -->
|
<!-- Name & Path -->
|
||||||
<Grid Grid.Row="0">
|
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||||
<Grid.ColumnDefinitions>
|
<Label x:Name="repoName" FontSize="20" FontWeight="Bold"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<Label x:Name="repoPath" FontSize="20" FontWeight="Light" Opacity="0.5" VerticalAlignment="Center"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
</StackPanel>
|
||||||
<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>
|
|
||||||
|
|
||||||
<!-- Status of selected repository -->
|
<!-- Status of selected repository -->
|
||||||
<Label Grid.Row="1" Content="STATUS" FontSize="16" Margin="0,16,0,4" FontWeight="Bold" Opacity=".8"/>
|
<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;
|
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
|
#endregion
|
||||||
|
|
||||||
#region EVENT_TREEVIEW
|
#region EVENT_TREEVIEW
|
||||||
|
@ -299,6 +335,7 @@ namespace SourceGit.UI {
|
||||||
delete.Header = "Delete";
|
delete.Header = "Delete";
|
||||||
delete.Click += (o, ev) => {
|
delete.Click += (o, ev) => {
|
||||||
DeleteNode(node);
|
DeleteNode(node);
|
||||||
|
HideBrief();
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -364,10 +401,6 @@ namespace SourceGit.UI {
|
||||||
private void HideBrief() {
|
private void HideBrief() {
|
||||||
briefMask.Visibility = Visibility.Visible;
|
briefMask.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenRepo(object sender, RoutedEventArgs e) {
|
|
||||||
CheckAndOpenRepo(repoPath.Content as string);
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region PRIVATES
|
#region PRIVATES
|
||||||
|
|
Loading…
Reference in a new issue