Example #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;
        }
Example #3
0
        public async Task ActivateLastProfileAnimated(ProfileModule profileModule)
        {
            ProfileDescriptor activeProfile = GetLastActiveProfile(profileModule);

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

            if (activeProfile != null)
            {
                ActivateProfile(activeProfile);
            }
        }
Example #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));
        }
Example #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);
        }
Example #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);
        }
Example #8
0
        public void DeleteProfile(ProfileDescriptor profileDescriptor)
        {
            ProfileEntity profileEntity = _profileRepository.Get(profileDescriptor.Id);

            _profileRepository.Remove(profileEntity);
        }