private async Task Save(object parameters) { IsBusy = true; try { var validationErrors = new List <ValidationResult>(); CurrentDetails.Validate(validationErrors); if (validationErrors.Any()) { var message = string.Join(Environment.NewLine, validationErrors.Select(v => v.ErrorMessage)); await DialogManager.ShowMessageBoxAsync(message, "Error"); IsBusy = false; return; } CurrentDetails.EndEdit(); await CurrentDetails.Save(); await OnSaved(); IsEditMode = false; IsBusy = false; } catch (TimeoutException toe) { IsBusy = false; await OnSaveError(toe); } catch (Exception e) { IsBusy = false; IsEditMode = false; await OnSaveError(e); } }
public override void OnUpdate() { if (Visible) { PrinterObject selectedPrinter = MainWindow.GetSelectedPrinter(); if (selectedPrinter == null) { MainWindow.ActivateFrame(Manage3DInkMainWindow.PageID.Page0_StartupPage, new Mangage3DInkStageDetails(Manage3DInkMainWindow.Mode.None)); return; } if ((selectedPrinter.Info.Status == PrinterStatus.Firmware_Ready || selectedPrinter.Info.Status == PrinterStatus.Firmware_Idle || selectedPrinter.Info.Status == PrinterStatus.Firmware_PrintingPaused) && !selectedPrinter.WaitingForCommandToComplete && ((CurrentDetails.waitCondition != null ? (CurrentDetails.waitCondition() ? 1 : 0) : 1) != 0 && !finishedWaiting)) { if (CurrentDetails.pageAfterWait == Manage3DInkMainWindow.PageID.Page0_StartupPage) { if (selectedPrinter.LockStatus == PrinterLockStatus.Unlocked) { finishedWaiting = true; var num = (int)selectedPrinter.AcquireLock(new AsyncCallback(DoStartUpSequenceCallsAfterLock), selectedPrinter); } else if (selectedPrinter.LockStatus == PrinterLockStatus.WeOwnLocked) { finishedWaiting = true; DoStartUpSequence(selectedPrinter); } else { MainWindow.ActivateFrame(CurrentDetails.pageAfterWait, CurrentDetails); } } else { finishedWaiting = true; MainWindow.ActivateFrame(CurrentDetails.pageAfterWait, CurrentDetails); } } else if (!selectedPrinter.WaitingForCommandToComplete && CurrentDetails.waitCondition == null) { MainWindow.ActivateFrame(CurrentDetails.pageAfterWait, CurrentDetails); } else if (selectedPrinter.Info.Status == PrinterStatus.Firmware_Idle) { if (!m_osIdleStopwatchTimer.IsRunning) { m_osIdleStopwatchTimer.Restart(); } else if (m_osIdleStopwatchTimer.ElapsedMilliseconds > 3000L) { var num = (int)selectedPrinter.BreakLock(null, null); finishedWaiting = true; } } } base.OnUpdate(); }
private bool CanSave(object parameters) => IsEditMode && CurrentDetails.CanEndEdit();
protected void CancelEdit() { CurrentDetails.CancelEdit(); OnCanceled(); IsEditMode = false; }
protected bool CanCancelEdit() => IsEditMode && CurrentDetails.CanCancelEdit();
protected void EnterEdit() { IsEditMode = true; CurrentDetails.BeginEdit(); }
protected bool CanEnterEdit() => !IsEditMode && CurrentDetails.CanBeginEdit();