/// <summary> /// Removes action from the list of monitored actions /// </summary> /// <param name="aAction"> /// Action to remove <see cref="ActionMonitor"/> /// </param> public void Remove(ActionMonitor aAction) { if ((object)aAction == null) { return; } ActionMonitor am; for (int i = actions.Count - 1; i >= 0; i--) { am = (ActionMonitor)actions[i]; if ((object)am != null) { if (am.IsValid == true) { if ((am.Action == aAction.Action) && (am.MonitorType == aAction.MonitorType)) { // am.Action.Activated -= OnActionActivated; actions.Remove(am); } } } } }
/// <summary> /// Calculates Sensitive for specific ActionMonitor /// </summary> /// <param name="aMonitor"> /// Action monitor being calculated Sensitive for <see cref="ActionMonitor"/> /// </param> /// <param name="aValue"> /// New value to be assigned <see cref="System.Boolean"/> /// </param> /// <returns> /// true if sensitive, false if not <see cref="System.Boolean"/> /// </returns> private bool CalcSensitive(ActionMonitor aMonitor, bool aValue) { if (IsValid == false) { if (aMonitor.Defaults.Mode == ActionMonitorDefaultsType.NotNullTarget) { return(aMonitor.MonitorType == ActionMonitorType.InvertedSensitivity); } if (aMonitor.Defaults.Mode == ActionMonitorDefaultsType.NeedsValid) { return(aMonitor.Defaults.DefaultValue); } } else { if (aMonitor.Defaults.Mode == ActionMonitorDefaultsType.NotNullTarget) { return(aMonitor.MonitorType == ActionMonitorType.Sensitivity); } else { if (aMonitor.MonitorType == ActionMonitorType.Sensitivity) { return(aValue); } return(!aValue); } } // Should not get here throw new Exception("Invalid ActionMonitor"); }
/// <summary> /// Adds action to the list of monitored actions /// </summary> /// <param name="aAction"> /// Action to add <see cref="ActionMonitor"/> /// </param> public void Add(ActionMonitor aAction) { if ((object)aAction == null) { return; } foreach (ActionMonitor am in actions) { if ((object)am != null) { if (am.IsValid == true) { if ((am.Action == aAction.Action) && (am.MonitorType == aAction.MonitorType)) { return; } } } } actions.Add(aAction); // aAction.Action.Activated += OnActionActivated; }