finish addedit

This commit is contained in:
Natlinux81
2022-09-09 23:50:17 +02:00
parent e2f41a8f43
commit b3c62b0104
12 changed files with 81 additions and 34 deletions

View File

@@ -14,14 +14,17 @@ namespace Apollon.WPF.Commands
private readonly TournamentsStore _tournamentStore; private readonly TournamentsStore _tournamentStore;
private readonly NavigationStore _navigationStore; private readonly NavigationStore _navigationStore;
private readonly ModalNavigationStore _modalNavigationStore; private readonly ModalNavigationStore _modalNavigationStore;
private readonly SelectedTournamentsStore _selectedTournamentsStore;
private AddTournamentViewModel _addTournamentViewModel; private AddTournamentViewModel _addTournamentViewModel;
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore)
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore, SelectedTournamentsStore selectedTournamentsStore)
{ {
_addTournamentViewModel = addTournamentViewModel; _addTournamentViewModel = addTournamentViewModel;
_tournamentStore = tournamentStore; _tournamentStore = tournamentStore;
_modalNavigationStore = modalNavigationStore; _modalNavigationStore = modalNavigationStore;
_navigationStore = navigationStore; _navigationStore = navigationStore;
_selectedTournamentsStore = selectedTournamentsStore;
} }
public override async Task ExecuteAsync(object parameter) public override async Task ExecuteAsync(object parameter)
@@ -47,7 +50,7 @@ namespace Apollon.WPF.Commands
await _tournamentStore.Add(tournament); await _tournamentStore.Add(tournament);
_modalNavigationStore.Close(); _modalNavigationStore.Close();
_navigationStore.CurrentViewModel = new NavBarViewModel(_navigationStore); //_navigationStore.CurrentViewModel = new NavBarViewModel(_navigationStore, _selectedTournamentsStore, _modalNavigationStore,_tournamentStore);
} }
catch (Exception) catch (Exception)

View File

@@ -11,19 +11,21 @@ namespace Apollon.WPF.Commands
public class OpenAddTournamentCommand : CommandBase public class OpenAddTournamentCommand : CommandBase
{ {
private readonly TournamentsStore _tournamentStore; private readonly TournamentsStore _tournamentStore;
private readonly SelectedTournamentsStore _selectedTournamentsStore;
private readonly NavigationStore _navigationStore; private readonly NavigationStore _navigationStore;
private readonly ModalNavigationStore _modalNavigationStore; private readonly ModalNavigationStore _modalNavigationStore;
public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore) public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore, SelectedTournamentsStore selectedTournamentsStore)
{ {
_tournamentStore = tournamentStore; _tournamentStore = tournamentStore;
_navigationStore = navigationStore; _navigationStore = navigationStore;
_modalNavigationStore = modalNavigationStore; _modalNavigationStore = modalNavigationStore;
_selectedTournamentsStore = selectedTournamentsStore;
} }
public override void Execute(object parameter) public override void Execute(object parameter)
{ {
AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore, _navigationStore); AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore, _navigationStore, _selectedTournamentsStore);
_modalNavigationStore.CurrentViewModel = addTournamentViewModel; _modalNavigationStore.CurrentViewModel = addTournamentViewModel;
} }
} }

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
namespace Apollon.WPF.ViewModels namespace Apollon.WPF.ViewModels
@@ -56,13 +57,13 @@ namespace Apollon.WPF.ViewModels
public string CompetitionImage public string CompetitionImage
{ {
get get
{ {
return _competitionImage; return _competitionImage;
} }
set set
{ {
_competitionImage = value; _competitionImage = value;
OnPropertyChanged(nameof(CompetitionImage)); OnPropertyChanged(nameof(CompetitionImage));;
} }
} }

View File

@@ -13,9 +13,9 @@ namespace Apollon.WPF.ViewModels
{ {
public AddEditDetailsViewModel AddEditDetailsViewModel { get; } public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore) public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore,SelectedTournamentsStore selectedTournamentsStore)
{ {
ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore,navigationStore); ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore,navigationStore, selectedTournamentsStore);
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore); ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand); AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand);
} }

