Beispiel #1
0
        public PercentageProfileWindow()
        {
            InitializeComponent();

            LayoutDisplay.SetWithAndHeight((int)LayoutDisplay.Width, (int)LayoutDisplay.Height);
            LayoutDisplay.DrawLayout();
            LayoutDisplay.EnableClick();
            LayoutDisplay.DisableColorTimer();

            if (UserSettings.Settings.ActiveDevice.PercentageProfile != null)
            {
                var serialized = JsonConvert.SerializeObject(UserSettings.Settings.ActiveDevice.PercentageProfile); //Deep copy the profile when editing
                _profile = JsonConvert.DeserializeObject <PercentageProfile>(serialized);

                BuildStepList();

                foreach (var step in _profile.Steps)
                {
                    LayoutDisplay.LockPanels(step.PanelIds);
                }
            }
            else
            {
                _profile = new PercentageProfile();
            }
        }
Beispiel #2
0
        protected BaseProcessPercentageEventTrigger(ITrigger trigger, Orchestrator orchestrator, string processName)
        {
            _trigger      = trigger;
            _orchestrator = orchestrator;
            _processName  = processName;

            var client = NanoleafClient.GetClientForDevice(_orchestrator.Device);

            _externalControlEndpoint = client.ExternalControlEndpoint;

            //Check if the user has somehow messed up their percentage profile, then we create a single step percentage profile
            if (_orchestrator.Device.PercentageProfile == null || _orchestrator.Device.PercentageProfile.Steps.Count == 0)
            {
                _percentageProfile = new PercentageProfile();
                var step = new PercentageStep();

                foreach (var panel in client.LayoutEndpoint.GetLayout().PanelPositions)
                {
                    step.PanelIds.Add(panel.PanelId);
                }

                _percentageProfile.Steps.Add(step);
                _percentagePerStep = 100f;
                _amountOfSteps     = 1;
            }
            else
            {
                _percentageProfile = _orchestrator.Device.PercentageProfile;
                _amountOfSteps     = _percentageProfile.Steps.Count;
                _percentagePerStep = 100f / _amountOfSteps;
            }

            var processCheckTimer = new Timer(60000);

            processCheckTimer.Elapsed  += CheckProcess;
            processCheckTimer.AutoReset = true;
            processCheckTimer.Start();

            _effectTimer           = new Timer(100);
            _effectTimer.Elapsed  += ApplyEffect;
            _effectTimer.AutoReset = true;
        }