1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 06:56:10 +00:00
This commit is contained in:
Yan Maniez 2019-05-08 17:53:02 +02:00
parent d3b81c32c5
commit 4c63fce22f
3 changed files with 86 additions and 9 deletions

View file

@ -14,6 +14,26 @@ namespace AideDeJeu.ViewModels
_Random = new Random(Environment.TickCount);
}
private int _Quantity = 3;
public int Quantity
{
get
{
return _Quantity;
}
set
{
SetProperty(ref _Quantity, value);
}
}
public int _Type = 6;
public int Type { get { return _Type; } set { SetProperty(ref _Type, value); } }
public int _Mod = 0;
public int Mod { get { return _Mod; } set { SetProperty(ref _Mod, value); } }
public List<int> RollMRick()
{
var dices = new List<int>();

View file

@ -6,17 +6,65 @@
x:Class="AideDeJeu.Views.DicesPage">
<ContentPage.Content>
<StackLayout>
<!--<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />-->
<StackLayout Orientation="Horizontal">
<Picker SelectedItem="{Binding BindingContext.Quantity, Mode=TwoWay}">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:Int32}">
<x:Int32>6</x:Int32>
<x:Int32>5</x:Int32>
<x:Int32>4</x:Int32>
<x:Int32>3</x:Int32>
<x:Int32>2</x:Int32>
<x:Int32>1</x:Int32>
</x:Array>
</Picker.ItemsSource>
</Picker>
<Picker ItemDisplayBinding="{Binding StringFormat='d{0}'}" SelectedItem="{Binding BindingContext.Type, Mode=TwoWay}">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:Int32}">
<x:Int32>20</x:Int32>
<x:Int32>12</x:Int32>
<x:Int32>10</x:Int32>
<x:Int32>8</x:Int32>
<x:Int32>6</x:Int32>
<x:Int32>4</x:Int32>
</x:Array>
</Picker.ItemsSource>
</Picker>
<Picker ItemDisplayBinding="{Binding StringFormat='{}{0:+0;-#}'}" SelectedItem="{Binding BindingContext.Mod, Mode=TwoWay}">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:Int32}">
<x:Int32>10</x:Int32>
<x:Int32>9</x:Int32>
<x:Int32>8</x:Int32>
<x:Int32>7</x:Int32>
<x:Int32>6</x:Int32>
<x:Int32>5</x:Int32>
<x:Int32>4</x:Int32>
<x:Int32>3</x:Int32>
<x:Int32>2</x:Int32>
<x:Int32>1</x:Int32>
<x:Int32>0</x:Int32>
<x:Int32>-1</x:Int32>
<x:Int32>-2</x:Int32>
<x:Int32>-3</x:Int32>
<x:Int32>-4</x:Int32>
<x:Int32>-5</x:Int32>
<x:Int32>-6</x:Int32>
<x:Int32>-7</x:Int32>
<x:Int32>-8</x:Int32>
<x:Int32>-9</x:Int32>
<x:Int32>-10</x:Int32>
</x:Array>
</Picker.ItemsSource>
</Picker>
<!--<pickers:StringPickerView BindingContext="{Binding}" Title="{Binding PreferedBackgroundSpecialties.Name}" Description="{Binding PreferedBackgroundSpecialties.Description}" ItemsSource="{Binding PreferedBackgroundSpecialties.BindableTable}" SelectedItem="{Binding BackgroundSpecialty, Mode=TwoWay}" />
<pickers:StringPickerView BindingContext="{Binding}" Title="{Binding PreferedBackgroundSpecialties.Name}" Description="{Binding PreferedBackgroundSpecialties.Description}" ItemsSource="{Binding PreferedBackgroundSpecialties.BindableTable}" SelectedItem="{Binding BackgroundSpecialty, Mode=TwoWay}" />
<pickers:StringPickerView BindingContext="{Binding}" Title="{Binding PreferedBackgroundSpecialties.Name}" Description="{Binding PreferedBackgroundSpecialties.Description}" ItemsSource="{Binding PreferedBackgroundSpecialties.BindableTable}" SelectedItem="{Binding BackgroundSpecialty, Mode=TwoWay}" />
<pickers:StringPickerView BindingContext="{Binding}" Title="{Binding PreferedBackgroundSpecialties.Name}" Description="{Binding PreferedBackgroundSpecialties.Description}" ItemsSource="{Binding PreferedBackgroundSpecialties.BindableTable}" SelectedItem="{Binding BackgroundSpecialty, Mode=TwoWay}" />
<pickers:StringPickerView BindingContext="{Binding}" Title="{Binding PreferedBackgroundSpecialties.Name}" Description="{Binding PreferedBackgroundSpecialties.Description}" ItemsSource="{Binding PreferedBackgroundSpecialties.BindableTable}" SelectedItem="{Binding BackgroundSpecialty, Mode=TwoWay}" />-->
</StackLayout>
<skviews:SKCanvasView Margin="15" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" PaintSurface="SKCanvasView_PaintSurface">
<skviews:SKCanvasView x:Name="CanvasDices" Margin="15" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" PaintSurface="SKCanvasView_PaintSurface">
</skviews:SKCanvasView>
</StackLayout>
</ContentPage.Content>

View file

@ -18,15 +18,24 @@ namespace AideDeJeu.Views
public DicesPage()
{
InitializeComponent();
var vm = new DiceRollerViewModel();
vm.PropertyChanged += Vm_PropertyChanged;
BindingContext = vm;
}
private void Vm_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
CanvasDices.InvalidateSurface();
}
private void SKCanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs args)
{
var vm = BindingContext as DiceRollerViewModel;
var diceRoller = new DiceRollerViewModel();
var diceRolls = diceRoller.DicesValues(6, 3);
var diceRolls = diceRoller.DicesValues(vm.Type, vm.Quantity);
foreach (var diceRoll in diceRolls)
{
Debug.WriteLine($"{diceRoll.Key} => {diceRoll.Value / 3}");
Debug.WriteLine($"{diceRoll.Key} => {diceRoll.Value / vm.Quantity}");
}