/// <summary> /// Marks a specific PhysicalControlInfo in the Output Map as 'enabled' /// </summary> /// <param name="inputControl"> /// a PhysicalControlInfo object to mark as 'enabled' /// in the output map /// </param> public void EnableMapping(PhysicalControlInfo inputControl) { if (_disabledMappings.Contains(inputControl)) { _disabledMappings.Remove(inputControl); } }
/// <summary> /// Marks a specific physical control in the map as 'disabled', preventing it /// from being seen by Mediators /// </summary> /// <param name="inputControl"> /// a PhysicalControlInfo object to mark as disabled /// in the output map /// </param> public void DisableMapping(PhysicalControlInfo inputControl) { if (!_disabledMappings.Contains(inputControl)) { _disabledMappings.Add(inputControl); } }
/// <summary> /// Returns the VirtualControlInfo object currently mapped to the specified /// PhysicalControlInfo object, if any. If no mapping is defined for the /// specified PhysicalControlInfo, then null is returned. /// </summary> /// <param name="inputControl"> /// a PhysicalControlInfo object whose /// corresponding VirtualControlInfo object (if any), will be returned /// from the defined mappings set /// </param> /// <returns> /// a VirtualControlInfo object representing the virtual control /// which is currently mapped to receive data from the specified /// physical control /// </returns> public VirtualControlInfo GetMapping(PhysicalControlInfo inputControl) { if (_mappings.ContainsKey(inputControl)) { var vc = _mappings[inputControl]; return(vc); } return(null); }
/// <summary> /// Removes a mapping from the output map /// </summary> /// <param name="inputControl"> /// a PhysicalControlInfo object representing the physical control whose mappings will be /// removed from the output map /// </param> /// <returns>a bool indicating if any changes were actually made to the output map as a result of this call</returns> public bool RemoveMapping(PhysicalControlInfo inputControl) { var toReturn = false; if (_mappings.ContainsKey(inputControl)) { toReturn = true; _mappings.Remove(inputControl); } if (_disabledMappings.Contains(inputControl)) { toReturn = true; _disabledMappings.Remove(inputControl); } return(toReturn); }
/// <summary> /// Defines or removes a mapping in the output map. /// </summary> /// <param name="inputControl"> /// a PhysicalControlInfo object /// representing the source of data (input) /// </param> /// <param name="outputControl"> /// a VirtualControlInfo object representing the target /// (output) for data coming from the specified physical control /// </param> /// <returns> /// a boolean indicating if the output map has changed as a result /// of this operation. Allows editors to call this method without /// being aware of all of the current mappings, and yet still be able to /// detect whether changes have occurred as a result of an attempted /// modification of the map. /// </returns> public bool SetMapping(PhysicalControlInfo inputControl, VirtualControlInfo outputControl) { VirtualControlInfo currentMapping = null; if (_mappings.ContainsKey(inputControl)) { currentMapping = _mappings[inputControl]; _mappings.Remove(inputControl); } _mappings.Add(inputControl, outputControl); if (currentMapping != null) { if (outputControl == null) { return(true); } return(!currentMapping.Equals(outputControl)); } if (outputControl == null) { return(false); } return(true); }
/// <summary> /// Creates a new PhysicalControlStateChangedEventArgs event argument object and sets its required properties in a /// single call. /// </summary> /// <param name="control"> /// a PhysicalControlInfo object representing the physical control (axis, button, Pov, etc) whose /// state change is being signalled by raising the event /// </param> /// <param name="currentstate"> /// an integer value indicating the current state of the physical control whose state change is /// being signalled /// </param> /// <param name="previousState"> /// an integer value indicating the previous state of the physical control whose state change /// is being signalled /// </param> public PhysicalControlStateChangedEventArgs(PhysicalControlInfo control, int currentstate, int previousState) { _control = control; _currentState = currentstate; _previousState = previousState; }
/// <summary> /// Checks whether a specific physical control is enabled in the output map /// for being read from by Mediators. /// </summary> /// <param name="control"> /// a PhysicalControlInfo object representing the /// physical control to check /// </param> /// <returns> /// a boolean indicating true if the specified physical control is /// enabled in the output map, or false if the specified physical control is /// not enabled (disabled) in the map /// </returns> public bool IsMappingEnabled(PhysicalControlInfo control) { return(!_disabledMappings.Contains(control)); }
/// <summary> /// Checks whether the output map contains a mapping from a given physical input control /// </summary> /// <param name="physicalControl"> /// a PhysicalControlInfo object representing the physical input control to check for known /// mappings /// </param> /// <returns> /// true if the output map contains any mappings from the specified physical control, or false if it does not /// contain any mappings from that input control /// </returns> public bool ContainsMappingFrom(PhysicalControlInfo physicalControl) { return(_mappings.ContainsKey(physicalControl)); }