Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Bindable Strokes / Points / SignatureImage Properties #133

Open
mattleibow opened this issue May 16, 2018 · 13 comments
Open

Bindable Strokes / Points / SignatureImage Properties #133

mattleibow opened this issue May 16, 2018 · 13 comments

Comments

@mattleibow
Copy link
Contributor

This is a larger issue to discuss the possibility for creating bindable properties for:

  • IEnumerable<Point> Points { get; set; }
  • IEnumerable<IEnumerable<Point>> Strokes { get; set; }
  • ImageSource SignatureImage { get; } or Stream SignatureImage { get; }

This discussion has already started in #107, #109, and #120.

The main concern is that this might be hard to do in a performant manner because the image and points update each time the stroke is in the process of drawing. This could mean that a simple line may generate thousands of events. Although, we should limit the event to only firing when the stroke is complete because the user can cancel at any time.

Already, there is a way to be notified of strokes ending by using the StrokeCompleted event - we could leverage this and then just ask for a new image each time. This is still quite heavy as if there are many strokes, the control has to first render the image or collect the points.
There may be a way to just trigger the event and not actually collect points or render images - wait until a binding requests it.

@mattleibow
Copy link
Contributor Author

@TheRealSteveJudge, @VladislavAntonyuk, @MaxFe do you guys have any comments or suggestions in this area as you have opened issues.

Another question for everyone, what are your use-cases so we can address them correctly?

@VladislavAntonyuk
Copy link

VladislavAntonyuk commented May 17, 2018

what is the problem? Is it in a performance of many events which calls when you set any of this properties?
By the way for now we can get and set this properties on events ( strokes completed) and then manually via binding context set in VM.

@VladislavAntonyuk
Copy link

VladislavAntonyuk commented May 17, 2018

For now I do like this:
in XAML

StrokeCompleted="OnPointsChangeCompleted"
Cleared="OnPointsChangeCompleted"

In code behind

    public View()
    {
        InitializeComponent();
        PadView.Points = ((ViewModel) BindingContext).Points;
    }

    private void OnPointsChangeCompleted(object sender, EventArgs e)
    {
        ((ViewModel) BindingContext).Points = PadView.Points;
    }

@VladislavAntonyuk
Copy link

VladislavAntonyuk commented May 17, 2018

Also it would be great to use command instead of events, but not necessary

            <forms:SignaturePadView.Behaviors>
                <behaviors:EventToCommandBehavior
                            EventName="StrokeCompleted"
                            Command="{Binding MyCommand}" />
            </forms:SignaturePadView.Behaviors>

@mattleibow
Copy link
Contributor Author

I will definitely add commands to make life easier.

@VladislavAntonyuk
Copy link

VladislavAntonyuk commented May 17, 2018

what about points? As I see you have subscription on StrokeCompleted event where you call UpdateUI method. I think it is ok to set Points there.

@mattleibow
Copy link
Contributor Author

My only concern with that is if there are many points. The points and strokes are COPIED from the native side, so if there are 10K strokes, it copies that and it may take a few milliseconds. This may cause a jitter on the UI, but I never actually tested any this this may not be the case at all.

@VladislavAntonyuk
Copy link

By the way it should be a big delay on ui because user will see the points he painted before. It can be only delay with sending it to VM. Also I haven't count number of points for signature but I think it should be a lot of them

@VladislavAntonyuk
Copy link

Great, you have implemented Commands. Why you added this (https://github.com/xamarin/SignaturePad/tree/master/samples/Sample.Forms/Samples/Helpers) in Samples but not in Library?

@mattleibow
Copy link
Contributor Author

I want to get a release out soon, but I don't want to commit to anything with Points and Strokes just yet. If you need this support, you can just copy the behavior into your app for the time being.

Also, this will provide a way to get some feedback without having to break anyone in the next release if there is a bug or some other issue.

@mattleibow
Copy link
Contributor Author

I haven't done any testing, but it may work with the older v2.x releases

@nativenolde
Copy link

hey @mattleibow, what about the efforts to make the signature pad more mvvm capable? Are there any news on that?

@saidbehaine
Copy link

hey @mattleibow, what about the efforts to make the signature pad more mvvm capable? Are there any news on that?

Any news about that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants