Finish LoadingSpinner

This commit is contained in:
Natlinux81
2022-08-28 01:58:33 +02:00
parent 7fe2fd08ea
commit dfe0f72d04
20 changed files with 181 additions and 85 deletions

View File

@@ -11,7 +11,6 @@ using System.Threading.Tasks;
namespace Apollon.EntityFramework.Commands
{
public class CreateTournamentCommand : ICreateTournamentCommand
{
private readonly TournamentsDbContextFactory _contextFactory;

View File

@@ -13,7 +13,6 @@ namespace Apollon.EntityFramework
public TournamentsDbContext(DbContextOptions options) : base(options)
{
}
public DbSet<TournamentDto> Tournaments { get; set; }
}
}

View File

@@ -8,6 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LoadingSpinner.WPF" Version="1.0.0" />
<PackageReference Include="MahApps.Metro.IconPacks.Material" Version="4.11.0" />
<PackageReference Include="SimpleModal.WPF" Version="1.0.0" />
</ItemGroup>

View File

@@ -32,7 +32,6 @@ namespace Apollon.WPF
private readonly TournamentsStore _tournamentStore;
private readonly SelectedTournamentsStore _selectedTournamentStore;
public App()
{
string connectionString = "Server=NATHALIE-PC\\NATLINUXDB;Database=Apollon;Trusted_Connection=True;MultipleActiveResultSets=true";
@@ -61,10 +60,10 @@ namespace Apollon.WPF
_tournamentStore,
_navigationStore);
_navigationStore.CurrentViewModel = new OverviewViewModel(
_tournamentStore,
_navigationStore.CurrentViewModel = OverviewViewModel.LoadViewModel(
_selectedTournamentStore,
_modalNavigationStore,
_tournamentStore,
_navigationStore);
MainWindow = new MainWindow()

View File

@@ -15,7 +15,6 @@ namespace Apollon.WPF.Commands
private readonly ModalNavigationStore _modalNavigationStore;
private AddTournamentViewModel _addTournamentViewModel;
public AddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
{
_tournamentStore = tournamentStore;
@@ -32,6 +31,9 @@ namespace Apollon.WPF.Commands
public override async Task ExecuteAsync(object parameter)
{
AddEditDetailsViewModel detailsViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
detailsViewModel.IsSubmitting = true;
Tournament tournament = new Tournament(
Guid.NewGuid(),
detailsViewModel.Organisation,
@@ -51,9 +53,12 @@ namespace Apollon.WPF.Commands
}
catch (Exception)
{
throw;
}
finally
{
detailsViewModel.IsSubmitting = false;
}
}
}
}

View File

@@ -8,13 +8,35 @@ namespace Apollon.WPF.Commands
{
public abstract class AsyncCommandBase : CommandBase
{
private bool _isExecuring;
public bool IsExecuting
{
get
{
return _isExecuring;
}
set
{
_isExecuring = value;
OnCanExecutedChanged();
}
}
public override bool CanExecute(object parameter)
{
return !IsExecuting && base.CanExecute(parameter);
}
public override async void Execute(object parameter)
{
IsExecuting = true;
try
{
await ExecuteAsync(parameter);
}
catch (Exception) { }
finally
{
IsExecuting = false;
}
}
public abstract Task ExecuteAsync(object parameter);
}

View File

@@ -14,16 +14,25 @@ namespace Apollon.WPF.Commands
private readonly OverviewListingItemViewModel _overviewListingItemViewModel;
private readonly TournamentsStore _tournamentStore;
private readonly ModalNavigationStore _modalNavigationStore;
private readonly WarningDeleteViewModel _warningDeleteViewModel;
public DeleteTournamentCommand(OverviewListingItemViewModel overviewListingItemViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
public DeleteTournamentCommand(WarningDeleteViewModel warningDeleteViewModel, OverviewListingItemViewModel overviewListingItemViewModel, TournamentsStore tournamentsStore, ModalNavigationStore modalNavigationStore)
{
_warningDeleteViewModel = warningDeleteViewModel;
_overviewListingItemViewModel = overviewListingItemViewModel;
_tournamentStore = tournamentStore;
_tournamentStore = tournamentsStore;
_modalNavigationStore = modalNavigationStore;
}
public OverviewListingItemViewModel OverviewListingItemViewModel { get; }
public TournamentsStore TournamentsStore { get; }
public ModalNavigationStore ModalNavigationStore { get; }
public WarningDeleteViewModel WarningDeleteViewModel { get; }
public override async Task ExecuteAsync(object parameter)
{
_warningDeleteViewModel.IsDeleting = true;
Tournament tournament = _overviewListingItemViewModel.Tournament;
try
@@ -36,6 +45,11 @@ namespace Apollon.WPF.Commands
{
throw;
}
finally
{
_warningDeleteViewModel.IsDeleting = false;
}
}
}
}

