Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d0b3df8
merge main -> dev (#1300)
pictos May 16, 2021
eefea7c
Merge branch 'main' into develop
jfversluis May 16, 2021
fc9e01f
Merge branch 'main' into develop
jfversluis May 17, 2021
b558d91
Merge branch 'main' into develop
jfversluis May 20, 2021
4711e71
Expander: Add touch capture view + common animation length / easing p…
AndreiMisiukevich Jun 2, 2021
867d491
Merge branch 'main' into develop
jfversluis Jun 2, 2021
e9805fd
Updated light dismiss xml docs (#1366)
SkyeHoefling Jun 5, 2021
c0dc1bb
Merge branch 'main' into develop
TheCodeTraveler Jun 7, 2021
c1e290b
Merge branch 'main' into develop
TheCodeTraveler Jun 8, 2021
70d5df5
Merge branch 'main' into develop
jfversluis Jun 14, 2021
da5d0a3
Merge branch 'main' into develop
TheCodeTraveler Jun 17, 2021
9ba26d8
Merge branch 'main' into develop
jfversluis Jun 18, 2021
6dfc3d2
[Converter] Added IsInRangeConverter (#1158)
GUOLDEV Jun 20, 2021
a762932
Drawing View (#740)
pictos Jun 20, 2021
0ab0be0
Added IsLightDismissed to PopupDismissedEvent (#1362)
SkyeHoefling Jun 20, 2021
1be322f
Merge branch 'main' into develop
TheCodeTraveler Jun 21, 2021
6e93253
Fix Android crashes if Bitmap is small, Fix iOS drawing in scrollView…
VladislavAntonyuk Jun 22, 2021
3571304
Merge branch 'main' into develop
jfversluis Jun 22, 2021
247d990
Merge branch 'main' into develop
TheCodeTraveler Jun 27, 2021
c7ef97b
Add StatusBarEffect and NavigationBarEffect classes to manage their c…
maxkoshevoi Jun 30, 2021
0822454
Merge branch 'main' into develop
TheCodeTraveler Jul 1, 2021
b08f3c4
Drawing view fixes (#1459)
VladislavAntonyuk Jul 2, 2021
50d153e
Snackbar corner radius (#1437)
VladislavAntonyuk Jul 2, 2021
66bf143
Merge branch 'main' into develop
TheCodeTraveler Jul 6, 2021
d066bed
Merge branch 'main' into develop
jfversluis Jul 7, 2021
98939bc
Added missing using System (#1483)
pictos Jul 7, 2021
742c783
Merge branch 'main' into develop
jfversluis Jul 9, 2021
8ece47b
[MacOS] Added MediaElement implementation (#1488)
yurkinh Jul 9, 2021
baa8990
Merge branch 'main' into develop
jfversluis Jul 13, 2021
5b930b3
Merge branch 'main' into develop
jfversluis Jul 15, 2021
8d688e4
Drawing view multi line (#1475)
VladislavAntonyuk Jul 16, 2021
80d05aa
[Bug] Fixed CameraView Linker issue (#1503)
GUOLDEV Jul 17, 2021
65bbc68
[iOS | Android] TextSwitcher + [iOS] ImageSwitcher (#1422)
AndreiMisiukevich Jul 18, 2021
a7eaf7d
Merge branch 'main' into develop
jfversluis Jul 19, 2021
fb6dc0a
iOS, macOS - Clean DrawingView on Lines clean (#1520)
VladislavAntonyuk Jul 20, 2021
8299885
Merge branch 'main' into develop
TheCodeTraveler Jul 27, 2021
229f398
[Bug] Fixed CameraView crash on FlashMode Torch (#1522)
GUOLDEV Jul 27, 2021
e865863
Consolidate our XCT platform class (#1559)
pictos Aug 6, 2021
4573f5d
Merge branch 'main' into develop
jfversluis Aug 9, 2021
ac206d4
[Bug] Fixed CameraView Shutter not responding (#1535)
GUOLDEV Aug 9, 2021
5d28f0b
Added Speed Property to mediaelement (#1570)
jfversluis Aug 11, 2021
f64f4e0
Merge branch 'main' into develop
jfversluis Aug 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/XCT.Sample.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected override void OnCreate(Bundle savedInstanceState)
ToolbarResource = Resource.Layout.Toolbar;

base.OnCreate(savedInstanceState);

Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
Expand Down
109 changes: 76 additions & 33 deletions samples/XCT.Sample.WPF/DrawingViewRenderer.wpf.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Specialized;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Windows.Controls;
Expand All @@ -10,6 +11,7 @@
using Xamarin.Forms.Platform.WPF;

[assembly: ExportRenderer(typeof(DrawingView), typeof(DrawingViewRenderer))]

namespace Xamarin.CommunityToolkit.Sample.WPF
{
public class DrawingViewRenderer : ViewRenderer<DrawingView, InkCanvas>
Expand All @@ -19,11 +21,11 @@ public class DrawingViewRenderer : ViewRenderer<DrawingView, InkCanvas>
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == DrawingView.PointsProperty.PropertyName)
if (e.PropertyName == DrawingView.LinesProperty.PropertyName)
{
canvas!.Strokes.StrokesChanged -= OnStrokesChanged;
canvas.Strokes.Clear();
LoadPoints();
LoadLines();
canvas.Strokes.StrokesChanged += OnStrokesChanged;
}
}
Expand All @@ -35,15 +37,15 @@ protected override void OnElementChanged(ElementChangedEventArgs<DrawingView> e)
{
canvas = new InkCanvas
{
DefaultDrawingAttributes =
Background = Element.BackgroundColor.ToBrush(),
DefaultDrawingAttributes = new()
{
Color = Element.LineColor.ToMediaColor(),
Width = Element.LineWidth,
Height = Element.LineWidth
},
Background = Element.BackgroundColor.ToBrush()
Color = Element.DefaultLineColor.ToMediaColor(),
Width = Element.DefaultLineWidth,
Height = Element.DefaultLineWidth
}
};
Element.Points.CollectionChanged += OnCollectionChanged;
Element.Lines.CollectionChanged += OnCollectionChanged;
SetNativeControl(canvas);

canvas.Strokes.StrokesChanged += OnStrokesChanged;
Expand All @@ -53,55 +55,96 @@ protected override void OnElementChanged(ElementChangedEventArgs<DrawingView> e)
if (e.OldElement != null)
{
canvas!.Strokes.StrokesChanged -= OnStrokesChanged;
Element!.Points.CollectionChanged -= OnCollectionChanged;
Element!.Lines.CollectionChanged -= OnCollectionChanged;
if (Control != null)
Control.PreviewMouseDown -= OnPreviewMouseDown;
}
}

void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) => LoadPoints();
void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
{
canvas!.Strokes.StrokesChanged -= OnStrokesChanged;
canvas.Strokes.Clear();
LoadLines();
canvas.Strokes.StrokesChanged += OnStrokesChanged;
}

void OnPreviewMouseDown(object sender, MouseButtonEventArgs e) => Clear();

void OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
void Clear(bool force = false)
{
canvas!.Strokes.Clear();
Element.Points.Clear();
if (!Element.MultiLineMode || force)
{
canvas!.Strokes.Clear();
Element.Lines.Clear();
}
}

void OnStrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
{
Element.Points.CollectionChanged -= OnCollectionChanged;
Element.Lines.CollectionChanged -= OnCollectionChanged;
if (e.Added.Count > 0)
{
var points = e.Added.First().StylusPoints.Select(point => new Point(point.X, point.Y));
Element.Points.Clear();
foreach (var point in points)
Element.Points.Add(point);
if (!Element.MultiLineMode)
{
Element.Lines.Clear();
}

if (Element.Points.Count > 0)
var lines = Element.MultiLineMode ? e.Added : new StrokeCollection() {e.Added.First()};

foreach (var line in lines)
{
var points = line.StylusPoints.Select(point => new Point(point.X, point.Y)).ToList();
Element.Lines.Add(new Line()
{
Points = new ObservableCollection<Point>(points),
LineColor = Color.FromRgba(line.DrawingAttributes.Color.R, line.DrawingAttributes.Color.G,
line.DrawingAttributes.Color.B, line.DrawingAttributes.Color.A),
LineWidth = (float) line.DrawingAttributes.Width
});
}

if (Element.Lines.Count > 0)
{
if (Element.DrawingCompletedCommand?.CanExecute(null) ?? false)
Element.DrawingCompletedCommand.Execute(Element.Points);
var lastLine = Element.Lines.Last();
if (Element.DrawingLineCompletedCommand?.CanExecute(lastLine) ?? false)
Element.DrawingLineCompletedCommand.Execute(lastLine);
}

if (Element.ClearOnFinish)
{
canvas!.Strokes.StrokesChanged -= OnStrokesChanged;
canvas.Strokes.Clear();
canvas.Strokes.StrokesChanged += OnStrokesChanged;
Element.Points.Clear();
Element.Lines.CollectionChanged -= OnCollectionChanged;
Clear(true);
canvas!.Strokes.StrokesChanged += OnStrokesChanged;
}
}

Element.Points.CollectionChanged += OnCollectionChanged;
Element.Lines.CollectionChanged += OnCollectionChanged;
}

void LoadPoints()
void LoadLines()
{
var stylusPoints = Element?.Points.Select(point => new StylusPoint(point.X, point.Y)).ToList();
if (stylusPoints is { Count: > 0 })
var lines = Element.MultiLineMode
? Element.Lines
: Element.Lines.Any()
? new ObservableCollection<Line> {Element.Lines.LastOrDefault()}
: new ObservableCollection<Line>();
foreach (var line in lines)
{
var stroke = new Stroke(new StylusPointCollection(stylusPoints), canvas!.DefaultDrawingAttributes);
canvas.Strokes.Add(stroke);
var stylusPoints = line.Points.Select(point => new StylusPoint(point.X, point.Y)).ToList();
if (stylusPoints is {Count: > 0})
{
var stroke = new Stroke(new StylusPointCollection(stylusPoints))
{
DrawingAttributes = new()
{
Color = line.LineColor.ToMediaColor(),
Width = line.LineWidth,
Height = line.LineWidth
}
};
canvas!.Strokes.Add(stroke);
}
}
}
}
Expand Down
47 changes: 47 additions & 0 deletions samples/XCT.Sample/Pages/TestCases/LinkerCameraViewPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8" ?>
<pages:BasePage
x:Class="Xamarin.CommunityToolkit.Sample.Pages.TestCases.LinkerCameraViewPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit">
<ContentPage.Content>
<StackLayout>
<Label HorizontalTextAlignment="Center" Text="This is to test if the Linker is keeping the MediaCaptured and MediaCaptureFailed events if they are used!" />
<Grid>
<xct:CameraView
x:Name="cameraView"
CaptureMode="Photo"
HorizontalOptions="FillAndExpand"
OnAvailable="CameraView_OnAvailable"
VerticalOptions="FillAndExpand">
<xct:CameraView.Behaviors>
<xct:EventToCommandBehavior Command="{Binding CaptureCommand}" EventName="MediaCaptured" />
</xct:CameraView.Behaviors>
</xct:CameraView>
<Button
x:Name="shutterButton"
Margin="40"
BackgroundColor="WhiteSmoke"
BorderColor="Black"
BorderWidth="1"
Clicked="ShutterButtonClicked"
CornerRadius="40"
HeightRequest="80"
HorizontalOptions="CenterAndExpand"
IsEnabled="False"
VerticalOptions="End"
WidthRequest="80" />
<Image
x:Name="previewPicture"
Margin="40"
Aspect="AspectFill"
BackgroundColor="Black"
HeightRequest="80"
HorizontalOptions="EndAndExpand"
VerticalOptions="EndAndExpand"
WidthRequest="80" />
</Grid>
</StackLayout>
</ContentPage.Content>
</pages:BasePage>
55 changes: 55 additions & 0 deletions samples/XCT.Sample/Pages/TestCases/LinkerCameraViewPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.CommunityToolkit.Sample.ViewModels;
using Xamarin.CommunityToolkit.UI.Views;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Xamarin.CommunityToolkit.Sample.Pages.TestCases
{
public partial class LinkerCameraViewPage
{
int counter = 0;

public LinkerCameraViewPage()
{
InitializeComponent();
BindingContext = new CameraViewTestViewModel();
}

public void CameraView_OnAvailable(object sender, bool e)
{
shutterButton.IsEnabled = e;
}

public void CameraView_MediaCaptured(object sender, MediaCapturedEventArgs e)
{
shutterButton.Text = $"{++counter}";
previewPicture.Source = e.Image;
previewPicture.Rotation = e.Rotation;
}

void ShutterButtonClicked(object sender, EventArgs e)
{
cameraView.Shutter();
}
}

sealed class CameraViewTestViewModel : BaseViewModel
{
public Command<object> CaptureCommand { get; }

public CameraViewTestViewModel()
{
CaptureCommand = new Command<object>(CaptureCommandExecute);
}

void CaptureCommandExecute(object args)
{
Console.WriteLine(args);
}
}
}
61 changes: 28 additions & 33 deletions samples/XCT.Sample/Pages/Views/DrawingViewPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@
xmlns:pages="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages"
xmlns:viewsVodel="clr-namespace:Xamarin.CommunityToolkit.Sample.ViewModels.Views;assembly=Xamarin.CommunityToolkit.Sample">

<pages:BasePage.BindingContext>
<viewsVodel:DrawingViewViewModel/>
</pages:BasePage.BindingContext>

<ScrollView>
<StackLayout>
<Switch x:Name="ClearOnFinish" />
<StackLayout Orientation="Horizontal" Margin="5">
<Label Text="Clear on Finish" Margin="0,0,5,0" />
<Switch x:Name="ClearOnFinish" />
</StackLayout>
<StackLayout Orientation="Horizontal" Margin="5">
<Label Text="Multi-Line Mode" Margin="0,0,5,0" />
<Switch x:Name="MultiLineMode" />
</StackLayout>
<Button
BackgroundColor="White"
Clicked="LoadPointsButtonClicked"
Text="Load points"
Clicked="AddNewLine"
Text="Add new line"
TextColor="Black" />
<Button
BackgroundColor="White"
Command="{Binding SetPointsCommand}"
Text="Load points ViewModel"
Clicked="LoadPointsButtonClicked"
Text="Load points"
TextColor="Black" />
<Label
x:Name="HiddenLabel"
<StackLayout x:Name="HiddenPanel"
HorizontalOptions="CenterAndExpand"
IsVisible="False"
Text="Draw &amp; GO" />
IsVisible="False">
<Label Text="Draw &amp; GO" />
<Button Text="Clear all lines"
Clicked="ClearLines_Clicked"/>
</StackLayout>
<Button
BackgroundColor="White"
Clicked="DisplayHiddenLabelButtonClicked"
Text="Display hidden label"
TextColor="Black" />
<Button
BackgroundColor="White"
Command="{Binding GetPointsCommand}"
Text="Get points ViewModel"
TextColor="Black" />
<Button
BackgroundColor="White"
Clicked="GetCurrentDrawingViewImageClicked"
Expand All @@ -52,22 +52,17 @@
x:Name="GestureImage"
HeightRequest="100"
WidthRequest="100" />

<Label Text="Default DrawingView"/>
<views:DrawingView BackgroundColor="LightGray" HeightRequest="200" />

<Label Text="Advanced DrawingView"/>
<views:DrawingView
x:Name="DrawingViewControl"
Points="{Binding MacroPoints, Mode=TwoWay}"
EnableSmoothedPath="false"
Granularity="5"
BackgroundColor="DarkGray"
ClearOnFinish="{Binding Source={x:Reference ClearOnFinish}, Path=IsToggled}"
HorizontalOptions="FillAndExpand"
LineColor="Red"
LineWidth="10"
HeightRequest="200" />
<Label Text="DrawingView (Code behind)"/>
<views:DrawingView x:Name="DrawingViewControl"
BackgroundColor="LightGray"
HeightRequest="200"
DefaultLineColor="Red"
DefaultLineWidth="3"
Lines="{Binding Lines, Mode=TwoWay}"
ClearOnFinish="{Binding Source={x:Reference ClearOnFinish}, Path=IsToggled}"
MultiLineMode="{Binding Source={x:Reference MultiLineMode}, Path=IsToggled}"/>

<Editor x:Name="Logs" HeightRequest="50" />
</StackLayout>
</ScrollView>
Expand Down
Loading