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

Commit d4ead9d

Browse files
jfversluispictosgithub-actions[bot]AndreiMisiukevichSkyeHoefling
authored
Develop to main for 1.3-pre3 (#1573)
* merge main -> dev (#1300) * Automated dotnet-format update (#1296) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * #1292 (#1301) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Andrei <[email protected]> * Expander: Add touch capture view + common animation length / easing properties (#1349) * Added base animation props * Added TouchCaptureView property * Updated light dismiss xml docs (#1366) * [Converter] Added IsInRangeConverter (#1158) * Added IsBetweenConverter * Renamed to IsInRangeConverter * Added Sample Page * Added IsInRangeConverterViewModel * Updated UnitTests * Cleanup * Removed RevertResult * Implemented BindableObjectExtension * Made ValueConverterExtension inherited from BindableObject Co-authored-by: Brandon Minnick <[email protected]> Co-authored-by: Javier Suárez <[email protected]> Co-authored-by: Pedro Jesus <[email protected]> Co-authored-by: Andrei <[email protected]> Co-authored-by: Gerald Versluis <[email protected]> * Drawing View (#740) * DrawingView (#468) * DrawingView control, samples, documentation * fix build issues Co-authored-by: Vladislav Antonyuk <[email protected]> Co-authored-by: Pedro Jesus <[email protected]> * fixed codestyle on Android renderer * GTK renderer adjustments * iOS renderer adjustments * MacOS renderer adjustments * TIzen rendere adjustments * UWP renderer adjustments * WPF tests * Fixed merge conflict * Fixed wpf stackoverflow exception * fixed iOS leaks * revert toast change * removed wpf implementations * root sample page to WelcomePage * removed DrawingView ctor from MainWindow * removed drawing instructions from readme * Update README.md * Drawing View - Fix nullable, add doc to the public method (#1293) * Fix nullable, add doc to the public method. add WPF * Remove WPF renderer from the library. * Change exception message for small images, fix nullable * return null instead of exception (#1339) Co-authored-by: Vladislav Antonyuk <[email protected]> Co-authored-by: Vladislav Antonyuk <[email protected]> Co-authored-by: Brandon Minnick <[email protected]> Co-authored-by: Javier Suárez <[email protected]> Co-authored-by: Gerald Versluis <[email protected]> * Added IsLightDismissed to PopupDismissedEvent (#1362) * Added IsLightDismissed to PopupDismissedEvent; Fixed Dismissed event so it fires when light dismissed for UWP and Android * Removing stale comments * Added Opened event handler to set isOpen to true when Popup displays * Fixed event cleanup code to unregisterd Closing event Co-authored-by: Gerald Versluis <[email protected]> * Fix Android crashes if Bitmap is small, Fix iOS drawing in scrollView (#1421) * Add StatusBarEffect and NavigationBarEffect classes to manage their color and style (#812) * Sample Android implementation (doesn't work) * Update to Android 11 * Add OnElementPropertyChanged * Refactor GetWindow a bit * Add dummy implementations for iOS and UWP * Update Xamarin.CommunityToolkit.csproj * Update Xamarin.CommunityToolkit.csproj * Fixed get Activity property * Update PlatformBarStyle.android.cs * Remove NavigationBar bits * Make SetStatusBarColor available on API 23+ * Make StatusBar white for demo app * Rename BarStyle to Window * Fix spaces * Revert "Update to Android 11" This reverts commit 656f0d0. * Update Xamarin.CommunityToolkit.csproj * Rename Window to WindowEffect * Revert Android 11 API support * Set status bar style in app.xaml * Replaced Window with WindowEffect is other places * Remove Detached implementation * Add WindowEffectAndroid for navigation bar stuff * Refactor SetBarStyle methods * Add UWP implementation * Add iOS implemetation (not tested) * Use switch expression * Add `#region` to specify Linker Work-Around * Rename WindowEffect to StatusBarEffect * Rename WindowEffectAndroid to PlatformNavigationBarEffect * Fix nullability errors * Commit to rerun tests * Revert "Commit to rerun tests" This reverts commit f207c74. * Add sample page * Fix default is not applied on Android * Fix radiobutton name on sample page * Add android specific NavigationBar class * Remove unneeded null checks * Coverted StatusBarEffect to static class * Improve description * Update EffectIds.shared.cs * Remove unneeded activity parameter * Refactor StatusBar.uwp * Setting view model in XAML * Update NavigationBar.android.cs * Make StatusBar style setters accessible from C# * Add XML documentation * Remove unrelated code * Move constant outside the loop * Add logs if bar style is not supported * Remove LightContent case * Commit to rerun build * Revert "Commit to rerun build" This reverts commit a49e18f. * Revert "Revert "Commit to rerun build"" This reverts commit c9b3d5b. * Revert "Revert "Revert "Commit to rerun build""" This reverts commit 7152b25. * Change Debug to Trace * Replace Trace with Log * Update src/CommunityToolkit/Xamarin.CommunityToolkit/PlatformConfiguration/AndroidSpecific/NavigationBar.shared.cs Co-authored-by: Pedro Jesus <[email protected]> * Update src/CommunityToolkit/Xamarin.CommunityToolkit/PlatformConfiguration/AndroidSpecific/NavigationBar.shared.cs Co-authored-by: Pedro Jesus <[email protected]> * Revert "Update src/CommunityToolkit/Xamarin.CommunityToolkit/PlatformConfiguration/AndroidSpecific/NavigationBar.shared.cs" This reverts commit c56f02b. * Revert "Update src/CommunityToolkit/Xamarin.CommunityToolkit/PlatformConfiguration/AndroidSpecific/NavigationBar.shared.cs" This reverts commit 6d37b50. * Move enums to sepparate files * Replace linq with methods * Update UpdateStatusBarAppearance to support iOS 13 Co-Authored-By: Daniel Christmas <[email protected]> * View controller-based status bar appearance: No Co-Authored-By: Daniel Christmas <[email protected]> * Commit to rerun tests * Update EffectsGalleryViewModel.cs * Move files to Effects folder * Converted BarStyle to effects * Update sample app * Drop Windows Mobile support * Get activity from control * Update NavigationBarEffect.shared.cs * Commit to rerun tests * refactoring ios * removed UWP linker hack We don't need it for UWP since we don't have a Linker for it * Removed not needed properties * Remove not needed null checks * Remove using * Commit to rerun tests * Moved NavigationBarEffect to use the platformspecific API * Updated the sample * Fix test * Little better styling Co-authored-by: Pedro Jesus <[email protected]> Co-authored-by: Brandon Minnick <[email protected]> Co-authored-by: Javier Suárez <[email protected]> Co-authored-by: Daniel Christmas <[email protected]> Co-authored-by: Gerald Versluis <[email protected]> * Drawing view fixes (#1459) * Set default line LineColor as black, Fix ClearOnFinish * Fix SmoothPath issue, update macOS renderer, update sample * Fix tizen build * Snackbar corner radius (#1437) * Snackbar/Toast CornerRadius * iOS, macOS * UWP * WPF * Update sample, add NativeSnackBar.ios.macos.cs * Fix ios, macos corner radius * Update default corner radius to 4 ```xml <shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#323232"/> <corners android:radius="4dp"/> </shape> ``` * Set CornerRadius to 10 * Set CornerRadius to 10 * Use default Corner Radius if not specified Co-authored-by: Brandon Minnick <[email protected]> Co-authored-by: Gerald Versluis <[email protected]> * Added missing using System (#1483) * [MacOS] Added MediaElement implementation (#1488) Co-authored-by: Yuriy Holembyovskyy <[email protected]> Co-authored-by: Gerald Versluis <[email protected]> * Drawing view multi line (#1475) * DrawingView MultiLine WPF, UWP * Android * GTK, Tizen * iOS, macOS * DrawingViewService Get Stream from lines * added missing System using * Add GetImageStream * Fix tests * Add description to switches * Styling and comments * DrawingLineCompletedEventArgs * Add summary, Add tests Co-authored-by: Pedro Jesus <[email protected]> Co-authored-by: Gerald Versluis <[email protected]> Co-authored-by: Gerald Versluis <[email protected]> * [Bug] Fixed CameraView Linker issue (#1503) * Fixed CameraView linker issue * Added Preserve Conditional * Added test case Co-authored-by: Gustavo Oliveira <[email protected]> Co-authored-by: Andrei <[email protected]> Co-authored-by: Pedro Jesus <[email protected]> * [iOS | Android] TextSwitcher + [iOS] ImageSwitcher (#1422) * Added text switcher * Added text switcher sample * Address comments * Update src/CommunityToolkit/Xamarin.CommunityToolkit/Views/ViewSwitcher/TextSwitcherRenderer.android.cs Co-authored-by: Pedro Jesus <[email protected]> * Update src/CommunityToolkit/Xamarin.CommunityToolkit/Views/ViewSwitcher/TextSwitcherRenderer.android.cs Co-authored-by: Pedro Jesus <[email protected]> * address comment * fixed build * fixed typo * Update src/CommunityToolkit/Xamarin.CommunityToolkit/Views/ViewSwitcher/TextSwitcherRenderer.android.cs Co-authored-by: Pedro Jesus <[email protected]> * cached sdk int * Fixed warnings Co-authored-by: Pedro Jesus <[email protected]> * iOS, macOS - Clean DrawingView on Lines clean (#1520) * [Bug] Fixed CameraView crash on FlashMode Torch (#1522) * Update FormsCameraView.ios.cs Fixed CameraView crashing in Torch FlashMode * Update src/CommunityToolkit/Xamarin.CommunityToolkit/Views/CameraView/iOS/FormsCameraView.ios.cs Co-authored-by: Pedro Jesus <[email protected]> Co-authored-by: Pedro Jesus <[email protected]> Co-authored-by: Andrei <[email protected]> * Consolidate our XCT platform class (#1559) * Moved and renamed ToolkitPlatform to XCT inside helpers folder * replaced all SDK version calls to XCT cached one * removed unecessary space * Added a cache to the iOS version * [Bug] Fixed CameraView Shutter not responding (#1535) * Fixed CameraView Shutter not responding * Fixed Merge conflict * Update FormsCameraView.ios.cs Removed unnecessary code * Update FormsCameraView.ios.cs Co-authored-by: Andrei <[email protected]> Co-authored-by: Gerald Versluis <[email protected]> Co-authored-by: Gerald Versluis <[email protected]> * Added Speed Property to mediaelement (#1570) * Added Speed control for MediaElement in iOS and Android * Added Update Speed inside Play Method so after pausing and playing speed will be remembered * Added Sample for speed * Update src/CommunityToolkit/Xamarin.CommunityToolkit/Views/MediaElement/Android/MediaElementRenderer.android.cs Co-authored-by: Andrei <[email protected]> * Update src/CommunityToolkit/Xamarin.CommunityToolkit/Views/MediaElement/Android/MediaElementRenderer.android.cs Co-authored-by: Andrei <[email protected]> * Changed Speed Property binding mode to oneway and removed un necessary property Speed from IMediaElementController * Added Speed control for MediaElement in iOS and Android * Changed Speed Property binding mode to oneway and removed un necessary property Speed from IMediaElementController Co-authored-by: Aswin P G <[email protected]> Co-authored-by: Andrei <[email protected]> Co-authored-by: Pedro Jesus <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Andrei <[email protected]> Co-authored-by: Andrew Hoefling <[email protected]> Co-authored-by: Brandon Minnick <[email protected]> Co-authored-by: Gustavo Oliveira <[email protected]> Co-authored-by: Javier Suárez <[email protected]> Co-authored-by: Vladislav Antonyuk <[email protected]> Co-authored-by: Vladislav Antonyuk <[email protected]> Co-authored-by: Maksym Koshovyi <[email protected]> Co-authored-by: Daniel Christmas <[email protected]> Co-authored-by: Yuriy Holembyovskyy <[email protected]> Co-authored-by: Yuriy Holembyovskyy <[email protected]> Co-authored-by: Gustavo Oliveira <[email protected]> Co-authored-by: Aswin P G <[email protected]>
1 parent 3b6b831 commit d4ead9d

File tree

66 files changed

+2722
-500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2722
-500
lines changed

samples/XCT.Sample.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 savedInstanceState)
1414
ToolbarResource = Resource.Layout.Toolbar;
1515

1616
base.OnCreate(savedInstanceState);
17-
17+
1818
Essentials.Platform.Init(this, savedInstanceState);
1919
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
2020
LoadApplication(new App());

samples/XCT.Sample.WPF/DrawingViewRenderer.wpf.cs

Lines changed: 76 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Specialized;
1+
using System.Collections.ObjectModel;
2+
using System.Collections.Specialized;
23
using System.ComponentModel;
34
using System.Linq;
45
using System.Windows.Controls;
@@ -10,6 +11,7 @@
1011
using Xamarin.Forms.Platform.WPF;
1112

1213
[assembly: ExportRenderer(typeof(DrawingView), typeof(DrawingViewRenderer))]
14+
1315
namespace Xamarin.CommunityToolkit.Sample.WPF
1416
{
1517
public class DrawingViewRenderer : ViewRenderer<DrawingView, InkCanvas>
@@ -19,11 +21,11 @@ public class DrawingViewRenderer : ViewRenderer<DrawingView, InkCanvas>
1921
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
2022
{
2123
base.OnElementPropertyChanged(sender, e);
22-
if (e.PropertyName == DrawingView.PointsProperty.PropertyName)
24+
if (e.PropertyName == DrawingView.LinesProperty.PropertyName)
2325
{
2426
canvas!.Strokes.StrokesChanged -= OnStrokesChanged;
2527
canvas.Strokes.Clear();
26-
LoadPoints();
28+
LoadLines();
2729
canvas.Strokes.StrokesChanged += OnStrokesChanged;
2830
}
2931
}
@@ -35,15 +37,15 @@ protected override void OnElementChanged(ElementChangedEventArgs<DrawingView> e)
3537
{
3638
canvas = new InkCanvas
3739
{
38-
DefaultDrawingAttributes =
40+
Background = Element.BackgroundColor.ToBrush(),
41+
DefaultDrawingAttributes = new()
3942
{
40-
Color = Element.LineColor.ToMediaColor(),
41-
Width = Element.LineWidth,
42-
Height = Element.LineWidth
43-
},
44-
Background = Element.BackgroundColor.ToBrush()
43+
Color = Element.DefaultLineColor.ToMediaColor(),
44+
Width = Element.DefaultLineWidth,
45+
Height = Element.DefaultLineWidth
46+
}
4547
};
46-
Element.Points.CollectionChanged += OnCollectionChanged;
48+
Element.Lines.CollectionChanged += OnCollectionChanged;
4749
SetNativeControl(canvas);
4850

4951
canvas.Strokes.StrokesChanged += OnStrokesChanged;
@@ -53,55 +55,96 @@ protected override void OnElementChanged(ElementChangedEventArgs<DrawingView> e)
5355
if (e.OldElement != null)
5456
{
5557
canvas!.Strokes.StrokesChanged -= OnStrokesChanged;
56-
Element!.Points.CollectionChanged -= OnCollectionChanged;
58+
Element!.Lines.CollectionChanged -= OnCollectionChanged;
5759
if (Control != null)
5860
Control.PreviewMouseDown -= OnPreviewMouseDown;
5961
}
6062
}
6163

62-
void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) => LoadPoints();
64+
void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
65+
{
66+
canvas!.Strokes.StrokesChanged -= OnStrokesChanged;
67+
canvas.Strokes.Clear();
68+
LoadLines();
69+
canvas.Strokes.StrokesChanged += OnStrokesChanged;
70+
}
71+
72+
void OnPreviewMouseDown(object sender, MouseButtonEventArgs e) => Clear();
6373

