diff --git a/TheGameExtreme.Android/Resources/Resource.designer.cs b/TheGameExtreme.Android/Resources/Resource.designer.cs
index 455e66d..884c56f 100644
--- a/TheGameExtreme.Android/Resources/Resource.designer.cs
+++ b/TheGameExtreme.Android/Resources/Resource.designer.cs
@@ -1,11 +1,11 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
//
-// Ce code a été généré par un outil.
-// Version du runtime :4.0.30319.42000
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
//
-// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
-// le code est régénéré.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
//------------------------------------------------------------------------------
diff --git a/TheGameExtreme/view/MainPage.xaml b/TheGameExtreme/view/MainPage.xaml
index deb7c7f..90bea66 100644
--- a/TheGameExtreme/view/MainPage.xaml
+++ b/TheGameExtreme/view/MainPage.xaml
@@ -11,7 +11,8 @@
mc:Ignorable="d"
x:Class="TheGameExtreme.view.MainPage">
-
+
@@ -21,12 +22,6 @@
-
-
-
-
@@ -42,7 +37,7 @@
VerticalTextAlignment="Center"
TextColor="{DynamicResource WhiteColor}"
FontSize="28"/>
-
@@ -58,7 +53,7 @@
4
-
+ -->
@@ -148,13 +143,20 @@
-->
-
+ Grid.ColumnSpan="3">
+
+
+
+
+
+
diff --git a/TheGameExtreme/view/MainPage.xaml.cs b/TheGameExtreme/view/MainPage.xaml.cs
index 7d8af20..bc2f195 100644
--- a/TheGameExtreme/view/MainPage.xaml.cs
+++ b/TheGameExtreme/view/MainPage.xaml.cs
@@ -25,9 +25,10 @@ namespace TheGameExtreme.view
List playersNames;
- TouchManipulationBitmap bitmap;
- List bitmapCollection = new List();
- Dictionary bitmapDictionary = new Dictionary();
+ TouchManipulationBitmap textPaint;
+ List textCollection = new List();
+ List stackCollection = new List();
+ Dictionary textDictionary = new Dictionary();
@@ -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();
}
}
diff --git a/TheGameExtreme/view/TouchManipulationBitmap.cs b/TheGameExtreme/view/TouchManipulationBitmap.cs
index c7cc65a..6df5945 100644
--- a/TheGameExtreme/view/TouchManipulationBitmap.cs
+++ b/TheGameExtreme/view/TouchManipulationBitmap.cs
@@ -6,17 +6,21 @@ namespace TheGameExtreme.view
{
public class TouchManipulationBitmap
{
- SKBitmap bitmap;
+ public SKPoint InitialPoint { get; set; }
+ SKPaint textPaint;
Dictionary touchDictionary = new Dictionary();
+ string value;
+ SKCanvas canvas;
- public TouchManipulationBitmap(SKBitmap bitmap)
+ public TouchManipulationBitmap(SKPaint textPaint, string value)
{
- this.bitmap = bitmap;
+ this.textPaint = textPaint;
+ this.value = value;
Matrix = SKMatrix.MakeIdentity();
TouchManager = new TouchManipulationManager
{
- Mode = TouchManipulationMode.IsotropicScale
+ Mode = TouchManipulationMode.PanOnly
};
}
@@ -26,10 +30,14 @@ namespace TheGameExtreme.view
public void Paint(SKCanvas canvas)
{
+ this.canvas = canvas;
canvas.Save();
SKMatrix matrix = Matrix;
canvas.Concat(ref matrix);
- canvas.DrawBitmap(bitmap, 0, 0);
+ textPaint.Color = SKColors.Red;
+ SKRect textBounds = new SKRect();
+ textPaint.MeasureText(value, ref textBounds);
+ canvas.DrawText(value, 0, 0, textPaint);
canvas.Restore();
}
@@ -44,13 +52,13 @@ namespace TheGameExtreme.view
SKPoint transformedPoint = inverseMatrix.MapPoint(location);
// Check if it's in the untransformed bitmap rectangle
- SKRect rect = new SKRect(0, 0, bitmap.Width, bitmap.Height);
+ SKRect rect = new SKRect(0, 0, textPaint.MeasureText(value), textPaint.TextSize);
return rect.Contains(transformedPoint);
}
return false;
}
- public void ProcessTouchEvent(long id, TouchActionType type, SKPoint location)
+ public void ProcessTouchEvent(long id, TouchActionType type, SKPoint location, List stackCollection)
{
switch (type)
{
@@ -70,9 +78,22 @@ namespace TheGameExtreme.view
break;
case TouchActionType.Released:
- touchDictionary[id].NewPoint = location;
- Manipulate();
- touchDictionary.Remove(id);
+ bool find = false;
+ foreach (TouchManipulationBitmap stack in stackCollection)
+ {
+ if (stack.HitTest(location))
+ {
+ stackCollection[stackCollection.IndexOf(stack)] = this;
+ break;
+ }
+ }
+ if (!find)
+ {
+ touchDictionary[id].NewPoint = InitialPoint;
+ Manipulate();
+ touchDictionary[id].PreviousPoint = touchDictionary[id].NewPoint;
+ touchDictionary.Remove(id);
+ }
break;
case TouchActionType.Cancelled:
@@ -91,7 +112,7 @@ namespace TheGameExtreme.view
{
SKPoint prevPoint = infos[0].PreviousPoint;
SKPoint newPoint = infos[0].NewPoint;
- SKPoint pivotPoint = Matrix.MapPoint(bitmap.Width / 2, bitmap.Height / 2);
+ SKPoint pivotPoint = Matrix.MapPoint(textPaint.MeasureText(value) / 2, textPaint.TextSize / 2);
touchMatrix = TouchManager.OneFingerManipulate(prevPoint, newPoint, pivotPoint);
}