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 NavigationStore _navigationStore;
private readonly ModalNavigationStore _modalNavigationStore;
private readonly SelectedTournamentsStore _selectedTournamentsStore;
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;
_tournamentStore = tournamentStore;
_modalNavigationStore = modalNavigationStore;
_navigationStore = navigationStore;
_selectedTournamentsStore = selectedTournamentsStore;
}
public override async Task ExecuteAsync(object parameter)
@@ -47,7 +50,7 @@ namespace Apollon.WPF.Commands
await _tournamentStore.Add(tournament);
_modalNavigationStore.Close();
_navigationStore.CurrentViewModel = new NavBarViewModel(_navigationStore);
//_navigationStore.CurrentViewModel = new NavBarViewModel(_navigationStore, _selectedTournamentsStore, _modalNavigationStore,_tournamentStore);
}
catch (Exception)

View File

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

View File

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

View File

@@ -13,9 +13,9 @@ namespace Apollon.WPF.ViewModels
{
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);
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand);
}

View File

@@ -26,7 +26,8 @@ namespace Apollon.WPF.ViewModels
{
Organisation = tournament.Organisation,
TournamentName = tournament.TournamentName,
Competition = tournament.Competition,
Competition = tournament.Competition,
CompetitionImage = tournament.CompetitionImage,
StartDate = tournament.StartDate,
EndDate = tournament.EndDate,
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.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Apollon.WPF.ViewModels
{
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 TournamentName => SelectedTournament?.TournamentName ?? "kein Name";
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 EndDate => SelectedTournament?.EndDate.ToString("d") ?? "kein Datum";
public string Location => SelectedTournament?.Location ?? "kein Ort";

View File

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

View File

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

View File

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

View File

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