View File

@@ -26,7 +26,8 @@ namespace Apollon.WPF.ViewModels
{ {
Organisation = tournament.Organisation, Organisation = tournament.Organisation,
TournamentName = tournament.TournamentName, TournamentName = tournament.TournamentName,
Competition = tournament.Competition, Competition = tournament.Competition,
CompetitionImage = tournament.CompetitionImage,
StartDate = tournament.StartDate, StartDate = tournament.StartDate,
EndDate = tournament.EndDate, EndDate = tournament.EndDate,
Location = tournament.Location, Location = tournament.Location,

View File

@@ -1,16 +1,23 @@
using Apollon.WPF.Stores; using Apollon.WPF.Commands;
using Apollon.WPF.Stores;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input;
namespace Apollon.WPF.ViewModels namespace Apollon.WPF.ViewModels
{ {
public class NavBarViewModel : ViewModelBase public class NavBarViewModel : ViewModelBase
{ {
public NavBarViewModel(NavigationStore navigationStore)
public ICommand NavigateOverviewCommand { get; }
public NavBarViewModel(NavigationStore navigationStore, SelectedTournamentsStore selectedTournamentsStore, ModalNavigationStore modalNavigationStore, TournamentsStore tournamentsStore)
{ {
NavigateOverviewCommand = new NavigateCommand<OverviewViewModel>(navigationStore, () => new OverviewViewModel(tournamentsStore, selectedTournamentsStore, modalNavigationStore,navigationStore));
} }
} }
} }

View File

@@ -17,7 +17,7 @@ namespace Apollon.WPF.ViewModels
public string Organisation => SelectedTournament?.Organisation ?? "keine Organisation"; public string Organisation => SelectedTournament?.Organisation ?? "keine Organisation";
public string TournamentName => SelectedTournament?.TournamentName ?? "kein Name"; public string TournamentName => SelectedTournament?.TournamentName ?? "kein Name";
public string Competition => SelectedTournament?.Competition ?? "keine Kategorie"; public string Competition => SelectedTournament?.Competition ?? "keine Kategorie";
public string CompetitionImage => SelectedTournament?.CompetitionImage ?? "kein Bild"; public string CompetitionImage => SelectedTournament?.CompetitionImage ?? "D:\\Projekte\\Apollon\\Apollon\\Apollon.WPF\\Images\\Archery.png";
public string StartDate => SelectedTournament?.StartDate.ToString("d") ?? "kein Datum"; public string StartDate => SelectedTournament?.StartDate.ToString("d") ?? "kein Datum";
public string EndDate => SelectedTournament?.EndDate.ToString("d") ?? "kein Datum"; public string EndDate => SelectedTournament?.EndDate.ToString("d") ?? "kein Datum";
public string Location => SelectedTournament?.Location ?? "kein Ort"; public string Location => SelectedTournament?.Location ?? "kein Ort";

View File

@@ -57,8 +57,8 @@ namespace Apollon.WPF.ViewModels
OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore); OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore);
LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore); LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore);
AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore, navigationStore); AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore, navigationStore, selectedTournamentStore);
NavigateNavBarCommand = new NavigateCommand<NavBarViewModel>(navigationStore, () => new NavBarViewModel(navigationStore)); NavigateNavBarCommand = new NavigateCommand<NavBarViewModel>(navigationStore, () => new NavBarViewModel(navigationStore,selectedTournamentStore,modalNavigationStore,tournamentStore));
} }

View File

