void AddDesktop(DesktopConfigItem item) { var cfg = this.cfg.Instance; IntPtr handle = IntPtr.Zero; if (item.Handle == IntPtr.Zero) { handle = Desktops.DesktopOpenOrCreate(item.Name); item.Handle = handle; } AddPictureBox(cfg, item); }
private void AddPictureBox(DesktopConfig cfg, DesktopConfigItem item) { var r = Screen.PrimaryScreen.Bounds; var b = new Bitmap(r.Width, r.Height); using (var g = Graphics.FromImage(b)) { g.FillRectangle(new SolidBrush(Color.Black), r); } var pb = new PictureBox(); pb.Image = b; pb.SizeMode = PictureBoxSizeMode.StretchImage; pb.Width = cfg.ScreenshotWidth; pb.Height = cfg.ScreenshotHeight; pb.Click += deskPicClick; pb.Tag = item; fpn.Controls.Add(pb); }