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); }
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); }
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); }
protected void OnScreenRemoved(VirtualScreen screen) { Removed?.Invoke(screen); }
protected VirtualScreen OnScreenChanged(Direction direction, VirtualScreen screen) { Added?.Invoke(direction, screen); return(screen); }
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))); }
public VirtualScreen AddScreenBelow(VirtualScreen orig, VirtualScreen other) { return(OnScreenChanged(Direction.Bottom, AddScreen(orig.X, orig.Y + orig.Height, other))); }
public VirtualScreen AddScreenAbove(VirtualScreen orig, VirtualScreen other) { return(OnScreenChanged(Direction.Top, AddScreen(orig.X, orig.Y - other.Height, other))); }
public VirtualScreen AddScreenLeft(VirtualScreen orig, VirtualScreen other) { return(OnScreenChanged(Direction.Left, AddScreen(orig.X - other.Width, orig.Y, other))); }
public VirtualScreen AddScreenRight(VirtualScreen orig, VirtualScreen other) { return(OnScreenChanged(Direction.Right, AddScreen(orig.X + orig.Width, orig.Y, other))); }