Beispiel #1
0
        public ProfileExportViewModel(ProfileDescriptor profileDescriptor, IProfileService profileService, ISnackbarMessageQueue mainMessageQueue)
        {
            ProfileDescriptor = profileDescriptor;

            _profileService   = profileService;
            _mainMessageQueue = mainMessageQueue;
        }
        public ProfileExportViewModel(ProfileDescriptor profileDescriptor, IProfileService profileService, IMessageService messageService)
        {
            ProfileDescriptor = profileDescriptor;

            _profileService = profileService;
            _messageService = messageService;
        }
Beispiel #3
0
        public async Task ActivateLastProfileAnimated(ProfileModule profileModule)
        {
            ProfileDescriptor activeProfile = GetLastActiveProfile(profileModule);

            if (activeProfile != null)
            {
                await ActivateProfileAnimated(activeProfile);
            }
        }
Beispiel #4
0
        public void ActivateLastProfile(ProfileModule profileModule)
        {
            ProfileDescriptor activeProfile = GetLastActiveProfile(profileModule);

            if (activeProfile != null)
            {
                ActivateProfile(activeProfile);
            }
        }
Beispiel #5
0
        public string ExportProfile(ProfileDescriptor profileDescriptor)
        {
            ProfileEntity profileEntity = _profileRepository.Get(profileDescriptor.Id);

            if (profileEntity == null)
            {
                throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}");
            }

            return(JsonConvert.SerializeObject(profileEntity, ExportSettings));
        }
Beispiel #6
0
        public async Task <Profile> ActivateProfileAnimated(ProfileDescriptor profileDescriptor)
        {
            if (profileDescriptor.ProfileModule.ActiveProfile?.EntityId == profileDescriptor.Id)
            {
                return(profileDescriptor.ProfileModule.ActiveProfile);
            }

            ProfileEntity profileEntity = _profileRepository.Get(profileDescriptor.Id);

            if (profileEntity == null)
            {
                throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}");
            }

            Profile profile = new Profile(profileDescriptor.ProfileModule, profileEntity);

            InstantiateProfile(profile);

            void ActivatingProfileSurfaceUpdate(object sender, SurfaceConfigurationEventArgs e)
            {
                profile.PopulateLeds(e.Surface);
            }

            void ActivatingProfilePluginToggle(object sender, PluginEventArgs e)
            {
                InstantiateProfile(profile);
            }

            // This could happen during activation so subscribe to it
            _pluginService.PluginEnabled  += ActivatingProfilePluginToggle;
            _pluginService.PluginDisabled += ActivatingProfilePluginToggle;
            _surfaceService.SurfaceConfigurationUpdated += ActivatingProfileSurfaceUpdate;

            await profileDescriptor.ProfileModule.ChangeActiveProfileAnimated(profile, _surfaceService.ActiveSurface);

            SaveActiveProfile(profileDescriptor.ProfileModule);

            _pluginService.PluginEnabled  -= ActivatingProfilePluginToggle;
            _pluginService.PluginDisabled -= ActivatingProfilePluginToggle;
            _surfaceService.SurfaceConfigurationUpdated -= ActivatingProfileSurfaceUpdate;

            return(profile);
        }
Beispiel #7
0
        public Profile ActivateProfile(ProfileDescriptor profileDescriptor)
        {
            if (profileDescriptor.ProfileModule.ActiveProfile?.EntityId == profileDescriptor.Id)
            {
                return(profileDescriptor.ProfileModule.ActiveProfile);
            }

            ProfileEntity profileEntity = _profileRepository.Get(profileDescriptor.Id);

            if (profileEntity == null)
            {
                throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}");
            }

            Profile profile = new Profile(profileDescriptor.ProfileModule, profileEntity);

            InstantiateProfile(profile);

            profileDescriptor.ProfileModule.ChangeActiveProfile(profile, _surfaceService.ActiveSurface);
            SaveActiveProfile(profileDescriptor.ProfileModule);

            return(profile);
        }
Beispiel #8
0
        public void DeleteProfile(ProfileDescriptor profileDescriptor)
        {
            ProfileEntity profileEntity = _profileRepository.Get(profileDescriptor.Id);

            _profileRepository.Remove(profileEntity);
        }