blob: 6598e0f5cd789a16a633e6b86bfb6249887a3d52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting.Messaging;
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.Queries;
using Xamarin.UITest.Android;
using Xamarin.UITest.iOS;
using System.Globalization;
using System.Text.RegularExpressions;
using System.IO;
namespace Xamarin.Forms.Core.UITests
{
internal static class ParsingUtils
{
public static Font ParseUIFont (string font)
{
FontAttributes fontAttrs = FontAttributes.None;
// Logger.LogLine ("TEST PARSING");
if (font.Contains ("font-weight: bold;")) {
// Logger.LogLine ("Found Bold");
fontAttrs = FontAttributes.Bold;
}
return new Font ().WithAttributes (fontAttrs);
}
public static Color ParseUIColor (string backgroundColor)
{
var delimiters = new char[] { ' ' };
string[] words = backgroundColor.Split (delimiters, StringSplitOptions.RemoveEmptyEntries);
return new Color (double.Parse (words[1]), double.Parse (words[2]), double.Parse (words[3]), double.Parse (words[4]));
}
public static Point ParseCGPoint (object CGPoint) {
var point = new Point { X = 0, Y = 0 };
return point;
}
public static Matrix ParseCATransform3D (string CATransform3D)
{
// Logger.Log (CATransform3D);
char[] delimiters = { '<', ' ', '>' };
string[] words = CATransform3D.Split (delimiters, StringSplitOptions.RemoveEmptyEntries);
List<double> numbers = new List<double> ();
// Each number is represented by 2 blocks returned by server
for (int i = 0; i < (words.Length - 1); i += 2) {
string word = words[i] + words[i + 1];
var number = Int64.Parse (word, NumberStyles.HexNumber);
byte[] bytes = BitConverter.GetBytes (number);
byte[] reversedBytes = bytes.Reverse ().ToArray ();
double value = BitConverter.ToDouble (reversedBytes, 0);
numbers.Add (value);
}
var transformationMatrix = new Matrix ();
transformationMatrix.M00 = numbers[0];
transformationMatrix.M01 = numbers[1];
transformationMatrix.M02 = numbers[2];
transformationMatrix.M03 = numbers[3];
transformationMatrix.M10 = numbers[4];
transformationMatrix.M11 = numbers[5];
transformationMatrix.M12 = numbers[6];
transformationMatrix.M13 = numbers[7];
transformationMatrix.M20 = numbers[8];
transformationMatrix.M21 = numbers[9];
transformationMatrix.M22 = numbers[10];
transformationMatrix.M23 = numbers[11];
transformationMatrix.M30 = numbers[12];
transformationMatrix.M31 = numbers[13];
transformationMatrix.M32 = numbers[14];
transformationMatrix.M33 = numbers[15];
return transformationMatrix;
}
}
}
|