64-
void OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
74+
void Clear(bool force = false)
6575
{
66-
canvas!.Strokes.Clear();
67-
Element.Points.Clear();
76+
if (!Element.MultiLineMode || force)
77+
{
78+
canvas!.Strokes.Clear();
79+
Element.Lines.Clear();
80+
}
6881
}
6982

7083
void OnStrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
7184
{
72-
Element.Points.CollectionChanged -= OnCollectionChanged;
85+
Element.Lines.CollectionChanged -= OnCollectionChanged;
7386
if (e.Added.Count > 0)
7487
{
75-
var points = e.Added.First().StylusPoints.Select(point => new Point(point.X, point.Y));
76-
Element.Points.Clear();
77-
foreach (var point in points)
78-
Element.Points.Add(point);
88+
if (!Element.MultiLineMode)
89+
{
90+
Element.Lines.Clear();
91+
}
7992

80-
if (Element.Points.Count > 0)
93+
var lines = Element.MultiLineMode ? e.Added : new StrokeCollection() {e.Added.First()};
94+
95+
foreach (var line in lines)
96+
{
97+
var points = line.StylusPoints.Select(point => new Point(point.X, point.Y)).ToList();
98+
Element.Lines.Add(new Line()
99+
{
100+
Points = new ObservableCollection<Point>(points),
101+
LineColor = Color.FromRgba(line.DrawingAttributes.Color.R, line.DrawingAttributes.Color.G,
102+
line.DrawingAttributes.Color.B, line.DrawingAttributes.Color.A),
103+
LineWidth = (float) line.DrawingAttributes.Width
104+
});
105+
}
106+
107+
if (Element.Lines.Count > 0)
81108
{
82-
if (Element.DrawingCompletedCommand?.CanExecute(null) ?? false)
83-
Element.DrawingCompletedCommand.Execute(Element.Points);
109+
var lastLine = Element.Lines.Last();
110+
if (Element.DrawingLineCompletedCommand?.CanExecute(lastLine) ?? false)
111+
Element.DrawingLineCompletedCommand.Execute(lastLine);
84112
}
85113

86114
if (Element.ClearOnFinish)
87115
{
88-
canvas!.Strokes.StrokesChanged -= OnStrokesChanged;
89-
canvas.Strokes.Clear();
90-
canvas.Strokes.StrokesChanged += OnStrokesChanged;
91-
Element.Points.Clear();
116+
Element.Lines.CollectionChanged -= OnCollectionChanged;
117+
Clear(true);
118+
canvas!.Strokes.StrokesChanged += OnStrokesChanged;
92119
}
93120
}
94121

95-
Element.Points.CollectionChanged += OnCollectionChanged;
122+
Element.Lines.CollectionChanged += OnCollectionChanged;
96123
}
97124

