DatePicker implemented

This commit is contained in:
Natlinux81
2022-08-17 18:29:51 +02:00
parent b10a792aad
commit 6cf060628f
10 changed files with 56 additions and 65 deletions

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net6.0-windows</TargetFramework>
<Nullable>disable</Nullable> <Nullable>enable</Nullable>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
</PropertyGroup> </PropertyGroup>

View File

@@ -32,7 +32,7 @@ namespace Apollon.WPF.Commands
public override async Task ExecuteAsync(object parameter) public override async Task ExecuteAsync(object parameter)
{ {
AddEditDetailsViewModel formViewModel = _addTournamentViewModel.AddEditDetailsViewModel; AddEditDetailsViewModel formViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
Tournament tournament = new Tournament(formViewModel.Organisation,formViewModel.Tournamentname, formViewModel.Competition, formViewModel.Startdate, formViewModel.Enddate, Tournament tournament = new Tournament(formViewModel.Organisation,formViewModel.TournamentName, formViewModel.Competition, formViewModel.StartDate, formViewModel.EndDate,
formViewModel.Location, formViewModel.Rounds); formViewModel.Location, formViewModel.Rounds);
try try

View File

@@ -8,22 +8,22 @@ namespace Apollon.WPF.Models
{ {
public class Tournament public class Tournament
{ {
public Tournament(string organisation, string tournamentname, string competition, string startdate, string enddate, string location, int rounds = 0) public Tournament(string organisation, string tournamentName, string competition, DateTime startDate, DateTime endDate, string location, int rounds = 0)
{ {
Organisation = organisation; Organisation = organisation;
Tournamentname = tournamentname; TournamentName = tournamentName;
Competition = competition; Competition = competition;
Startdate = startdate; StartDate = startDate;
Enddate = enddate; EndDate = endDate;
Location = location; Location = location;
Rounds = rounds; Rounds = rounds;
} }
public string Organisation { get; } public string Organisation { get; }
public string Tournamentname { get; } public string TournamentName { get; }
public string Competition { get; } public string Competition { get; }
public string Startdate { get; } public DateTime StartDate { get; }
public string Enddate { get; } public DateTime EndDate { get; }
public string Location { get; } public string Location { get; }
public int Rounds { get; } public int Rounds { get; }

View File

@@ -22,18 +22,19 @@ namespace Apollon.WPF.ViewModels
OnPropertyChanged(nameof(Organisation)); OnPropertyChanged(nameof(Organisation));
} }
} }
private string _tournamentname; private string _tournamentName;
public string Tournamentname public string TournamentName
{ {
get get
{ {
return _tournamentname; return _tournamentName;
} }
set set
{ {
_tournamentname = value; _tournamentName = value;
OnPropertyChanged(nameof(Tournamentname)); OnPropertyChanged(nameof(TournamentName));
OnPropertyChanged(nameof(CanSubmit)); OnPropertyChanged(nameof(CanSubmit));
} }
} }
@@ -52,31 +53,37 @@ namespace Apollon.WPF.ViewModels
} }
} }
private string _startdate; private DateTime _startDate = DateTime.Today;
public string Startdate
public DateTime StartDate
{ {
get get
{ {
return _startdate;
return _startDate;
} }
set set
{ {
_startdate = value; _startDate = value;
OnPropertyChanged(nameof(Startdate));
OnPropertyChanged(nameof(StartDate));
} }
} }
private string _enddate; private DateTime _endDate = DateTime.Today;
public string Enddate public DateTime EndDate
{ {
get get
{ {
return _enddate; return _endDate;
} }
set set
{ {
_enddate = value; _endDate = value;
OnPropertyChanged(nameof(Enddate)); OnPropertyChanged(nameof(EndDate));
} }
} }
@@ -108,7 +115,7 @@ namespace Apollon.WPF.ViewModels
} }
} }
public bool CanSubmit => !string.IsNullOrEmpty(Tournamentname); public bool CanSubmit => !string.IsNullOrEmpty(TournamentName);
public ICommand SubmitCommand { get; } public ICommand SubmitCommand { get; }
public ICommand CancelCommand { get; } public ICommand CancelCommand { get; }

View File

@@ -21,10 +21,10 @@ namespace Apollon.WPF.ViewModels
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand ) AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand )
{ {
Organisation = tournament.Organisation, Organisation = tournament.Organisation,
Tournamentname = tournament.Tournamentname, TournamentName = tournament.TournamentName,
Competition = tournament.Competition, Competition = tournament.Competition,
Startdate = tournament.Startdate, StartDate = tournament.StartDate,
Enddate = tournament.Enddate, EndDate = tournament.EndDate,
Location = tournament.Location, Location = tournament.Location,
Rounds = tournament.Rounds, Rounds = tournament.Rounds,
}; };

View File

