|
|
|
@ -19,17 +19,14 @@ namespace TheGameExtreme.view
|
|
|
|
|
{
|
|
|
|
|
private bool isFirst = true;
|
|
|
|
|
private Main viewmodel;
|
|
|
|
|
private List<CheckBox> stacks = new List<CheckBox>();
|
|
|
|
|
private List<SKRect> stacks = new List<SKRect>();
|
|
|
|
|
Button button = new Button();
|
|
|
|
|
List<string> playersNames;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SKBitmap bitmap;
|
|
|
|
|
SKBitmap bitmap2;
|
|
|
|
|
SKMatrix matrix = SKMatrix.MakeIdentity();
|
|
|
|
|
// Touch information
|
|
|
|
|
long touchId = -1;
|
|
|
|
|
SKPoint previousPoint;
|
|
|
|
|
TouchManipulationBitmap bitmap;
|
|
|
|
|
List<TouchManipulationBitmap> bitmapCollection = new List<TouchManipulationBitmap>();
|
|
|
|
|
Dictionary<long, TouchManipulationBitmap> bitmapDictionary = new Dictionary<long, TouchManipulationBitmap>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MainPage(List<string> playersNames)
|
|
|
|
@ -39,17 +36,29 @@ namespace TheGameExtreme.view
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
NavigationPage.SetHasNavigationBar(this, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string resourceID = "TheGameExtreme.Media.thegame.jpg";
|
|
|
|
|
string resourceID2 = "TheGameExtreme.Media.moon.jpg";
|
|
|
|
|
Assembly assembly = GetType().GetTypeInfo().Assembly;
|
|
|
|
|
|
|
|
|
|
Stream stream = assembly.GetManifestResourceStream(resourceID);
|
|
|
|
|
bitmap = SKBitmap.Decode(stream);
|
|
|
|
|
string[] resourceIDs = assembly.GetManifestResourceNames();
|
|
|
|
|
|
|
|
|
|
Stream stream2 = assembly.GetManifestResourceStream(resourceID2);
|
|
|
|
|
bitmap2 = SKBitmap.Decode(stream2);
|
|
|
|
|
SKPoint position = new SKPoint();
|
|
|
|
|
|
|
|
|
|
foreach (string resourceID in resourceIDs)
|
|
|
|
|
{
|
|
|
|
|
if (resourceID.EndsWith(".png") ||
|
|
|
|
|
resourceID.EndsWith(".jpg"))
|
|
|
|
|
{
|
|
|
|
|
using (Stream stream = assembly.GetManifestResourceStream(resourceID))
|
|
|
|
|
{
|
|
|
|
|
SKBitmap bitmap = SKBitmap.Decode(stream);
|
|
|
|
|
bitmapCollection.Add(new TouchManipulationBitmap(bitmap)
|
|
|
|
|
{
|
|
|
|
|
Matrix = SKMatrix.MakeTranslation(position.X, position.Y),
|
|
|
|
|
});
|
|
|
|
|
position.X += 100;
|
|
|
|
|
position.Y += 100;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//stacks.Add(checkbox0);
|
|
|
|
@ -75,19 +84,15 @@ namespace TheGameExtreme.view
|
|
|
|
|
|
|
|
|
|
void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args) // Faire plusieurs canvas
|
|
|
|
|
{
|
|
|
|
|
SKImageInfo info = args.Info;
|
|
|
|
|
SKSurface surface = args.Surface;
|
|
|
|
|
SKCanvas canvas = surface.Canvas;
|
|
|
|
|
|
|
|
|
|
SKCanvas canvas = args.Surface.Canvas;
|
|
|
|
|
canvas.Clear();
|
|
|
|
|
|
|
|
|
|
// Display the bitmap
|
|
|
|
|
canvas.SetMatrix(matrix);
|
|
|
|
|
canvas.DrawBitmap(bitmap, new SKPoint());
|
|
|
|
|
//canvas.DrawBitmap(bitmap2, new SKPoint(500, 500));
|
|
|
|
|
foreach (TouchManipulationBitmap bitmap in bitmapCollection)
|
|
|
|
|
{
|
|
|
|
|
bitmap.Paint(canvas);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OnTouchEffectAction(object sender, TouchActionEventArgs args)
|
|
|
|
|
{
|
|
|
|
@ -100,36 +105,56 @@ namespace TheGameExtreme.view
|
|
|
|
|
switch (args.Type)
|
|
|
|
|
{
|
|
|
|
|
case TouchActionType.Pressed:
|
|
|
|
|
// Find transformed bitmap rectangle
|
|
|
|
|
SKRect rect = new SKRect(0, 0, bitmap.Width, bitmap.Height);
|
|
|
|
|
rect = matrix.MapRect(rect);
|
|
|
|
|
for (int i = bitmapCollection.Count - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
TouchManipulationBitmap bitmap = bitmapCollection[i];
|
|
|
|
|
|
|
|
|
|
// Determine if the touch was within that rectangle
|
|
|
|
|
if (rect.Contains(point))
|
|
|
|
|
if (bitmap.HitTest(point))
|
|
|
|
|
{
|
|
|
|
|
touchId = args.Id;
|
|
|
|
|
previousPoint = point;
|
|
|
|
|
// Move bitmap to end of collection
|
|
|
|
|
bitmapCollection.Remove(bitmap);
|
|
|
|
|
bitmapCollection.Add(bitmap);
|
|
|
|
|
|
|
|
|
|
// Do the touch processing
|
|
|
|
|
bitmapDictionary.Add(args.Id, bitmap);
|
|
|
|
|
bitmap.ProcessTouchEvent(args.Id, args.Type, point);
|
|
|
|
|
canvasView.InvalidateSurface();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TouchActionType.Moved:
|
|
|
|
|
if (touchId == args.Id)
|
|
|
|
|
if (bitmapDictionary.ContainsKey(args.Id))
|
|
|
|
|
{
|
|
|
|
|
// Adjust the matrix for the new position
|
|
|
|
|
matrix.TransX += point.X - previousPoint.X;
|
|
|
|
|
matrix.TransY += point.Y - previousPoint.Y;
|
|
|
|
|
previousPoint = point;
|
|
|
|
|
TouchManipulationBitmap bitmap = bitmapDictionary[args.Id];
|
|
|
|
|
bitmap.ProcessTouchEvent(args.Id, args.Type, point);
|
|
|
|
|
canvasView.InvalidateSurface();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TouchActionType.Released:
|
|
|
|
|
case TouchActionType.Cancelled:
|
|
|
|
|
touchId = -1;
|
|
|
|
|
if (bitmapDictionary.ContainsKey(args.Id))
|
|
|
|
|
{
|
|
|
|
|
TouchManipulationBitmap bitmap = bitmapDictionary[args.Id];
|
|
|
|
|
bitmap.ProcessTouchEvent(args.Id, args.Type, point);
|
|
|
|
|
bitmapDictionary.Remove(args.Id);
|
|
|
|
|
canvasView.InvalidateSurface();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnTouchModePickerSelectedIndexChanged(object sender, EventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (bitmap != null)
|
|
|
|
|
{
|
|
|
|
|
Picker picker = (Picker)sender;
|
|
|
|
|
bitmap.TouchManager.Mode = (TouchManipulationMode)picker.SelectedItem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|