public ScreenMirror(Orchestrator orchestrator, INanoleafClient nanoleafClient, ScaleType scaleType, FlipType flipType) { _externalControlEndpoint = nanoleafClient.ExternalControlEndpoint; _panelAreas = new List <Rectangle>(); _panelIds = new List <int>(); _deviceType = orchestrator.PanelLayout.DeviceType; var screenBounds = ScreenBoundsHelper.GetScreenBounds(UserSettings.Settings.ScreenMirrorMonitorIndex); var panels = orchestrator.PanelLayout.GetScaledPolygons(screenBounds.Width, screenBounds.Height, scaleType, flipType); switch (_deviceType) { case DeviceType.Aurora: LoadPanelsForTriangles(panels); break; case DeviceType.Canvas: LoadPanelsForSquares(panels); break; case DeviceType.Shapes: LoadPanelsForShapes(panels); break; default: throw new NotImplementedException($"Screen mirror constructor for device of type {orchestrator.PanelLayout.DeviceType} not implemented"); } }
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 Ambilght(INanoleafClient nanoleafClient, Device device) { _nanoleafClient = nanoleafClient; _screenBounds = new List <Rectangle> { ScreenBoundsHelper.GetScreenBounds(UserSettings.Settings.ScreenMirrorMonitorIndex) }; }
public PanelLayout(Device device) { _nanoleafClient = NanoleafClient.GetClientForDevice(device); _unscaledPolygons = new List <DrawablePanel>(); GetLayout(); }
private readonly List <Rectangle> _captureArea; //A list since that is what the screengrabber expects as input public Ambilght(INanoleafClient nanoleafClient) { _nanoleafClient = nanoleafClient; var screenBounds = ScreenBoundsHelper.GetScreenBounds(UserSettings.Settings.ScreenMirrorMonitorIndex); _captureArea = new List <Rectangle> { //Which area of the screenshot we need to look at, in the case of Ambilight, we need to look at the whole screenshot. //So start at 0, 0 and then use the width and height of the screen being captured new Rectangle(0, 0, screenBounds.Width, screenBounds.Height) }; }
private readonly Rectangle _capturedBounds; //Simple rectangle that start at 0,0 and has width and height set to the rectangle size public ScreenMirror(Device device, Orchestrator orchestrator, INanoleafClient nanoleafClient, ScaleType scaleType) { _nanoleafClient = nanoleafClient; _externalControlEndpoint = _nanoleafClient.ExternalControlEndpoint; _screenBounds = MonitorHelper.GetScreenBounds(device.ScreenMirrorMonitorIndex); _panels = orchestrator.PanelLayout.GetScaledTriangles(_screenBounds.Width, _screenBounds.Height, scaleType); //Set the rectangle size to 1/3th of the length of a side of the triangle. TODO: test what size is best var triangle = _panels.FirstOrDefault().Polygon; _rectangleSize = (int)Math.Floor(System.Windows.Point.Subtract(triangle.Points[0], triangle.Points[1]).Length / 3); _capturedBounds = new Rectangle(0, 0, _rectangleSize, _rectangleSize); }
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; }
public TurnOffEffect(INanoleafClient nanoleafClient) { _nanoleafClient = nanoleafClient; }
public Ambilght(INanoleafClient nanoleafClient, Device device) { _nanoleafClient = nanoleafClient; _controlBrightness = device.ScreenMirrorControlBrightness; _screenBounds = ScreenBoundsHelper.GetScreenBounds(device.ScreenMirrorMonitorIndex); }
public CustomColorEffect(INanoleafClient nanoleafClient, Color color) { _nanoleafClient = nanoleafClient; Color = color; }
public CustomColorEffect(INanoleafClient nanoleafClient, Color color, string effectName) { _nanoleafClient = nanoleafClient; Color = color; _effectName = effectName; }
internal void SetNanoleaf(INanoleafClient nanoleaf) { this.nanoleaf = nanoleaf; }