Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomEffectsCollection"/> class.
        /// </summary>
        /// <param name="orchestrator">The orchestrator instance currently in use.</param>
        public CustomEffectsCollection(Orchestrator orchestrator)
        {
            var nanoleafClient = NanoleafClient.GetClientForDevice(orchestrator.Device);

            _customEffects = new Dictionary <string, ICustomEffect>();

            var customColorEffects = UserSettings.Settings.CustomEffects;

            if (customColorEffects != null && customColorEffects.Any())
            {
                foreach (var customColorEffect in customColorEffects)
                {
                    var effect = new CustomColorEffect(nanoleafClient, customColorEffect.Color, customColorEffect.EffectName);
                    _customEffects.Add(effect.GetName(), effect);
                }
            }

            //We will not translate effect names since their names are identifiers
            if (ScreenMirrorEffect.SupportedDeviceTypes.Contains(orchestrator.PanelLayout.DeviceType))
            {
                //Only add screen mirror to supported devices
                var screenMirrorEffect = new ScreenMirrorEffect(orchestrator, nanoleafClient);
                _customEffects.Add(screenMirrorEffect.GetName(), screenMirrorEffect);
            }

            var turnOffEffect = new TurnOffEffect(nanoleafClient);

            _customEffects.Add(turnOffEffect.GetName(), turnOffEffect);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomEffectsCollection"/> class.
        /// </summary>
        /// <param name="device">The device to be used to generate a <see cref="NanoleafClient"/></param>
        /// <param name="orchestrator">The orchestrator instance currently in use.</param>
        public CustomEffectsCollection(Device device, Orchestrator orchestrator)
        {
            var nanoleafClient = NanoleafClient.GetClientForDevice(device);

            _customEffects = new Dictionary <string, ICustomEffect>();

            var customColorEffects = UserSettings.Settings.CustomEffects;

            if (customColorEffects != null && customColorEffects.Any())
            {
                foreach (var customColorEffect in customColorEffects)
                {
                    var effect = new CustomColorEffect(nanoleafClient, customColorEffect.Color, customColorEffect.EffectName);
                    _customEffects.Add(effect.GetName(), effect);
                }
            }

            //We will not translate effect names since their names are identifiers
            var screenMirrorEffect = new ScreenMirrorEffect(device, orchestrator, nanoleafClient);

            _customEffects.Add(screenMirrorEffect.GetName(), screenMirrorEffect);

            var turnOffEffect = new TurnOffEffect(nanoleafClient);

            _customEffects.Add(turnOffEffect.GetName(), turnOffEffect);
        }