public CaptureForm(SetunaOption.SetunaOptionData opt) { this.InitializeComponent(); this.targetScreen = this.GetCurrentScreen(); InitScreenNewSize(); var tBitmap = new Bitmap(this.ScreenNewSize.Width, this.ScreenNewSize.Height, PixelFormat.Format24bppRgb); var tXDpi = (float)this.ScreenNewSize.Width / this.targetScreen.Bounds.Width; var tYDpi = (float)this.ScreenNewSize.Height / this.targetScreen.Bounds.Height; if (tXDpi != 1 || tYDpi != 1) { tXDpi = tXDpi - .1F; tYDpi = tYDpi - .1F; tBitmap.SetResolution(tXDpi * 100, tYDpi * 100); } Console.WriteLine(string.Format("XDpi:{0},YDpi:{1}", tXDpi, tYDpi)); imgSnap = tBitmap; selArea = new Form(); selArea.AutoScaleMode = AutoScaleMode.None; selArea.BackColor = Color.Blue; selArea.BackgroundImageLayout = ImageLayout.None; selArea.ControlBox = false; selArea.FormBorderStyle = FormBorderStyle.None; selArea.MaximizeBox = false; selArea.MinimizeBox = false; selArea.MinimumSize = new Size(1, 1); selArea.ClientSize = new Size(1, 1); selArea.ShowIcon = false; selArea.ShowInTaskbar = false; selArea.SizeGripStyle = SizeGripStyle.Hide; selArea.StartPosition = FormStartPosition.Manual; selArea.Text = "CaptureSelArea"; selArea.TopMost = true; selArea.Left = 0; selArea.Top = 0; selArea.Width = 1; selArea.Height = 1; selArea.Visible = false; base.AddOwnedForm(selArea); selLineHor1 = new CaptureSelLine(SelLineType.Horizon, opt.SelectLineSolid, opt.SelectLineColor); base.AddOwnedForm(selLineHor1); selLineHor1.Show(this); selLineHor2 = new CaptureSelLine(SelLineType.Horizon, opt.SelectLineSolid, opt.SelectLineColor); base.AddOwnedForm(selLineHor2); selLineHor2.Show(this); selLineVer1 = new CaptureSelLine(SelLineType.Vertical, opt.SelectLineSolid, opt.SelectLineColor); base.AddOwnedForm(selLineVer1); selLineVer1.Show(this); selLineVer2 = new CaptureSelLine(SelLineType.Vertical, opt.SelectLineSolid, opt.SelectLineColor); base.AddOwnedForm(selLineVer2); selLineVer2.Show(this); selLineHor1.Visible = false; selLineHor2.Visible = false; selLineVer1.Visible = false; selLineVer2.Visible = false; selArea.Visible = false; base.Opacity = 0.99000000953674316; }
public void ShowCapture(SetunaOption.SetunaOptionData opt) { if (ImgSnap != null) { if ((this.screenNewSize.Width != ImgSnap.Width) || (this.screenNewSize.Height != ImgSnap.Height)) { ImgSnap = new Bitmap(this.screenNewSize.Width, this.screenNewSize.Height, PixelFormat.Format24bppRgb); } this.trd = new Thread(new ThreadStart(this.ThreadTask)); this.trd.IsBackground = true; this.trd.Start(); Console.WriteLine(string.Concat(new object[] { "10 - ", DateTime.Now.ToString(), " ", DateTime.Now.Millisecond })); Console.WriteLine(string.Concat(new object[] { "11 - ", DateTime.Now.ToString(), " ", DateTime.Now.Millisecond })); this.blAreaVisible = opt.SelectAreaTransparent != 100; selArea.Opacity = 1f - (((float)opt.SelectAreaTransparent) / 100f); selArea.BackColor = opt.SelectBackColor; if (!selArea.Visible) { selArea.Show(this); } Console.WriteLine(string.Concat(new object[] { "12 - ", DateTime.Now.ToString(), " ", DateTime.Now.Millisecond })); this.SetBoundsCore(this.targetScreen.Bounds.X, this.targetScreen.Bounds.Y, this.screenNewSize.Width, this.screenNewSize.Height, BoundsSpecified.All); Console.WriteLine(string.Concat(new object[] { "13 - ", DateTime.Now.ToString(), " ", DateTime.Now.Millisecond })); selLineHor1.SetPen(opt.SelectLineSolid, opt.SelectLineColor); selLineHor1.SetBounds(this.targetScreen.Bounds.X, this.targetScreen.Bounds.Y - 10, this.screenNewSize.Width, 1); if (!selLineHor1.Visible) { selLineHor1.Show(this); } selLineHor2.SetPen(opt.SelectLineSolid, opt.SelectLineColor); selLineHor2.SetBounds(this.targetScreen.Bounds.X, this.targetScreen.Bounds.Y - 10, this.screenNewSize.Width, 1); if (!selLineHor2.Visible) { selLineHor2.Show(this); } selLineVer1.SetPen(opt.SelectLineSolid, opt.SelectLineColor); selLineVer1.SetBounds(this.targetScreen.Bounds.X - 10, this.targetScreen.Bounds.Y, 1, this.screenNewSize.Height); if (!selLineVer1.Visible) { selLineVer1.Show(this); } selLineVer2.SetPen(opt.SelectLineSolid, opt.SelectLineColor); selLineVer2.SetBounds(this.targetScreen.Bounds.X - 10, this.targetScreen.Bounds.Y, 1, selLineVer2.Height = this.screenNewSize.Height); if (!selLineVer2.Visible) { selLineVer2.Show(this); } Console.WriteLine(string.Concat(new object[] { "14 - ", DateTime.Now.ToString(), " ", DateTime.Now.Millisecond })); Thread.Sleep(1); Cursor.Current = Cursors.Cross; Cursor.Clip = this.targetScreen.Bounds; } }
public CaptureForm(SetunaOption.SetunaOptionData opt) { this.InitializeComponent(); imgSnap = new Bitmap(this.screenNewSize.Width, this.screenNewSize.Height, PixelFormat.Format24bppRgb); selArea = new Form(); selArea.AutoScaleMode = AutoScaleMode.None; selArea.BackColor = Color.Blue; selArea.BackgroundImageLayout = ImageLayout.None; selArea.ControlBox = false; selArea.FormBorderStyle = FormBorderStyle.None; selArea.MaximizeBox = false; selArea.MinimizeBox = false; selArea.MinimumSize = new Size(1, 1); selArea.ClientSize = new Size(1, 1); selArea.ShowIcon = false; selArea.ShowInTaskbar = false; selArea.SizeGripStyle = SizeGripStyle.Hide; selArea.StartPosition = FormStartPosition.Manual; selArea.Text = "CaptureSelArea"; selArea.TopMost = true; selArea.Left = 0; selArea.Top = 0; selArea.Width = 1; selArea.Height = 1; selArea.Visible = false; base.AddOwnedForm(selArea); selLineHor1 = new CaptureSelLine(SelLineType.Horizon, opt.SelectLineSolid, opt.SelectLineColor); base.AddOwnedForm(selLineHor1); selLineHor1.Show(this); selLineHor2 = new CaptureSelLine(SelLineType.Horizon, opt.SelectLineSolid, opt.SelectLineColor); base.AddOwnedForm(selLineHor2); selLineHor2.Show(this); selLineVer1 = new CaptureSelLine(SelLineType.Vertical, opt.SelectLineSolid, opt.SelectLineColor); base.AddOwnedForm(selLineVer1); selLineVer1.Show(this); selLineVer2 = new CaptureSelLine(SelLineType.Vertical, opt.SelectLineSolid, opt.SelectLineColor); base.AddOwnedForm(selLineVer2); selLineVer2.Show(this); selLineHor1.Visible = false; selLineHor2.Visible = false; selLineVer1.Visible = false; selLineVer2.Visible = false; selArea.Visible = false; base.Opacity = 0.99000000953674316; }