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>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>disable</Nullable>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>

View File

@@ -32,7 +32,7 @@ namespace Apollon.WPF.Commands
public override async Task ExecuteAsync(object parameter)
{
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);
try

View File

@@ -8,22 +8,22 @@ namespace Apollon.WPF.Models
{
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;
Tournamentname = tournamentname;
TournamentName = tournamentName;
Competition = competition;
Startdate = startdate;
Enddate = enddate;
StartDate = startDate;
EndDate = endDate;
Location = location;
Rounds = rounds;
}
public string Organisation { get; }
public string Tournamentname { get; }
public string TournamentName { get; }
public string Competition { get; }
public string Startdate { get; }
public string Enddate { get; }
public DateTime StartDate { get; }
public DateTime EndDate { get; }
public string Location { get; }
public int Rounds { get; }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -34,7 +34,7 @@
</TextBlock>
<StackPanel>
<TextBlock Text="{Binding Tournamentname}"
<TextBlock Text="{Binding TournamentName}"
TextAlignment="Center"
FontFamily="Arial"
FontWeight="Bold"
@@ -109,26 +109,8 @@
</Image>
</WrapPanel>
<WrapPanel Margin="10" HorizontalAlignment="Center">
<TextBlock Text="vom "
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}"
<WrapPanel Margin="10" HorizontalAlignment="Center">
<TextBlock Text="{Binding StartDate}"
TextAlignment="Center"
FontFamily="Arial"
FontWeight="Bold"
@@ -163,7 +145,7 @@
</Style>
</TextBlock.Style>
</TextBlock>
<TextBlock Text="{Binding Enddate}"
<TextBlock Text="{Binding EndDate}"
TextAlignment="Center"
FontFamily="Arial"
FontWeight="Bold"