예제 #1
0
        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");
            }
        }
예제 #2
0
 public Ambilght(INanoleafClient nanoleafClient, Device device)
 {
     _nanoleafClient = nanoleafClient;
     _screenBounds   = new List <Rectangle> {
         ScreenBoundsHelper.GetScreenBounds(UserSettings.Settings.ScreenMirrorMonitorIndex)
     };
 }
예제 #3
0
        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)
            };
        }
예제 #4
0
        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();
        }
예제 #5
0
        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 = ScreenBoundsHelper.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);
        }
예제 #6
0
 public Ambilght(INanoleafClient nanoleafClient, Device device)
 {
     _nanoleafClient    = nanoleafClient;
     _controlBrightness = device.ScreenMirrorControlBrightness;
     _screenBounds      = ScreenBoundsHelper.GetScreenBounds(device.ScreenMirrorMonitorIndex);
 }
예제 #7
0
        private void DrawMonitors()
        {
            var monitorBounds = new List <System.Drawing.Rectangle>();

            for (var i = 0; i < _monitorNames.Count; i++)
            {
                monitorBounds.Add(ScreenBoundsHelper.GetScreenBounds(i));
            }

            var minX = monitorBounds.Min(bounds => bounds.X);
            var minY = monitorBounds.Min(bounds => bounds.Y);

            //Normalize all X and Y coordinates such that the left most bottom monitor start at 0,0
            for (var i = 0; i < monitorBounds.Count; i++)
            {
                var rectangle = monitorBounds[i];

                var x = rectangle.X;
                if (minX > 0)
                {
                    x = rectangle.X - minX;
                }
                else if (minX < 0)
                {
                    x = rectangle.X + Math.Abs(minX);
                }

                var y = rectangle.Y;
                if (minY > 0)
                {
                    y = rectangle.Y - minY;
                }
                else if (minY < 0)
                {
                    y = rectangle.Y + Math.Abs(minY);
                }

                monitorBounds[i] = new System.Drawing.Rectangle(x, y, rectangle.Width, rectangle.Height);
            }

            var maxMonitorWidth  = monitorBounds.Max(bounds => bounds.X + bounds.Width);
            var maxMonitorHeight = monitorBounds.Max(bounds => bounds.Y + bounds.Height);

            var scale = Math.Max(maxMonitorWidth / MonitorCanvas.Width, maxMonitorHeight / MonitorCanvas.Height);

            for (var i = 0; i < monitorBounds.Count; i++)
            {
                //Draw a polygon in the shape of the monitor, scaled down
                var polygon = new Polygon();

                var scaledX       = monitorBounds[i].X / scale;
                var scaledY       = monitorBounds[i].Y / scale;
                var scaledXWidth  = (monitorBounds[i].X + monitorBounds[i].Width) / scale;
                var scaledYHeight = (monitorBounds[i].Y + monitorBounds[i].Height) / scale;

                polygon.Points.Add(new System.Windows.Point(scaledX, scaledY));            //Left top
                polygon.Points.Add(new System.Windows.Point(scaledX, scaledYHeight));      //Left bottom
                polygon.Points.Add(new System.Windows.Point(scaledXWidth, scaledYHeight)); //Right bottom
                polygon.Points.Add(new System.Windows.Point(scaledXWidth, scaledY));       //Right top

                polygon.Stroke          = Brushes.LightGray;
                polygon.StrokeThickness = 3;

                MonitorCanvas.Children.Add(polygon);

                //Draw the number of the monitor
                var textBlock = new TextBlock();

                textBlock.Text       = (i + 1).ToString(); //+ 1 since i starts at 0
                textBlock.Foreground = Brushes.LightGray;
                textBlock.FontSize   = 20;

                Canvas.SetLeft(textBlock, ((monitorBounds[i].X + (monitorBounds[i].Width / 2)) / scale) - 5); //-5 and -15 to position the numbers more to the center
                Canvas.SetTop(textBlock, ((monitorBounds[i].Y + (monitorBounds[i].Height / 2)) / scale) - 15);

                MonitorCanvas.Children.Add(textBlock);
            }
        }