Пример #1
0
        private void buttonCapture_Click(object sender, EventArgs e)
        {
            Image     image;
            Rectangle rcSelect;

            this.Hide();
            Thread.Sleep(1000);
            if (SnippingTool.Snip(out image, out rcSelect))
            {
                DialogResult  dr;
                ConditionForm conForm = new ConditionForm(rcSelect);
                dr = conForm.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    ProcessModel data = conForm.getResultData();

                    listProcess.Add(data);
                    listBoxCapture.Items.Add(string.Format("{0},threshold:{1}, operation:{2},action:{3}", rcSelect, data.threshold, data.operaion.Value, data.action.Value));
                    if (image != null)
                    {
                        pictureBoxFirstSnip.Image = image;
                    }
                    if (checkBoxShowRealTimeSnip.Checked)
                    {
                        pictureBoxRealtimeSnip.Image = SpecificSnap.Snip(rcSelect);
                    }
                }
                this.Show();
            }
        }
Пример #2
0
        public static bool Snip(out Image image, out Rectangle rcSelect)
        {
            var rc = Screen.PrimaryScreen.Bounds;

            using (Bitmap bmp = new Bitmap(rc.Width, rc.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb))
            {
                using (Graphics gr = Graphics.FromImage(bmp))
                    gr.CopyFromScreen(0, 0, 0, 0, bmp.Size);
                using (var snipper = new SnippingTool(bmp))
                {
                    if (snipper.ShowDialog() == DialogResult.OK)
                    {
                        image    = snipper.Image;
                        rcSelect = snipper.rcSelect;
                        return(true);
                    }
                }
            }
            image    = null;
            rcSelect = new Rectangle();
            return(false);
        }