public ControllerActionPageViewModel( INavigationService navigationService, ITranslationService translationService, ICreationManager creationManager, IDeviceManager deviceManager, IDialogService dialogService, IPreferences preferences, NavigationParameters parameters) : base(navigationService, translationService) { _creationManager = creationManager; _deviceManager = deviceManager; _dialogService = dialogService; _preferences = preferences; ControllerAction = parameters.Get <ControllerAction>("controlleraction", null); ControllerEvent = parameters.Get <ControllerEvent>("controllerevent", null) ?? ControllerAction?.ControllerEvent; var device = _deviceManager.GetDeviceById(ControllerAction?.DeviceId); if (ControllerAction != null && device != null) { SelectedDevice = device; Action.Channel = ControllerAction.Channel; Action.IsInvert = ControllerAction.IsInvert; Action.ChannelOutputType = ControllerAction.ChannelOutputType; Action.MaxServoAngle = ControllerAction.MaxServoAngle; Action.ButtonType = ControllerAction.ButtonType; Action.AxisType = ControllerAction.AxisType; Action.AxisCharacteristic = ControllerAction.AxisCharacteristic; Action.MaxOutputPercent = ControllerAction.MaxOutputPercent; Action.AxisDeadZonePercent = ControllerAction.AxisDeadZonePercent; Action.ServoBaseAngle = ControllerAction.ServoBaseAngle; Action.StepperAngle = ControllerAction.StepperAngle; Action.SequenceName = ControllerAction.SequenceName; } else { var lastSelectedDeviceId = _preferences.Get <string>("LastSelectedDeviceId", null, "com.scn.BrickController2.ControllerActionPage"); SelectedDevice = _deviceManager.GetDeviceById(lastSelectedDeviceId) ?? _deviceManager.Devices.FirstOrDefault(); Action.Channel = 0; Action.IsInvert = false; Action.ChannelOutputType = ChannelOutputType.NormalMotor; Action.MaxServoAngle = 90; Action.ButtonType = ControllerButtonType.Normal; Action.AxisType = ControllerAxisType.Normal; Action.AxisCharacteristic = ControllerAxisCharacteristic.Linear; Action.MaxOutputPercent = 100; Action.AxisDeadZonePercent = 0; Action.ServoBaseAngle = 0; Action.StepperAngle = 90; Action.SequenceName = string.Empty; } SaveControllerActionCommand = new SafeCommand(async() => await SaveControllerActionAsync(), () => SelectedDevice != null); DeleteControllerActionCommand = new SafeCommand(async() => await DeleteControllerActionAsync()); OpenDeviceDetailsCommand = new SafeCommand(async() => await OpenDeviceDetailsAsync(), () => SelectedDevice != null); OpenChannelSetupCommand = new SafeCommand(async() => await OpenChannelSetupAsync(), () => SelectedDevice != null); OpenSequenceEditorCommand = new SafeCommand(async() => await OpenSequenceEditorAsync()); }
public SequenceEditorPageViewModel( INavigationService navigationService, ITranslationService translationService, IDialogService dialogService, ICreationManager creationManager, ISharedFileStorageService sharedFileStorageService, NavigationParameters parameters) : base(navigationService, translationService) { _dialogService = dialogService; _creationManager = creationManager; SharedFileStorageService = sharedFileStorageService; OriginalSequence = parameters.Get <Sequence>("sequence"); Sequence = new Sequence { Name = OriginalSequence.Name, Loop = OriginalSequence.Loop, Interpolate = OriginalSequence.Interpolate, ControlPoints = new ObservableCollection <SequenceControlPoint>(OriginalSequence.ControlPoints.Select(cp => new SequenceControlPoint { Value = cp.Value, DurationMs = cp.DurationMs }).ToArray()) }; ExportSequenceCommand = new SafeCommand(async() => await ExportSequenceAsync(), () => SharedFileStorageService.IsSharedStorageAvailable); RenameSequenceCommand = new SafeCommand(async() => await RenameSequenceAsync()); AddControlPointCommand = new SafeCommand(() => AddControlPoint()); DeleteControlPointCommand = new SafeCommand <SequenceControlPoint>(async(controlPoint) => await DeleteControlPointAsync(controlPoint)); SaveSequenceCommand = new SafeCommand(async() => await SaveSequenceAsync(), () => !_dialogService.IsDialogOpen); ChangeControlPointDurationCommand = new SafeCommand <SequenceControlPoint>(async(controlPoint) => await ChangeControlPointDurationAsync(controlPoint)); }
public PlayerPageViewModel( INavigationService navigationService, ITranslationService translationService, IDeviceManager deviceManager, IDialogService dialogService, IGameControllerService gameControllerService, IUIThreadService uIThreadService, IPlayLogic playLogic, NavigationParameters parameters) : base(navigationService, translationService) { _deviceManager = deviceManager; _dialogService = dialogService; _gameControllerService = gameControllerService; _uIThreadService = uIThreadService; _playLogic = playLogic; Creation = parameters.Get <Creation>("creation"); ActiveProfile = Creation.ControllerProfiles.First(); CollectDevices(); BuWizzOutputLevelChangedCommand = new SafeCommand <int>(level => ChangeOutputLevel(level, _buwizzDevices)); BuWizz2OutputLevelChangedCommand = new SafeCommand <int>(level => ChangeOutputLevel(level, _buwizz2Devices)); }
public ControllerProfilePageViewModel( INavigationService navigationService, ITranslationService translationService, ICreationManager creationManager, IDeviceManager deviceManager, IDialogService dialogService, IPlayLogic playLogic, NavigationParameters parameters) : base(navigationService, translationService) { _creationManager = creationManager; _deviceManager = deviceManager; _dialogService = dialogService; _playLogic = playLogic; ControllerProfile = parameters.Get <ControllerProfile>("controllerprofile"); RenameProfileCommand = new SafeCommand(async() => await RenameControllerProfileAsync()); AddControllerEventCommand = new SafeCommand(async() => await AddControllerEventAsync()); PlayCommand = new SafeCommand(async() => await PlayAsync()); ControllerActionTappedCommand = new SafeCommand <ControllerActionViewModel>(async controllerActionViewModel => await NavigationService.NavigateToAsync <ControllerActionPageViewModel>(new NavigationParameters(("controlleraction", controllerActionViewModel.ControllerAction)))); DeleteControllerEventCommand = new SafeCommand <ControllerEvent>(async controllerEvent => await DeleteControllerEventAsync(controllerEvent)); DeleteControllerActionCommand = new SafeCommand <ControllerAction>(async controllerAction => await DeleteControllerActionAsync(controllerAction)); PopulateControllerEvents(); }
public CreationPageViewModel( INavigationService navigationService, ITranslationService translationService, ICreationManager creationManager, IDialogService dialogService, ISharedFileStorageService sharedFileStorageService, IPlayLogic playLogic, NavigationParameters parameters) : base(navigationService, translationService) { _creationManager = creationManager; _dialogService = dialogService; SharedFileStorageService = sharedFileStorageService; _playLogic = playLogic; Creation = parameters.Get <Creation>("creation"); ImportControllerProfileCommand = new SafeCommand(async() => await ImportControllerProfileAsync(), () => SharedFileStorageService.IsSharedStorageAvailable); ExportCreationCommand = new SafeCommand(async() => await ExportCreationAsync(), () => SharedFileStorageService.IsSharedStorageAvailable); RenameCreationCommand = new SafeCommand(async() => await RenameCreationAsync()); PlayCommand = new SafeCommand(async() => await PlayAsync()); AddControllerProfileCommand = new SafeCommand(async() => await AddControllerProfileAsync()); ControllerProfileTappedCommand = new SafeCommand <ControllerProfile>(async controllerProfile => await NavigationService.NavigateToAsync <ControllerProfilePageViewModel>(new NavigationParameters(("controllerprofile", controllerProfile)))); DeleteControllerProfileCommand = new SafeCommand <ControllerProfile>(async controllerProfile => await DeleteControllerProfileAsync(controllerProfile)); }
public ControllerActionPageViewModel( INavigationService navigationService, ITranslationService translationService, ICreationManager creationManager, IDeviceManager deviceManager, IDialogService dialogService, NavigationParameters parameters) : base(navigationService, translationService) { _creationManager = creationManager; _deviceManager = deviceManager; _dialogService = dialogService; ControllerAction = parameters.Get <ControllerAction>("controlleraction", null); ControllerEvent = parameters.Get <ControllerEvent>("controllerevent", null) ?? ControllerAction.ControllerEvent; var device = _deviceManager.GetDeviceById(ControllerAction?.DeviceId); if (ControllerAction != null && device != null) { SelectedDevice = device; Channel = ControllerAction.Channel; IsInvert = ControllerAction.IsInvert; ChannelOutputType = ControllerAction.ChannelOutputType; MaxServoAngle = ControllerAction.MaxServoAngle; ButtonType = ControllerAction.ButtonType; AxisCharacteristic = ControllerAction.AxisCharacteristic; MaxOutputPercent = ControllerAction.MaxOutputPercent; AxisDeadZonePercent = ControllerAction.AxisDeadZonePercent; } else { SelectedDevice = _deviceManager.Devices.FirstOrDefault(); Channel = 0; IsInvert = false; ChannelOutputType = ChannelOutputType.NormalMotor; MaxServoAngle = 90; ButtonType = ControllerButtonType.Normal; AxisCharacteristic = ControllerAxisCharacteristic.Linear; MaxOutputPercent = 100; AxisDeadZonePercent = 0; } SaveControllerActionCommand = new SafeCommand(async() => await SaveControllerActionAsync(), () => SelectedDevice != null); DeleteControllerActionCommand = new SafeCommand(async() => await DeleteControllerActionAsync()); OpenDeviceDetailsCommand = new SafeCommand(async() => await OpenDeviceDetailsAsync(), () => SelectedDevice != null); }
public ChannelSetupPageViewModel( INavigationService navigationService, ITranslationService translationService, IDeviceManager deviceManager, IDialogService dialogService, NavigationParameters parameters) : base(navigationService, translationService) { _deviceManager = deviceManager; _dialogService = dialogService; Device = parameters.Get <Device>("device"); Action = parameters.Get <ControllerAction>("controlleraction"); ServoBaseAngle = Action.ServoBaseAngle; SaveChannelSettingsCommand = new SafeCommand(async() => await SaveChannelSettingsAsync(), () => !_dialogService.IsDialogOpen); AutoCalibrateServoCommand = new SafeCommand(async() => await AutoCalibrateServoAsync(), () => Device.CanAutoCalibrateOutput); ResetServoBaseCommand = new SafeCommand(async() => await ResetServoBaseAngleAsync(), () => Device.CanResetOutput); }
public DevicePageViewModel( INavigationService navigationService, IDeviceManager deviceManager, IDialogService dialogService, NavigationParameters parameters) : base(navigationService) { _deviceManager = deviceManager; _dialogService = dialogService; Device = parameters.Get <Device>("device"); RenameCommand = new SafeCommand(async() => await RenameDeviceAsync()); BuWizzOutputLevelChangedCommand = new SafeCommand <int>(outputLevel => SetBuWizzOutputLevel(outputLevel)); BuWizz2OutputLevelChangedCommand = new SafeCommand <int>(outputLevel => SetBuWizzOutputLevel(outputLevel)); }
public CreationPageViewModel( INavigationService navigationService, ICreationManager creationManager, IDeviceManager deviceManager, IDialogService dialogService, NavigationParameters parameters) : base(navigationService) { _creationManager = creationManager; _deviceManager = deviceManager; _dialogService = dialogService; Creation = parameters.Get <Creation>("creation"); RenameCreationCommand = new SafeCommand(async() => await RenameCreationAsync()); PlayCommand = new SafeCommand(async() => await PlayAsync()); AddControllerProfileCommand = new SafeCommand(async() => await AddControllerProfileAsync()); ControllerProfileTappedCommand = new SafeCommand <ControllerProfile>(async controllerProfile => await NavigationService.NavigateToAsync <ControllerProfilePageViewModel>(new NavigationParameters(("controllerprofile", controllerProfile)))); DeleteControllerProfileCommand = new SafeCommand <ControllerProfile>(async controllerProfile => await DeleteControllerProfileAsync(controllerProfile)); }
public DevicePageViewModel( INavigationService navigationService, ITranslationService translationService, IDeviceManager deviceManager, IDialogService dialogService, NavigationParameters parameters) : base(navigationService, translationService) { _deviceManager = deviceManager; _dialogService = dialogService; Device = parameters.Get <Device>("device"); DeviceOutputs = Enumerable .Range(0, Device.NumberOfChannels) .Select(channel => new DeviceOutputViewModel(Device, channel)) .ToArray(); RenameCommand = new SafeCommand(async() => await RenameDeviceAsync()); BuWizzOutputLevelChangedCommand = new SafeCommand <int>(outputLevel => SetBuWizzOutputLevel(outputLevel)); BuWizz2OutputLevelChangedCommand = new SafeCommand <int>(outputLevel => SetBuWizzOutputLevel(outputLevel)); }