View File

@@ -25,6 +25,9 @@ namespace Apollon.WPF.Commands
public override async Task ExecuteAsync(object parameter)
{
AddEditDetailsViewModel detailsViewModel = _editTournamentViewModel.AddEditDetailsViewModel;
detailsViewModel.IsSubmitting = true;
Tournament tournament = new Tournament(
_editTournamentViewModel.TournamentId,
detailsViewModel.Organisation,
@@ -46,6 +49,10 @@ namespace Apollon.WPF.Commands
throw;
}
finally
{
detailsViewModel.IsSubmitting = false;
}
}
}
}

View File

@@ -24,7 +24,6 @@ namespace Apollon.WPF.Commands
public override void Execute(object parameter)
{
Tournament tournament =_overviewListingItemViewModel.Tournament;
WarningDeleteViewModel warningDeleteViewModel = new WarningDeleteViewModel(_modalNavigationStore,_tournamentsStore,_overviewListingItemViewModel);
_modalNavigationStore.CurrentViewModel = warningDeleteViewModel;
}

View File

@@ -23,7 +23,6 @@ namespace Apollon.WPF.ViewModels
}
}
private string _tournamentName;
public string TournamentName
{
@@ -54,9 +53,6 @@ namespace Apollon.WPF.ViewModels
}
private DateTime _startDate = DateTime.Today;
public DateTime StartDate
{
@@ -115,6 +111,20 @@ namespace Apollon.WPF.ViewModels
}
}
private bool _isSubmitting;
public bool IsSubmitting
{
get
{
return _isSubmitting;
}
set
{
_isSubmitting = value;
OnPropertyChanged(nameof(IsSubmitting));
}
}
public bool CanSubmit => !string.IsNullOrEmpty(TournamentName);
public ICommand SubmitCommand { get; }
@@ -127,6 +137,4 @@ namespace Apollon.WPF.ViewModels
}
}
}

View File

@@ -17,17 +17,14 @@ namespace Apollon.WPF.ViewModels
public bool IsModalOpen => _modalNavigationStore.IsOpen;
public OverviewViewModel OverviewViewModel { get; }
public MainViewModel(ModalNavigationStore modalNavigationStore, OverviewViewModel overviewViewModel, NavigationStore navigationStore)
{
_navigationStore = navigationStore;
_modalNavigationStore = modalNavigationStore;
OverviewViewModel = overviewViewModel;
_navigationStore.CurrentViewModelChanged += NavigationStore_CurrentViewModelChanged;
_modalNavigationStore.CurrentViewModelChanged += ModalNavigationStore_CurrentViewModelChanged;
}
protected override void Dispose()
@@ -45,7 +42,6 @@ namespace Apollon.WPF.ViewModels
{
OnPropertyChanged(nameof(CurrentModalViewModel));
OnPropertyChanged(nameof(IsModalOpen));
}
}
}

View File