98-
void LoadPoints()
125+
void LoadLines()
99126
{
100-
var stylusPoints = Element?.Points.Select(point => new StylusPoint(point.X, point.Y)).ToList();
101-
if (stylusPoints is { Count: > 0 })
127+
var lines = Element.MultiLineMode
128+
? Element.Lines
129+
: Element.Lines.Any()
130+
? new ObservableCollection<Line> {Element.Lines.LastOrDefault()}
131+
: new ObservableCollection<Line>();
132+
foreach (var line in lines)
102133
{
103-
var stroke = new Stroke(new StylusPointCollection(stylusPoints), canvas!.DefaultDrawingAttributes);
104-
canvas.Strokes.Add(stroke);
134+
var stylusPoints = line.Points.Select(point => new StylusPoint(point.X, point.Y)).ToList();
135+
if (stylusPoints is {Count: > 0})
136+
{
137+
var stroke = new Stroke(new StylusPointCollection(stylusPoints))
138+
{
139+
DrawingAttributes = new()
140+
{
141+
Color = line.LineColor.ToMediaColor(),
142+
Width = line.LineWidth,
143+
Height = line.LineWidth
144+
}
145+
};
146+
canvas!.Strokes.Add(stroke);
147+
}
105148
}
106149
}
107150
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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="ShutterButtonClicked"
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>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 ShutterButtonClicked(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+
}