@@ -16,10 +16,10 @@ namespace Apollon.WPF.ViewModels
public bool HasSelectedTournament => SelectedTournament != null; public bool HasSelectedTournament => SelectedTournament != null;
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 Category => SelectedTournament?.Competition ?? "keine Kategorie"; public string Category => SelectedTournament?.Competition ?? "keine Kategorie";
public string Startdate => SelectedTournament?.Startdate ?? "kein Datum"; public string StartDate => SelectedTournament?.StartDate.ToString("d") ?? "kein Datum";
public string Enddate => SelectedTournament?.Enddate ?? "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";
public int Rounds => SelectedTournament?.Rounds ?? 0; public int Rounds => SelectedTournament?.Rounds ?? 0;
@@ -40,10 +40,10 @@ namespace Apollon.WPF.ViewModels
{ {
OnPropertyChanged(nameof(HasSelectedTournament)); OnPropertyChanged(nameof(HasSelectedTournament));
OnPropertyChanged(nameof(Organisation)); OnPropertyChanged(nameof(Organisation));
OnPropertyChanged(nameof(Tournamentname)); OnPropertyChanged(nameof(TournamentName));
OnPropertyChanged(nameof(Category)); OnPropertyChanged(nameof(Category));
OnPropertyChanged(nameof(Startdate)); OnPropertyChanged(nameof(StartDate));
OnPropertyChanged(nameof(Enddate)); OnPropertyChanged(nameof(EndDate));
OnPropertyChanged(nameof(Location)); OnPropertyChanged(nameof(Location));
OnPropertyChanged(nameof(Rounds)); OnPropertyChanged(nameof(Rounds));
} }

View File

@@ -12,7 +12,7 @@ namespace Apollon.WPF.ViewModels
{ {
public Tournament Tournament { get;} public Tournament Tournament { get;}
public string Tournamentname => Tournament.Tournamentname; public string TournamentName => Tournament.TournamentName;
public string Location => Tournament.Location; public string Location => Tournament.Location;
public ICommand DeleteCommand { get; } public ICommand DeleteCommand { get; }

View File

@@ -51,7 +51,7 @@
VerticalContentAlignment="Center"/> VerticalContentAlignment="Center"/>
<TextBox Grid.Row="1" <TextBox Grid.Row="1"
Grid.Column="1" Grid.Column="1"
Text="{Binding Tournamentname, UpdateSourceTrigger=PropertyChanged}" Text="{Binding TournamentName, UpdateSourceTrigger=PropertyChanged}"
FontFamily="Arial" FontFamily="Arial"
FontSize="16" FontSize="16"
Height="30" Height="30"
@@ -65,18 +65,20 @@
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
HorizontalAlignment="Left"/> HorizontalAlignment="Left"/>
<DatePicker Grid.Row="3" <DatePicker SelectedDateFormat="Long"
Grid.Row="3"
SelectedDate="{Binding StartDate}"
Grid.Column="1" Grid.Column="1"
Height="30" Height="30"
FontSize="16" FontSize="16"
Width="160"
HorizontalAlignment="Left"/> HorizontalAlignment="Left"/>
<DatePicker Grid.Row="4" <DatePicker SelectedDateFormat="Long"
Grid.Row="4"
SelectedDate="{Binding EndDate}"
Grid.Column="1" Grid.Column="1"
Height="30" Height="30"
FontSize="16" FontSize="16"
Width="160"
HorizontalAlignment="Left"/> HorizontalAlignment="Left"/>
<TextBox Grid.Row="5" <TextBox Grid.Row="5"

View File

@@ -33,7 +33,7 @@
<ColumnDefinition Width="auto"></ColumnDefinition> <ColumnDefinition Width="auto"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<WrapPanel Grid.Column="0"> <WrapPanel Grid.Column="0">
<TextBlock Text="{Binding Tournamentname}" <TextBlock Text="{Binding TournamentName}"
Margin="0 0 4 0"/> Margin="0 0 4 0"/>
<TextBlock Text="{Binding Location}"/> <TextBlock Text="{Binding Location}"/>
</WrapPanel> </WrapPanel>

View File

@@ -34,7 +34,7 @@
</TextBlock> </TextBlock>
<StackPanel> <StackPanel>
<TextBlock Text="{Binding Tournamentname}" <TextBlock Text="{Binding TournamentName}"
TextAlignment="Center" TextAlignment="Center"
FontFamily="Arial" FontFamily="Arial"
FontWeight="Bold" FontWeight="Bold"
@@ -109,26 +109,8 @@
</Image> </Image>
</WrapPanel> </WrapPanel>
<WrapPanel Margin="10" HorizontalAlignment="Center"> <WrapPanel Margin="10" HorizontalAlignment="Center">
<TextBlock Text="vom " <TextBlock Text="{Binding StartDate}"
TextAlignment="Center"
FontFamily="Arial"
FontWeight="Bold"
FontSize="14"
Foreground="#0000a0">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Visibility" Value="Hidden"/>
<Style.Triggers>
<DataTrigger Binding="{Binding HasSelectedTournament}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<TextBlock Text="{Binding Startdate}"
TextAlignment="Center" TextAlignment="Center"
FontFamily="Arial" FontFamily="Arial"
FontWeight="Bold" FontWeight="Bold"
@@ -163,7 +145,7 @@
</Style> </Style>
</TextBlock.Style> </TextBlock.Style>
</TextBlock> </TextBlock>
<TextBlock Text="{Binding Enddate}" <TextBlock Text="{Binding EndDate}"
TextAlignment="Center" TextAlignment="Center"
FontFamily="Arial" FontFamily="Arial"
FontWeight="Bold" FontWeight="Bold"