/// <summary> /// Used to dispose of resources in use by the <see cref="AdminViewModel{TViewModel, TModel, TModelSearcher}"/> /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { if (!_disposedValue) { if (disposing) { ApplicationRestrictor.RequestUnlock(_adminToken); FamilialLocker.RequestUnlock(_adminToken); CriticalOperationType = CriticalOperationType.None; if (ModelSearcher != null) { ModelSearcher.SelectedItems.CollectionChanged -= SelectedItems_CollectionChanged; ModelSearcher.ExportId -= ModelSearcher_ExportId; ModelSearcher.Cleared -= ModelSearcher_Cleared; ModelSearcher.RequestEnable(_adminToken); } Model.ErrorsChanged -= Model_ErrorsChanged; Model.Dispose(); _newEnableCallback = null; _duplicateEnableCallback = null; _modifyEnableCallback = null; _backEnableCallback = null; _forwardEnableCallback = null; _performDeleteOnRecordEnableCallback = null; _backForwardNavigator.CurrentItemChangedCallback = null; _backForwardNavigator?.Dispose(); Navigation.Dispose(); RecordChangeLocker.Dispose(); ConfirmCancelLocker.Dispose(); NewRecordCancelLocker.Dispose(); NavigationalOverride.Dispose(); OutsideModificationLocker.Dispose(); DefaultModelCallback = null; Locators.ForEach(locator => { locator.SearchToBegin -= Locator_SearchToBegin; locator.SearchComplete -= Locator_SearchComplete; locator.RecordRequested -= Locator_RecordRequested; locator.RequestEnable(_adminToken); }); Locators.Clear(); } _disposedValue = true; } base.Dispose(disposing); }
/// <summary> /// The logic used when a search has been initiated. /// </summary> /// <param name="sender">The initiator of the event. Is used as token.</param> /// <param name="e">The EventArgs of the event.</param> private void Locator_SearchToBegin(object sender, EventArgs e) { ModelSearcher?.RequestDisable(sender); RecordChangeLocker?.RequestLock(sender); }
/// <summary> /// The logic used when a search has been completed. /// </summary> /// <param name="sender">The initiator of the event. Is used as token.</param> /// <param name="e">The EventArgs of the event.</param> private void Locator_SearchComplete(object sender, EventArgs e) { ModelSearcher?.RequestEnable(sender); RecordChangeLocker?.RequestUnlock(sender); }
/// <summary> /// The default enable for the Forward Command. /// </summary> /// <returns>True enables button. False is a disable.</returns> protected virtual bool ForwardEnable() => _backForwardNavigator.CanNavigateForward() && this.StateNotCriticalEnable() && RecordChangeLocker.IsFree() && NavigationalOverride.IsFree();
/// <summary> /// The default enable for the Cascading Delete command. /// </summary> /// <returns>True enables button. False is a disable.</returns> protected bool DefaultPerformDeleteOnRecordEnable() => this.ModelValidEnable() && this.StateNotCriticalEnable() && this.StateNotRestrictedEnable() && RecordChangeLocker.IsFree();
/// <summary> /// The default enable for the Duplicate command; /// </summary> /// <returns>True enables button. False is a disable.</returns> protected virtual bool DuplicateEnable() => this.ModelValidEnable() && this.StateNotCriticalEnable() && this.StateNotRestrictedEnable() && RecordChangeLocker.IsFree() && NavigationalOverride.IsFree();