protected void Save() { bool update = false; if (_currentPortMapping != null) { update = true; if (_currentDevice != null) { _currentPortMapping.SetDevice(_currentDevice); _mappingProxy.AddPortMapping(_currentPortMapping); } else { _mappingProxy.RemovePortMapping(_currentPortMapping.Port); } } DeviceMapperProxy mapper = DeviceMapper; if (mapper != null) { update = true; mapper.Save(); _mappingProxy.AddDeviceMapping(mapper.Mapping); } if (update) { _mappingProxy.Save(); } }
void OnSelectedInputChanged(AbstractProperty property, object oldValue) { DeviceMapperProxy mapper = DeviceMapper; if (mapper != null && mapper.SelectedInput != null) { var wm = ServiceRegistration.Get <IWorkflowManager>(); wm.NavigatePushAsync(STATE_MAP_INPUT); } }
protected void ResetMapper() { DeviceMapperProxy mapper = DeviceMapper; if (mapper != null) { DeviceMapper = null; mapper.SelectedInputProperty.Detach(OnSelectedInputChanged); mapper.Dispose(); } }
protected void EndMapping() { _doPoll = false; if (_inputPollThread != null) { _inputPollThread.Join(); _inputPollThread = null; } DeviceMapperProxy mapper = DeviceMapper; if (mapper != null) { mapper.SelectedInput = null; } }
protected void UpdateMappings() { ResetMapper(); _inputList.Clear(); if (_currentDevice != null) { IDeviceMapper mapper = _currentDevice.CreateMapper(); RetroPadMapping mapping = _mappingProxy.GetDeviceMapping(_currentDevice); if (mapper != null && mapping != null) { DeviceMapperProxy deviceMapper = new DeviceMapperProxy(mapper, mapping); deviceMapper.SelectedInputProperty.Attach(OnSelectedInputChanged); CollectionUtils.AddAll(_inputList, deviceMapper.Inputs); DeviceMapper = deviceMapper; } } _inputList.FireChange(); }
protected void DoPoll() { DeviceMapperProxy mapper = DeviceMapper; if (mapper == null) { return; } Thread.Sleep(POLL_INITIAL_WAIT); while (_doPoll) { if (mapper.TryMap()) { var wm = ServiceRegistration.Get <IWorkflowManager>(); wm.NavigatePopToStateAsync(STATE_DEVICE_CONFIGURE, false); break; } Thread.Sleep(POLL_INTERVAL); } }
protected void UpdateState(NavigationContext oldContext, NavigationContext newContext, bool push) { if (oldContext.WorkflowState.StateId == STATE_MAP_INPUT) { EndMapping(); DeviceMapperProxy mapper = DeviceMapper; if (mapper != null) { mapper.UpdateInputs(); _inputList.FireChange(); } } Guid newState = newContext.WorkflowState.StateId; if (newState == STATE_PORT_SELECT) { if (!push) { Save(); } Reset(); UpdatePortsList(); } if (newState == STATE_DEVICE_CONFIGURE) { if (push) { UpdateMappings(); } } else if (newState == STATE_MAP_INPUT) { BeginMapping(newContext); } }