Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 2f9e23f

Browse files
authored
Added Shapes to FormsGallery (#638)
* Initial Shapes support. * Shapes updates.
1 parent 0423162 commit 2f9e23f

23 files changed

+598
-3
lines changed

FormsGallery/FormsGallery/FormsGallery.Android/MainActivity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ protected override void OnCreate(Bundle bundle)
1414

1515
base.OnCreate(bundle);
1616

17-
Xamarin.Forms.Forms.SetFlags(new string[] {"SwipeView_Experimental", "CarouselView_Experimental", "MediaElement_Experimental", "RadioButton_Experimental", "Expander_Experimental" });
17+
Xamarin.Forms.Forms.SetFlags(new string[] {"SwipeView_Experimental", "CarouselView_Experimental", "MediaElement_Experimental", "RadioButton_Experimental", "Expander_Experimental", "Shapes_Experimental" });
1818
global::Xamarin.Forms.Forms.Init(this, bundle);
1919
global::Xamarin.FormsMaps.Init(this, bundle);
2020
LoadApplication(new App());

FormsGallery/FormsGallery/FormsGallery.UWP/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
5858

5959
rootFrame.NavigationFailed += OnNavigationFailed;
6060

61-
Xamarin.Forms.Forms.SetFlags(new string[] { "SwipeView_Experimental", "CarouselView_Experimental", "MediaElement_Experimental", "RadioButton_Experimental", "Expander_Experimental" });
61+
Xamarin.Forms.Forms.SetFlags(new string[] { "SwipeView_Experimental", "CarouselView_Experimental", "MediaElement_Experimental", "RadioButton_Experimental", "Expander_Experimental", "Shapes_Experimental" });
6262
Xamarin.Forms.Forms.Init(e);
6363

6464
Xamarin.FormsMaps.Init("MAP_KEY");

FormsGallery/FormsGallery/FormsGallery.iOS/AppDelegate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsAppli
1818
//
1919
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
2020
{
21-
Xamarin.Forms.Forms.SetFlags(new string[] { "SwipeView_Experimental", "CarouselView_Experimental", "MediaElement_Experimental", "RadioButton_Experimental", "Expander_Experimental" });
21+
Xamarin.Forms.Forms.SetFlags(new string[] { "SwipeView_Experimental", "CarouselView_Experimental", "MediaElement_Experimental", "RadioButton_Experimental", "Expander_Experimental", "Shapes_Experimental" });
2222
global::Xamarin.Forms.Forms.Init();
2323
global::Xamarin.FormsMaps.Init();
2424
LoadApplication(new App());
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Xamarin.Forms;
2+
using Xamarin.Forms.Shapes;
3+
4+
namespace FormsGallery.CodeExamples
5+
{
6+
public class EllipseDemoPage : ContentPage
7+
{
8+
public EllipseDemoPage()
9+
{
10+
Label header = new Label
11+
{
12+
Text = "Ellipse",
13+
FontSize = 50,
14+
FontAttributes = FontAttributes.Bold,
15+
HorizontalOptions = LayoutOptions.Center
16+
};
17+
18+
Ellipse ellipse = new Ellipse
19+
{
20+
Fill = Color.Red,
21+
WidthRequest = 150,
22+
HeightRequest = 50,
23+
HorizontalOptions = LayoutOptions.Center
24+
};
25+
26+
Ellipse circle = new Ellipse
27+
{
28+
Stroke = Color.Red,
29+
StrokeThickness = 4,
30+
WidthRequest = 150,
31+
HeightRequest = 150,
32+
HorizontalOptions = LayoutOptions.Center
33+
};
34+
35+
// Build the page.
36+
Title = "Ellipse Demo";
37+
Content = new StackLayout
38+
{
39+
Children =
40+
{
41+
header,
42+
ellipse,
43+
circle
44+
}
45+
};
46+
}
47+
}
48+
}
49+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Xamarin.Forms;
2+
using Xamarin.Forms.Shapes;
3+
4+
namespace FormsGallery.CodeExamples
5+
{
6+
public class LineDemoPage : ContentPage
7+
{
8+
public LineDemoPage()
9+
{
10+
Label header = new Label
11+
{
12+
Text = "Line",
13+
FontSize = 50,
14+
FontAttributes = FontAttributes.Bold,
15+
HorizontalOptions = LayoutOptions.Center
16+
};
17+
18+
Line line = new Line
19+
{
20+
X1 = 40,
21+
Y1 = 0,
22+
X2 = 0,
23+
Y2 = 120,
24+
Stroke = Color.Red,
25+
HorizontalOptions = LayoutOptions.Center
26+
};
27+
28+
// Build the page.
29+
Title = "Line Demo";
30+
Content = new StackLayout
31+
{
32+
Children =
33+
{
34+
header,
35+
line
36+
}
37+
};
38+
}
39+
}
40+
}
41+
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using Xamarin.Forms;
2+
using Xamarin.Forms.Shapes;
3+
4+
namespace FormsGallery.CodeExamples
5+
{
6+
public class PathDemoPage : ContentPage
7+
{
8+
public PathDemoPage()
9+
{
10+
Label header = new Label
11+
{
12+
Text = "Path",
13+
FontSize = 50,
14+
FontAttributes = FontAttributes.Bold,
15+
HorizontalOptions = LayoutOptions.Center
16+
};
17+
18+
Path path = new Path
19+
{
20+
Stroke = Color.Black,
21+
Aspect = Stretch.Uniform,
22+
HorizontalOptions = LayoutOptions.Center,
23+
HeightRequest = 100,
24+
WidthRequest = 100,
25+
Data = new PathGeometry
26+
{
27+
Figures = new PathFigureCollection
28+
{
29+
new PathFigure
30+
{
31+
IsClosed = true,
32+
StartPoint = new Point { X = 13.908992, Y = 16.207977 },
33+
Segments = new PathSegmentCollection
34+
{
35+
new LineSegment { Point = new Point { X = 32.000048, Y = 16.207977 } },
36+
new LineSegment { Point = new Point { X = 32.000049, Y = 31.999985 } },
37+
new LineSegment { Point = new Point { X = 13.908992, Y = 30.109983 } }
38+
}
39+
},
40+
new PathFigure
41+
{
42+
IsClosed = true,
43+
StartPoint = new Point { X = 0, Y = 16.207977 },
44+
Segments = new PathSegmentCollection
45+
{
46+
new LineSegment { Point = new Point { X = 11.904009, Y = 16.207977 } },
47+
new LineSegment { Point = new Point { X = 11.904009, Y = 29.900984 } },
48+
new LineSegment { Point = new Point { X = 0, Y = 28.657984 } }
49+
}
50+
},
51+
new PathFigure
52+
{
53+
IsClosed = true,
54+
StartPoint = new Point { X = 11.904036, Y = 2.0979624 },
55+
Segments = new PathSegmentCollection
56+
{
57+
new LineSegment { Point = new Point { X = 11.904036, Y = 14.202982 } },
58+
new LineSegment { Point = new Point { X = 2.7656555E-05, Y = 14.202982 } },
59+
new LineSegment { Point = new Point { X = 2.7656555E-05, Y = 3.3409645 } }
60+
}
61+
},
62+
new PathFigure
63+
{
64+
IsClosed = true,
65+
StartPoint = new Point { X = 32.000058, Y = 0},
66+
Segments = new PathSegmentCollection
67+
{
68+
new LineSegment { Point = new Point { X = 32.000058, Y = 14.203001 } },
69+
new LineSegment { Point = new Point { X = 13.909059, Y = 14.203001 } },
70+
new LineSegment { Point = new Point { X = 13.909059, Y = 1.8890382 } }
71+
}
72+
}
73+
}
74+
}
75+
};
76+
77+
// Build the page.
78+
Title = "Path Demo";
79+
Content = new StackLayout
80+
{
81+
Children =
82+
{
83+
header,
84+
path
85+
}
86+
};
87+
}
88+
}
89+
}
90+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using Xamarin.Forms;
2+
using Xamarin.Forms.Shapes;
3+
4+
namespace FormsGallery.CodeExamples
5+
{
6+
public class PolygonDemoPage : ContentPage
7+
{
8+
public PolygonDemoPage()
9+
{
10+
Label header = new Label
11+
{
12+
Text = "Polygon",
13+
FontSize = 50,
14+
FontAttributes = FontAttributes.Bold,
15+
HorizontalOptions = LayoutOptions.Center
16+
};
17+
18+
Polygon polygon = new Polygon
19+
{
20+
Points = new PointCollection
21+
{
22+
new Point { X = 0, Y = 48 },
23+
new Point { X = 0, Y = 144 },
24+
new Point { X = 96, Y = 150 },
25+
new Point { X = 100, Y = 0 },
26+
new Point { X = 192, Y = 0 },
27+
new Point { X = 192, Y = 96 },
28+
new Point { X = 50, Y = 96 },
29+
new Point { X = 48, Y = 192 },
30+
new Point { X = 150, Y = 200 },
31+
new Point { X = 144, Y = 48 }
32+
},
33+
Fill = Color.Blue,
34+
Stroke = Color.Red,
35+
StrokeThickness = 3,
36+
HorizontalOptions = LayoutOptions.Center
37+
};
38+
39+
// Build the page.
40+
Title = "Polygon Demo";
41+
Content = new StackLayout
42+
{
43+
Children =
44+
{
45+
header,
46+
polygon
47+
}
48+
};
49+
}
50+
}
51+
}
52+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Xamarin.Forms;
2+
using Xamarin.Forms.Shapes;
3+
4+
namespace FormsGallery.CodeExamples
5+
{
6+
public class PolylineDemoPage : ContentPage
7+
{
8+
public PolylineDemoPage()
9+
{
10+
Label header = new Label
11+
{
12+
Text = "Polyline",
13+
FontSize = 50,
14+
FontAttributes = FontAttributes.Bold,
15+
HorizontalOptions = LayoutOptions.Center
16+
};
17+
18+
Polyline polyline = new Polyline
19+
{
20+
Points = new PointCollection
21+
{
22+
new Point { X = 0, Y = 0 },
23+
new Point { X = 10, Y = 30 },
24+
new Point { X = 15, Y = 0 },
25+
new Point { X = 18, Y = 60 },
26+
new Point { X = 23, Y = 30 },
27+
new Point { X = 35, Y = 30 },
28+
new Point { X = 40, Y = 0 },
29+
new Point { X = 43, Y = 60 },
30+
new Point { X = 48, Y = 30 },
31+
new Point { X = 100, Y = 30 }
32+
},
33+
Stroke = Color.Red,
34+
HorizontalOptions = LayoutOptions.Center
35+
};
36+
37+
// Build the page.
38+
Title = "Polyline Demo";
39+
Content = new StackLayout
40+
{
41+
Children =
42+
{
43+
header,
44+
polyline
45+
}
46+
};
47+
}
48+
}
49+
}
50+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Xamarin.Forms;
2+
using Rect = Xamarin.Forms.Shapes.Rectangle;
3+
4+
namespace FormsGallery.CodeExamples
5+
{
6+
public class RectangleDemoPage : ContentPage
7+
{
8+
public RectangleDemoPage()
9+
{
10+
Label header = new Label
11+
{
12+
Text = "Rectangle",
13+
FontSize = 50,
14+
FontAttributes = FontAttributes.Bold,
15+
HorizontalOptions = LayoutOptions.Center
16+
};
17+
18+
Rect rectangle = new Rect
19+
{
20+
Fill = Color.Red,
21+
WidthRequest = 150,
22+
HeightRequest = 50,
23+
HorizontalOptions = LayoutOptions.Center
24+
};
25+
26+
Rect square = new Rect
27+
{
28+
Stroke = Color.Red,
29+
StrokeThickness = 4,
30+
WidthRequest = 150,
31+
HeightRequest = 150,
32+
HorizontalOptions = LayoutOptions.Center
33+
};
34+
35+
// Build the page.
36+
Title = "Rectangle Demo";
37+
Content = new StackLayout
38+
{
39+
Children =
40+
{
41+
header,
42+
rectangle,
43+
square
44+
}
45+
};
46+
}
47+
}
48+
}
49+

0 commit comments

Comments
 (0)