public ScreenMirrorEffect(Orchestrator orchestrator, INanoleafClient nanoleafClient)
        {
            _nanoleafClient        = nanoleafClient;
            _device                = orchestrator.Device;
            _screenMirrorAlgorithm = orchestrator.Device.ScreenMirrorAlgorithm;
            var flipType = FlipTypeHelper.ScreenMirrorFlipToFlipType(orchestrator.Device.ScreenMirrorFlip);

            try
            {
                if (_screenMirrorAlgorithm == ScreenMirrorAlgorithm.ScreenMirrorFit)
                {
                    _screenMirrorEffect = new ScreenMirror(orchestrator, nanoleafClient, ScaleType.Fit, flipType);
                }
                else if (_screenMirrorAlgorithm == ScreenMirrorAlgorithm.ScreenMirrorStretch)
                {
                    _screenMirrorEffect = new ScreenMirror(orchestrator, nanoleafClient, ScaleType.Stretch, flipType);
                }
                else if (_screenMirrorAlgorithm == ScreenMirrorAlgorithm.Ambilight)
                {
                    _screenMirrorEffect = new Ambilght(nanoleafClient);
                }
            }
            catch (Exception e)
            {
                // It is possible that the user adjusted his/her screens and therefore we get an error when initializing the effect
                _logger.Error(e, $"Something went wrong initializing the screen mirror effect for device {orchestrator.Device.ToString()}");
                _screenMirrorEffect = null;
            }

            _timer           = new System.Timers.Timer(100); //Refresh a panel every 10th of a second (10hz)
            _timer.Elapsed  += OnTimedEvent;
            _timer.AutoReset = true;
        }
Exemple #2
0
        public void Visualize(double scale)
        {
            var width     = Convert.ToInt32(_screenBounds.Width / scale);
            var height    = Convert.ToInt32(_screenBounds.Height / scale);
            var scaleType = _screenMirrorAlgorithm == ScreenMirrorAlgorithm.ScreenMirrorFit ? ScaleType.Fit : ScaleType.Stretch;
            var flipType  = FlipTypeHelper.ScreenMirrorFlipToFlipType(_screenMirrorFlip);

            var panels = OrchestratorCollection.GetOrchestratorForDevice(_device).PanelLayout.GetScaledPolygons(width, height, scaleType, flipType);

            DrawPanels(panels);

            //Horizontally center the close label
            CloseInfoLabel.Margin = new Thickness(width / 2, 0, 0, 0);
        }