/// <summary> /// 生成截图的Form /// </summary> /// <returns></returns> private CaptureForm GetCaptureForm() { int swidth = Screen.PrimaryScreen.Bounds.Width; int sheight = Screen.PrimaryScreen.Bounds.Height; using (Graphics graphics = Graphics.FromHwnd(IntPtr.Zero)) { float dpiX = graphics.DpiX; float dpiY = graphics.DpiY; } Bitmap bit = new Bitmap(swidth, sheight); Graphics g = Graphics.FromImage(bit); g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(swidth, sheight)); CaptureForm capture = new CaptureForm(bit); capture.WindowState = FormWindowState.Maximized; capture.AutoSize = true; capture.Size = new System.Drawing.Size(swidth, sheight); capture.TopMost = true; capture.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; capture.BackgroundImage = bit; return(capture); }
/// <summary> /// ui修改 /// </summary> /// <param name="uic"></param> private void FixImage(UiControl uic) { this.Hide(); CaptureForm capture = GetCaptureForm(); if (capture.ShowDialog() == DialogResult.OK) { uic.uiInfo = new UiInfo(capture._captureImg, capture._captureLoca, capture._clickLoca); uic.UiImage = capture._captureImg; } this.Show(); }
/// <summary> /// UI追加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUIAdd_Click(object sender, EventArgs e) { this.Hide(); Thread.Sleep(500); CaptureForm cutter = GetCaptureForm(); if (cutter.ShowDialog() == DialogResult.OK) { AddNewUI(cutter._captureImg, cutter._captureLoca, cutter._clickLoca, false); } this.Show(); }