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

@@ -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

@@ -30,8 +30,7 @@ namespace Apollon.WPF
private readonly IUpdateTournamentCommand _updateTournamentCommand;
private readonly IDeleteTournamentCommand _deleteTournamentCommand;
private readonly TournamentsStore _tournamentStore;
private readonly SelectedTournamentsStore _selectedTournamentStore;
private readonly SelectedTournamentsStore _selectedTournamentStore;
public App()
{
@@ -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

@@ -13,8 +13,7 @@ namespace Apollon.WPF.Commands
{
private readonly TournamentsStore _tournamentStore;
private readonly ModalNavigationStore _modalNavigationStore;
private AddTournamentViewModel _addTournamentViewModel;
private AddTournamentViewModel _addTournamentViewModel;
public AddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
{
@@ -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) { }
catch (Exception) { }
finally
{
IsExecuting = false;
}
}
public abstract Task ExecuteAsync(object parameter);
}

View File

@@ -10,20 +10,29 @@ using System.Threading.Tasks;
namespace Apollon.WPF.Commands
{
public class DeleteTournamentCommand : AsyncCommandBase
{
{
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
@@ -35,7 +44,12 @@ namespace Apollon.WPF.Commands
catch (Exception)
{
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

@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace Apollon.WPF.Commands
{
public class OpenWarningDeleteCommand : CommandBase
{
{
private readonly OverviewListingItemViewModel _overviewListingItemViewModel;
private readonly ModalNavigationStore _modalNavigationStore;
private readonly TournamentsStore _tournamentsStore;
@@ -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

@@ -21,8 +21,7 @@ namespace Apollon.WPF.ViewModels
_organisation = value;
OnPropertyChanged(nameof(Organisation));
}
}
}
private string _tournamentName;
public string TournamentName
@@ -53,10 +52,7 @@ namespace Apollon.WPF.ViewModels
}
}
private DateTime _startDate = DateTime.Today;
private DateTime _startDate = DateTime.Today;
public DateTime StartDate
{
@@ -115,7 +111,21 @@ namespace Apollon.WPF.ViewModels
}
}
public bool CanSubmit => !string.IsNullOrEmpty(TournamentName);
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; }
public ICommand CancelCommand { get; }
@@ -125,8 +135,6 @@ namespace Apollon.WPF.ViewModels
SubmitCommand = submitCommand;
CancelCommand = cancelCommand;
}
}
}
}

View File

@@ -15,19 +15,16 @@ namespace Apollon.WPF.ViewModels
public ViewModelBase CurrentModalViewModel => _modalNavigationStore.CurrentViewModel;
public ViewModelBase CurrentViewModel => _navigationStore.CurrentViewModel;
public bool IsModalOpen => _modalNavigationStore.IsOpen;
public OverviewViewModel OverviewViewModel { get; }
public OverviewViewModel OverviewViewModel { get; }
public MainViewModel(ModalNavigationStore modalNavigationStore, OverviewViewModel overviewViewModel, NavigationStore navigationStore)
{
_navigationStore = navigationStore;
_modalNavigationStore = modalNavigationStore;
OverviewViewModel = overviewViewModel;
OverviewViewModel = overviewViewModel;
_navigationStore.CurrentViewModelChanged += NavigationStore_CurrentViewModelChanged;
_modalNavigationStore.CurrentViewModelChanged += ModalNavigationStore_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
{
public ICommand WarningCloseCommand { get;}
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

@@ -3,7 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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: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

@@ -65,15 +65,11 @@
Grid.Column="1"
Foreground="Red"/>
</Button>
</WrapPanel>
</Grid>
</WrapPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
</Border>
</Grid>
</UserControl>

View File

@@ -4,7 +4,8 @@
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:components="clr-namespace:Apollon.WPF.Views.Components"
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">
@@ -18,20 +19,7 @@
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<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>-->
</Grid.ColumnDefinitions>
<StackPanel Grid.ColumnSpan="3">
<TextBlock
@@ -54,7 +42,7 @@
FontSize="20"
Foreground="{StaticResource BrushPrimary1}">
</TextBlock>
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="2"
VerticalAlignment="Stretch">
@@ -75,39 +63,75 @@
Cursor="Hand"
Command="{Binding AddTournamentCommand}"/>
</StackPanel>
<StackPanel Grid.Column="1"
<Grid Grid.Column="1"
Grid.Row="1"
Margin="20">
<TextBlock Margin="20"
Margin="20">
<StackPanel>
<TextBlock Margin="20"
Text="Liste der erstellten Turniere"
TextAlignment="Center"
FontFamily="Arial"
FontWeight="Bold"
FontSize="16"
Foreground="{StaticResource BrushPrimary1}"/>
<components:OverViewListing Height="400"
<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">
<TextBlock Margin="20"
<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"
FontFamily="Arial"
FontWeight="Bold"
FontSize="16"
Foreground="{StaticResource BrushPrimary1}"/>
<components:OverviewDetails Width="320"
<components:OverviewDetails Width="320"
DataContext="{Binding OverviewDetailsViewModel}"/>
<Button Style="{StaticResource ModernButton}"
<Button Style="{StaticResource ModernButton}"
Content="Namensliste"
FontSize="16"
Height="40"
@@ -115,7 +139,9 @@
Margin="40"
Cursor="Hand"
Command="{Binding NavigateNavBarCommand}"/>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
</UserControl>

View File

@@ -3,7 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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: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>