Skip to content

Commit

Permalink
Fix Bugs that occure in ComboBox and enhance betting.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanDeveloper committed Jun 22, 2017
1 parent 1a67fff commit 2d8f33f
Show file tree
Hide file tree
Showing 36 changed files with 266 additions and 867 deletions.
14 changes: 8 additions & 6 deletions LigaManagerAdminClient/Controllers/AddMatchWindowController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ public Match ShowMatch()
_viewModel = new AddMatchWindowViewModel
{
SelectedMatch = Match,
DateTime = Match.DateTime,
SelectedAwayTeam = Match.AwayTeam,
SelectedHomeTeam = Match.HomeTeam,
Minute = Match.DateTime.Minute,
Hour = Match.DateTime.Hour,
HomeTeams = HomeTeams,
AwayTeams = AwayTeams,
OkCommand = new RelayCommand(ExecuteOkCommand),
CancelCommand = new RelayCommand(ExecuteCancelCommand)

};
_view.TimeControl.DateTimeValue = Match.DateTime;
_view.DataContext = _viewModel;
#endregion

Expand All @@ -44,17 +44,19 @@ public Match ShowMatch()
public void ExecuteOkCommand(object obj)
{
if (_view.AwayTeamComboBox.SelectedValue == null ||
_view.HomeTeamComboBox.SelectedValue == null)
_view.HomeTeamComboBox.SelectedValue == null ||
_view.HourTextBox.Text == string.Empty ||
_view.MinuteTextBox.Text == string.Empty ||
_view.HomeTeamScore.Text == string.Empty ||
_view.AwayTeamScore.Text == string.Empty)
{
MessageBox.Show("Spiel konnte nicht hinzugefügt werden, da die Angaben nicht korrekt ausgefüllt sind!", "Hinzufügen fehlgeschlagen",
MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
Match.AwayTeam = _viewModel.SelectedAwayTeam;
Match.HomeTeam = _viewModel.SelectedHomeTeam;
Match.DateTime = new DateTime(year: _viewModel.DateTime.Year, month: _viewModel.DateTime.Month, day: _viewModel.DateTime.Day
, hour: _view.TimeControl.DateTimeValue.Value.Hour, minute: _view.TimeControl.DateTimeValue.Value.Minute, second: _view.TimeControl.DateTimeValue.Value.Second);

Match.DateTime = new DateTime(Match.DateTime.Year, Match.DateTime.Month, Match.DateTime.Day, _viewModel.Hour, _viewModel.Minute, 0);
_view.DialogResult = true;
_view.Close();
}
Expand Down
12 changes: 9 additions & 3 deletions LigaManagerAdminClient/Controllers/MatchesWindowController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using System.Windows;
using LigaManagerAdminClient.AdminClientService;
using LigaManagerAdminClient.Framework;
Expand Down Expand Up @@ -50,9 +51,14 @@ protected override async void ExecuteAddCommand(object obj)
var teams = await _adminClient.GetAllTeamsAsync();
var addBettorWindow = new AddMatchWindowController
{
Match = new Match(),
Match = new Match
{
Season = _viewModel.SelectedSeason,
DateTime = DateTime.Now
},
AwayTeams = teams.ToList(),
HomeTeams = teams.ToList()
HomeTeams = teams.ToList(),

};

var showMatch = addBettorWindow.ShowMatch();
Expand Down
7 changes: 0 additions & 7 deletions LigaManagerAdminClient/LigaManagerAdminClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@
<Compile Include="Views\TeamWindow.xaml.cs">
<DependentUpon>TeamWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\TimeControl.xaml.cs">
<DependentUpon>TimeControl.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Connected Services\AdminClientService\Reference.cs">
Expand Down Expand Up @@ -267,10 +264,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\TimeControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="FodyWeavers.xml" />
Expand Down
3 changes: 2 additions & 1 deletion LigaManagerAdminClient/ViewModels/AddMatchWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace LigaManagerAdminClient.ViewModels
public class AddMatchWindowViewModel : ViewModelBase
{
public Match SelectedMatch { get; set; }
public DateTime DateTime { get; set; }
public int Hour { get; set; }
public int Minute { get; set; }
public List<Team> AwayTeams { get; set; }
public Team SelectedAwayTeam { get; set; }
public List<Team> HomeTeams { get; set; }
Expand Down
20 changes: 12 additions & 8 deletions LigaManagerAdminClient/Views/AddMatchWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:LigaManagerAdminClient.Views"
mc:Ignorable="d" Name="MatchWindow"
Title="Spiel hinzufügen" Height="600" Width="500">
<Grid>
Expand All @@ -18,9 +17,9 @@
<RowDefinition Height="18*"/>
<RowDefinition Height="5*"/>
</Grid.RowDefinitions>
<Calendar x:Name="MatchDateCalendar" SelectedDate="{Binding DateTime}" DisplayDate="{Binding DateTime}" HorizontalAlignment="Left" Grid.Row="3" VerticalAlignment="Top" Grid.Column="1" Height="165" Width="220" Margin="0,43,0,0"/>
<ComboBox x:Name="HomeTeamComboBox" ItemsSource="{Binding HomeTeams}" SelectedValue="{Binding SelectedHomeTeam.Name}" DisplayMemberPath="Name" SelectedValuePath="Name" HorizontalAlignment="Left" Margin="10,35,0,0" Grid.Row="1" Grid.Column="0" VerticalAlignment="Top" Width="226" />
<ComboBox x:Name="AwayTeamComboBox" ItemsSource="{Binding AwayTeams}" SelectedValue="{Binding SelectedAwayTeam.Name}" DisplayMemberPath="Name" SelectedValuePath="Name" HorizontalAlignment="Left" Margin="10,35,0,0" Grid.Row="1" VerticalAlignment="Top" Width="220" Grid.Column="1"/>
<Calendar x:Name="MatchDateCalendar" SelectedDate="{Binding SelectedMatch.DateTime}" DisplayDate="{Binding SelectedMatch.DateTime}" HorizontalAlignment="Left" Grid.Row="3" VerticalAlignment="Top" Grid.Column="1" Height="165" Width="220" Margin="0,43,0,0"/>
<ComboBox x:Name="HomeTeamComboBox" ItemsSource="{Binding HomeTeams}" SelectedValue="{Binding SelectedHomeTeam.Name}" SelectedItem="{Binding SelectedHomeTeam}" SelectedValuePath="Name" DisplayMemberPath="Name" HorizontalAlignment="Left" Margin="10,35,0,0" Grid.Row="1" Grid.Column="0" VerticalAlignment="Top" Width="226" />
<ComboBox x:Name="AwayTeamComboBox" ItemsSource="{Binding AwayTeams}" SelectedValue="{Binding SelectedAwayTeam.Name}" SelectedItem="{Binding SelectedAwayTeam}" SelectedValuePath="Name" DisplayMemberPath="Name" HorizontalAlignment="Left" Margin="10,35,0,0" Grid.Row="1" VerticalAlignment="Top" Width="220" Grid.Column="1"/>
<Label Content="Heimschaft" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Grid.Row="1"
Grid.Column="0" Width="220"/>
<Label Content="Auswärtsmannschaft" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" Grid.Row="1" Width="220" Grid.Column="1"/>
Expand All @@ -30,10 +29,15 @@
Grid.Column="1" Width="220" Margin="10,10,0,0"/>
<Label Content="Uhrzeit" HorizontalAlignment="Left" HorizontalContentAlignment="Center" Margin="10,10,0,0" VerticalAlignment="Top" Grid.Row="3"
Grid.Column="0" Width="220"/>
<views:TimeControl x:Name="TimeControl" Grid.Row="3" Grid.Column="0" Margin="50,65,50,65" DateTimeValue="{Binding SelectedMatch.DateTime}"/>
<TextBox x:Name="AwayTeamScore" HorizontalContentAlignment="Center" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="50,30,0,0" Grid.Row="2" TextWrapping="Wrap" Text="{Binding SelectedMatch.AwayTeamScore}" VerticalAlignment="Top" Width="120" ToolTip="Spieltip"/>
<TextBox x:Name="HomeTeamScore" HorizontalContentAlignment="Center" TextChanged="OnTextChanged" HorizontalAlignment="Left" Height="23" Margin="50,30,0,0" Grid.Row="2"
Grid.Column="0" TextWrapping="Wrap" Text="{Binding SelectedMatch.HomeTeamScore}" VerticalAlignment="Top" Width="120" ToolTip="Spieltip"/>

<TextBox x:Name="AwayTeamScore" MaxLength="3" HorizontalContentAlignment="Center" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="50,30,0,0" Grid.Row="2" TextWrapping="Wrap" Text="{Binding SelectedMatch.AwayTeamScore}" VerticalAlignment="Top" Width="120" ToolTip="Spieltip" UndoLimit="3"/>
<TextBox x:Name="HomeTeamScore" MaxLength="3" HorizontalContentAlignment="Center" TextChanged="OnTextChanged" HorizontalAlignment="Left" Height="23" Margin="50,30,0,0" Grid.Row="2"
Grid.Column="0" TextWrapping="Wrap" Text="{Binding SelectedMatch.HomeTeamScore}" VerticalAlignment="Top" Width="120" ToolTip="Spieltip" UndoLimit="3"/>
<TextBox x:Name="MinuteTextBox" MaxLength="2" TextChanged="OnMinuteChanged" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Height="23" Margin="128,99,0,0" Grid.Row="3"
Grid.Column="0" TextWrapping="Wrap" Text="{Binding Minute}" VerticalAlignment="Top" Width="55" UndoLimit="2"/>
<TextBox x:Name="HourTextBox" MaxLength="2" TextChanged="OnHourChanged" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Height="23" Margin="60,99,0,0" Grid.Row="3"
Grid.Column="0" TextWrapping="Wrap" Text="{Binding Hour}" VerticalAlignment="Top" Width="55" UndoLimit="2"/>
<TextBlock HorizontalAlignment="Left" Margin="120,102,0,0" Grid.Row="3" Grid.Column="0" TextWrapping="Wrap" Text=":" VerticalAlignment="Top"/>

</Grid>
</Window>
34 changes: 32 additions & 2 deletions LigaManagerAdminClient/Views/AddMatchWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -27,11 +28,40 @@ public AddMatchWindow()
private void OnTextChanged(object sender, TextChangedEventArgs e)
{
var textBox = (TextBox)sender;
if (System.Text.RegularExpressions.Regex.IsMatch(textBox.Text, "[^0-9]"))
if (Regex.IsMatch(textBox.Text, "[^0-9]"))
{
MessageBox.Show("Please enter only numbers.");
textBox.Text = textBox.Text.Remove(textBox.Text.Length - 1);
}
if (textBox.Text != string.Empty && int.Parse(textBox.Text) > 24)
{
textBox.Text = "24";
}
}

private void OnHourChanged(object sender, TextChangedEventArgs e)
{
var textBox = (TextBox)sender;
if (Regex.IsMatch(textBox.Text, "[^0-9]"))
{
textBox.Text = textBox.Text.Remove(textBox.Text.Length - 1);
}
if (textBox.Text != string.Empty && int.Parse(textBox.Text) > 24)
{
textBox.Text = "24";
}
}

private void OnMinuteChanged(object sender, TextChangedEventArgs e)
{
var textBox = (TextBox)sender;
if (Regex.IsMatch(textBox.Text, "[^0-9]"))
{
textBox.Text = textBox.Text.Remove(textBox.Text.Length - 1);
}
if (textBox.Text != string.Empty && int.Parse(textBox.Text) > 60)
{
textBox.Text = "60";
}
}
}
}
2 changes: 1 addition & 1 deletion LigaManagerAdminClient/Views/MatchesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
<Button Command="{Binding DeleteCommand}" Content="Löschen" HorizontalAlignment="Left" Margin="20,15,0,10" VerticalAlignment="Top" Width="80" Grid.Column="3"/>
</Grid>
<Label Grid.Row="0" Content="Saison" FontWeight="Bold" HorizontalAlignment="Left" Margin="485,60,0,0" VerticalAlignment="Top" Width="50"/>
<ComboBox Grid.Row="0" ItemsSource="{Binding Seasons}" SelectedValue="{Binding SelectedSeason.Name}" DisplayMemberPath="Name" SelectedValuePath="Name" HorizontalAlignment="Left" Margin="540,60,0,0" VerticalAlignment="Top" Width="250" Height="26" />
<ComboBox Grid.Row="0" ItemsSource="{Binding Seasons}" SelectedValue="{Binding SelectedSeason.Name}" SelectedItem="{Binding SelectedSeason}" DisplayMemberPath="Name" SelectedValuePath="Name" HorizontalAlignment="Left" Margin="540,60,0,0" VerticalAlignment="Top" Width="250" Height="26" />
</Grid>
</Page>
33 changes: 0 additions & 33 deletions LigaManagerAdminClient/Views/TimeControl.xaml

This file was deleted.

Loading

0 comments on commit 2d8f33f

Please sign in to comment.