|
|
|
@ -25,9 +25,10 @@ namespace TheGameExtreme.view
|
|
|
|
|
List<string> playersNames;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TouchManipulationBitmap bitmap;
|
|
|
|
|
List<TouchManipulationBitmap> bitmapCollection = new List<TouchManipulationBitmap>();
|
|
|
|
|
Dictionary<long, TouchManipulationBitmap> bitmapDictionary = new Dictionary<long, TouchManipulationBitmap>();
|
|
|
|
|
TouchManipulationBitmap textPaint;
|
|
|
|
|
List<TouchManipulationBitmap> textCollection = new List<TouchManipulationBitmap>();
|
|
|
|
|
List<TouchManipulationBitmap> stackCollection = new List<TouchManipulationBitmap>();
|
|
|
|
|
Dictionary<long, TouchManipulationBitmap> textDictionary = new Dictionary<long, TouchManipulationBitmap>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -38,32 +39,8 @@ namespace TheGameExtreme.view
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
NavigationPage.SetHasNavigationBar(this, false);
|
|
|
|
|
|
|
|
|
|
//Assembly assembly = GetType().GetTypeInfo().Assembly;
|
|
|
|
|
InflateStack();
|
|
|
|
|
|
|
|
|
|
////string[] resourceIDs = assembly.GetManifestResourceNames();
|
|
|
|
|
//string resourceID = "TheGameExtreme.Media.thegame.jpg";
|
|
|
|
|
|
|
|
|
|
//SKPoint position = new SKPoint(100, (float)(DeviceDisplay.MainDisplayInfo.Height - 0.2 * DeviceDisplay.MainDisplayInfo.Height));
|
|
|
|
|
|
|
|
|
|
//for (int i = 0; i < 8; i++)
|
|
|
|
|
//{
|
|
|
|
|
// using (Stream stream = assembly.GetManifestResourceStream(resourceID))
|
|
|
|
|
// {
|
|
|
|
|
// SKBitmap bitmap = SKBitmap.Decode(stream).Resize(new SKImageInfo(225, 225), SKFilterQuality.High);
|
|
|
|
|
|
|
|
|
|
// bitmapCollection.Add(new TouchManipulationBitmap(bitmap)
|
|
|
|
|
// {
|
|
|
|
|
// Matrix = SKMatrix.MakeTranslation(position.X, position.Y - bitmap.Height),
|
|
|
|
|
// });
|
|
|
|
|
// position.X += bitmap.Width + 50;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//stacks.Add(checkbox0);
|
|
|
|
|
//stacks.Add(checkbox1);
|
|
|
|
|
//stacks.Add(checkbox2);
|
|
|
|
|
//stacks.Add(checkbox3);
|
|
|
|
|
//button.Text = "Retry";
|
|
|
|
|
//button.Clicked += retry;
|
|
|
|
|
|
|
|
|
@ -71,8 +48,6 @@ namespace TheGameExtreme.view
|
|
|
|
|
|
|
|
|
|
//viewmodel.BindingChanged += OnBindingChanged;
|
|
|
|
|
|
|
|
|
|
//viewmodel.PlayerChanged += OnPlayerChanged;
|
|
|
|
|
|
|
|
|
|
viewmodel.AlertChanged += OnAlertChanged;
|
|
|
|
|
|
|
|
|
|
pseudo.SetBinding(Label.TextProperty, new Binding("Pseudo", source: viewmodel));
|
|
|
|
@ -92,17 +67,20 @@ namespace TheGameExtreme.view
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args) // Faire plusieurs canvas
|
|
|
|
|
public void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
SKCanvas canvas = args.Surface.Canvas;
|
|
|
|
|
canvas.Clear();
|
|
|
|
|
|
|
|
|
|
foreach (TouchManipulationBitmap bitmap in bitmapCollection)
|
|
|
|
|
foreach (TouchManipulationBitmap textPaint in stackCollection)
|
|
|
|
|
{
|
|
|
|
|
bitmap.Paint(canvas);
|
|
|
|
|
|
|
|
|
|
textPaint.Paint(canvas);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (TouchManipulationBitmap textPaint in textCollection)
|
|
|
|
|
{
|
|
|
|
|
textPaint.Paint(canvas);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -117,19 +95,19 @@ namespace TheGameExtreme.view
|
|
|
|
|
switch (args.Type)
|
|
|
|
|
{
|
|
|
|
|
case TouchActionType.Pressed:
|
|
|
|
|
for (int i = bitmapCollection.Count - 1; i >= 0; i--)
|
|
|
|
|
for (int i = textCollection.Count - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
TouchManipulationBitmap bitmap = bitmapCollection[i];
|
|
|
|
|
TouchManipulationBitmap textPaint = textCollection[i];
|
|
|
|
|
|
|
|
|
|
if (bitmap.HitTest(point))
|
|
|
|
|
if (textPaint.HitTest(point))
|
|
|
|
|
{
|
|
|
|
|
// Move bitmap to end of collection
|
|
|
|
|
bitmapCollection.Remove(bitmap);
|
|
|
|
|
bitmapCollection.Add(bitmap);
|
|
|
|
|
textCollection.Remove(textPaint);
|
|
|
|
|
textCollection.Add(textPaint);
|
|
|
|
|
|
|
|
|
|
// Do the touch processing
|
|
|
|
|
bitmapDictionary.Add(args.Id, bitmap);
|
|
|
|
|
bitmap.ProcessTouchEvent(args.Id, args.Type, point);
|
|
|
|
|
textDictionary.Add(args.Id, textPaint);
|
|
|
|
|
textPaint.ProcessTouchEvent(args.Id, args.Type, point, stackCollection);
|
|
|
|
|
canvasView.InvalidateSurface();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -137,82 +115,78 @@ namespace TheGameExtreme.view
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TouchActionType.Moved:
|
|
|
|
|
if (bitmapDictionary.ContainsKey(args.Id))
|
|
|
|
|
if (textDictionary.ContainsKey(args.Id))
|
|
|
|
|
{
|
|
|
|
|
TouchManipulationBitmap bitmap = bitmapDictionary[args.Id];
|
|
|
|
|
bitmap.ProcessTouchEvent(args.Id, args.Type, point);
|
|
|
|
|
TouchManipulationBitmap bitmap = textDictionary[args.Id];
|
|
|
|
|
bitmap.ProcessTouchEvent(args.Id, args.Type, point, stackCollection);
|
|
|
|
|
canvasView.InvalidateSurface();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TouchActionType.Released:
|
|
|
|
|
case TouchActionType.Cancelled:
|
|
|
|
|
if (bitmapDictionary.ContainsKey(args.Id))
|
|
|
|
|
if (textDictionary.ContainsKey(args.Id))
|
|
|
|
|
{
|
|
|
|
|
TouchManipulationBitmap bitmap = bitmapDictionary[args.Id];
|
|
|
|
|
bitmap.ProcessTouchEvent(args.Id, args.Type, point);
|
|
|
|
|
bitmapDictionary.Remove(args.Id);
|
|
|
|
|
TouchManipulationBitmap bitmap = textDictionary[args.Id];
|
|
|
|
|
bitmap.ProcessTouchEvent(args.Id, args.Type, point, stackCollection);
|
|
|
|
|
textDictionary.Remove(args.Id);
|
|
|
|
|
canvasView.InvalidateSurface();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnTouchModePickerSelectedIndexChanged(object sender, EventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (bitmap != null)
|
|
|
|
|
{
|
|
|
|
|
Picker picker = (Picker)sender;
|
|
|
|
|
bitmap.TouchManager.Mode = (TouchManipulationMode)picker.SelectedItem;
|
|
|
|
|
//public void OnTouchModePickerSelectedIndexChanged(object sender, EventArgs args)
|
|
|
|
|
//{
|
|
|
|
|
// if (textPaint != null)
|
|
|
|
|
// {
|
|
|
|
|
// Picker picker = (Picker)sender;
|
|
|
|
|
// textPaint.TouchManager.Mode = (TouchManipulationMode)picker.SelectedItem;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
private void InflateStack()
|
|
|
|
|
{
|
|
|
|
|
stackCollection.Clear();
|
|
|
|
|
|
|
|
|
|
SKPoint position = new SKPoint(150, (float)((DeviceDisplay.MainDisplayInfo.Height * 0.1) + (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.01));
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
|
|
|
|
SKPaint textPaint = new SKPaint();
|
|
|
|
|
float textWidth = textPaint.MeasureText("1");
|
|
|
|
|
textPaint.TextSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textWidth;
|
|
|
|
|
|
|
|
|
|
stackCollection.Add(new TouchManipulationBitmap(textPaint, "1")
|
|
|
|
|
{
|
|
|
|
|
Matrix = SKMatrix.MakeTranslation(position.X, position.Y + textPaint.TextSize),
|
|
|
|
|
InitialPoint = position
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//private void OnPlayerChanged(object sender, PlayerChangedEventArgs args)
|
|
|
|
|
//{
|
|
|
|
|
// inflateHand();
|
|
|
|
|
//}
|
|
|
|
|
position.X += textPaint.MeasureText("1") + (float)(DeviceDisplay.MainDisplayInfo.Width * 0.15);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InflateHand()
|
|
|
|
|
{
|
|
|
|
|
//Hand.Children.Clear();
|
|
|
|
|
//for (int i = 0; i < viewmodel.CurrentHand.Count; i++)
|
|
|
|
|
//{
|
|
|
|
|
// Button card = new Button();
|
|
|
|
|
// card.Text = viewmodel.CurrentHand[i].Value.ToString();
|
|
|
|
|
// card.Clicked += played;
|
|
|
|
|
// Hand.Children.Add(card);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bitmapCollection.Clear();
|
|
|
|
|
textCollection.Clear();
|
|
|
|
|
|
|
|
|
|
Assembly assembly = GetType().GetTypeInfo().Assembly;
|
|
|
|
|
|
|
|
|
|
string resourceID = "TheGameExtreme.Media.thegame.jpg";
|
|
|
|
|
|
|
|
|
|
SKPoint position = new SKPoint(100, (float)(DeviceDisplay.MainDisplayInfo.Height - 0.2 * DeviceDisplay.MainDisplayInfo.Height));
|
|
|
|
|
SKPoint position = new SKPoint(100, (float)((DeviceDisplay.MainDisplayInfo.Height * 0.9) - (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.2));
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < viewmodel.CurrentHand.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
using (Stream stream = assembly.GetManifestResourceStream(resourceID))
|
|
|
|
|
SKPaint textPaint = new SKPaint();
|
|
|
|
|
float textWidth = textPaint.MeasureText(viewmodel.CurrentHand[i].Value.ToString());
|
|
|
|
|
textPaint.TextSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textWidth;
|
|
|
|
|
|
|
|
|
|
textCollection.Add(new TouchManipulationBitmap(textPaint, viewmodel.CurrentHand[i].Value.ToString())
|
|
|
|
|
{
|
|
|
|
|
SKBitmap bitmap = SKBitmap.Decode(stream).Resize(new SKImageInfo(225, 225), SKFilterQuality.High);
|
|
|
|
|
Matrix = SKMatrix.MakeTranslation(position.X, position.Y - textPaint.TextSize),
|
|
|
|
|
InitialPoint = position
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
bitmapCollection.Add(new TouchManipulationBitmap(bitmap)
|
|
|
|
|
{
|
|
|
|
|
Matrix = SKMatrix.MakeTranslation(position.X, position.Y - bitmap.Height),
|
|
|
|
|
});
|
|
|
|
|
position.X += bitmap.Width + 50;
|
|
|
|
|
}
|
|
|
|
|
position.X += textPaint.MeasureText(viewmodel.CurrentHand[i].Value.ToString()) + 50;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -274,24 +248,6 @@ namespace TheGameExtreme.view
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//private void radioButton(object sender, EventArgs args)
|
|
|
|
|
//{
|
|
|
|
|
// if (isFirst)
|
|
|
|
|
// {
|
|
|
|
|
// isFirst = false;
|
|
|
|
|
|
|
|
|
|
// stacks.ForEach(checkbox =>
|
|
|
|
|
// {
|
|
|
|
|
// if (!checkbox.Equals(sender))
|
|
|
|
|
// {
|
|
|
|
|
// checkbox.IsChecked = false;
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// isFirst = true;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
private void retry(object sender, EventArgs args)
|
|
|
|
|
{
|
|
|
|
|
viewmodel = new Main(playersNames);
|
|
|
|
@ -300,12 +256,9 @@ namespace TheGameExtreme.view
|
|
|
|
|
|
|
|
|
|
pseudo.SetBinding(Label.TextProperty, new Binding("Pseudo", source: viewmodel));
|
|
|
|
|
|
|
|
|
|
inflateHand();
|
|
|
|
|
InflateStack();
|
|
|
|
|
|
|
|
|
|
//pile0.Text = "1";
|
|
|
|
|
//pile1.Text = "1";
|
|
|
|
|
//pile2.Text = "100";
|
|
|
|
|
//pile3.Text = "100";
|
|
|
|
|
InflateHand();
|
|
|
|
|
|
|
|
|
|
gameOption.Children.Clear();
|
|
|
|
|
gameOption.Children.Add(button);
|
|
|
|
@ -324,7 +277,7 @@ namespace TheGameExtreme.view
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
inflateHand();
|
|
|
|
|
InflateHand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|