This repository was archived by the owner on May 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +107
-0
lines changed Expand file tree Collapse file tree 3 files changed +107
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <pages : BasePage
3
+ x : Class =" Xamarin.CommunityToolkit.Sample.Pages.TestCases.LinkerCameraViewPage"
4
+ xmlns =" http://xamarin.com/schemas/2014/forms"
5
+ xmlns : x =" http://schemas.microsoft.com/winfx/2009/xaml"
6
+ xmlns : pages =" clr-namespace:Xamarin.CommunityToolkit.Sample.Pages"
7
+ xmlns : xct =" http://xamarin.com/schemas/2020/toolkit" >
8
+ <ContentPage .Content>
9
+ <StackLayout >
10
+ <Label HorizontalTextAlignment =" Center" Text =" This is to test if the Linker is keeping the MediaCaptured and MediaCaptureFailed events if they are used!" />
11
+ <Grid >
12
+ <xct : CameraView
13
+ x : Name =" cameraView"
14
+ CaptureMode =" Photo"
15
+ HorizontalOptions =" FillAndExpand"
16
+ OnAvailable =" CameraView_OnAvailable"
17
+ VerticalOptions =" FillAndExpand" >
18
+ <xct : CameraView .Behaviors>
19
+ <xct : EventToCommandBehavior Command =" {Binding CaptureCommand}" EventName =" MediaCaptured" />
20
+ </xct : CameraView .Behaviors>
21
+ </xct : CameraView >
22
+ <Button
23
+ x : Name =" shutterButton"
24
+ Margin =" 40"
25
+ BackgroundColor =" WhiteSmoke"
26
+ BorderColor =" Black"
27
+ BorderWidth =" 1"
28
+ Clicked =" shutterButton_Clicked"
29
+ CornerRadius =" 40"
30
+ HeightRequest =" 80"
31
+ HorizontalOptions =" CenterAndExpand"
32
+ IsEnabled =" False"
33
+ VerticalOptions =" End"
34
+ WidthRequest =" 80" />
35
+ <Image
36
+ x : Name =" previewPicture"
37
+ Margin =" 40"
38
+ Aspect =" AspectFill"
39
+ BackgroundColor =" Black"
40
+ HeightRequest =" 80"
41
+ HorizontalOptions =" EndAndExpand"
42
+ VerticalOptions =" EndAndExpand"
43
+ WidthRequest =" 80" />
44
+ </Grid >
45
+ </StackLayout >
46
+ </ContentPage .Content>
47
+ </pages : BasePage >
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+ using System . Threading . Tasks ;
6
+ using Xamarin . CommunityToolkit . Sample . ViewModels ;
7
+ using Xamarin . CommunityToolkit . UI . Views ;
8
+ using Xamarin . Forms ;
9
+ using Xamarin . Forms . Xaml ;
10
+
11
+ namespace Xamarin . CommunityToolkit . Sample . Pages . TestCases
12
+ {
13
+ public partial class LinkerCameraViewPage
14
+ {
15
+ int counter = 0 ;
16
+
17
+ public LinkerCameraViewPage ( )
18
+ {
19
+ InitializeComponent ( ) ;
20
+ BindingContext = new CameraViewTestViewModel ( ) ;
21
+ }
22
+
23
+ public void CameraView_OnAvailable ( object sender , bool e )
24
+ {
25
+ shutterButton . IsEnabled = e ;
26
+ }
27
+
28
+ public void CameraView_MediaCaptured ( object sender , MediaCapturedEventArgs e )
29
+ {
30
+ shutterButton . Text = $ "{ ++ counter } ";
31
+ previewPicture . Source = e . Image ;
32
+ previewPicture . Rotation = e . Rotation ;
33
+ }
34
+
35
+ void shutterButton_Clicked ( object sender , EventArgs e )
36
+ {
37
+ cameraView . Shutter ( ) ;
38
+ }
39
+ }
40
+
41
+ sealed class CameraViewTestViewModel : BaseViewModel
42
+ {
43
+ public Command < object > CaptureCommand { get ; }
44
+
45
+ public CameraViewTestViewModel ( )
46
+ {
47
+ CaptureCommand = new Command < object > ( CaptureCommandExecute ) ;
48
+ }
49
+
50
+ void CaptureCommandExecute ( object args )
51
+ {
52
+ Console . WriteLine ( args ) ;
53
+ }
54
+ }
55
+ }
Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ protected override IEnumerable<SectionModel> CreateItems() => new[]
33
33
typeof ( PopupModalPage ) ,
34
34
"Popup into modal" ,
35
35
"Using Popup into modal page show the popup" ) ,
36
+
37
+ new SectionModel (
38
+ typeof ( LinkerCameraViewPage ) ,
39
+ "Linker for CameraView" ,
40
+ "Make sure that Linker is keeping the MediaCaptured and MediaCaptureFailed events if they are used." ) ,
36
41
} ;
37
42
}
38
43
}
You can’t perform that action at this time.
0 commit comments