samples/XCT.Sample/Pages/Views/DrawingViewPage.xaml

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,38 @@
66
xmlns:pages="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages"
77
xmlns:viewsVodel="clr-namespace:Xamarin.CommunityToolkit.Sample.ViewModels.Views;assembly=Xamarin.CommunityToolkit.Sample">
88

9-
<pages:BasePage.BindingContext>
10-
<viewsVodel:DrawingViewViewModel/>
11-
</pages:BasePage.BindingContext>
12-
139
<ScrollView>
1410
<StackLayout>
15-
<Switch x:Name="ClearOnFinish" />
11+
<StackLayout Orientation="Horizontal" Margin="5">
12+
<Label Text="Clear on Finish" Margin="0,0,5,0" />
13+
<Switch x:Name="ClearOnFinish" />
14+
</StackLayout>
15+
<StackLayout Orientation="Horizontal" Margin="5">
16+
<Label Text="Multi-Line Mode" Margin="0,0,5,0" />
17+
<Switch x:Name="MultiLineMode" />
18+
</StackLayout>
1619
<Button
1720
BackgroundColor="White"
18-
Clicked="LoadPointsButtonClicked"
19-
Text="Load points"
21+
Clicked="AddNewLine"
22+
Text="Add new line"
2023
TextColor="Black" />
2124
<Button
2225
BackgroundColor="White"
23-
Command="{Binding SetPointsCommand}"
24-
Text="Load points ViewModel"
26+
Clicked="LoadPointsButtonClicked"
27+
Text="Load points"
2528
TextColor="Black" />
26-
<Label
27-
x:Name="HiddenLabel"
29+
<StackLayout x:Name="HiddenPanel"
2830
HorizontalOptions="CenterAndExpand"
29-
IsVisible="False"
30-
Text="Draw &amp; GO" />
31+
IsVisible="False">
32+
<Label Text="Draw &amp; GO" />
33+
<Button Text="Clear all lines"
34+
Clicked="ClearLines_Clicked"/>
35+
</StackLayout>
3136
<Button
3237
BackgroundColor="White"
3338
Clicked="DisplayHiddenLabelButtonClicked"
3439
Text="Display hidden label"
3540
TextColor="Black" />
36-
<Button
37-
BackgroundColor="White"
38-
Command="{Binding GetPointsCommand}"
39-
Text="Get points ViewModel"
40-
TextColor="Black" />
4141
<Button
4242
BackgroundColor="White"
4343
Clicked="GetCurrentDrawingViewImageClicked"
@@ -52,22 +52,17 @@
5252
x:Name="GestureImage"
5353
HeightRequest="100"
5454
WidthRequest="100" />
55-
56-
<Label Text="Default DrawingView"/>
57-
<views:DrawingView BackgroundColor="LightGray" HeightRequest="200" />
5855