@@ -7,7 +7,7 @@
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl" xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
mc:Ignorable="d"> mc:Ignorable="d">
<UserControl.Resources> <UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -76,24 +76,23 @@
IsEditable="True" IsEditable="True"
Grid.Column="1" Grid.Column="1"
Height="30" Height="30"
Width="150" Width="200"
FontSize="16" FontSize="16"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
HorizontalAlignment="Left"> HorizontalAlignment="Left"
<ComboBoxItem Content="Halle"></ComboBoxItem> Loaded="ComboBox_Loaded"
<ComboBoxItem Content="im Freien"></ComboBoxItem> SelectionChanged="ComboBox_SelectionChanged">
<ComboBoxItem Content="Feld"></ComboBoxItem>
<ComboBoxItem Content="3 D"></ComboBoxItem>
</ComboBox> </ComboBox>
<Image x:Name="CompetitionImage" <Image Name="CompetitionImage"
Grid.Row="2" Grid.Row="2"
Grid.Column="1" Grid.Column="1"
Grid.RowSpan="2" Grid.RowSpan="2"
Height="80" Height="80"
Width="80" Width="80"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Margin="0 0 80 0"/> Margin="0 0 80 0"
Source="{Binding CompetitionImage, Mode=TwoWay, TargetNullValue={x:Null}}" />
<DatePicker SelectedDateFormat="Long" <DatePicker SelectedDateFormat="Long"
Grid.Row="3" Grid.Row="3"

View File

@@ -1,4 +1,5 @@
using System; using Apollon.Domain.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -22,8 +23,38 @@ namespace Apollon.WPF.Views.Components
{ {
public AddEditDetails() public AddEditDetails()
{ {
InitializeComponent(); InitializeComponent();
}
private void ComboBox_Loaded(object sender, RoutedEventArgs e)
{
List<string> competitions = new List<string>()
{
"Halle", "im Freien", "Feld", "3D"
};
ComboBox.ItemsSource = competitions;
}
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (ComboBox.SelectedIndex == 0)
{
CompetitionImage.Source = new BitmapImage(new Uri(@"D:\Projekte\Apollon\Apollon\Apollon.WPF\Images\TargetHall.png"));
}
if (ComboBox.SelectedIndex == 1)
{
CompetitionImage.Source = new BitmapImage(new Uri("D:\\Projekte\\Apollon\\Apollon\\Apollon.WPF\\Images\\TargetField.png"));
}
if (ComboBox.SelectedIndex == 2)
{
CompetitionImage.Source = new BitmapImage(new Uri("D:\\Projekte\\Apollon\\Apollon\\Apollon.WPF\\Images\\TargetOutdoor.png"));
}
}
}
} }
} }

View File

@@ -4,8 +4,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 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:converter="clr-namespace:Apollon.WPF.Views.Components"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>
<Border BorderBrush="#0000a0" <Border BorderBrush="#0000a0"
BorderThickness="1" BorderThickness="1"
@@ -92,19 +93,20 @@
</TextBlock> </TextBlock>
<Image Grid.Column="2" <Image Grid.Column="2"
Grid.Row="2" Grid.Row="2"
Source="D:\Projekte\Apollon\Apollon\Apollon.WPF\Images\TargetField.png" Source="{Binding CompetitionImage}"
Width="50" Width="50"
Height="50"> Height="50">
<Image.Style> <Image.Style>
<Style TargetType="Image"> <Style TargetType="Image">
<Setter Property="Visibility" Value="Hidden"/> <Setter Property="Visibility" Value="Hidden"/>
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding HasSelectedTournament}" Value="True"> <DataTrigger Binding="{Binding HasSelectedTournament}" Value="True">
<Setter Property="Visibility" Value="Visible"/> <Setter Property="Visibility" Value="Visible"/>
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
</Image.Style> </Image.Style>
</Image> </Image>
</WrapPanel> </WrapPanel>

View File

@@ -23,7 +23,8 @@
Background="Transparent" Background="Transparent"
BorderThickness="0" BorderThickness="0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Margin="5"> Margin="5"
Command="{Binding NavigateOverviewCommand}">
<iconPacks:PackIconMaterial Kind="ArrowLeft" <iconPacks:PackIconMaterial Kind="ArrowLeft"
Height="25" Height="25"
Width="35" Width="35"