mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-30 16:44:59 +00:00
code_style: remove all IDE warnings
This commit is contained in:
parent
24ca3eaf8c
commit
f4eca45754
79 changed files with 1462 additions and 1378 deletions
|
@ -4,8 +4,6 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:s="using:SourceGit"
|
||||
xmlns:vm="using:SourceGit.ViewModels"
|
||||
xmlns:m="using:SourceGit.Models"
|
||||
xmlns:c="using:SourceGit.Converters"
|
||||
xmlns:v="using:SourceGit.Views"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.Launcher"
|
||||
|
@ -75,110 +73,14 @@
|
|||
<v:CaptionButtons Height="30" VerticalAlignment="Top"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<!-- Page body -->
|
||||
<ContentControl Grid.Row="1" Background="{DynamicResource Brush.ToolBar}" Content="{Binding ActivePage.Data}">
|
||||
|
||||
<!-- Page -->
|
||||
<ContentControl Grid.Row="1" Content="{Binding ActivePage}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:Welcome">
|
||||
<v:Welcome/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="vm:Repository">
|
||||
<v:Repository/>
|
||||
<DataTemplate DataType="vm:LauncherPage">
|
||||
<v:LauncherPage/>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
|
||||
<!-- Popup container -->
|
||||
<Grid Grid.Row="1" Margin="0,36,0,0" IsVisible="{Binding ActivePage.Popup, Converter={x:Static ObjectConverters.IsNotNull}}" ClipToBounds="True">
|
||||
<Border Background="Transparent" PointerPressed="OnPopupCancelByClickMask"/>
|
||||
|
||||
<Border Width="500" HorizontalAlignment="Center" VerticalAlignment="Top" Effect="drop-shadow(0 0 8 #8F000000)" CornerRadius="0,0,8,8" ClipToBounds="True">
|
||||
<ContentControl Content="{Binding ActivePage.Popup}" Background="{DynamicResource Brush.Popup}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:Popup">
|
||||
<StackPanel Orientation="Vertical" Background="{DynamicResource Brush.Popup}">
|
||||
<!-- Popup Widget -->
|
||||
<ContentPresenter Margin="8,16,8,8"
|
||||
Content="{Binding View}"
|
||||
IsHitTestVisible="{Binding InProgress, Converter={x:Static BoolConverters.Not}}"/>
|
||||
|
||||
<!-- Options -->
|
||||
<StackPanel Margin="8,4,8,8"
|
||||
Height="32"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
IsVisible="{Binding InProgress, Converter={x:Static BoolConverters.Not}}">
|
||||
<Button Classes="flat primary"
|
||||
Width="80"
|
||||
Content="{DynamicResource Text.Sure}"
|
||||
Click="OnPopupSure"
|
||||
HotKey="Enter"/>
|
||||
<Button Classes="flat"
|
||||
Width="80"
|
||||
Margin="8,0,0,0"
|
||||
Content="{DynamicResource Text.Cancel}"
|
||||
Click="OnPopupCancel"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Running -->
|
||||
<v:PopupRunningStatus Margin="12,8"
|
||||
Description="{Binding ProgressDescription}"
|
||||
IsVisible="{Binding InProgress}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<!-- Notification container -->
|
||||
<Grid Grid.Row="1" Width="360" Margin="0,36,0,0" HorizontalAlignment="Right" VerticalAlignment="Top">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||
<ItemsControl ItemsSource="{Binding ActivePage.Notifications}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="vm:Notification">
|
||||
<Border Margin="10,6" HorizontalAlignment="Stretch" VerticalAlignment="Top" Effect="drop-shadow(0 0 12 #A0000000)">
|
||||
<Border Padding="8" CornerRadius="6" Background="{DynamicResource Brush.Popup}">
|
||||
<Grid RowDefinitions="26,Auto,32">
|
||||
<StackPanel Grid.Row="0" Margin="8,0,0,0" Orientation="Horizontal" IsVisible="{Binding IsError}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Error}" Fill="Red"/>
|
||||
<TextBlock Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.Launcher.Error}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Margin="8,0,0,0" Orientation="Horizontal" IsVisible="{Binding !IsError}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Info}" Fill="Green"/>
|
||||
<TextBlock Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.Launcher.Info}"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBox Grid.Row="1"
|
||||
Classes="no_background no_border"
|
||||
IsReadOnly="True"
|
||||
TextWrapping="Wrap"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
MaxHeight="100"
|
||||
Margin="8" Padding="0"
|
||||
VerticalContentAlignment="Top"
|
||||
Text="{Binding Message}"/>
|
||||
|
||||
<StackPanel Grid.Row="2" Margin="0,4,0,0" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Classes="flat"
|
||||
Margin="0,0,8,0"
|
||||
Command="{Binding CopyMessage}"
|
||||
Content="{DynamicResource Text.CopyMessage}"
|
||||
IsVisible="{Binding IsError}"/>
|
||||
|
||||
<Button Classes="flat primary"
|
||||
Margin="0,0"
|
||||
Content="{DynamicResource Text.Close}"
|
||||
Click="OnDismissNotification"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</v:ChromelessWindow>
|
||||
|
|
|
@ -3,7 +3,6 @@ using System;
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
|
@ -199,35 +198,6 @@ namespace SourceGit.Views
|
|||
_pressedTitleBar = false;
|
||||
}
|
||||
|
||||
private void OnPopupSure(object _, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.Launcher vm)
|
||||
vm.ActivePage.ProcessPopup();
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnPopupCancel(object _, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.Launcher vm)
|
||||
vm.ActivePage.CancelPopup();
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnPopupCancelByClickMask(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
OnPopupCancel(sender, e);
|
||||
}
|
||||
|
||||
private void OnDismissNotification(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button btn && DataContext is ViewModels.Launcher vm)
|
||||
vm.DismissNotification(btn.DataContext as ViewModels.Notification);
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private bool _pressedTitleBar = false;
|
||||
}
|
||||
}
|
||||
|
|
133
src/Views/LauncherPage.axaml
Normal file
133
src/Views/LauncherPage.axaml
Normal file
|
@ -0,0 +1,133 @@
|
|||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
xmlns:v="using:SourceGit.Views"
|
||||
xmlns:vm="using:SourceGit.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.LauncherPage"
|
||||
x:DataType="vm:LauncherPage">
|
||||
<Grid RowDefinitions="36,*">
|
||||
<!-- ToolBar -->
|
||||
<Border Grid.Row="0" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" Background="{DynamicResource Brush.ToolBar}">
|
||||
<ContentControl Content="{Binding Data}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:Welcome">
|
||||
<v:WelcomeToolbar/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="vm:Repository">
|
||||
<v:RepositoryToolbar/>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
</Border>
|
||||
|
||||
<!-- Body -->
|
||||
<Border Grid.Row="1" Background="{DynamicResource Brush.Window}">
|
||||
<ContentControl Content="{Binding Data}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:Welcome">
|
||||
<v:Welcome/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="vm:Repository">
|
||||
<v:Repository/>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
</Border>
|
||||
|
||||
<!-- Popup -->
|
||||
<Grid Grid.Row="1" IsVisible="{Binding Popup, Converter={x:Static ObjectConverters.IsNotNull}}" ClipToBounds="True">
|
||||
<Border Background="Transparent" PointerPressed="OnPopupCancelByClickMask"/>
|
||||
|
||||
<Border Width="500" HorizontalAlignment="Center" VerticalAlignment="Top" Effect="drop-shadow(0 0 8 #8F000000)" CornerRadius="0,0,8,8" ClipToBounds="True">
|
||||
<ContentControl Content="{Binding Popup}" Background="{DynamicResource Brush.Popup}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:Popup">
|
||||
<StackPanel Orientation="Vertical" Background="{DynamicResource Brush.Popup}">
|
||||
<!-- Popup Widget -->
|
||||
<ContentPresenter Margin="8,16,8,8"
|
||||
Content="{Binding View}"
|
||||
IsHitTestVisible="{Binding InProgress, Converter={x:Static BoolConverters.Not}}"/>
|
||||
|
||||
<!-- Options -->
|
||||
<StackPanel Margin="8,4,8,8"
|
||||
Height="32"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
IsVisible="{Binding InProgress, Converter={x:Static BoolConverters.Not}}">
|
||||
<Button Classes="flat primary"
|
||||
Width="80"
|
||||
Content="{DynamicResource Text.Sure}"
|
||||
Click="OnPopupSure"
|
||||
HotKey="Enter"/>
|
||||
<Button Classes="flat"
|
||||
Width="80"
|
||||
Margin="8,0,0,0"
|
||||
Content="{DynamicResource Text.Cancel}"
|
||||
Click="OnPopupCancel"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Running -->
|
||||
<v:PopupRunningStatus Margin="12,8"
|
||||
Description="{Binding ProgressDescription}"
|
||||
IsVisible="{Binding InProgress}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<!-- Notification -->
|
||||
<Grid Grid.Row="1" Width="360" HorizontalAlignment="Right" VerticalAlignment="Top">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||
<ItemsControl ItemsSource="{Binding Notifications}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="vm:Notification">
|
||||
<Border Margin="10,6" HorizontalAlignment="Stretch" VerticalAlignment="Top" Effect="drop-shadow(0 0 12 #A0000000)">
|
||||
<Border Padding="8" CornerRadius="6" Background="{DynamicResource Brush.Popup}">
|
||||
<Grid RowDefinitions="26,Auto,32">
|
||||
<StackPanel Grid.Row="0" Margin="8,0,0,0" Orientation="Horizontal" IsVisible="{Binding IsError}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Error}" Fill="Red"/>
|
||||
<TextBlock Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.Launcher.Error}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Margin="8,0,0,0" Orientation="Horizontal" IsVisible="{Binding !IsError}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Info}" Fill="Green"/>
|
||||
<TextBlock Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.Launcher.Info}"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBox Grid.Row="1"
|
||||
Classes="no_background no_border"
|
||||
IsReadOnly="True"
|
||||
TextWrapping="Wrap"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
MaxHeight="100"
|
||||
Margin="8" Padding="0"
|
||||
VerticalContentAlignment="Top"
|
||||
Text="{Binding Message}"/>
|
||||
|
||||
<StackPanel Grid.Row="2" Margin="0,4,0,0" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Classes="flat"
|
||||
Margin="0,0,8,0"
|
||||
Command="{Binding CopyMessage}"
|
||||
Content="{DynamicResource Text.CopyMessage}"
|
||||
IsVisible="{Binding IsError}"/>
|
||||
|
||||
<Button Classes="flat primary"
|
||||
Margin="0,0"
|
||||
Content="{DynamicResource Text.Close}"
|
||||
Click="OnDismissNotification"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
44
src/Views/LauncherPage.axaml.cs
Normal file
44
src/Views/LauncherPage.axaml.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class LauncherPage : UserControl
|
||||
{
|
||||
public LauncherPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnPopupSure(object _, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.LauncherPage page)
|
||||
page.ProcessPopup();
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnPopupCancel(object _, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.LauncherPage page)
|
||||
page.CancelPopup();
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnPopupCancelByClickMask(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
OnPopupCancel(sender, e);
|
||||
}
|
||||
|
||||
private void OnDismissNotification(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button { DataContext: ViewModels.Notification notice } &&
|
||||
DataContext is ViewModels.LauncherPage page)
|
||||
page.Notifications.Remove(notice);
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -21,48 +21,6 @@ namespace SourceGit.Views
|
|||
UpdateLeftSidebarLayout();
|
||||
}
|
||||
|
||||
private void OpenWithExternalTools(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button button && DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForExternalTools();
|
||||
button.OpenContextMenu(menu);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenGitFlowMenu(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForGitFlow();
|
||||
(sender as Control)?.OpenContextMenu(menu);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OpenGitLFSMenu(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForGitLFS();
|
||||
(sender as Control)?.OpenContextMenu(menu);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private async void OpenStatistics(object _, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.Repository repo && TopLevel.GetTopLevel(this) is Window owner)
|
||||
{
|
||||
var dialog = new Statistics() { DataContext = new ViewModels.Statistics(repo.FullPath) };
|
||||
await dialog.ShowDialog(owner);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSearchCommitPanelPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.Property == IsVisibleProperty && sender is Grid { IsVisible: true })
|
||||
|
|
78
src/Views/RepositoryToolbar.axaml
Normal file
78
src/Views/RepositoryToolbar.axaml
Normal file
|
@ -0,0 +1,78 @@
|
|||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
xmlns:vm="using:SourceGit.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.RepositoryToolbar"
|
||||
x:DataType="vm:Repository">
|
||||
<Grid ColumnDefinitions="*,Auto,*">
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="4,0,0,0">
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding OpenInFileManager}" ToolTip.Tip="{DynamicResource Text.Repository.Explore}">
|
||||
<Path Width="15" Height="13" Data="{StaticResource Icons.Folder.Open}" Margin="0,1,0,0"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding OpenInTerminal}" ToolTip.Tip="{DynamicResource Text.Repository.Terminal}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.Terminal}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Click="OpenWithExternalTools" ToolTip.Tip="{DynamicResource Text.Repository.OpenWithExternalTools}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.OpenWith}"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding Fetch}" ToolTip.Tip="{DynamicResource Text.Fetch}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Fetch}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Command="{Binding Pull}" ToolTip.Tip="{DynamicResource Text.Pull}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Pull}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Command="{Binding Push}" ToolTip.Tip="{DynamicResource Text.Push}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Push}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Command="{Binding StashAll}" ToolTip.Tip="{DynamicResource Text.Stash}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Stashes}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Command="{Binding ApplyPatch}" ToolTip.Tip="{DynamicResource Text.Apply}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Diff}"/>
|
||||
</Button>
|
||||
|
||||
<Rectangle Width="1" Height="16"
|
||||
Margin="16,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Fill="{DynamicResource Brush.Border2}"/>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Margin="16,0,0,0" Command="{Binding CreateNewBranch}" ToolTip.Tip="{DynamicResource Text.Repository.NewBranch}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Branch.Add}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Margin="8,0,0,0" Click="OpenGitFlowMenu" ToolTip.Tip="{DynamicResource Text.GitFlow}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.GitFlow}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Margin="8,0,0,0" Click="OpenGitLFSMenu" ToolTip.Tip="{DynamicResource Text.GitLFS}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.LFS}"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,4,0">
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding Cleanup}" ToolTip.Tip="{DynamicResource Text.Repository.Clean}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Clean}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Click="OpenStatistics" ToolTip.Tip="{DynamicResource Text.Repository.Statistics}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Statistics}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding OpenConfigure}" ToolTip.Tip="{DynamicResource Text.Repository.Configure}">
|
||||
<Path Width="15" Height="15" Data="{StaticResource Icons.Settings}"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
56
src/Views/RepositoryToolbar.axaml.cs
Normal file
56
src/Views/RepositoryToolbar.axaml.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class RepositoryToolbar : UserControl
|
||||
{
|
||||
public RepositoryToolbar()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OpenWithExternalTools(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button button && DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForExternalTools();
|
||||
button.OpenContextMenu(menu);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenGitFlowMenu(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForGitFlow();
|
||||
(sender as Control)?.OpenContextMenu(menu);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OpenGitLFSMenu(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForGitLFS();
|
||||
(sender as Control)?.OpenContextMenu(menu);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private async void OpenStatistics(object _, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.Repository repo && TopLevel.GetTopLevel(this) is Window owner)
|
||||
{
|
||||
var dialog = new Statistics() { DataContext = new ViewModels.Statistics(repo.FullPath) };
|
||||
await dialog.ShowDialog(owner);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,37 +4,11 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:c="using:SourceGit.Converters"
|
||||
xmlns:vm="using:SourceGit.ViewModels"
|
||||
xmlns:v="using:SourceGit.Views"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.Welcome"
|
||||
x:DataType="vm:Welcome">
|
||||
<Grid RowDefinitions="36,*,36" Background="{DynamicResource Brush.Window}">
|
||||
<Border Grid.Row="0" BorderBrush="{DynamicResource Brush.Border0}" BorderThickness="0,0,0,1" Background="{DynamicResource Brush.ToolBar}">
|
||||
<StackPanel Orientation="Horizontal" Margin="4,0,0,0">
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding Clone}" ToolTip.Tip="{DynamicResource Text.Welcome.Clone}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.Pull}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Click="OpenLocalRepository" ToolTip.Tip="{DynamicResource Text.Welcome.OpenOrInit}">
|
||||
<Path Width="16" Height="16" Data="{StaticResource Icons.Folder.Add2}" Margin="0,4,0,0"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding OpenTerminal}" ToolTip.Tip="{DynamicResource Text.Welcome.OpenTerminal}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.Terminal}"/>
|
||||
</Button>
|
||||
|
||||
<Rectangle Width="1" Height="16"
|
||||
Margin="4,0"
|
||||
VerticalAlignment="Center"
|
||||
Fill="{DynamicResource Brush.Border2}"/>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding AddRootNode}" ToolTip.Tip="{DynamicResource Text.Welcome.AddRootFolder}">
|
||||
<Path Width="14" Height="14" Margin="0,2,0,0" Data="{StaticResource Icons.Folder.Add}"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1" Margin="0,8" ColumnDefinitions="*,600,*">
|
||||
<Grid RowDefinitions="*,36">
|
||||
<Grid Grid.Row="0" Margin="0,8" ColumnDefinitions="*,600,*">
|
||||
<Grid Grid.Column="1" RowDefinitions="Auto,*">
|
||||
<TextBox Grid.Row="0"
|
||||
Height="32"
|
||||
|
@ -126,7 +100,7 @@
|
|||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="2"
|
||||
<TextBlock Grid.Row="1"
|
||||
Classes="italic"
|
||||
Margin="0,0,8,0"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace SourceGit.Views
|
||||
|
@ -107,7 +104,7 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
private async void DropOnTreeView(object sender, DragEventArgs e)
|
||||
private void DropOnTreeView(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.Get("MovedRepositoryTreeNode") is ViewModels.RepositoryNode moved)
|
||||
{
|
||||
|
@ -125,7 +122,7 @@ namespace SourceGit.Views
|
|||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
await OpenOrInitRepository(item.Path.LocalPath);
|
||||
OpenOrInitRepository(item.Path.LocalPath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +157,7 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
private async void DropOnTreeNode(object sender, DragEventArgs e)
|
||||
private void DropOnTreeNode(object sender, DragEventArgs e)
|
||||
{
|
||||
if (sender is not Grid grid)
|
||||
return;
|
||||
|
@ -188,7 +185,7 @@ namespace SourceGit.Views
|
|||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
await OpenOrInitRepository(item.Path.LocalPath, to);
|
||||
OpenOrInitRepository(item.Path.LocalPath, to);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -212,55 +209,27 @@ namespace SourceGit.Views
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private async void OpenLocalRepository(object _1, RoutedEventArgs e)
|
||||
{
|
||||
if (!ViewModels.PopupHost.CanCreatePopup())
|
||||
return;
|
||||
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
if (topLevel == null)
|
||||
return;
|
||||
|
||||
var options = new FolderPickerOpenOptions() { AllowMultiple = false };
|
||||
var selected = await topLevel.StorageProvider.OpenFolderPickerAsync(options);
|
||||
if (selected.Count == 1)
|
||||
await OpenOrInitRepository(selected[0].Path.LocalPath);
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private Task OpenOrInitRepository(string path, ViewModels.RepositoryNode parent = null)
|
||||
private void OpenOrInitRepository(string path, ViewModels.RepositoryNode parent = null)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
if (File.Exists(path))
|
||||
path = Path.GetDirectoryName(path);
|
||||
else
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
var owner = this.FindAncestorOfType<Launcher>();
|
||||
var launcher = owner?.DataContext as ViewModels.Launcher;
|
||||
if (launcher == null)
|
||||
return null;
|
||||
|
||||
var page = launcher.ActivePage;
|
||||
return Task.Run(() =>
|
||||
var root = new Commands.QueryRepositoryRootPath(path).Result();
|
||||
if (string.IsNullOrEmpty(root))
|
||||
{
|
||||
var root = new Commands.QueryRepositoryRootPath(path).Result();
|
||||
if (string.IsNullOrEmpty(root))
|
||||
{
|
||||
Dispatcher.UIThread.Invoke(() => (DataContext as ViewModels.Welcome)?.InitRepository(path, parent));
|
||||
return;
|
||||
}
|
||||
(DataContext as ViewModels.Welcome)?.InitRepository(path, parent);
|
||||
return;
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
var normalizedPath = root.Replace("\\", "/");
|
||||
var node = ViewModels.Preference.FindOrAddNodeByRepositoryPath(normalizedPath, parent, true);
|
||||
launcher.OpenRepositoryInTab(node, page);
|
||||
});
|
||||
});
|
||||
var normalizedPath = root.Replace("\\", "/");
|
||||
var node = ViewModels.Preference.FindOrAddNodeByRepositoryPath(normalizedPath, parent, true);
|
||||
var launcher = this.FindAncestorOfType<Launcher>()?.DataContext as ViewModels.Launcher;
|
||||
launcher?.OpenRepositoryInTab(node, launcher.ActivePage);
|
||||
}
|
||||
|
||||
private bool _pressedTreeNode = false;
|
||||
|
|
32
src/Views/WelcomeToolbar.axaml
Normal file
32
src/Views/WelcomeToolbar.axaml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
xmlns:vm="using:SourceGit.ViewModels"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.WelcomeToolbar"
|
||||
x:DataType="vm:Welcome">
|
||||
<StackPanel Orientation="Horizontal" Margin="4,0,0,0">
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding Clone}" ToolTip.Tip="{DynamicResource Text.Welcome.Clone}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.Pull}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Click="OpenLocalRepository" ToolTip.Tip="{DynamicResource Text.Welcome.OpenOrInit}">
|
||||
<Path Width="16" Height="16" Data="{StaticResource Icons.Folder.Add2}" Margin="0,4,0,0"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding OpenTerminal}" ToolTip.Tip="{DynamicResource Text.Welcome.OpenTerminal}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.Terminal}"/>
|
||||
</Button>
|
||||
|
||||
<Rectangle Width="1" Height="16"
|
||||
Margin="4,0"
|
||||
VerticalAlignment="Center"
|
||||
Fill="{DynamicResource Brush.Border2}"/>
|
||||
|
||||
<Button Classes="icon_button" Width="32" Command="{Binding AddRootNode}" ToolTip.Tip="{DynamicResource Text.Welcome.AddRootFolder}">
|
||||
<Path Width="14" Height="14" Margin="0,2,0,0" Data="{StaticResource Icons.Folder.Add}"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
58
src/Views/WelcomeToolbar.axaml.cs
Normal file
58
src/Views/WelcomeToolbar.axaml.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using System.IO;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class WelcomeToolbar : UserControl
|
||||
{
|
||||
public WelcomeToolbar()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void OpenLocalRepository(object _1, RoutedEventArgs e)
|
||||
{
|
||||
if (!ViewModels.PopupHost.CanCreatePopup())
|
||||
return;
|
||||
|
||||
var topLevel = TopLevel.GetTopLevel(this);
|
||||
if (topLevel == null)
|
||||
return;
|
||||
|
||||
var options = new FolderPickerOpenOptions() { AllowMultiple = false };
|
||||
var selected = await topLevel.StorageProvider.OpenFolderPickerAsync(options);
|
||||
if (selected.Count == 1)
|
||||
OpenOrInitRepository(selected[0].Path.LocalPath);
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OpenOrInitRepository(string path, ViewModels.RepositoryNode parent = null)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
if (File.Exists(path))
|
||||
path = Path.GetDirectoryName(path);
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
var root = new Commands.QueryRepositoryRootPath(path).Result();
|
||||
if (string.IsNullOrEmpty(root))
|
||||
{
|
||||
(DataContext as ViewModels.Welcome)?.InitRepository(path, parent);
|
||||
return;
|
||||
}
|
||||
|
||||
var normalizedPath = root.Replace("\\", "/");
|
||||
var node = ViewModels.Preference.FindOrAddNodeByRepositoryPath(normalizedPath, parent, true);
|
||||
var launcher = this.FindAncestorOfType<Launcher>()?.DataContext as ViewModels.Launcher;
|
||||
launcher?.OpenRepositoryInTab(node, launcher.ActivePage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue