public ScreenMirrorEffect(Device device, Orchestrator orchestrator, INanoleafClient nanoleafClient) { _nanoleafClient = nanoleafClient; _orchestrator = orchestrator; _screenMirrorAlgorithm = device.ScreenMirrorAlgorithm; try { if (_screenMirrorAlgorithm == ScreenMirrorAlgorithm.ScreenMirrorFit) { _screenMirrorEffect = new ScreenMirror(orchestrator, nanoleafClient, ScaleType.Fit); } else if (_screenMirrorAlgorithm == ScreenMirrorAlgorithm.ScreenMirrorStretch) { _screenMirrorEffect = new ScreenMirror(orchestrator, nanoleafClient, ScaleType.Stretch); } else if (_screenMirrorAlgorithm == ScreenMirrorAlgorithm.Ambilight) { _screenMirrorEffect = new Ambilght(nanoleafClient, device); } } 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 {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; }
public void ScreenMirrorAlgorithmChanged(ScreenMirrorAlgorithm selectedScreenMirrorAlgorithm) { if (selectedScreenMirrorAlgorithm == ScreenMirrorAlgorithm.ScreenMirrorFit || selectedScreenMirrorAlgorithm == ScreenMirrorAlgorithm.ScreenMirrorStretch) { VisualizeButton.IsEnabled = true; VisualizeButton.Foreground = Brushes.White; } else { VisualizeButton.IsEnabled = false; VisualizeButton.Foreground = Brushes.Gray; } }
public ScreenMirrorVisualizationWindow(Device device, int monitorIndex, ScreenMirrorAlgorithm screenMirrorAlgorithm) { _screenMirrorAlgorithm = screenMirrorAlgorithm; _device = device; _screenBounds = ScreenBoundsHelper.GetScreenBounds(monitorIndex); Width = _screenBounds.Width; Height = _screenBounds.Height; Left = _screenBounds.X; Top = _screenBounds.Y; InitializeComponent(); }
public ScreenMirrorEffect(Device device, Orchestrator orchestrator, INanoleafClient nanoleafClient) { _nanoleafClient = nanoleafClient; _screenMirrorAlgorithm = device.ScreenMirrorAlgorithm; try { if (_screenMirrorAlgorithm == ScreenMirrorAlgorithm.ScreenMirrorFit) { _screenMirrorEffect = new ScreenMirror(device, orchestrator, nanoleafClient, ScaleType.Fit); } else if (_screenMirrorAlgorithm == ScreenMirrorAlgorithm.ScreenMirrorStretch) { _screenMirrorEffect = new ScreenMirror(device, orchestrator, nanoleafClient, ScaleType.Stretch); } else if (_screenMirrorAlgorithm == ScreenMirrorAlgorithm.Ambilight) { _screenMirrorEffect = new Ambilght(nanoleafClient, device); } } 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 {device.ToString()}"); _screenMirrorEffect = null; } var timerRefreshRate = 1000; if (device.ScreenMirrorRefreshRatePerSecond > 0 && device.ScreenMirrorRefreshRatePerSecond <= 10) { timerRefreshRate = 1000 / device.ScreenMirrorRefreshRatePerSecond; } if (_screenMirrorAlgorithm == ScreenMirrorAlgorithm.Ambilight && device.ScreenMirrorControlBrightness && timerRefreshRate > 1000 / 5) { timerRefreshRate = 1000 / 5; //When ambilight is on and controls brightness is enabled, we can update a maximum of 5 times per second since setting brightness is a different action } _timer = new System.Timers.Timer(timerRefreshRate); _timer.Elapsed += OnTimedEvent; _timer.AutoReset = true; }
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; } var timerRefreshRate = 1000; if (UserSettings.Settings.ScreenMirrorRefreshRatePerSecond > 0 && UserSettings.Settings.ScreenMirrorRefreshRatePerSecond <= 10) { timerRefreshRate = 1000 / UserSettings.Settings.ScreenMirrorRefreshRatePerSecond; } _timer = new System.Timers.Timer(timerRefreshRate); _timer.Elapsed += OnTimedEvent; _timer.AutoReset = true; }