protected void scr_MouseEnter(object sender, EventArgs e) { if (sender is PlayerControl) { PlayerControl player = (PlayerControl)sender; hover = (ScreenControl)player.Parent; } else { hover = (ScreenControl)sender; } for (int i = 0; i < loaded_screens.Count; i++) { var screen = loaded_screens[i]; if (screen == hover) { screen.Highlight(); } else { screen.Darken(); } } }
protected virtual void MakeMonitors() { panel1.Controls.Clear(); loaded_screens.Clear(); Screen[] screens = Screen.AllScreens; // get screens int minX = 0; int minY = 0; int maxWidth = 0; int maxHeight = 0; for (int i = 0; i < screens.Length; i++) { var screen = screens[i]; var bounds = screen.Bounds; minX = Math.Min(minX, bounds.X); minY = Math.Min(minY, bounds.Y); maxWidth += bounds.Width; maxHeight += bounds.Height; } int width = this.Width; int height = this.Height; int maxSize = Math.Max(maxWidth, maxHeight); int size = Math.Max(width, height); float factor = maxSize / (float)size; if (screens.Length == 1) { factor *= 1.3f; } for (int i = 0; i < screens.Length; i++) { var screen = screens[i]; var bounds = screen.Bounds; int swidth = bounds.Width; int sheight = bounds.Height; int x = bounds.X + Math.Abs(minX); int y = bounds.Y; swidth = (int)(swidth / factor); sheight = (int)(sheight / factor); x = (int)(x / factor); y = (int)(y / factor); ScreenControl scr = new ScreenControl(); scr.MouseEnter += scr_MouseEnter; scr.ContextMenuStrip = screenStrip; scr.Size = new Size(swidth, sheight); scr.Location = new Point(x, y); scr.ChangeID(screen.DeviceName.Remove(0, screen.DeviceName.Length - 1)); scr.ChangeName(screen.DeviceName); scr.Tag = screen; panel1.Controls.Add(scr); loaded_screens.Add(scr); } }