You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.5 KiB
96 lines
3.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TheGameExtreme.model;
|
|
using TheGameExtreme.model.manager;
|
|
using Xamarin.Forms;
|
|
using Xamarin.Forms.Xaml;
|
|
using TheGameExtreme.model.@event;
|
|
using TheGameExtreme.viewmodel;
|
|
|
|
namespace TheGameExtreme
|
|
{
|
|
// Learn more about making custom code visible in the Xamarin.Forms previewer
|
|
// by visiting https://aka.ms/xamarinforms-previewer
|
|
[DesignTimeVisible(false)]
|
|
public partial class MainPage : ContentPage
|
|
{
|
|
|
|
private Main viewmodel;
|
|
|
|
public MainPage()
|
|
{
|
|
InitializeComponent();
|
|
|
|
viewmodel = new Main(Alert);
|
|
|
|
viewmodel.BindingChanged += OnBindingChanged;
|
|
|
|
//pile0.SetBinding(Label.TextProperty, new Binding("Stack0", source: viewmodel));
|
|
//pile1.SetBinding(Label.TextProperty, new Binding("Stack1", source: viewmodel));
|
|
//pile2.SetBinding(Label.TextProperty, new Binding("Stack2", source: viewmodel));
|
|
//pile3.SetBinding(Label.TextProperty, new Binding("Stack3", source: viewmodel));
|
|
//card1.SetBinding(Button.TextProperty, new Binding("ValueCard1", source: viewmodel));
|
|
//card2.SetBinding(Button.TextProperty, new Binding("ValueCard2", source: viewmodel));
|
|
//card3.SetBinding(Button.TextProperty, new Binding("ValueCard3", source: viewmodel));
|
|
//card4.SetBinding(Button.TextProperty, new Binding("ValueCard4", source: viewmodel));
|
|
//card5.SetBinding(Button.TextProperty, new Binding("ValueCard5", source: viewmodel));
|
|
//card6.SetBinding(Button.TextProperty, new Binding("ValueCard6", source: viewmodel));
|
|
//card7.SetBinding(Button.TextProperty, new Binding("ValueCard7", source: viewmodel));
|
|
}
|
|
|
|
private void OnBindingChanged(object sender, TopRangeChangedEventArgs args)
|
|
{
|
|
switch (args.NumStackChanged)
|
|
{
|
|
case 0:
|
|
pile0.SetBinding(Label.TextProperty, new Binding("ListOrderedStacks[0].Peek().Value", source: viewmodel));
|
|
break;
|
|
case 1:
|
|
pile1.SetBinding(Label.TextProperty, new Binding("ListOrderedStacks[1].Peek().Value", source: viewmodel));
|
|
break;
|
|
case 2:
|
|
pile2.SetBinding(Label.TextProperty, new Binding("ListOrderedStacks[2].Peek().Value", source: viewmodel));
|
|
break;
|
|
case 3:
|
|
pile3.SetBinding(Label.TextProperty, new Binding("ListOrderedStacks[3].Peek().Value", source: viewmodel));
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void played(object sender, EventArgs args)
|
|
{
|
|
int numStack;
|
|
if (checkbox0.IsChecked)
|
|
{
|
|
numStack = 0;
|
|
}
|
|
else if (checkbox1.IsChecked)
|
|
{
|
|
numStack = 1;
|
|
}
|
|
else if (checkbox2.IsChecked)
|
|
{
|
|
numStack = 2;
|
|
}
|
|
else if (checkbox3.IsChecked)
|
|
{
|
|
numStack = 3;
|
|
}
|
|
else
|
|
{
|
|
throw new Exception();
|
|
}
|
|
viewmodel.played(numStack, Convert.ToInt32((sender as Button).Text));
|
|
}
|
|
|
|
private void endTurn(object sender, EventArgs args)
|
|
{
|
|
viewmodel.endTurn();
|
|
}
|
|
}
|
|
}
|