test_old_branch
Jérémy Mouyon 11 months ago
parent c446099974
commit 71e4f856f6

@ -0,0 +1,33 @@
using System;
using System.Globalization;
namespace Qwirkle.Converters
{
public class Int2ColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is not string) return Colors.Transparent;
string colorstring = (string)value;
if(string.IsNullOrWhiteSpace(colorstring)) return Colors.Transparent;
if (colorstring == "Yellow") return Colors.Yellow;
if (colorstring == "Red") return Colors.Red;
if (colorstring == "Blue") return Colors.Blue;
if (colorstring == "Green") return Colors.Green;
if (colorstring == "Orange") return Colors.Orange;
if (colorstring == "Purple") return Colors.Purple;
if (colorstring == "Transparent") return Colors.Transparent;
return Colors.Plum;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

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

@ -54,6 +54,7 @@ public partial class SetPlayers : ContentPage
game.GiveTilesToPlayers();
game.SetNextPlayer();
Navigation.PushAsync(new Gameboard());
}
game.PlayerAddNotified -= Game_PlayerAddNotified;

@ -19,6 +19,12 @@
<Color x:Key="MidnightBlue">#190649</Color>
<Color x:Key="OffBlack">#1f1f1f</Color>
<Color x:Key="Blue">Blue</Color>
<Color x:Key="Green">Green</Color>
<Color x:Key="Yellow">Yellow</Color>
<Color x:Key="Orange">Orange</Color>
<Color x:Key="Purple">Purple</Color>
<Color x:Key="Gray100">#E1E1E1</Color>
<Color x:Key="Gray200">#C8C8C8</Color>
<Color x:Key="Gray300">#ACACAC</Color>

@ -3,20 +3,27 @@
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Qwirkle.Views.TileCircle"
xmlns:conv="clr-namespace:Qwirkle.Converters"
x:Name="root">
<ContentView.Resources>
<conv:Int2ColorConverter x:Key="int2ColorConverter"/>
</ContentView.Resources>
<Grid>
<Label Text="{Binding Shape, Source={x:Reference root}}"></Label>
<Rectangle HeightRequest="70"
Grid.Row="0"
Grid.Column="0"
WidthRequest="70"
VerticalOptions="Center"
HorizontalOptions="Center"
BackgroundColor="{Binding BC, Source={x:Reference root}}"/>
BackgroundColor="Transparent"/>
<Ellipse HeightRequest="50"
WidthRequest="50"
BackgroundColor="{Binding Color, Source={x:Reference root}}"
BackgroundColor="{Binding ColorPush, Source={x:Reference root}, Converter={StaticResource int2ColorConverter}}"
VerticalOptions="Center"
HorizontalOptions="Center"/>
<Label Text="{Binding ColorPush, Source={x:Reference root}}"></Label>
</Grid>
</ContentView>

@ -9,40 +9,51 @@ using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles;
using QwirkleClassLibrary.Events;
using QwirkleClassLibrary.Boards;
using System.Globalization;
namespace Qwirkle.Views;
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()
{
InitializeComponent();
((App)Application.Current!).Game.Board.PropertyChanged += Board_PropertyChanged;
ColorPush = "Transparent";
}
private void Board_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (TileInfo == null)
Console.WriteLine(Shape);
if (Shape == "Round")
{
return;
ColorPush = Color;
}
Shape = TileInfo.GetShape.ToString();
if (Shape != "Round")
else
{
return;
ColorPush = "Transparent";
}
}
Color = TileInfo.GetColor.ToString();
BC = "Grey300";
public static readonly BindableProperty ColorProperty =
BindableProperty.Create("Color", typeof(string), typeof(TileCircle), "");
public string Color
{
get => (string)GetValue(ColorProperty);
set => SetValue(ColorProperty, value);
}
public string BC { get; set; } = "Transparent";
public string Color { get; set; } = "Transparent";
public string Shape { get; set; } = "None";
public static readonly BindableProperty ShapeProperty =
BindableProperty.Create("Shape", typeof(string), typeof(TileCircle), "");
public string Shape
{
get => (string)GetValue(ShapeProperty);
set => SetValue(ShapeProperty, value);
}
public string? ColorPush { get; set; }
}
Loading…
Cancel
Save