test_old_branch
Jérémy Mouyon 11 months ago
parent 87911f1ee0
commit 53559292bb

@ -26,7 +26,7 @@
DropCommand="{Binding OnDrop, Source={x:Reference root}}" DropCommand="{Binding OnDrop, Source={x:Reference root}}"
DropCommandParameter="{Binding .}" /> DropCommandParameter="{Binding .}" />
</Border.GestureRecognizers> </Border.GestureRecognizers>
<Label Text="{Binding Tile}" /> <controls:TileCircle TileInfo="{Binding Tile}"></controls:TileCircle>
</Border> </Border>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>

@ -2,18 +2,20 @@
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Qwirkle.Views.TileCircle"> x:Class="Qwirkle.Views.TileCircle"
x:Name="root">
<Grid> <Grid>
<Rectangle HeightRequest="600" <Label Text="{Binding Shape, Source={x:Reference root}}"></Label>
<Rectangle HeightRequest="70"
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
WidthRequest="600" WidthRequest="70"
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Center" HorizontalOptions="Center"
BackgroundColor="{StaticResource Gray800}"/> BackgroundColor="{Binding BC, Source={x:Reference root}}"/>
<Ellipse HeightRequest="400" <Ellipse HeightRequest="50"
WidthRequest="400" WidthRequest="50"
BackgroundColor="Red" BackgroundColor="{Binding Color, Source={x:Reference root}}"
VerticalOptions="Center" VerticalOptions="Center"
HorizontalOptions="Center"/> HorizontalOptions="Center"/>
</Grid> </Grid>

@ -3,13 +3,46 @@ 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 Microsoft.Maui.Controls;
using QwirkleClassLibrary.Games;
using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles;
using QwirkleClassLibrary.Events;
using QwirkleClassLibrary.Boards;
namespace Qwirkle.Views; namespace Qwirkle.Views;
public partial class TileCircle : ContentView public partial class TileCircle : ContentView
{ {
public static readonly BindableProperty TileInfoProperty = BindableProperty.Create(nameof(TileInfo), typeof(Tile), typeof(TileCircle), default(Tile));
public Tile TileInfo
{
get => (Tile)GetValue(TileInfoProperty);
set => SetValue(TileInfoProperty, value);
}
public TileCircle() public TileCircle()
{ {
InitializeComponent(); InitializeComponent();
((App)Application.Current!).Game.Board.PropertyChanged += Board_PropertyChanged;
}
private void Board_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (TileInfo == null)
{
return;
}
Shape = TileInfo.GetShape.ToString();
if (Shape != "Round")
{
return;
}
Color = TileInfo.GetColor.ToString();
BC = "Grey300";
} }
public string BC { get; set; } = "Transparent";
public string Color { get; set; } = "Transparent";
public string Shape { get; set; } = "None";
} }
Loading…
Cancel
Save