Esempio n. 1
0
        public VirtualScreen AddScreen(int virtualX, int virtualY, VirtualScreen other)
        {
            double newXBottomCorner = virtualX + other.Width - 1;
            double newYBottomCorner = virtualY + other.Height - 1;

            //check and make sure we can add this

            foreach (VirtualScreen s in screens.Values.SelectMany(x => x))
            {
                double existingX             = s.X;
                double existingY             = s.Y;
                double existingXBottomCorner = s.X + s.Width - 1;
                double existingYBottomCorner = s.Y + s.Height - 1;

                //no overlap of x coords
                if (virtualX > existingXBottomCorner || newXBottomCorner < existingX)
                {
                    continue;
                }

                // If one rectangle is above other
                //screen coordinates have the Y flipped, so we have to adjust this part by flipping the comparisons from what you would normally see
                if (virtualY > existingYBottomCorner || newYBottomCorner < existingY)
                {
                    continue;
                }

                return(null); //this is a coordinate overlap
            }

            //all good, add the new screen
            VirtualScreen newScreen = new VirtualScreen(other.Client, other.Dpi)
            {
                LocalX = other.X,
                LocalY = other.Y,
                X      = virtualX,
                Y      = virtualY,
                Width  = other.Width,
                Height = other.Height
            };

            if (!screens.ContainsKey(other.Client))
            {
                screens.TryAdd(other.Client, new List <VirtualScreen>());
            }
            screens[other.Client].Add(newScreen);
            return(newScreen);
        }
Esempio n. 2
0
        public VirtualScreen GetFurthestRight()
        {
            VirtualScreen furthestRight = VirtualScreen.Empty;
            double        maxX          = double.MinValue;

            foreach (VirtualScreen s in screens.Values.SelectMany(x => x))
            {
                double maxForThisScreen = s.X + s.Width;
                if (maxForThisScreen > maxX)
                {
                    maxX          = maxForThisScreen;
                    furthestRight = s;
                }
            }

            return(furthestRight);
        }
Esempio n. 3
0
        public VirtualScreen GetFurthestLeft()
        {
            VirtualScreen furthestLeft = VirtualScreen.Empty;
            double        minX         = double.MaxValue;

            foreach (VirtualScreen s in screens.Values.SelectMany(x => x))
            {
                double minForThisScreen = s.X;
                if (minForThisScreen < minX)
                {
                    minX         = minForThisScreen;
                    furthestLeft = s;
                }
            }

            return(furthestLeft);
        }
Esempio n. 4
0
 protected void OnScreenRemoved(VirtualScreen screen)
 {
     Removed?.Invoke(screen);
 }
Esempio n. 5
0
 protected VirtualScreen OnScreenChanged(Direction direction, VirtualScreen screen)
 {
     Added?.Invoke(direction, screen);
     return(screen);
 }
Esempio n. 6
0
 public VirtualScreen AddScreenBelow(VirtualScreen orig, IDisplay display, Win32.Hooks.Dpi dpi, string client)
 {
     return(OnScreenChanged(Direction.Bottom, AddScreen(display.X, display.Y, orig.X, orig.Y + orig.Height, display.Width, display.Height, dpi, client)));
 }
Esempio n. 7
0
 public VirtualScreen AddScreenBelow(VirtualScreen orig, VirtualScreen other)
 {
     return(OnScreenChanged(Direction.Bottom, AddScreen(orig.X, orig.Y + orig.Height, other)));
 }
Esempio n. 8
0
 public VirtualScreen AddScreenAbove(VirtualScreen orig, VirtualScreen other)
 {
     return(OnScreenChanged(Direction.Top, AddScreen(orig.X, orig.Y - other.Height, other)));
 }
Esempio n. 9
0
 public VirtualScreen AddScreenLeft(VirtualScreen orig, VirtualScreen other)
 {
     return(OnScreenChanged(Direction.Left, AddScreen(orig.X - other.Width, orig.Y, other)));
 }
Esempio n. 10
0
 public VirtualScreen AddScreenRight(VirtualScreen orig, VirtualScreen other)
 {
     return(OnScreenChanged(Direction.Right, AddScreen(orig.X + orig.Width, orig.Y, other)));
 }