-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathParsingUtils.cs
77 lines (63 loc) · 2.19 KB
/
ParsingUtils.cs
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
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.Maui.Graphics;
namespace Microsoft.Maui.Controls.Compatibility.Platform.iOS.UnitTests
{
internal static class ParsingUtils
{
public static Font ParseUIFont(string font)
{
FontAttributes fontAttrs = FontAttributes.None;
// Logger.LogLine ("TEST PARSING");
if (font.IndexOf("font-weight: bold;", StringComparison.Ordinal) != -1)
{
// 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(float.Parse(words[1]), float.Parse(words[2]), float.Parse(words[3]), float.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; i++)
{
numbers.Add(Convert.ToDouble(words[i]));
}
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;
}
}
}