Skip to content

Commit c1e844b

Browse files
committed
Add drawing infrastructure to XF
1 parent 5d20f2a commit c1e844b

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

sandbox/SandboxXF/SandboxXF.Android/Resources/Resource.designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Plugin.InputKit.Shared.Helpers;
2+
using Xamarin.Forms.Shapes;
3+
4+
namespace Plugin.InputKit.Shared.Controls
5+
{
6+
public static class PredefinedShapes
7+
{
8+
public static Geometry Check = GeometryConverter.FromPath(Paths.Check);
9+
public static Geometry CheckCircle = GeometryConverter.FromPath(Paths.CheckCircle);
10+
public static Geometry Line = GeometryConverter.FromPath(Paths.LineHorizontal);
11+
public static Geometry Square = GeometryConverter.FromPath(Paths.Square);
12+
public static Geometry Dot = GeometryConverter.FromPath(Paths.Dot);
13+
14+
public static class Paths
15+
{
16+
public const string Check = "M 6.5212 16.4777 l -6.24 -6.24 c -0.3749 -0.3749 -0.3749 -0.9827 0 -1.3577 l 1.3576 -1.3577 c 0.3749 -0.3749 0.9828 -0.3749 1.3577 0 L 7.2 11.7259 L 16.2036 2.7224 c 0.3749 -0.3749 0.9828 -0.3749 1.3577 0 l 1.3576 1.3577 c 0.3749 0.3749 0.3749 0.9827 0 1.3577 l -11.04 11.04 c -0.3749 0.3749 -0.9828 0.3749 -1.3577 -0 z";
17+
public const string CheckCircle = "M12,22 C6.4771525,22 2,17.5228475 2,12 C2,6.4771525 6.4771525,2 12,2 C17.5228475,2 22,6.4771525 22,12 C22,17.5228475 17.5228475,22 12,22 Z M8,10 L6,12 L11,17 L18,10 L16,8 L11,13 L8,10 Z";
18+
public const string Square = "M12 12H0V0h12v12z";
19+
public const string LineHorizontal = "M 17.2026 6.7911 H 0.9875 C 0.4422 6.7911 0 7.2332 0 7.7784 v 2.6331 c 0 0.5453 0.442 0.9873 0.9875 0.9873 h 16.2151 c 0.5453 0 0.9873 -0.442 0.9873 -0.9873 v -2.6331 C 18.1901 7.2332 17.7481 6.7911 17.2026 6.7911 z";
20+
public const string Dot = "M12 18a6 6 0 100-12 6 6 0 000 12z";
21+
}
22+
}
23+
}

src/Xamarin.Forms.InputKit/Shared/Helpers/ColorExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@ public static Color ToSurfaceColor(this Color color)
1616
else
1717
return Color.White;
1818
}
19+
20+
public static Brush ToBrush(this Color color)
21+
{
22+
return new SolidColorBrush(color);
23+
}
1924
}
2025
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+

2+
using Xamarin.Forms.Shapes;
3+
4+
namespace Plugin.InputKit.Shared.Helpers
5+
{
6+
public static class GeometryConverter
7+
{
8+
private static PathGeometryConverter PathGeometryConverter { get; } = new PathGeometryConverter();
9+
public static Geometry FromPath(string path)
10+
{
11+
return (Geometry)PathGeometryConverter.ConvertFromInvariantString(path);
12+
}
13+
}
14+
}

src/Xamarin.Forms.InputKit/Xamarin.Forms.InputKit.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,10 @@
138138

139139
<Import Project="inputkit.targets" Condition="Exists('inputkit.targets')" />
140140
<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
141+
<ItemGroup>
142+
<None Remove="Shared\Controls\PredefinedShapes.cs" />
143+
</ItemGroup>
144+
<ItemGroup>
145+
<None Remove="Shared\Helpers\GeometryConverter.cs" />
146+
</ItemGroup>
141147
</Project>

0 commit comments

Comments
 (0)