@@ -11,7 +11,6 @@ namespace Apollon.WPF.ViewModels
public class OverviewDetailsViewModel : ViewModelBase
{
private readonly SelectedTournamentsStore _selectedTournamentStore;
private Tournament SelectedTournament => _selectedTournamentStore.SelectedTournament;
public bool HasSelectedTournament => SelectedTournament != null;

View File

@@ -33,7 +33,6 @@ namespace Apollon.WPF.ViewModels
}
}
public OverviewListingViewModel(SelectedTournamentsStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, TournamentsStore tournamentStore)
{
_tournamentStore = tournamentStore;

View File

@@ -20,7 +20,7 @@ namespace Apollon.WPF.ViewModels
{
get
{
return IsLoading;
return _isLoading;
}
set
{

View File

@@ -11,12 +11,25 @@ namespace Apollon.WPF.ViewModels
{
public class WarningDeleteViewModel : ViewModelBase
{
private bool _isDeleting;
public bool IsDeleting
{
get
{
return _isDeleting;
}
set
{
_isDeleting = value;
OnPropertyChanged(nameof(IsDeleting));
}
}
public ICommand WarningCloseCommand { get;}
public ICommand DeleteCommand { get; }
public WarningDeleteViewModel(ModalNavigationStore modalNavigationStore,TournamentsStore tournamentsStore, OverviewListingItemViewModel overviewListingItemViewModel)
{
WarningCloseCommand = new CloseModalCommand(modalNavigationStore);
DeleteCommand = new DeleteTournamentCommand(overviewListingItemViewModel, tournamentsStore, modalNavigationStore);
DeleteCommand = new DeleteTournamentCommand(this, overviewListingItemViewModel, tournamentsStore, modalNavigationStore);
}
}
}

View File

@@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Apollon.WPF.Views.Components"
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
@@ -133,6 +134,7 @@
HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="35"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
@@ -150,7 +152,12 @@
Width="120"
Height="35"
FontSize="16"
Grid.Column="1"/>
Grid.Column="2"/>
<custom:LoadingSpinner Grid.Column="1"
Diameter="25"
Thickness="2"
Color="{StaticResource BrushPrimary1}"
IsLoading="{Binding IsSubmitting}"/>
</Grid>
</Grid>
</UserControl>

View File

@@ -66,14 +66,10 @@
Foreground="Red"/>
</Button>
</WrapPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
</Grid>
</UserControl>

View File

@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Apollon.WPF.Views"
xmlns:components="clr-namespace:Apollon.WPF.Views.Components"
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
mc:Ignorable="d"
d:DesignHeight="680" d:DesignWidth="1080"
Background="Transparent">
@@ -20,19 +21,6 @@
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<!--<Border BorderThickness="4"
BorderBrush="#0000a0"
CornerRadius="5"
Grid.RowSpan="2"
Grid.ColumnSpan="3">
<Border.Background>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="{StaticResource ColorPrimary4}" Offset="0.2"/>
<GradientStop Color="{StaticResource ColorPrimary5}" Offset="0.8"/>
</LinearGradientBrush>
</Border.Background>
</Border>-->
<StackPanel Grid.ColumnSpan="3">
<TextBlock
Text="Apollon"
@@ -76,9 +64,10 @@
Command="{Binding AddTournamentCommand}"/>
</StackPanel>
<StackPanel Grid.Column="1"
<Grid Grid.Column="1"
Grid.Row="1"
Margin="20">
<StackPanel>
<TextBlock Margin="20"
Text="Liste der erstellten Turniere"
@@ -88,15 +77,49 @@
FontSize="16"
Foreground="{StaticResource BrushPrimary1}"/>
<components:OverViewListing Height="400"
Width="400"
DataContext="{Binding OverviewListingViewModel}"/>
</StackPanel>
<StackPanel Grid.Column="2"
</StackPanel>
<StackPanel VerticalAlignment="Center">
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsLoading}" Value="true">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<TextBlock Text="Daten werden geladen...."
TextAlignment="Center"
VerticalAlignment="Center"
Foreground="{StaticResource BrushPrimary1}"
Margin="0 0 0 30"
FontSize="14">
</TextBlock>
<custom:LoadingSpinner Diameter="50" IsLoading="True" Thickness="3" Color="{StaticResource BrushPrimary1}"/>
</StackPanel>
</Grid>
<Grid Grid.Column="2"
Grid.Row="1"
VerticalAlignment="Center">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Hidden"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsLoading}" Value="false">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<StackPanel>
<TextBlock Margin="20"
Text="Turnieredetails"
TextAlignment="Center"
@@ -104,6 +127,7 @@
FontWeight="Bold"
FontSize="16"
Foreground="{StaticResource BrushPrimary1}"/>
<components:OverviewDetails Width="320"
DataContext="{Binding OverviewDetailsViewModel}"/>
@@ -116,6 +140,8 @@
Cursor="Hand"
Command="{Binding NavigateNavBarCommand}"/>
</StackPanel>
</Grid>
</Grid>
</UserControl>

View File

@@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Apollon.WPF.Views"
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
@@ -25,6 +26,7 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="35"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
@@ -36,13 +38,18 @@
FontSize="14"
/>
<Button Grid.Column="1"
<Button Grid.Column="2"
Content="Abbrechen"
Command="{Binding WarningCloseCommand}"
Style="{StaticResource ModernButton}"
Width="100"
Height="30"
FontSize="14"/>
<custom:LoadingSpinner Grid.Column="1"
Diameter="25"
Thickness="2"
Color="{StaticResource BrushPrimary1}"
IsLoading="{Binding IsDeleting}"/>
</Grid>
</StackPanel>
</Grid>