private void runNextStep(Action onCompletion, Action <Exception> onError, Func <StepButton, bool> stopCondition) { try { if (loadableStep != null) { if (actionRepetition == 0) { Logger.Log($"🔸 Step #{actionIndex + 1} {loadableStep?.Text}"); } scroll.ScrollIntoView(loadableStep); loadableStep.PerformStep(); } } catch (Exception e) { Logger.Log(actionRepetition > 0 ? $"💥 Failed (on attempt {actionRepetition:#,0})" : "💥 Failed"); LoadingComponentsLogger.LogAndFlush(); onError?.Invoke(e); return; } actionRepetition++; if (actionRepetition > (loadableStep?.RequiredRepetitions ?? 1) - 1) { if (actionIndex >= 0 && actionRepetition > 1) { Logger.Log($"✔️ {actionRepetition} repetitions"); } actionIndex++; actionRepetition = 0; if (loadableStep != null && stopCondition?.Invoke(loadableStep) == true) { return; } } if (actionIndex > StepsContainer.Children.Count - 1) { Logger.Log($"✅ {GetType().ReadableName()} completed"); onCompletion?.Invoke(); return; } if (Parent != null) { stepRunner = Scheduler.AddDelayed(() => runNextStep(onCompletion, onError, stopCondition), TimePerAction); } }
public LabelStep AddLabel(string description) { var step = new LabelStep { Text = description, }; step.Action = () => { Logger.Log($@"💨 {this} {description}"); // kinda hacky way to avoid this doesn't get triggered by automated runs. if (step.IsHovered) { RunAllSteps(startFromStep: step, stopCondition: s => s is LabelStep); } }; AddStep(step); return(step); }