public void StartConfirmationPanel( ConfirmationAction yes, ConfirmationAction no, string textoDoPainel, bool selectedYes = false, bool cancelIsNo = true, bool hideSelections = false ) { gameObject.SetActive(true); yesBtn += yes; noBtn += no; //selectedYes = !selectedYes; if (hideSelections) { btnNoSelector.enabled = false; btnYesSelector.enabled = false; } else { ChangeSelectedOption(selectedYes); } Debug.Log("Seleção é: " + selectedYes); this.selectedYes = selectedYes; this.panelText.text = textoDoPainel; this.cancelIsNo = cancelIsNo; }
public Task <bool> ProcessConfirmationAsync(ConfirmationItem confirmation, ConfirmationAction action) { return(Task.Run(() => { confirmation.Status = ConfirmationStatus.Processing; bool result = false; var actionResult = ConfirmationActionResult.None; if (action == ConfirmationAction.Accept) { result = App.SteamGuardHelper.CurrentSteamGuard.AcceptConfirmation(confirmation); confirmation.Status = result ? ConfirmationStatus.Accepted : ConfirmationStatus.Unknow; actionResult = result ? ConfirmationActionResult.Accept : ConfirmationActionResult.Error; } else if (action == ConfirmationAction.Decline) { result = App.SteamGuardHelper.CurrentSteamGuard.DenyConfirmation(confirmation); confirmation.Status = result ? ConfirmationStatus.Declined : ConfirmationStatus.Unknow; actionResult = result ? ConfirmationActionResult.Decline : ConfirmationActionResult.Error; } App.Logger.Info($"Authenticator.ProcessConfirmationAsync {action.ToString()}: {confirmation}\t" + (result == true ? "[success]" : "[error]")); App.History.Write($"{confirmation} {action.ToString()}: {result}"); ConfirmationEvent.Invoke(this, new AuthenticatorConfirmationEventArgs(actionResult, confirmation)); return result; })); }
public Task StartConfirmationAsync(int timeout, bool autoConfirm, ConfirmationAction action, CancellationToken cancellationToken) { App.Logger.Info($"Authenticator.StartConfirmation: confirm [{autoConfirm}] action [{action}] timeout [{timeout}]"); if (!_isAutoStarted && _autocancellationTokenSource != null && !_autocancellationTokenSource.IsCancellationRequested) { _autocancellationTokenSource.Cancel(); } _isAutoStarted = false; return(Task.Run(async() => { _autoupdateSemaphore.Wait(); _isAutoUpdate = true; _isAutoConfirm = autoConfirm; _timeout = timeout; int errorCounter = 0; var error = false; while (!cancellationToken.IsCancellationRequested && !disposedValue) { try { App.Logger.Trace($"Authenticator.StartConfirmation Error Counter: {errorCounter}"); var success = await UpdateConfirmationsAsync(); if (!success && (++errorCounter > MaxErrors)) { State = AuthenticatorState.Error; error = true; break; } else { errorCounter = 0; } if (_isAutoConfirm) { IEnumerable <ConfirmationItem> confirmations = ConfirmationsSource.Where(c => c.Status == ConfirmationStatus.Waiting).ToList(); await ProcessConfirmationsAsync(confirmations, action, cancellationToken); } State = AuthenticatorState.Wait; await Task.Delay(TimeSpan.FromSeconds(_timeout), cancellationToken); } catch (OperationCanceledException) { App.Logger.Info($"Authenticator.StartConfirmation: Canceled"); break; } catch (Exception ex) { App.Logger.Info($"Authenticator.StartConfirmation: Error {ex.Message}"); break; } } _isAutoUpdate = false; State = error ? AuthenticatorState.Error : AuthenticatorState.Ready; _autoupdateSemaphore.Release(); })); }
public void StartConfirmationPanel( ConfirmationAction yes, ConfirmationAction no, string textoDoPainel, bool selectedYes = false, bool cancelIsNo = true) { gameObject.SetActive(true); yesBtn += yes; noBtn += no; selectedYes = !selectedYes; ChangeSelectedOption(); Debug.Log(selectedYes); this.selectedYes = selectedYes; this.panelText.text = textoDoPainel; this.cancelIsNo = cancelIsNo; }
public Task <bool> ProcessConfirmationsAsync(IEnumerable <ConfirmationItem> confirmations, ConfirmationAction action, CancellationToken cancellationToken) { return(Task.Run(async() => { _confirmationSemaphore.Wait(); _isConirmationInProcess = true; bool success = true; try { App.Logger.Info($"Authenticator.ProcessConfirmationsAsync Action: {action}"); State = AuthenticatorState.ConfirmationProcessing; if (confirmations == null || confirmations.Count() == 0) { App.Logger.Trace($"Authenticator.ProcessConfirmationsAsync [Empty]"); return success; } App.Logger.Info($"Authenticator.ProcessConfirmationsAsync Confirmations for process: {confirmations.Count()}"); int counter = 0; foreach (ConfirmationItem confirmation in confirmations) { try { cancellationToken.ThrowIfCancellationRequested(); await ProcessConfirmationAsync(confirmation, action); counter++; } catch (OperationCanceledException) { App.Logger.Info($"Authenticator.ProcessConfirmationsAsync Canceled"); break; } } ConfirmationActionResult confirmationActionResult = action == ConfirmationAction.Accept ? ConfirmationActionResult.Accept : ConfirmationActionResult.Decline; ConfirmationsEvent.Invoke(this, new AuthenticatorConfirmationsEventArgs(confirmationActionResult, counter)); return success; } finally { State = AuthenticatorState.ConfirmationProcessed; _isConirmationInProcess = false; _confirmationSemaphore.Release(); } })); }
/// <summary> /// When click on back button and leave editor /// </summary> public void OnExitButtonClick() { actionToConfirm = ConfirmationAction.LeaveEditor; confirmationPanel.GetComponentInChildren <Text>().text = "Are You Sure?"; confirmationPanel.SetActive(true); }
/// <summary> /// when click on erase all tool button /// </summary> public void OnEraseAllToolButtonClick() { actionToConfirm = ConfirmationAction.EraseAll; confirmationPanel.GetComponentInChildren <Text>().text = "Are You Sure?"; confirmationPanel.SetActive(true); }
public Confirmation(ConfirmationAction actionToConfirm, string levelFile) { this.actionToConfirm = actionToConfirm; this.levelFile = levelFile; }
public Confirmation(ConfirmationAction actionToConfirm) { this.actionToConfirm = actionToConfirm; }