59-
<Label Text="Advanced DrawingView"/>
60-
<views:DrawingView
61-
x:Name="DrawingViewControl"
62-
Points="{Binding MacroPoints, Mode=TwoWay}"
63-
EnableSmoothedPath="false"
64-
Granularity="5"
65-
BackgroundColor="DarkGray"
66-
ClearOnFinish="{Binding Source={x:Reference ClearOnFinish}, Path=IsToggled}"
67-
HorizontalOptions="FillAndExpand"
68-
LineColor="Red"
69-
LineWidth="10"
70-
HeightRequest="200" />
56+
<Label Text="DrawingView (Code behind)"/>
57+
<views:DrawingView x:Name="DrawingViewControl"
58+
BackgroundColor="LightGray"
59+
HeightRequest="200"
60+
DefaultLineColor="Red"
61+
DefaultLineWidth="3"
62+
Lines="{Binding Lines, Mode=TwoWay}"
63+
ClearOnFinish="{Binding Source={x:Reference ClearOnFinish}, Path=IsToggled}"
64+
MultiLineMode="{Binding Source={x:Reference MultiLineMode}, Path=IsToggled}"/>
65+
7166
<Editor x:Name="Logs" HeightRequest="50" />
7267
</StackLayout>
7368
</ScrollView>

0 commit comments

Comments
 (0)