Ejemplo n.º 1
0
        public void SetCurrentStep(int pIndex, bool pUserInteract)
        {
            if (FreezeCurrentStep)
            {
                return;
            }

            Task.Run(async() =>
            {
                await mLocker.WaitAsync();
                try
                {
                    if (pIndex == CurrentStep)
                    {
                        return;
                    }

                    int oldStep = CurrentStep;
                    int newStep = pIndex;

                    var args = new StepChangedArgs()
                    {
                        OldStepIndex = oldStep,
                        NewStepIndex = newStep,
                        OldStep      = WizardSteps[oldStep],
                        NewStep      = WizardSteps[newStep],
                        UserInteract = pUserInteract
                    };

                    await InvokeAsync(async() =>
                    {
                        await OnStepChanged.InvokeAsync(args);
                    });

                    if (args.Cancelled)
                    {
                        return;
                    }

                    CurrentStep = newStep;

                    await InvokeAsync(() =>
                    {
                        StateHasChanged();
                    });
                }
                finally
                {
                    mLocker.Release();
                }
            });
        }
Ejemplo n.º 2
0
        internal async void OnNextClicked()
        {
            if (FreezeCurrentStep)
            {
                return;
            }

            await mLocker.WaitAsync();

            try
            {
                int oldStep = CurrentStep;

                int?next = FindNextVisible(CurrentStep, i => i + 1);
                if (!next.HasValue)
                {
                    return;
                }

                int newStep = next.Value;

                var args = new StepChangedArgs()
                {
                    OldStepIndex = oldStep,
                    NewStepIndex = newStep,
                    OldStep      = WizardSteps[oldStep],
                    NewStep      = WizardSteps[newStep],
                    UserInteract = true
                };

                await OnStepChanged.InvokeAsync(args);

                //   task.Wait();

                if (args.Cancelled)
                {
                    return;
                }

                CurrentStep = newStep;

                StateHasChanged();
            }
            finally
            {
                mLocker.Release();
            }
        }
Ejemplo n.º 3
0
        protected async Task InternalSetStep(int pOldStep, bool pUserInteract, Func <int, int> pModifier)
        {
            try
            {
                var result = await mLocker.WaitAsync(1000);

                if (!result)
                {
                    return;
                }

                int?next = FindNextVisible(pOldStep, pModifier);
                if (!next.HasValue)
                {
                    return;
                }

                var newStep = next.Value;

                var args = new StepChangedArgs()
                {
                    OldStepIndex = pOldStep,
                    NewStepIndex = newStep,
                    OldStep      = WizardSteps[pOldStep],
                    NewStep      = WizardSteps[newStep],
                    UserInteract = pUserInteract
                };

                await InvokeAsync(async() =>
                {
                    await OnStepChanged.InvokeAsync(args);
                });

                if (args.Cancelled)
                {
                    return;
                }

                if (args.DelayStepTransition)
                {
                    int step = CurrentStep;
                    _ = Task.Delay(50).ContinueWith(async t =>
                    {
                        await mLocker.WaitAsync();

                        CurrentStep  = FindNextVisible(step, pModifier) ?? step;
                        mEmptyRender = true;

                        mLocker.Release();

                        _ = InvokeAsync(StateHasChanged);
                    });
                    _ = InvokeAsync(StateHasChanged);
                    return;
                }

                CurrentStep  = newStep;
                mEmptyRender = true;

                _ = InvokeAsync(StateHasChanged);
            }
            finally
            {
                mLocker.Release();
            }
        }